on xenial help sign in
Fix tst_OrientedShell

+ Clear several warnings in Shell.qml + Move shellMode into applicationArguments context property

commitbc9308613377a13a1d71136065ee8b769859e765 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateTue 23 Jun 2015, 09:08 (11 years ago) parentbeb7168
9 files changed+28−39
qml/OrientedShell.qml+1 qml/Shell.qml+13−15 src/ApplicationArguments.h+5 src/main.cpp+2−1 tests/autopilot/unity8/greeter/tests/test_args.py+6−6 tests/qmltests/Tutorial/tst_Tutorial.qml−1 tests/qmltests/tst_OrientedShell.qml+1−12 tests/qmltests/tst_Shell.qml−2 tests/qmltests/tst_ShellWithPin.qml−2
qml/OrientedShell.qml+1
@@ -135,6 +135,7 @@ Rectangle {
135135 nativeOrientation: root.nativeOrientation
136136 nativeWidth: root.width
137137 nativeHeight: root.height
138+ mode: applicationArguments.mode
138139
139140 // TODO: Factor in the connected input devices (eg: physical keyboard, mouse, touchscreen),
140141 // what's the output device (eg: big TV, desktop monitor, phone display), etc.
qml/Shell.qml+13−15
@@ -55,6 +55,7 @@ Item {
5555 property alias indicatorAreaShowProgress: panel.indicatorAreaShowProgress
5656 property bool beingResized
5757 property string usageScenario: "phone" // supported values: "phone", "tablet" or "desktop"
58+ property string mode: "full-greeter"
5859 function updateFocusedAppOrientation() {
5960 applicationsDisplayLoader.item.updateFocusedAppOrientation();
6061 }
@@ -68,9 +69,9 @@ Item {
6869
6970 readonly property bool orientationChangesEnabled: panel.indicators.fullyClosed
7071 && (applicationsDisplayLoader.item && applicationsDisplayLoader.item.orientationChangesEnabled)
71− && !greeter.animating
72+ && (!greeter || !greeter.animating)
7273
73− readonly property bool showingGreeter: greeter.shown
74+ readonly property bool showingGreeter: greeter && greeter.shown
7475
7576 property bool startingUp: true
7677 Timer { id: finishStartUpTimer; interval: 500; onTriggered: startingUp = false }
@@ -79,7 +80,7 @@ Item {
7980 if (startingUp) {
8081 // Ensure we don't rotate during start up
8182 return Qt.PrimaryOrientation;
82− } else if (greeter.shown) {
83+ } else if (greeter && greeter.shown) {
8384 return Qt.PrimaryOrientation;
8485 } else if (mainApp) {
8586 return mainApp.supportedOrientations;
@@ -101,16 +102,13 @@ Item {
101102
102103 // Disable everything while greeter is waiting, so that the user can't swipe
103104 // the greeter or launcher until we know whether the session is locked.
104− enabled: !greeter.waiting
105+ enabled: greeter && !greeter.waiting
105106
106107 property real edgeSize: units.gu(2)
107108 property url defaultBackground: Qt.resolvedUrl(shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg")
108109 property url background: asImageTester.status == Image.Ready ? asImageTester.source
109110 : gsImageTester.status == Image.Ready ? gsImageTester.source : defaultBackground
110111
111− // This is _only_ used to expose the property to autopilot tests
112− readonly property string testShellMode: shellMode
113−
114112 readonly property alias greeter: greeterLoader.item
115113
116114 function activateApplication(appId) {
@@ -264,7 +262,7 @@ Item {
264262 ? "phone"
265263 : shell.usageScenario
266264 source: {
267− if(shellMode === "greeter") {
265+ if(shell.mode === "greeter") {
268266 return "Stages/ShimStage.qml"
269267 } else if (applicationsDisplayLoader.usageScenario === "phone") {
270268 return "Stages/PhoneStage.qml";
@@ -276,7 +274,7 @@ Item {
276274 }
277275
278276 property bool interactive: tutorial.spreadEnabled
279− && !greeter.shown
277+ && (!greeter || !greeter.shown)
280278 && panel.indicators.fullyClosed
281279 && launcher.progress == 0
282280 && !notifications.useModal
@@ -307,12 +305,12 @@ Item {
307305 Binding {
308306 target: applicationsDisplayLoader.item
309307 property: "spreadEnabled"
310− value: tutorial.spreadEnabled && !greeter.hasLockedApp
308+ value: tutorial.spreadEnabled && (!greeter || !greeter.hasLockedApp)
311309 }
312310 Binding {
313311 target: applicationsDisplayLoader.item
314312 property: "inverseProgress"
315− value: greeter.locked ? 0 : launcher.progress
313+ value: greeter && greeter.locked ? 0 : launcher.progress
316314 }
317315 Binding {
318316 target: applicationsDisplayLoader.item
@@ -422,7 +420,7 @@ Item {
422420 id: greeterLoader
423421 anchors.fill: parent
424422 anchors.topMargin: panel.panelHeight
425− sourceComponent: shellMode != "shell" ? integratedGreeter :
423+ sourceComponent: shell.mode != "shell" ? integratedGreeter :
426424 Qt.createComponent(Qt.resolvedUrl("Greeter/ShimGreeter.qml"));
427425 onLoaded: {
428426 item.objectName = "greeter"
@@ -434,7 +432,7 @@ Item {
434432 Greeter {
435433
436434 hides: [launcher, panel.indicators]
437− tabletMode: shell.sideStageEnabled
435+ tabletMode: shell.usageScenario != "phone"
438436 launcherOffset: launcher.progress
439437 forcedUnlock: tutorial.running
440438 background: shell.background
@@ -550,8 +548,8 @@ Item {
550548 indicators {
551549 hides: [launcher]
552550 available: tutorial.panelEnabled
553− && (!greeter.locked || AccountsService.enableIndicatorsWhileLocked)
554− && !greeter.hasLockedApp
551+ && ((!greeter || !greeter.locked) || AccountsService.enableIndicatorsWhileLocked)
552+ && (!greeter || !greeter.hasLockedApp)
555553 contentEnabled: tutorial.panelContentEnabled
556554 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
557555
src/ApplicationArguments.h+5
@@ -27,14 +27,19 @@ class ApplicationArguments : public QObject
2727{
2828 Q_OBJECT
2929 Q_PROPERTY(QString deviceName READ deviceName CONSTANT)
30+ Q_PROPERTY(QString mode READ mode CONSTANT)
3031public:
3132 ApplicationArguments(QObject *parent = nullptr);
3233
3334 void setDeviceName(QString deviceName) { m_deviceName = deviceName; }
3435 QString deviceName() const { return m_deviceName; }
3536
37+ void setMode(QString mode) { m_mode = mode; }
38+ QString mode() const { return m_mode; }
39+
3640private:
3741 QString m_deviceName;
42+ QString m_mode;
3843};
3944
4045#endif // APPLICATION_ARGUMENTS_H
src/main.cpp+2−1
@@ -60,6 +60,8 @@ int main(int argc, const char *argv[])
6060 qmlArgs.setDeviceName(QString(buffer));
6161 }
6262
63+ qmlArgs.setMode(parser.mode());
64+
6365 // The testability driver is only loaded by QApplication but not by QGuiApplication.
6466 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
6567 if (parser.hasTestability() || getenv("QT_LOAD_TESTABILITY")) {
@@ -92,7 +94,6 @@ int main(int argc, const char *argv[])
9294
9395 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
9496 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
95− view->rootContext()->setContextProperty("shellMode", parser.mode());
9697 if (parser.hasFrameless()) {
9798 view->setFlags(Qt::FramelessWindowHint);
9899 }
tests/autopilot/unity8/greeter/tests/test_args.py+6−6
@@ -28,27 +28,27 @@ class GreeterArgsTest(GreeterTestCase):
2828 def test_full_greeter_mode(self):
2929 unity_proxy = self.launch_unity(mode='full-greeter')
3030 shell = self.get_shell(unity_proxy)
31− self.assertTrue(shell.testShellMode == 'full-greeter')
31+ self.assertTrue(shell.mode == 'full-greeter')
3232
3333 def test_full_shell_mode(self):
3434 unity_proxy = self.launch_unity(mode='full-shell')
3535 shell = self.get_shell(unity_proxy)
36− self.assertTrue(shell.testShellMode == 'full-shell')
36+ self.assertTrue(shell.mode == 'full-shell')
3737
3838 def test_greeter_mode(self):
3939 unity_proxy = self.launch_unity(mode='greeter')
4040 shell = self.get_shell(unity_proxy)
41− self.assertTrue(shell.testShellMode == 'greeter')
41+ self.assertTrue(shell.mode == 'greeter')
4242
4343 def test_nonexistent_mode(self):
4444 unity_proxy = self.launch_unity(mode=self.NONEXISTENT_MODE)
4545 shell = self.get_shell(unity_proxy)
46− self.assertTrue(shell.testShellMode == self.DEFAULT_SHELL_MODE,
46+ self.assertTrue(shell.mode == self.DEFAULT_SHELL_MODE,
4747 "Shell mode was {} but should have been {}"
48− .format(shell.testShellMode,
48+ .format(shell.mode,
4949 self.DEFAULT_SHELL_MODE))
5050
5151 def test_shell_mode(self):
5252 unity_proxy = self.launch_unity(mode='shell')
5353 shell = self.get_shell(unity_proxy)
54− self.assertTrue(shell.testShellMode == 'shell')
54+ self.assertTrue(shell.mode == 'shell')
tests/qmltests/Tutorial/tst_Tutorial.qml−1
@@ -73,7 +73,6 @@ Item {
7373 sourceComponent: Component {
7474 Shell {
7575 property string indicatorProfile: "phone"
76− property string shellMode: "full-greeter" /* default */
7776
7877 Component.onDestruction: {
7978 shellLoader.itemDestroyed = true;
tests/qmltests/tst_OrientedShell.qml+1−12
@@ -34,19 +34,8 @@ Rectangle {
3434
3535 QtObject {
3636 id: applicationArguments
37−
38− function hasGeometry() {
39− return false;
40− }
41−
42− function width() {
43− return 0;
44− }
45−
46− function height() {
47− return 0;
48− }
4937 property string deviceName: "mako"
38+ property string mode: "full-greeter"
5039 }
5140
5241 QtObject {
tests/qmltests/tst_Shell.qml−2
@@ -81,8 +81,6 @@ Rectangle {
8181 property bool itemDestroyed: false
8282 sourceComponent: Component {
8383 Shell {
84− property string shellMode: "full-greeter" /* default */
85−
8684 usageScenario: usageScenarioSelector.model[usageScenarioSelector.selectedIndex]
8785 orientation: Qt.PortraitOrientation
8886 primaryOrientation: Qt.PortraitOrientation
tests/qmltests/tst_ShellWithPin.qml−2
@@ -69,8 +69,6 @@ Item {
6969 property bool itemDestroyed: false
7070 sourceComponent: Component {
7171 Shell {
72− property string shellMode: "full-greeter" /* default */
73−
7472 Component.onDestruction: {
7573 shellLoader.itemDestroyed = true
7674 }