Merge lp:~aacid/unity-2d/unity-2d-shell_choose_root_file into lp:~unity-2d-team/unity-2d/unity-2d-shell

Proposed by Albert Astals Cid on 2012-01-19
Status: Merged
Approved by: Michał Sawicz on 2012-01-24
Approved revision: 926
Merged at revision: 926
Proposed branch: lp:~aacid/unity-2d/unity-2d-shell_choose_root_file
Merge into: lp:~unity-2d-team/unity-2d/unity-2d-shell
Diff against target: 157 lines (+124/-3)
3 files modified
shell/app/shell.cpp (+15/-3)
tests/shell/root_qml_param.rb (+97/-0)
tests/shell/rootqmlparamtest.qml (+12/-0)
To merge this branch: bzr merge lp:~aacid/unity-2d/unity-2d-shell_choose_root_file
Reviewer Review Type Date Requested Status
Michał Sawicz 2012-01-19 Approve on 2012-01-24
Florian Boucault 2012-01-24 Pending
Ugo Riboni 2012-01-23 Pending
Review via email: mp+89290@code.launchpad.net

Description of the Change

[shell] Add the -rootfile option that lets the user specify the shell root qml file

To post a comment you must log in.
921. By Albert Astals Cid on 2012-01-23

merge

922. By Albert Astals Cid on 2012-01-23

Add a test to show the file is being loaded correctly

923. By Albert Astals Cid on 2012-01-23

merge

Michał Sawicz (saviq) wrote :

Could you maybe rename the argument to "-rootqml", please? it's more self-explanatory then.

review: Needs Fixing
924. By Albert Astals Cid on 2012-01-24

rename param to rootqml as per Michał suggestion

Michał Sawicz (saviq) wrote :

Here's the result of the tests on stock unity-2d-shell:

michal@michal-vm:~/dev/canonical/desktop/unity-2d/tests/shell$ ./root_file_param.rb
Running tests on applications contained within /home/michal/dev/canonical/desktop/unity-2d
Loaded suite ./root_file_param
Started
..E
Finished in 35.574464 seconds.

  1) Error:
test_Verify_app_starts_with_a_valid_rootfile_parameter(Shell_root_file_param_test):
MobyBase::VerificationError: Verification at ./root_file_param.rb:116:in `test_Verify_app_starts_with_a_valid_rootfile_parameter' failed as an exception was thrown when the verification block was executed
=> verify{ @app.QDeclarativeText( :text => 'This is the rootfile.qml test' ) }
     end

Details:
#<MobyBase::TestObjectNotFoundError: The application (id: 1633, name: "unity-2d-shell") has no child object with type or behaviour method with name "QDeclarativeText" (attributes :text=>"This is the rootfile.qml test") on :sut_qt>
    /usr/lib/ruby/vendor_ruby/tdriver/verify/verify.rb:168:in `verify'
    ./root_file_param.rb:116:in `test_Verify_app_starts_with_a_valid_rootfile_parameter'
    /media/sf_dev/canonical/desktop/unity-2d/tests/misc/lib/testhelper.rb:39:in `run'

3 tests, 0 assertions, 0 failures, 1 errors

review: Needs Fixing
925. By Albert Astals Cid on 2012-01-24

verify_not is kind of weird, i need a 0 here so that it passes with the feature and fails without

926. By Albert Astals Cid on 2012-01-24

As discussed with Michał does not make much sense to test that the shell starts in the rootqml tests, it belongs somewhere else

Michał Sawicz (saviq) wrote :

Good for me, Florian please tell if that's not what you had in mind for "Add cmd line option to choose which root QML file to load".

review: Approve
Florian Boucault (fboucault) wrote :

That's great guys. Step 2 will be to make sure we can do:

unity-2d-shell -rootqml shell/launcher/Launcher.qml
unity-2d-shell -rootqml shell/dash/Dash.qml

Michał Sawicz (saviq) wrote :

Approving, then, and we will need to split the shell up into separate components. Florian, what's the priority of that?

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'shell/app/shell.cpp'
2--- shell/app/shell.cpp 2011-11-30 13:07:38 +0000
3+++ shell/app/shell.cpp 2012-01-24 11:40:35 +0000
4@@ -51,11 +51,23 @@
5 Unity2dApplication::earlySetup(argc, argv);
6 Unity2dApplication application(argc, argv);
7
8+ QUrl rootFileUrl;
9+ const QStringList arguments = application.arguments();
10+ const int rootFileArgumentIndex = arguments.indexOf("-rootqml");
11+ if (rootFileArgumentIndex != -1) {
12+ if (rootFileArgumentIndex + 1 < arguments.count()) {
13+ rootFileUrl = arguments[rootFileArgumentIndex + 1];
14+ } else {
15+ qCritical() << "-rootqml argument given without file";
16+ return -1;
17+ }
18+ } else {
19+ rootFileUrl = QUrl("Shell.qml");
20+ }
21+
22 application.setApplicationName("Unity 2D Shell");
23 application.setQuitOnLastWindowClosed(false);
24
25- QSet<QString> arguments = QSet<QString>::fromList(QCoreApplication::arguments());
26-
27 GnomeSessionClient client(INSTALL_PREFIX "/share/applications/unity-2d-shell.desktop");
28 client.connectToSessionManager();
29
30@@ -83,7 +95,7 @@
31 /* Load the QML UI, focus and show the window */
32 view.setResizeMode(QDeclarativeView::SizeViewToRootObject);
33 view.rootContext()->setContextProperty("declarativeView", &view);
34- view.setSource(QUrl("Shell.qml"));
35+ view.setSource(rootFileUrl);
36
37 /* Unset DESKTOP_AUTOSTART_ID in order to avoid child processes (launched
38 applications) to use the same client id.
39
40=== added file 'tests/shell/root_qml_param.rb'
41--- tests/shell/root_qml_param.rb 1970-01-01 00:00:00 +0000
42+++ tests/shell/root_qml_param.rb 2012-01-24 11:40:35 +0000
43@@ -0,0 +1,97 @@
44+#!/usr/bin/env ruby1.8
45+=begin
46+/*
47+ * This file is part of unity-2d
48+ *
49+ * Copyright 2011 Canonical Ltd.
50+ *
51+ * Authors:
52+ * - Albert Astals Cid <albert.astals@canonical.com>
53+ *
54+ * This program is free software; you can redistribute it and/or modify
55+ * it under the terms of the GNU General Public License as published by
56+ * the Free Software Foundation; version 3.
57+ *
58+ * This program is distributed in the hope that it will be useful,
59+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
60+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
61+ * GNU General Public License for more details.
62+ *
63+ * You should have received a copy of the GNU General Public License
64+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
65+ */
66+=end
67+
68+require '../run-tests.rb' unless $INIT_COMPLETED
69+require 'xdo/xwindow'
70+require 'xdo/keyboard'
71+require 'xdo/mouse'
72+require 'tmpwindow'
73+
74+############################# Test Suite #############################
75+context "Shell root file param test" do
76+ # Run once at the beginning of this test suite
77+ startup do
78+ system 'killall unity-2d-shell > /dev/null 2>&1'
79+ system 'killall unity-2d-shell > /dev/null 2>&1'
80+
81+ end
82+
83+ # Run once at the end of this test suite
84+ shutdown do
85+ end
86+
87+ # Run before each test case begins
88+ setup do
89+ end
90+
91+ # Run after each test case completes
92+ teardown do
93+ system "pkill -nf unity-2d-shell"
94+ end
95+
96+ #####################################################################################
97+ # Test cases
98+
99+ # Test case objectives:
100+ # * Check the app does not start with the -rootqml parameter but without path for the file
101+ # Pre-conditions
102+ # * None
103+ # Test steps
104+ # * Verify app does not start
105+ # Post-conditions
106+ # * None
107+ # References
108+ # * None
109+ test "Verify app does not start without a rootqml parameter" do
110+ # Execute the application
111+ @sut = TDriver.sut(:Id => "sut_qt")
112+ verify_not(0) { @app = @sut.run( :name => UNITY_2D_SHELL,
113+ :arguments => "-testability,-rootqml",
114+ :sleeptime => 2 ) }
115+ end
116+
117+ # Test case objectives:
118+ # * Check the app loads the qml file specified in the -rootqml parameter
119+ # Pre-conditions
120+ # * None
121+ # Test steps
122+ # * Verify app starts
123+ # * Verify the contents of the qml file are loaded
124+ # Post-conditions
125+ # * None
126+ # References
127+ # * None
128+ test "Verify app starts with a valid rootqml parameter" do
129+ # Execute the application
130+ testQmlFile = File.expand_path(File.dirname(__FILE__)) + "/rootqmlparamtest.qml"
131+ @sut = TDriver.sut(:Id => "sut_qt")
132+ @app = @sut.run( :name => UNITY_2D_SHELL,
133+ :arguments => "-testability,-rootqml," + testQmlFile,
134+ :sleeptime => 2 )
135+ # Make certain application is ready for testing
136+ verify{ @app }
137+ verify{ @app.QDeclarativeText( :text => 'This is rootqmlparamtest.qml' ) }
138+ end
139+
140+end
141
142=== added file 'tests/shell/rootqmlparamtest.qml'
143--- tests/shell/rootqmlparamtest.qml 1970-01-01 00:00:00 +0000
144+++ tests/shell/rootqmlparamtest.qml 2012-01-24 11:40:35 +0000
145@@ -0,0 +1,12 @@
146+import QtQuick 1.1
147+
148+Rectangle {
149+ height: 400
150+ width: 400
151+ color: "white"
152+
153+ Text {
154+ text: "This is rootqmlparamtest.qml"
155+ }
156+ Component.onCompleted: declarativeView.show()
157+}

Subscribers

People subscribed via source and target branches