Merge lp:~nskaggs/ubuntu-terminal-app/ap-cleanup into lp:ubuntu-terminal-app

Proposed by Nicholas Skaggs
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 131
Merged at revision: 127
Proposed branch: lp:~nskaggs/ubuntu-terminal-app/ap-cleanup
Merge into: lp:ubuntu-terminal-app
Diff against target: 214 lines (+29/-101)
2 files modified
tests/autopilot/ubuntu_terminal_app/emulators.py (+0/-46)
tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py (+29/-55)
To merge this branch: bzr merge lp:~nskaggs/ubuntu-terminal-app/ap-cleanup
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Alan Pope 🍺🐧🐱 🦄 (community) Approve
Review via email: mp+232590@code.launchpad.net

Commit message

R-enable test_color_scheme_changes, fix test_font_size_changes, remove extraneous code

Description of the change

R-enable test_color_scheme_changes, fix test_font_size_changes, remove extraneous code.

No attempts made to overhaul the tests to a page object model.

To post a comment you must log in.
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Going to open / reference a bug for needing a toolkit helper for itemselector. The test still uses a rudimentary method for this.

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
Alan Pope 🍺🐧🐱 🦄 (popey) wrote :

Whop whoop! Thanks!

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
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 2014-06-16 10:38:24 +0000
3+++ tests/autopilot/ubuntu_terminal_app/emulators.py 2014-08-28 16:48:12 +0000
4@@ -24,15 +24,9 @@
5
6 """Terminal MainView Autopilot emulator."""
7
8- def get_main_view(self):
9- return self.wait_select_single("QQuickView")
10-
11 def get_slider_item(self, slider):
12 return self.wait_select_single("Slider", objectName=slider)
13
14- def get_kterm(self):
15- return self.wait_select_single("KTerminalDisplay", objectName="kterm")
16-
17 def get_control_panel(self):
18 return self.wait_select_single("CtrlKeys", objectName="kbCtrl")
19
20@@ -48,11 +42,6 @@
21 def get_circle_menu(self):
22 return self.wait_select_single("CircleMenu", objectName="cmenu")
23
24- def get_panel_actions_popover(self):
25- """Return the ActionSelectionPopover emulator of the popup action."""
26- return self.wait_select_single(ActionSelectionPopover,
27- objectName='panelpopover')
28-
29 def drag_horizontal_slider(self, slider, pos):
30 """Drag slider until value is set"""
31 slItem = self.get_slider_item(slider)
32@@ -90,38 +79,3 @@
33 sx = valuePos
34 sleep(0.3)
35 loop = loop + 1
36-
37-
38-class ActionSelectionPopover(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
39-
40- """ActionSelectionPopover Autopilot emulator."""
41- # TODO Move this to the ubuntu-ui-toolkit. Reported on
42- # https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1205205
43- # --elopio - 2013-07-25
44-
45- def __init__(self, *args):
46- super(ActionSelectionPopover, self).__init__(*args)
47- self.pointing_device = toolkit_emulators.get_pointing_device()
48-
49- def click_button(self, text):
50- """Click a button on the popover.
51-
52- XXX We are receiving the text because there's no way to set the
53- objectName on the action. This is reported at
54- https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1205144
55- --elopio - 2013-07-25
56-
57- :parameter text: The text of the button.
58-
59- """
60- button = self._get_button(text)
61- if button is None:
62- raise ValueError(
63- 'Button with text "{0}" not found.'.format(text))
64- self.pointing_device.click_object(button)
65-
66- def _get_button(self, text):
67- buttons = self.select_many('Empty')
68- for button in buttons:
69- if button.text == text:
70- return button
71
72=== modified file 'tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py'
73--- tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py 2014-08-10 16:58:06 +0000
74+++ tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py 2014-08-28 16:48:12 +0000
75@@ -10,14 +10,13 @@
76 from __future__ import absolute_import
77
78 from autopilot.matchers import Eventually
79-from testtools.matchers import Equals, Not, Is
80+from testtools.matchers import Equals
81 from autopilot.platform import model
82
83 from ubuntu_terminal_app.tests import TerminalTestCase, DbMan
84 from ubuntuuitoolkit import ToolkitException as ToolkitException
85
86 from time import sleep
87-import unittest
88 import random
89
90
91@@ -28,9 +27,6 @@
92 self.assertThat(
93 self.main_view.visible, Eventually(Equals(True)))
94
95- def tearDown(self):
96- super(TestMainWindow, self).tearDown()
97-
98 def hide_panels(self):
99 """Click hide panels button"""
100 header = self.main_view.get_header()
101@@ -47,33 +43,19 @@
102
103 def click_item_selector_item(self, selector, value):
104 """Clicks item from item selector"""
105- # The item selector is assumed to be the following format
106- # ListItem.ItemSelector {
107- # objectName:
108- # model:
109- self.assertThat(lambda: self.main_view.select_single("ItemSelector",
110- objectName=selector), Eventually(Not(Is(None))))
111- item_selector = self.main_view.select_single("ItemSelector",
112- objectName=selector)
113- # we need to regrab object as for some reason it can sometimes
114- # change and our ordering will be off down below
115- self.assertThat(lambda: self.main_view.select_single("ItemSelector",
116- objectName=selector), Eventually(Not(Is(None))))
117- item_selector = self.main_view.select_single("ItemSelector",
118- objectName=selector)
119- self.assertThat(lambda: item_selector.select_many("QQuickColumn"),
120- Eventually(Not(Is(None))))
121- rows = item_selector.select_many("QQuickColumn")
122- self.assertThat(lambda: rows[0].select_single("QQuickListView",
123- objectName="listView"), Eventually(Not(Is(None))))
124- items = rows[0].select_single("QQuickListView", objectName="listView")
125- self.pointing_device.click_object(items)
126- for ritem in items:
127- if ritem.text == value:
128- self.pointing_device.click_object(ritem)
129- # the first label is always the "color scheme"
130- itemLabel = lambda: ritem.text
131- self.assertThat(itemLabel, Eventually(Equals(value)))
132+ # This needs a toolkit helper
133+ # https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1272345
134+ item_selector = self.main_view.wait_select_single('ItemSelector',
135+ objectName=selector)
136+ selector = item_selector.wait_select_single('Standard',
137+ objectName='listContainer')
138+ self.pointing_device.click_object(selector)
139+ item_selector.currentlyExpanded.wait_for(True)
140+ # waiting for currentlyExpanded is not enough
141+ # some animation is not accounted for and thus we sleep
142+ sleep(2)
143+ item = selector.wait_select_single('Label', text=value)
144+ self.pointing_device.click_object(item)
145
146 def test_control_panel(self):
147 """Make sure that Control Keys Panel is visible
148@@ -136,28 +118,24 @@
149 else:
150 self.assertThat(header, Eventually(Equals(True)))
151
152- @unittest.skip("This test randomly fails and is not consistent")
153 def test_color_scheme_changes(self):
154 """Make sure that color scheme is set correctly"""
155- kterm = self.main_view.get_kterm()
156- self.main_view.switch_to_tab("SettingsTab")
157
158 # are these string translatable?
159 # if so, we need to do this another way
160- schemeList = ("DarkPastels",
161- "Linux",
162- "BlackOnRandomLight",
163+ schemeList = ("BlackOnRandomLight",
164 "BlackOnWhite",
165 "BlackOnLightYellow",
166+ "DarkPastels",
167 "GreenOnBlack",
168+ "Linux",
169 "WhiteOnBlack")
170
171+ colorScheme = self.get_color_scheme_from_storage
172 for scheme in schemeList:
173+ self.main_view.get_header().click_action_button('SettingsButton')
174 self.click_item_selector_item("liSchemes", scheme)
175- # This assert uses KTerminalDisplay property (old rev)
176- self.assertThat(kterm.colorScheme, Eventually(Equals(scheme)))
177- # This assert uses localstorage (new rev)
178- colorScheme = self.get_color_scheme_from_storage
179+ self.main_view.go_back()
180 self.assertThat(colorScheme, Eventually(Equals(scheme)))
181
182 def test_font_size_changes(self):
183@@ -165,22 +143,18 @@
184 header = self.main_view.get_header()
185 header.click_action_button('SettingsButton')
186
187+ font_size = self.get_font_size_from_storage
188+
189+ # change font size to min
190+ self.main_view.drag_horizontal_slider("slFont", 8)
191+ self.assertThat(font_size, Eventually(Equals(8)))
192+
193 # change font size to max
194 self.main_view.drag_horizontal_slider("slFont", 32)
195- sleep(1)
196- font_size = self.get_font_size_from_storage()
197- self.assertThat(font_size, Equals(32))
198-
199- # change font size to min
200- self.main_view.drag_horizontal_slider("slFont", 8)
201- sleep(1)
202- font_size = self.get_font_size_from_storage()
203- self.assertThat(font_size, Equals(8))
204+ self.assertThat(font_size, Eventually(Equals(32)))
205
206 # change font size to random sizes
207 for loop in range(1, 3):
208- randSize = random.randrange(8, 32, 1)
209+ randSize = random.randrange(9, 31, 1)
210 self.main_view.drag_horizontal_slider("slFont", randSize)
211- sleep(1)
212- font_size = self.get_font_size_from_storage()
213- self.assertThat(font_size, Equals(randSize))
214+ self.assertThat(font_size, Eventually(Equals(randSize)))

Subscribers

People subscribed via source and target branches