on xenial help sign in
fix more tests and focus handling
770e4e7Michael Zanetti
plugins/GlobalShortcut/globalshortcut.cpp+1−1
@@ -72,7 +72,7 @@ void GlobalShortcut::keyPressEvent(QKeyEvent * event)
72void GlobalShortcut::setupFilterOnWindow(QQuickWindow *window)
72void GlobalShortcut::setupFilterOnWindow(QQuickWindow *window)
73{
73{
74 if (!window) {
74 if (!window) {
75− qWarning() << Q_FUNC_INFO << "Failed to setup filter on window";
75+// qWarning() << Q_FUNC_INFO << "Failed to setup filter on window";
76 return;
76 return;
77 }
77 }
78
78
qml/Stages/DesktopSpread.qml+1
@@ -77,6 +77,7 @@ FocusScope {
77
77
78 Item {
78 Item {
79 id: spreadContainer
79 id: spreadContainer
80+ objectName: "spreadContainer"
80 anchors.fill: parent
81 anchors.fill: parent
81 visible: false
82 visible: false
82
83
qml/Stages/DesktopSpreadDelegate.qml+2−2
@@ -29,8 +29,8 @@ Item {
29 property bool highlightShown: false
29 property bool highlightShown: false
30 property real shadowOpacity: 1
30 property real shadowOpacity: 1
31
31
32− property int windowWidth: application.session.surface.size.width
32+ property int windowWidth: application.session && application.session.surface ? application.session.surface.size.width : 0
33− property int windowHeight: application.session.surface.size.height
33+ property int windowHeight: application.session && application.session.surface ? application.session.surface.size.height : 0
34
34
35 state: "normal"
35 state: "normal"
36 states: [
36 states: [
qml/Stages/DesktopStage.qml+3−15
@@ -70,7 +70,7 @@ Rectangle {
70 var appIndex = priv.indexOf(appId);
70 var appIndex = priv.indexOf(appId);
71 var appDelegate = appRepeater.itemAt(appIndex);
71 var appDelegate = appRepeater.itemAt(appIndex);
72 appDelegate.minimized = false;
72 appDelegate.minimized = false;
73− appDelegate.focus = true;
73+ ApplicationManager.focusApplication(appId)
74 }
74 }
75 }
75 }
76
76
@@ -132,12 +132,7 @@ Rectangle {
132 y: units.gu(3)
132 y: units.gu(3)
133 width: units.gu(60)
133 width: units.gu(60)
134 height: units.gu(50)
134 height: units.gu(50)
135−
135+ focus: model.appId === priv.focusedAppId
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
141
136
142 readonly property int minWidth: units.gu(10)
137 readonly property int minWidth: units.gu(10)
143 readonly property int minHeight: units.gu(10)
138 readonly property int minHeight: units.gu(10)
@@ -151,13 +146,6 @@ Rectangle {
151 }
146 }
152 }
147 }
153
148
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−
161 Binding {
149 Binding {
162 target: ApplicationManager.get(index)
150 target: ApplicationManager.get(index)
163 property: "requestedState"
151 property: "requestedState"
@@ -231,7 +219,7 @@ Rectangle {
231 resizeHandleWidth: units.gu(2)
219 resizeHandleWidth: units.gu(2)
232 windowId: model.appId // FIXME: Change this to point to windowId once we have such a thing
220 windowId: model.appId // FIXME: Change this to point to windowId once we have such a thing
233
221
234− onPressed: { appDelegate.focus = true; }
222+ onPressed: { ApplicationManager.focusApplication(model.appId) }
235 }
223 }
236
224
237 DecoratedWindow {
225 DecoratedWindow {
tests/mocks/Unity/Application/Session.cpp+4−4
@@ -35,14 +35,14 @@ Session::Session(const QString &name,
35 , m_parentSession(nullptr)
35 , m_parentSession(nullptr)
36 , m_children(new SessionModel(this))
36 , m_children(new SessionModel(this))
37{
37{
38− qDebug() << "Session::Session() " << this->name();
38+// qDebug() << "Session::Session() " << this->name();
39
39
40 QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
40 QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
41}
41}
42
42
43Session::~Session()
43Session::~Session()
44{
44{
45− qDebug() << "Session::~Session() " << name();
45+// qDebug() << "Session::~Session() " << name();
46
46
47 QList<Session*> children(m_children->list());
47 QList<Session*> children(m_children->list());
48 for (Session* child : children) {
48 for (Session* child : children) {
@@ -67,7 +67,7 @@ Session::~Session()
67
67
68void Session::release()
68void Session::release()
69{
69{
70− qDebug() << "Session::release " << name();
70+// qDebug() << "Session::release " << name();
71 deleteLater();
71 deleteLater();
72}
72}
73
73
@@ -82,7 +82,7 @@ void Session::setApplication(ApplicationInfo* application)
82
82
83void Session::setSurface(MirSurface* surface)
83void Session::setSurface(MirSurface* surface)
84{
84{
85− qDebug() << "Session::setSurface - session=" << name() << "surface=" << surface;
85+// qDebug() << "Session::setSurface - session=" << name() << "surface=" << surface;
86 if (m_surface == surface)
86 if (m_surface == surface)
87 return;
87 return;
88
88
tests/qmltests/tst_Shell.qml+39−34
@@ -322,8 +322,9 @@ Rectangle {
322
322
323 function loadDesktopShellWithApps() {
323 function loadDesktopShellWithApps() {
324 loadShell("desktop");
324 loadShell("desktop");
325+ waitForRendering(shell)
325 shell.usageScenario = "desktop"
326 shell.usageScenario = "desktop"
326− waitForRendering(root)
327+ waitForRendering(shell)
327 var app1 = ApplicationManager.startApplication("dialer-app")
328 var app1 = ApplicationManager.startApplication("dialer-app")
328 var app2 = ApplicationManager.startApplication("webbrowser-app")
329 var app2 = ApplicationManager.startApplication("webbrowser-app")
329 var app3 = ApplicationManager.startApplication("camera-app")
330 var app3 = ApplicationManager.startApplication("camera-app")
@@ -1407,17 +1408,18 @@ Rectangle {
1407 keyClick(Qt.Key_Tab, Qt.ControlModifier)
1408 keyClick(Qt.Key_Tab, Qt.ControlModifier)
1408 tryCompare(app2.session.surface, "activeFocus", true)
1409 tryCompare(app2.session.surface, "activeFocus", true)
1409
1410
1411+ var desktopSpread = findChild(shell, "spread")
1410
1412
1411− tryCompare(desktopStage, "state", "")
1413+ tryCompare(desktopSpread, "state", "")
1412
1414
1413 // Just press Alt, make sure the spread comes up
1415 // Just press Alt, make sure the spread comes up
1414 keyPress(Qt.Key_Control);
1416 keyPress(Qt.Key_Control);
1415 keyClick(Qt.Key_Tab);
1417 keyClick(Qt.Key_Tab);
1416− tryCompare(desktopStage, "state", "altTab")
1418+ tryCompare(desktopSpread, "state", "altTab")
1417
1419
1418 // Release control, check if spread disappears
1420 // Release control, check if spread disappears
1419 keyRelease(Qt.Key_Control)
1421 keyRelease(Qt.Key_Control)
1420− tryCompare(desktopStage, "state", "")
1422+ tryCompare(desktopSpread, "state", "")
1421
1423
1422 // Focus should have switched back now
1424 // Focus should have switched back now
1423 tryCompare(app3.session.surface, "activeFocus", true)
1425 tryCompare(app3.session.surface, "activeFocus", true)
@@ -1429,41 +1431,44 @@ Rectangle {
1429 var desktopStage = findChild(shell, "stage");
1431 var desktopStage = findChild(shell, "stage");
1430 verify(desktopStage !== null)
1432 verify(desktopStage !== null)
1431
1433
1432− var appContainer = findInvisibleChild(shell, "appContainer")
1434+ var desktopSpread = findChild(shell, "spread");
1433− verify(appContainer !== null)
1435+ verify(desktopSpread !== null)
1434
1436
1437+ var spreadContainer = findInvisibleChild(shell, "spreadContainer")
1438+ verify(spreadContainer !== null)
1439+
1435− var appRepeater = findInvisibleChild(shell, "appRepeater")
1440+ var spreadRepeater = findInvisibleChild(shell, "spreadRepeater")
1436− verify(appRepeater !== null)
1441+ verify(spreadRepeater !== null)
1437
1442
1438 // remember the focused appId
1443 // remember the focused appId
1439 var focused = ApplicationManager.get(ApplicationManager.findApplication(ApplicationManager.focusedApplicationId));
1444 var focused = ApplicationManager.get(ApplicationManager.findApplication(ApplicationManager.focusedApplicationId));
1440
1445
1441− tryCompare(desktopStage, "state", "")
1446+ tryCompare(desktopSpread, "state", "")
1442
1447
1443 // Just press Alt, make sure the spread comes up
1448 // Just press Alt, make sure the spread comes up
1444 keyPress(Qt.Key_Control);
1449 keyPress(Qt.Key_Control);
1445 keyClick(Qt.Key_Tab);
1450 keyClick(Qt.Key_Tab);
1446− tryCompare(desktopStage, "state", "altTab")
1451+ tryCompare(desktopSpread, "state", "altTab")
1447− tryCompare(appRepeater, "highlightedIndex", 1)
1452+ tryCompare(spreadRepeater, "highlightedIndex", 1)
1448 waitForRendering(shell)
1453 waitForRendering(shell)
1449
1454
1450 // Now press and hold Tab, make sure the highlight moves all the way but stops at the last one
1455 // Now press and hold Tab, make sure the highlight moves all the way but stops at the last one
1451 // We can't simulate a pressed key with keyPress() currently, so let's inject the events
1456 // We can't simulate a pressed key with keyPress() currently, so let's inject the events
1452 // at API level. Jump for 10 times, verify that it's still at the last one and didn't wrap around.
1457 // at API level. Jump for 10 times, verify that it's still at the last one and didn't wrap around.
1453 for (var i = 0; i < 10; i++) {
1458 for (var i = 0; i < 10; i++) {
1454− appContainer.selectNext(true); // true == isAutoRepeat
1459+ desktopSpread.selectNext(true); // true == isAutoRepeat
1455 wait(0); // Trigger the event loop to make sure all the things happen
1460 wait(0); // Trigger the event loop to make sure all the things happen
1456 }
1461 }
1457− tryCompare(appRepeater, "highlightedIndex", 6)
1462+ tryCompare(spreadRepeater, "highlightedIndex", 6)
1458
1463
1459 // Now release it once, and verify that it does wrap around with an additional Tab press
1464 // Now release it once, and verify that it does wrap around with an additional Tab press
1460 keyRelease(Qt.Key_Tab);
1465 keyRelease(Qt.Key_Tab);
1461 keyClick(Qt.Key_Tab);
1466 keyClick(Qt.Key_Tab);
1462− tryCompare(appRepeater, "highlightedIndex", 0)
1467+ tryCompare(spreadRepeater, "highlightedIndex", 0)
1463
1468
1464 // Release control, check if spread disappears
1469 // Release control, check if spread disappears
1465 keyRelease(Qt.Key_Control)
1470 keyRelease(Qt.Key_Control)
1466− tryCompare(desktopStage, "state", "")
1471+ tryCompare(desktopSpread, "state", "")
1467
1472
1468 // Make sure that after wrapping around once, we have the same one focused as at the beginning
1473 // Make sure that after wrapping around once, we have the same one focused as at the beginning
1469 tryCompare(focused.session.surface, "activeFocus", true)
1474 tryCompare(focused.session.surface, "activeFocus", true)
@@ -1472,30 +1477,30 @@ Rectangle {
1472 function test_altBackTabNavigation() {
1477 function test_altBackTabNavigation() {
1473 loadDesktopShellWithApps();
1478 loadDesktopShellWithApps();
1474
1479
1475− var appRepeater = findInvisibleChild(shell, "appRepeater");
1480+ var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
1476− verify(appRepeater !== null);
1481+ verify(spreadRepeater !== null);
1477
1482
1478 keyPress(Qt.Key_Control)
1483 keyPress(Qt.Key_Control)
1479 keyClick(Qt.Key_Tab);
1484 keyClick(Qt.Key_Tab);
1480− tryCompare(appRepeater, "highlightedIndex", 1);
1485+ tryCompare(spreadRepeater, "highlightedIndex", 1);
1481
1486
1482 keyClick(Qt.Key_Tab);
1487 keyClick(Qt.Key_Tab);
1483− tryCompare(appRepeater, "highlightedIndex", 2);
1488+ tryCompare(spreadRepeater, "highlightedIndex", 2);
1484
1489
1485 keyClick(Qt.Key_Tab);
1490 keyClick(Qt.Key_Tab);
1486− tryCompare(appRepeater, "highlightedIndex", 3);
1491+ tryCompare(spreadRepeater, "highlightedIndex", 3);
1487
1492
1488 keyClick(Qt.Key_Tab);
1493 keyClick(Qt.Key_Tab);
1489− tryCompare(appRepeater, "highlightedIndex", 4);
1494+ tryCompare(spreadRepeater, "highlightedIndex", 4);
1490
1495
1491 keyClick(Qt.Key_Backtab);
1496 keyClick(Qt.Key_Backtab);
1492− tryCompare(appRepeater, "highlightedIndex", 3);
1497+ tryCompare(spreadRepeater, "highlightedIndex", 3);
1493
1498
1494 keyClick(Qt.Key_Backtab);
1499 keyClick(Qt.Key_Backtab);
1495− tryCompare(appRepeater, "highlightedIndex", 2);
1500+ tryCompare(spreadRepeater, "highlightedIndex", 2);
1496
1501
1497 keyClick(Qt.Key_Backtab);
1502 keyClick(Qt.Key_Backtab);
1498− tryCompare(appRepeater, "highlightedIndex", 1);
1503+ tryCompare(spreadRepeater, "highlightedIndex", 1);
1499
1504
1500 keyRelease(Qt.Key_Control);
1505 keyRelease(Qt.Key_Control);
1501 }
1506 }
@@ -1503,20 +1508,20 @@ Rectangle {
1503 function test_highlightFollowsMouse() {
1508 function test_highlightFollowsMouse() {
1504 loadDesktopShellWithApps()
1509 loadDesktopShellWithApps()
1505
1510
1506− var appRepeater = findInvisibleChild(shell, "appRepeater");
1511+ var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
1507− verify(appRepeater !== null);
1512+ verify(spreadRepeater !== null);
1508
1513
1509 keyPress(Qt.Key_Control)
1514 keyPress(Qt.Key_Control)
1510 keyClick(Qt.Key_Tab);
1515 keyClick(Qt.Key_Tab);
1511
1516
1512− tryCompare(appRepeater, "highlightedIndex", 1);
1517+ tryCompare(spreadRepeater, "highlightedIndex", 1);
1513
1518
1514 var x = 0;
1519 var x = 0;
1515 var y = shell.height * .75;
1520 var y = shell.height * .75;
1516 mouseMove(shell, x, y)
1521 mouseMove(shell, x, y)
1517
1522
1518 for (var i = 0; i < 7; i++) {
1523 for (var i = 0; i < 7; i++) {
1519− while (appRepeater.highlightedIndex != i && x <= 4000) {
1524+ while (spreadRepeater.highlightedIndex != i && x <= 4000) {
1520 x+=10;
1525 x+=10;
1521 mouseMove(shell, x, y)
1526 mouseMove(shell, x, y)
1522 wait(0); // spin the loop so bindings get evaluated
1527 wait(0); // spin the loop so bindings get evaluated
@@ -1531,8 +1536,8 @@ Rectangle {
1531 function test_closeFromSpread() {
1536 function test_closeFromSpread() {
1532 loadDesktopShellWithApps()
1537 loadDesktopShellWithApps()
1533
1538
1534− var appRepeater = findInvisibleChild(shell, "appRepeater");
1539+ var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
1535− verify(appRepeater !== null);
1540+ verify(spreadRepeater !== null);
1536
1541
1537 keyPress(Qt.Key_Control)
1542 keyPress(Qt.Key_Control)
1538 keyClick(Qt.Key_Tab);
1543 keyClick(Qt.Key_Tab);
@@ -1540,14 +1545,14 @@ Rectangle {
1540 appRemovedSpy.clear();
1545 appRemovedSpy.clear();
1541
1546
1542 var closedAppId = ApplicationManager.get(2).appId;
1547 var closedAppId = ApplicationManager.get(2).appId;
1543− var appDelegate2 = appRepeater.itemAt(2);
1548+ var spreadDelegate2 = spreadRepeater.itemAt(2);
1544− var closeMouseArea = findChild(appDelegate2, "closeMouseArea");
1549+ var closeMouseArea = findChild(spreadDelegate2, "closeMouseArea");
1545
1550
1546 // Move the mosue over tile 2 and verify the close button becomes visible
1551 // Move the mosue over tile 2 and verify the close button becomes visible
1547 var x = 0;
1552 var x = 0;
1548 var y = shell.height * .5;
1553 var y = shell.height * .5;
1549 mouseMove(shell, x, y)
1554 mouseMove(shell, x, y)
1550− while (appRepeater.highlightedIndex !== 2 && x <= 4000) {
1555+ while (spreadRepeater.highlightedIndex !== 2 && x <= 4000) {
1551 x+=10;
1556 x+=10;
1552 mouseMove(shell, x, y)
1557 mouseMove(shell, x, y)
1553 wait(0); // spin the loop so bindings get evaluated
1558 wait(0); // spin the loop so bindings get evaluated
@@ -1594,7 +1599,7 @@ Rectangle {
1594 var x = 0;
1599 var x = 0;
1595 var y = shell.height * (data.tileInfo ? .95 : 0.5)
1600 var y = shell.height * (data.tileInfo ? .95 : 0.5)
1596 mouseMove(shell, x, y)
1601 mouseMove(shell, x, y)
1597− while (appRepeater.highlightedIndex !== 2 && x <= 4000) {
1602+ while (spreadRepeater.highlightedIndex !== 2 && x <= 4000) {
1598 x+=10;
1603 x+=10;
1599 mouseMove(shell, x, y)
1604 mouseMove(shell, x, y)
1600 wait(0); // spin the loop so bindings get evaluated
1605 wait(0); // spin the loop so bindings get evaluated