on xenial help sign in
fix more tests and focus handling
commit770e4e70099d66c5354e11a96707a2bdf277e96f authorMichael Zanetti <michael.zanetti@canonical.com> dateFri 18 Sep 2015, 13:03 (11 years ago) parentdcc7717
6 files changed+50−56
plugins/GlobalShortcut/globalshortcut.cpp+1−1 qml/Stages/DesktopSpread.qml+1 qml/Stages/DesktopSpreadDelegate.qml+2−2 qml/Stages/DesktopStage.qml+3−15 tests/mocks/Unity/Application/Session.cpp+4−4 tests/qmltests/tst_Shell.qml+39−34
plugins/GlobalShortcut/globalshortcut.cpp+1−1
@@ -72,7 +72,7 @@ void GlobalShortcut::keyPressEvent(QKeyEvent * event)
7272void GlobalShortcut::setupFilterOnWindow(QQuickWindow *window)
7373{
7474 if (!window) {
75− qWarning() << Q_FUNC_INFO << "Failed to setup filter on window";
75+// qWarning() << Q_FUNC_INFO << "Failed to setup filter on window";
7676 return;
7777 }
7878
qml/Stages/DesktopSpread.qml+1
@@ -77,6 +77,7 @@ FocusScope {
7777
7878 Item {
7979 id: spreadContainer
80+ objectName: "spreadContainer"
8081 anchors.fill: parent
8182 visible: false
8283
qml/Stages/DesktopSpreadDelegate.qml+2−2
@@ -29,8 +29,8 @@ Item {
2929 property bool highlightShown: false
3030 property real shadowOpacity: 1
3131
32− property int windowWidth: application.session.surface.size.width
33− property int windowHeight: application.session.surface.size.height
32+ property int windowWidth: application.session && application.session.surface ? application.session.surface.size.width : 0
33+ property int windowHeight: application.session && application.session.surface ? application.session.surface.size.height : 0
3434
3535 state: "normal"
3636 states: [
qml/Stages/DesktopStage.qml+3−15
@@ -70,7 +70,7 @@ Rectangle {
7070 var appIndex = priv.indexOf(appId);
7171 var appDelegate = appRepeater.itemAt(appIndex);
7272 appDelegate.minimized = false;
73− appDelegate.focus = true;
73+ ApplicationManager.focusApplication(appId)
7474 }
7575 }
7676
@@ -132,12 +132,7 @@ Rectangle {
132132 y: units.gu(3)
133133 width: units.gu(60)
134134 height: units.gu(50)
135−
136− property int windowWidth: 0
137− property int windowHeight: 0
138− // We don't want to resize the actual application when we're transforming things for the spread only
139− onWidthChanged: if (appDelegate.state !== "altTab") windowWidth = width
140− onHeightChanged: if (appDelegate.state !== "altTab") windowHeight = height
135+ focus: model.appId === priv.focusedAppId
141136
142137 readonly property int minWidth: units.gu(10)
143138 readonly property int minHeight: units.gu(10)
@@ -151,13 +146,6 @@ Rectangle {
151146 }
152147 }
153148
154− Component.onCompleted: {
155− // Focus the top-most or AppMan-focused application on start up.
156− if (ApplicationManager.focusedApplicationId === model.appId && !focus) {
157− focus = true;
158− }
159− }
160−
161149 Binding {
162150 target: ApplicationManager.get(index)
163151 property: "requestedState"
@@ -231,7 +219,7 @@ Rectangle {
231219 resizeHandleWidth: units.gu(2)
232220 windowId: model.appId // FIXME: Change this to point to windowId once we have such a thing
233221
234− onPressed: { appDelegate.focus = true; }
222+ onPressed: { ApplicationManager.focusApplication(model.appId) }
235223 }
236224
237225 DecoratedWindow {
tests/mocks/Unity/Application/Session.cpp+4−4
@@ -35,14 +35,14 @@ Session::Session(const QString &name,
3535 , m_parentSession(nullptr)
3636 , m_children(new SessionModel(this))
3737{
38− qDebug() << "Session::Session() " << this->name();
38+// qDebug() << "Session::Session() " << this->name();
3939
4040 QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
4141}
4242
4343Session::~Session()
4444{
45− qDebug() << "Session::~Session() " << name();
45+// qDebug() << "Session::~Session() " << name();
4646
4747 QList<Session*> children(m_children->list());
4848 for (Session* child : children) {
@@ -67,7 +67,7 @@ Session::~Session()
6767
6868void Session::release()
6969{
70− qDebug() << "Session::release " << name();
70+// qDebug() << "Session::release " << name();
7171 deleteLater();
7272}
7373
@@ -82,7 +82,7 @@ void Session::setApplication(ApplicationInfo* application)
8282
8383void Session::setSurface(MirSurface* surface)
8484{
85− qDebug() << "Session::setSurface - session=" << name() << "surface=" << surface;
85+// qDebug() << "Session::setSurface - session=" << name() << "surface=" << surface;
8686 if (m_surface == surface)
8787 return;
8888
tests/qmltests/tst_Shell.qml+39−34
@@ -322,8 +322,9 @@ Rectangle {
322322
323323 function loadDesktopShellWithApps() {
324324 loadShell("desktop");
325+ waitForRendering(shell)
325326 shell.usageScenario = "desktop"
326− waitForRendering(root)
327+ waitForRendering(shell)
327328 var app1 = ApplicationManager.startApplication("dialer-app")
328329 var app2 = ApplicationManager.startApplication("webbrowser-app")
329330 var app3 = ApplicationManager.startApplication("camera-app")
@@ -1407,17 +1408,18 @@ Rectangle {
14071408 keyClick(Qt.Key_Tab, Qt.ControlModifier)
14081409 tryCompare(app2.session.surface, "activeFocus", true)
14091410
1411+ var desktopSpread = findChild(shell, "spread")
14101412
1411− tryCompare(desktopStage, "state", "")
1413+ tryCompare(desktopSpread, "state", "")
14121414
14131415 // Just press Alt, make sure the spread comes up
14141416 keyPress(Qt.Key_Control);
14151417 keyClick(Qt.Key_Tab);
1416− tryCompare(desktopStage, "state", "altTab")
1418+ tryCompare(desktopSpread, "state", "altTab")
14171419
14181420 // Release control, check if spread disappears
14191421 keyRelease(Qt.Key_Control)
1420− tryCompare(desktopStage, "state", "")
1422+ tryCompare(desktopSpread, "state", "")
14211423
14221424 // Focus should have switched back now
14231425 tryCompare(app3.session.surface, "activeFocus", true)
@@ -1429,41 +1431,44 @@ Rectangle {
14291431 var desktopStage = findChild(shell, "stage");
14301432 verify(desktopStage !== null)
14311433
1432− var appContainer = findInvisibleChild(shell, "appContainer")
1433− verify(appContainer !== null)
1434+ var desktopSpread = findChild(shell, "spread");
1435+ verify(desktopSpread !== null)
14341436
1435− var appRepeater = findInvisibleChild(shell, "appRepeater")
1436− verify(appRepeater !== null)
1437+ var spreadContainer = findInvisibleChild(shell, "spreadContainer")
1438+ verify(spreadContainer !== null)
1439+
1440+ var spreadRepeater = findInvisibleChild(shell, "spreadRepeater")
1441+ verify(spreadRepeater !== null)
14371442
14381443 // remember the focused appId
14391444 var focused = ApplicationManager.get(ApplicationManager.findApplication(ApplicationManager.focusedApplicationId));
14401445
1441− tryCompare(desktopStage, "state", "")
1446+ tryCompare(desktopSpread, "state", "")
14421447
14431448 // Just press Alt, make sure the spread comes up
14441449 keyPress(Qt.Key_Control);
14451450 keyClick(Qt.Key_Tab);
1446− tryCompare(desktopStage, "state", "altTab")
1447− tryCompare(appRepeater, "highlightedIndex", 1)
1451+ tryCompare(desktopSpread, "state", "altTab")
1452+ tryCompare(spreadRepeater, "highlightedIndex", 1)
14481453 waitForRendering(shell)
14491454
14501455 // Now press and hold Tab, make sure the highlight moves all the way but stops at the last one
14511456 // We can't simulate a pressed key with keyPress() currently, so let's inject the events
14521457 // at API level. Jump for 10 times, verify that it's still at the last one and didn't wrap around.
14531458 for (var i = 0; i < 10; i++) {
1454− appContainer.selectNext(true); // true == isAutoRepeat
1459+ desktopSpread.selectNext(true); // true == isAutoRepeat
14551460 wait(0); // Trigger the event loop to make sure all the things happen
14561461 }
1457− tryCompare(appRepeater, "highlightedIndex", 6)
1462+ tryCompare(spreadRepeater, "highlightedIndex", 6)
14581463
14591464 // Now release it once, and verify that it does wrap around with an additional Tab press
14601465 keyRelease(Qt.Key_Tab);
14611466 keyClick(Qt.Key_Tab);
1462− tryCompare(appRepeater, "highlightedIndex", 0)
1467+ tryCompare(spreadRepeater, "highlightedIndex", 0)
14631468
14641469 // Release control, check if spread disappears
14651470 keyRelease(Qt.Key_Control)
1466− tryCompare(desktopStage, "state", "")
1471+ tryCompare(desktopSpread, "state", "")
14671472
14681473 // Make sure that after wrapping around once, we have the same one focused as at the beginning
14691474 tryCompare(focused.session.surface, "activeFocus", true)
@@ -1472,30 +1477,30 @@ Rectangle {
14721477 function test_altBackTabNavigation() {
14731478 loadDesktopShellWithApps();
14741479
1475− var appRepeater = findInvisibleChild(shell, "appRepeater");
1476− verify(appRepeater !== null);
1480+ var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
1481+ verify(spreadRepeater !== null);
14771482
14781483 keyPress(Qt.Key_Control)
14791484 keyClick(Qt.Key_Tab);
1480− tryCompare(appRepeater, "highlightedIndex", 1);
1485+ tryCompare(spreadRepeater, "highlightedIndex", 1);
14811486
14821487 keyClick(Qt.Key_Tab);
1483− tryCompare(appRepeater, "highlightedIndex", 2);
1488+ tryCompare(spreadRepeater, "highlightedIndex", 2);
14841489
14851490 keyClick(Qt.Key_Tab);
1486− tryCompare(appRepeater, "highlightedIndex", 3);
1491+ tryCompare(spreadRepeater, "highlightedIndex", 3);
14871492
14881493 keyClick(Qt.Key_Tab);
1489− tryCompare(appRepeater, "highlightedIndex", 4);
1494+ tryCompare(spreadRepeater, "highlightedIndex", 4);
14901495
14911496 keyClick(Qt.Key_Backtab);
1492− tryCompare(appRepeater, "highlightedIndex", 3);
1497+ tryCompare(spreadRepeater, "highlightedIndex", 3);
14931498
14941499 keyClick(Qt.Key_Backtab);
1495− tryCompare(appRepeater, "highlightedIndex", 2);
1500+ tryCompare(spreadRepeater, "highlightedIndex", 2);
14961501
14971502 keyClick(Qt.Key_Backtab);
1498− tryCompare(appRepeater, "highlightedIndex", 1);
1503+ tryCompare(spreadRepeater, "highlightedIndex", 1);
14991504
15001505 keyRelease(Qt.Key_Control);
15011506 }
@@ -1503,20 +1508,20 @@ Rectangle {
15031508 function test_highlightFollowsMouse() {
15041509 loadDesktopShellWithApps()
15051510
1506− var appRepeater = findInvisibleChild(shell, "appRepeater");
1507− verify(appRepeater !== null);
1511+ var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
1512+ verify(spreadRepeater !== null);
15081513
15091514 keyPress(Qt.Key_Control)
15101515 keyClick(Qt.Key_Tab);
15111516
1512− tryCompare(appRepeater, "highlightedIndex", 1);
1517+ tryCompare(spreadRepeater, "highlightedIndex", 1);
15131518
15141519 var x = 0;
15151520 var y = shell.height * .75;
15161521 mouseMove(shell, x, y)
15171522
15181523 for (var i = 0; i < 7; i++) {
1519− while (appRepeater.highlightedIndex != i && x <= 4000) {
1524+ while (spreadRepeater.highlightedIndex != i && x <= 4000) {
15201525 x+=10;
15211526 mouseMove(shell, x, y)
15221527 wait(0); // spin the loop so bindings get evaluated
@@ -1531,8 +1536,8 @@ Rectangle {
15311536 function test_closeFromSpread() {
15321537 loadDesktopShellWithApps()
15331538
1534− var appRepeater = findInvisibleChild(shell, "appRepeater");
1535− verify(appRepeater !== null);
1539+ var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
1540+ verify(spreadRepeater !== null);
15361541
15371542 keyPress(Qt.Key_Control)
15381543 keyClick(Qt.Key_Tab);
@@ -1540,14 +1545,14 @@ Rectangle {
15401545 appRemovedSpy.clear();
15411546
15421547 var closedAppId = ApplicationManager.get(2).appId;
1543− var appDelegate2 = appRepeater.itemAt(2);
1544− var closeMouseArea = findChild(appDelegate2, "closeMouseArea");
1548+ var spreadDelegate2 = spreadRepeater.itemAt(2);
1549+ var closeMouseArea = findChild(spreadDelegate2, "closeMouseArea");
15451550
15461551 // Move the mosue over tile 2 and verify the close button becomes visible
15471552 var x = 0;
15481553 var y = shell.height * .5;
15491554 mouseMove(shell, x, y)
1550− while (appRepeater.highlightedIndex !== 2 && x <= 4000) {
1555+ while (spreadRepeater.highlightedIndex !== 2 && x <= 4000) {
15511556 x+=10;
15521557 mouseMove(shell, x, y)
15531558 wait(0); // spin the loop so bindings get evaluated
@@ -1594,7 +1599,7 @@ Rectangle {
15941599 var x = 0;
15951600 var y = shell.height * (data.tileInfo ? .95 : 0.5)
15961601 mouseMove(shell, x, y)
1597− while (appRepeater.highlightedIndex !== 2 && x <= 4000) {
1602+ while (spreadRepeater.highlightedIndex !== 2 && x <= 4000) {
15981603 x+=10;
15991604 mouseMove(shell, x, y)
16001605 wait(0); // spin the loop so bindings get evaluated