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.
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?

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.

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.

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
1=== modified file 'qml/Rotation/ImmediateRotationAction.qml'
2--- qml/Rotation/ImmediateRotationAction.qml 2015-03-06 04:44:11 +0000
3+++ qml/Rotation/ImmediateRotationAction.qml 2015-04-01 16:45:52 +0000
4@@ -43,4 +43,3 @@
5 info.transitioning = false;
6 }
7 }
8-
9
10=== modified file 'tests/autopilot/unity8/fixture_setup.py'
11--- tests/autopilot/unity8/fixture_setup.py 2015-04-01 11:25:54 +0000
12+++ tests/autopilot/unity8/fixture_setup.py 2015-04-01 16:45:52 +0000
13@@ -147,7 +147,7 @@
14 with open(fifo_path, 'w') as fifo:
15 fifo.write('create accel 0 1000 0.1\n')
16 fifo.write('create light 0 10 1\n')
17- fifo.write('create proximity\n')
18+ fifo.write('create proximity\n')
19
20 class LaunchDashApp(fixtures.Fixture):
21
22
23=== modified file 'tests/autopilot/unity8/shell/tests/test_rotation.py'
24--- tests/autopilot/unity8/shell/tests/test_rotation.py 2015-03-30 14:53:21 +0000
25+++ tests/autopilot/unity8/shell/tests/test_rotation.py 2015-04-01 16:45:52 +0000
26@@ -31,6 +31,7 @@
27 import ubuntuuitoolkit
28 import logging
29 from testtools.matchers import Equals, NotEquals
30+from autopilot.matchers import Eventually
31
32 logger = logging.getLogger(__name__)
33
34@@ -46,16 +47,13 @@
35 self._qml_mock_enabled = False
36 #self._data_dirs_mock_enabled = False
37
38- # get unity8 with fake sensors running
39+ # get unity8 with fake sensors running
40 #unity_with_sensors = fixture_setup.LaunchUnityWithFakeSensors()
41 #self.useFixture(unity_with_sensors)
42 #process_helpers.unlock_unity(unity_with_sensors.unity_proxy)
43 #self.fake_sensors = unity_with_sensors.fake_sensors
44 #self.shell_proxy = unity_with_sensors.main_win.select_single(objectName="shell")
45
46- self.shell_proxy = self.launch_unity()
47- process_helpers.unlock_unity(self.shell_proxy)
48-
49 def _create_test_application(self):
50 desktop_file_dict = ubuntuuitoolkit.fixture_setup.DEFAULT_DESKTOP_FILE_DICT
51 desktop_file_dict.update({'X-Ubuntu-Single-Instance': 'true'})
52@@ -80,9 +78,96 @@
53 self.assertThat(self.orientation, Equals(tmp_o))
54 self.assertThat(self.angle, Equals(tmp_a))
55
56+ def test_fake_sensor(self):
57+ unity_with_sensors = fixture_setup.LaunchUnityWithFakeSensors()
58+ self.useFixture(unity_with_sensors)
59+ process_helpers.unlock_unity(unity_with_sensors.unity_proxy)
60+ fake_sensors = unity_with_sensors.fake_sensors
61+ oriented_shell_proxy = unity_with_sensors.main_win.select_single('OrientedShell')
62+
63+ fake_sensors.set_orientation_top_up()
64+ target_orientation = 1
65+ self.assertThat(oriented_shell_proxy.physicalOrientation, Eventually(Equals(target_orientation), timeout=15))
66+
67+ fake_sensors.set_orientation_right_up()
68+ target_orientation = 8
69+ self.assertThat(oriented_shell_proxy.physicalOrientation, Eventually(Equals(target_orientation), timeout=15))
70+
71+ fake_sensors.set_orientation_top_down()
72+ target_orientation = 4
73+ self.assertThat(oriented_shell_proxy.physicalOrientation, Eventually(Equals(target_orientation), timeout=15))
74+
75+ fake_sensors.set_orientation_left_up()
76+ target_orientation = 2
77+ self.assertThat(oriented_shell_proxy.physicalOrientation, Eventually(Equals(target_orientation), timeout=15))
78+
79+ def test_rotation_with_webbrowser_app(self):
80+ """Do an orientation-change and verify that an app and the shell adapted correctly"""
81+
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+ self.shell_proxy = unity_with_sensors.main_win.select_single('Shell')
88+
89+ # launch an application
90+ self.launch_upstart_application('webbrowser-app')
91+ unity_with_sensors.main_win.show_dash_from_launcher()
92+ unity_with_sensors.main_win.launch_application('webbrowser-app')
93+ self.assertThat(unity_with_sensors.main_win.get_current_focused_app_id(), Eventually(Equals('webbrowser-app')))
94+
95+ # get default orientation and angle
96+ self.orientation = self.shell_proxy.orientation
97+ self.angle = self.shell_proxy.orientationAngle
98+
99+ # check if fake sensors affect orientation and angle
100+ fake_sensors.set_orientation_top_up()
101+ self.orientation = 1
102+ self.angle = 0
103+ self.assertThat(oriented_shell_proxy.physicalOrientation, Eventually(Equals(self.orientation), timeout=15))
104+ print("\nafter fake-sensor changed to top-up...")
105+ if (self.orientation & oriented_shell_proxy.supportedOrientations):
106+ self._assert_change_of_orientation_and_angle()
107+ else:
108+ print("unsupported orientations. skipped.")
109+
110+ fake_sensors.set_orientation_right_up()
111+ self.orientation = 8
112+ self.angle = 90
113+ self.assertThat(oriented_shell_proxy.physicalOrientation, Eventually(Equals(self.orientation), timeout=15))
114+ print("\nafter fake-sensor changed to right-up...")
115+ if (self.orientation & oriented_shell_proxy.supportedOrientations):
116+ self._assert_change_of_orientation_and_angle()
117+ else:
118+ print("unsupported orientations. skipped.")
119+
120+ fake_sensors.set_orientation_top_down()
121+ self.orientation = 4
122+ self.angle = 180
123+ self.assertThat(oriented_shell_proxy.physicalOrientation, Eventually(Equals(self.orientation), timeout=15))
124+ print("\nafter top-down...")
125+ if (self.orientation & oriented_shell_proxy.supportedOrientations):
126+ self._assert_change_of_orientation_and_angle()
127+ else:
128+ print("unsupported orientations. skipped.")
129+
130+ fake_sensors.set_orientation_left_up()
131+ self.orientation = 2
132+ self.angle = 270
133+ self.assertThat(oriented_shell_proxy.physicalOrientation, Eventually(Equals(self.orientation), timeout=15))
134+ print("\nafter fake-sensor changed to left-up...")
135+ if (self.orientation & oriented_shell_proxy.supportedOrientations):
136+ self._assert_change_of_orientation_and_angle()
137+ else:
138+ print("unsupported orientations. skipped.")
139+
140 def test_rotation(self):
141 """Do an orientation-change and verify that an app and the shell adapted correctly"""
142
143+ shell_proxy = self.launch_unity()
144+ process_helpers.unlock_unity(shell_proxy)
145+
146 # launch an application
147 app_name = self._launch_fake_app()
148 print("\nfake app-name: ", app_name)

Subscribers

People subscribed via source and target branches

to all changes: