Merge lp:~paulliu/unity8/shellRotation_macslow into lp:~macslow/unity8/shellRotation

Proposed by Ying-Chun Liu
Status: Merged
Approved by: Mirco Müller
Approved revision: 1594
Merged at revision: 1594
Proposed branch: lp:~paulliu/unity8/shellRotation_macslow
Merge into: lp:~macslow/unity8/shellRotation
Diff against target: 148 lines (+90/-6)
3 files modified
qml/Rotation/ImmediateRotationAction.qml (+0/-1)
tests/autopilot/unity8/fixture_setup.py (+1/-1)
tests/autopilot/unity8/shell/tests/test_rotation.py (+89/-4)
To merge this branch: bzr merge lp:~paulliu/unity8/shellRotation_macslow
Reviewer Review Type Date Requested Status
Mirco Müller Approve
Review via email: mp+254949@code.launchpad.net

Commit message

Add test fake sensors.
Add test rotation on webbrowser-app

Description of the change

Add test fake sensors.
Add test rotation on webbrowser-app

To post a comment you must log in.
Revision history for this message
Mirco Müller (macslow) wrote :

I can only get your added tests test_fake_sensor() and test_rotation_with_webbrowser_app() to work when I add _environment['UBUNTU_PLATFORM_API_TEST_OVERRIDE']='sensors' to _restart_unity_with_testability() in <branch>/tests/autopilot/unity8/fixture_setup.py

I also get occasional failures like: http://pastebin.ubuntu.com/10723598

Do these tests always pass on your device?

Revision history for this message
Mirco Müller (macslow) wrote :

I can get test_fake_sensor() and test_rotation_with_webbrowser_app() to work and pass without the explicit _environment['UBUNTU_PLATFORM_API_TEST_OVERRIDE']='sensors'. But the success-rate is only 25% at best.

Revision history for this message
Mirco Müller (macslow) wrote :

Code-wise I'm fine with your branch and would like to approve it, but the failures I still see here make me hesitate a bit. But on the other hand, this is just to merge into my branch and not to trunk, so I would continue the battle there.

Revision history for this message
Mirco Müller (macslow) wrote :

See above.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'qml/Rotation/ImmediateRotationAction.qml'
--- qml/Rotation/ImmediateRotationAction.qml 2015-03-06 04:44:11 +0000
+++ qml/Rotation/ImmediateRotationAction.qml 2015-04-01 16:45:52 +0000
@@ -43,4 +43,3 @@
43 info.transitioning = false;43 info.transitioning = false;
44 }44 }
45}45}
46
4746
=== modified file 'tests/autopilot/unity8/fixture_setup.py'
--- tests/autopilot/unity8/fixture_setup.py 2015-04-01 11:25:54 +0000
+++ tests/autopilot/unity8/fixture_setup.py 2015-04-01 16:45:52 +0000
@@ -147,7 +147,7 @@
147 with open(fifo_path, 'w') as fifo:147 with open(fifo_path, 'w') as fifo:
148 fifo.write('create accel 0 1000 0.1\n')148 fifo.write('create accel 0 1000 0.1\n')
149 fifo.write('create light 0 10 1\n')149 fifo.write('create light 0 10 1\n')
150 fifo.write('create proximity\n') 150 fifo.write('create proximity\n')
151151
152class LaunchDashApp(fixtures.Fixture):152class LaunchDashApp(fixtures.Fixture):
153153
154154
=== modified file 'tests/autopilot/unity8/shell/tests/test_rotation.py'
--- tests/autopilot/unity8/shell/tests/test_rotation.py 2015-03-30 14:53:21 +0000
+++ tests/autopilot/unity8/shell/tests/test_rotation.py 2015-04-01 16:45:52 +0000
@@ -31,6 +31,7 @@
31import ubuntuuitoolkit31import ubuntuuitoolkit
32import logging32import logging
33from testtools.matchers import Equals, NotEquals33from testtools.matchers import Equals, NotEquals
34from autopilot.matchers import Eventually
3435
35logger = logging.getLogger(__name__)36logger = logging.getLogger(__name__)
3637
@@ -46,16 +47,13 @@
46 self._qml_mock_enabled = False47 self._qml_mock_enabled = False
47 #self._data_dirs_mock_enabled = False48 #self._data_dirs_mock_enabled = False
4849
49 # get unity8 with fake sensors running 50 # get unity8 with fake sensors running
50 #unity_with_sensors = fixture_setup.LaunchUnityWithFakeSensors()51 #unity_with_sensors = fixture_setup.LaunchUnityWithFakeSensors()
51 #self.useFixture(unity_with_sensors)52 #self.useFixture(unity_with_sensors)
52 #process_helpers.unlock_unity(unity_with_sensors.unity_proxy)53 #process_helpers.unlock_unity(unity_with_sensors.unity_proxy)
53 #self.fake_sensors = unity_with_sensors.fake_sensors54 #self.fake_sensors = unity_with_sensors.fake_sensors
54 #self.shell_proxy = unity_with_sensors.main_win.select_single(objectName="shell")55 #self.shell_proxy = unity_with_sensors.main_win.select_single(objectName="shell")
5556
56 self.shell_proxy = self.launch_unity()
57 process_helpers.unlock_unity(self.shell_proxy)
58
59 def _create_test_application(self):57 def _create_test_application(self):
60 desktop_file_dict = ubuntuuitoolkit.fixture_setup.DEFAULT_DESKTOP_FILE_DICT58 desktop_file_dict = ubuntuuitoolkit.fixture_setup.DEFAULT_DESKTOP_FILE_DICT
61 desktop_file_dict.update({'X-Ubuntu-Single-Instance': 'true'})59 desktop_file_dict.update({'X-Ubuntu-Single-Instance': 'true'})
@@ -80,9 +78,96 @@
80 self.assertThat(self.orientation, Equals(tmp_o))78 self.assertThat(self.orientation, Equals(tmp_o))
81 self.assertThat(self.angle, Equals(tmp_a))79 self.assertThat(self.angle, Equals(tmp_a))
8280
81 def test_fake_sensor(self):
82 unity_with_sensors = fixture_setup.LaunchUnityWithFakeSensors()
83 self.useFixture(unity_with_sensors)
84 process_helpers.unlock_unity(unity_with_sensors.unity_proxy)
85 fake_sensors = unity_with_sensors.fake_sensors
86 oriented_shell_proxy = unity_with_sensors.main_win.select_single('OrientedShell')
87
88 fake_sensors.set_orientation_top_up()
89 target_orientation = 1
90 self.assertThat(oriented_shell_proxy.physicalOrientation, Eventually(Equals(target_orientation), timeout=15))
91
92 fake_sensors.set_orientation_right_up()
93 target_orientation = 8
94 self.assertThat(oriented_shell_proxy.physicalOrientation, Eventually(Equals(target_orientation), timeout=15))
95
96 fake_sensors.set_orientation_top_down()
97 target_orientation = 4
98 self.assertThat(oriented_shell_proxy.physicalOrientation, Eventually(Equals(target_orientation), timeout=15))
99
100 fake_sensors.set_orientation_left_up()
101 target_orientation = 2
102 self.assertThat(oriented_shell_proxy.physicalOrientation, Eventually(Equals(target_orientation), timeout=15))
103
104 def test_rotation_with_webbrowser_app(self):
105 """Do an orientation-change and verify that an app and the shell adapted correctly"""
106
107 unity_with_sensors = fixture_setup.LaunchUnityWithFakeSensors()
108 self.useFixture(unity_with_sensors)
109 process_helpers.unlock_unity(unity_with_sensors.unity_proxy)
110 fake_sensors = unity_with_sensors.fake_sensors
111 oriented_shell_proxy = unity_with_sensors.main_win.select_single('OrientedShell')
112 self.shell_proxy = unity_with_sensors.main_win.select_single('Shell')
113
114 # launch an application
115 self.launch_upstart_application('webbrowser-app')
116 unity_with_sensors.main_win.show_dash_from_launcher()
117 unity_with_sensors.main_win.launch_application('webbrowser-app')
118 self.assertThat(unity_with_sensors.main_win.get_current_focused_app_id(), Eventually(Equals('webbrowser-app')))
119
120 # get default orientation and angle
121 self.orientation = self.shell_proxy.orientation
122 self.angle = self.shell_proxy.orientationAngle
123
124 # check if fake sensors affect orientation and angle
125 fake_sensors.set_orientation_top_up()
126 self.orientation = 1
127 self.angle = 0
128 self.assertThat(oriented_shell_proxy.physicalOrientation, Eventually(Equals(self.orientation), timeout=15))
129 print("\nafter fake-sensor changed to top-up...")
130 if (self.orientation & oriented_shell_proxy.supportedOrientations):
131 self._assert_change_of_orientation_and_angle()
132 else:
133 print("unsupported orientations. skipped.")
134
135 fake_sensors.set_orientation_right_up()
136 self.orientation = 8
137 self.angle = 90
138 self.assertThat(oriented_shell_proxy.physicalOrientation, Eventually(Equals(self.orientation), timeout=15))
139 print("\nafter fake-sensor changed to right-up...")
140 if (self.orientation & oriented_shell_proxy.supportedOrientations):
141 self._assert_change_of_orientation_and_angle()
142 else:
143 print("unsupported orientations. skipped.")
144
145 fake_sensors.set_orientation_top_down()
146 self.orientation = 4
147 self.angle = 180
148 self.assertThat(oriented_shell_proxy.physicalOrientation, Eventually(Equals(self.orientation), timeout=15))
149 print("\nafter top-down...")
150 if (self.orientation & oriented_shell_proxy.supportedOrientations):
151 self._assert_change_of_orientation_and_angle()
152 else:
153 print("unsupported orientations. skipped.")
154
155 fake_sensors.set_orientation_left_up()
156 self.orientation = 2
157 self.angle = 270
158 self.assertThat(oriented_shell_proxy.physicalOrientation, Eventually(Equals(self.orientation), timeout=15))
159 print("\nafter fake-sensor changed to left-up...")
160 if (self.orientation & oriented_shell_proxy.supportedOrientations):
161 self._assert_change_of_orientation_and_angle()
162 else:
163 print("unsupported orientations. skipped.")
164
83 def test_rotation(self):165 def test_rotation(self):
84 """Do an orientation-change and verify that an app and the shell adapted correctly"""166 """Do an orientation-change and verify that an app and the shell adapted correctly"""
85167
168 shell_proxy = self.launch_unity()
169 process_helpers.unlock_unity(shell_proxy)
170
86 # launch an application171 # launch an application
87 app_name = self._launch_fake_app()172 app_name = self._launch_fake_app()
88 print("\nfake app-name: ", app_name)173 print("\nfake app-name: ", app_name)

Subscribers

People subscribed via source and target branches

to all changes: