Merge lp:~nskaggs/ubuntu-terminal-app/fix-circle-test into lp:ubuntu-terminal-app

Proposed by Nicholas Skaggs
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 41
Merged at revision: 40
Proposed branch: lp:~nskaggs/ubuntu-terminal-app/fix-circle-test
Merge into: lp:ubuntu-terminal-app
Diff against target: 100 lines (+22/-34)
2 files modified
tests/autopilot/ubuntu_terminal_app/emulators.py (+10/-27)
tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py (+12/-7)
To merge this branch: bzr merge lp:~nskaggs/ubuntu-terminal-app/fix-circle-test
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Łukasz Zemczak Approve
Ubuntu Terminal Developers Pending
Review via email: mp+208635@code.launchpad.net

Commit message

Fix check for circle menu test
Remove polling test emulator function

Description of the change

Fix check for circle menu test
Remove polling test emulator function

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

hm, ok wait_select_single() changes are ok, so +1 on those. Not sure about line 77.
This will fix the test but it *might* theoretically make this test broken in certain cases, like when the phone is in landscape orientation. Then the first press is done in the middle of the screen, the OSK pops up, takes up half of the screen and the longpress is not registered (because the press happens on the OSK).

review: Needs Fixing
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

I wanted to see how jenkins responded as well to the changes. We can disable the OSK for the run, or select someplace outside the middle of the screen to ensure we don't run into the OSK.

41. By Nicholas Skaggs

tweak circle menu to top in top third of screen

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

I did the tap on the top of the screen with the following code:

        x, y = get_center_point(kterm)
        y = kterm.y + ((y - kterm.y) / 3)
        self.pointing_device.move(x, y)
        self.pointing_device.press()

But this was using autopilot.input._common's get_center_point, which seems to be a private function. Maybe we could use center_x or center_y instead?

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

It's coooool! +1

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/ubuntu_terminal_app/emulators.py'
2--- tests/autopilot/ubuntu_terminal_app/emulators.py 2013-08-14 22:40:48 +0000
3+++ tests/autopilot/ubuntu_terminal_app/emulators.py 2014-02-27 17:17:43 +0000
4@@ -23,54 +23,37 @@
5 class MainView(toolkit_emulators.MainView):
6 """Terminal MainView Autopilot emulator."""
7
8- def _poll_for_object(self, function, timeout = 10):
9- """Wait until the function returns an object, or timesout"""
10- poll = 0
11- while function == None and poll < timeout:
12- poll += 1
13- sleep(1)
14-
15 def get_main_view(self):
16- self._poll_for_object(lambda: self.select_single("QQuickView"))
17- return self.select_single("QQuickView")
18+ return self.wait_select_single("QQuickView")
19
20 def get_header_item(self):
21 """Get the header"""
22- self._poll_for_object(lambda: self.select_single("Header"))
23- return self.select_single("Header")
24+ return self.wait_select_single("Header")
25
26 def get_slider_item(self, slider):
27- self._poll_for_object(lambda: self.select_single("Slider", objectName=slider))
28- return self.select_single("Slider", objectName=slider)
29+ return self.wait_select_single("Slider", objectName=slider)
30
31 def get_kterm(self):
32- self._poll_for_object(lambda: self.select_single("KTerminalDisplay", objectName="kterm"))
33- return self.select_single("KTerminalDisplay", objectName="kterm")
34+ return self.wait_select_single("KTerminalDisplay", objectName="kterm")
35
36 def get_control_panel(self):
37- self._poll_for_object(lambda: self.select_single("CtrlKeys", objectName="kbCtrl"))
38- return self.select_single("CtrlKeys", objectName="kbCtrl")
39+ return self.wait_select_single("CtrlKeys", objectName="kbCtrl")
40
41 def get_function_panel(self):
42- self._poll_for_object(lambda: self.select_single("FnKeys", objectName="kbFn"))
43- return self.select_single("FnKeys", objectName="kbFn")
44+ return self.wait_select_single("FnKeys", objectName="kbFn")
45
46 def get_scroll_panel(self):
47- self._poll_for_object(lambda: self.select_single("ScrlKeys", objectName="kbScrl"))
48- return self.select_single("ScrlKeys", objectName="kbScrl")
49+ return self.wait_select_single("ScrlKeys", objectName="kbScrl")
50
51 def get_terminal_page(self):
52- self._poll_for_object(lambda: self.select_single("Terminal", objectName="pgTerm"))
53- return self.select_single("Terminal", objectName="pgTerm")
54+ return self.wait_select_single("Terminal", objectName="pgTerm")
55
56 def get_circle_menu(self):
57- self._poll_for_object(lambda: self.select_single("CircleMenu", objectName="cmenu"))
58- return self.select_single("CircleMenu", objectName="cmenu")
59+ return self.wait_select_single("CircleMenu", objectName="cmenu")
60
61 def get_panel_actions_popover(self):
62 """Return the ActionSelectionPopover emulator of the popup action."""
63- self._poll_for_object(lambda: self.select_single(ActionSelectionPopover, objectName='panelpopover'))
64- return self.select_single(ActionSelectionPopover, objectName='panelpopover')
65+ return self.wait_select_single(ActionSelectionPopover, objectName='panelpopover')
66
67 def drag_horizontal_slider(self, slider, pos):
68 """Drag slider until value is set"""
69
70=== modified file 'tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py'
71--- tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py 2014-01-07 16:35:37 +0000
72+++ tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py 2014-02-27 17:17:43 +0000
73@@ -113,15 +113,20 @@
74 """Make sure that Circle Menu is visible
75 on long tap"""
76 kterm = self.main_view.get_terminal_page()
77- #in order to ensure the longtap is pressed, we click and wait for OSK to appear
78- self.pointing_device.click_object(kterm)
79- sleep(2)
80- self.pointing_device.move_to_object(kterm)
81+ x, y, w, h = kterm.globalRect
82+ tap_x = (x + w ) / 2
83+ tap_y = (y + h ) / 3
84+
85+ #tap in the top third of the screen, to avoid OSK
86+ self.pointing_device.move(tap_x, tap_y)
87 self.pointing_device.press()
88- sleep(2)
89+ #we can hold the press for a long time without issue
90+ #so we'll ensure the app recieves our signal when under load
91+ sleep(4)
92 self.pointing_device.release()
93- menu = lambda: self.main_view.get_circle_menu().visible
94- self.assertThat(menu, Eventually(Equals(True)))
95+
96+ menu = self.main_view.get_circle_menu()
97+ self.assertThat(menu.visible, Eventually(Equals(True)))
98
99 def test_header(self):
100 """Make sure that Header is visible

Subscribers

People subscribed via source and target branches