Merge lp:~sbaldassin/ubuntu-system-tests/more_indicators_tests into lp:ubuntu-system-tests

Proposed by Santiago Baldassin
Status: Needs review
Proposed branch: lp:~sbaldassin/ubuntu-system-tests/more_indicators_tests
Merge into: lp:ubuntu-system-tests
Prerequisite: lp:~sbaldassin/ubuntu-system-tests/more_system_settings_tests
Diff against target: 551 lines (+344/-21)
13 files modified
ubuntu_system_tests/helpers/application.py (+1/-2)
ubuntu_system_tests/helpers/calendar/app.py (+2/-1)
ubuntu_system_tests/helpers/clock/app.py (+2/-1)
ubuntu_system_tests/helpers/gsettings.py (+7/-0)
ubuntu_system_tests/helpers/indicators/datetime.py (+40/-1)
ubuntu_system_tests/helpers/indicators/indicators.py (+0/-2)
ubuntu_system_tests/helpers/indicators/system.py (+107/-0)
ubuntu_system_tests/helpers/timedate.py (+22/-2)
ubuntu_system_tests/helpers/unity8/greeter.py (+7/-7)
ubuntu_system_tests/helpers/unity8/shell_view.py (+2/-2)
ubuntu_system_tests/tests/base.py (+2/-0)
ubuntu_system_tests/tests/indicators/test_indicator_datetime.py (+55/-3)
ubuntu_system_tests/tests/indicators/test_indicator_system.py (+97/-0)
To merge this branch: bzr merge lp:~sbaldassin/ubuntu-system-tests/more_indicators_tests
Reviewer Review Type Date Requested Status
platform-qa-bot continuous-integration Needs Fixing
Richard Huddie (community) Needs Fixing
Review via email: mp+321070@code.launchpad.net

Commit message

Adding test cases for the System indicator

Description of the change

This mp adds test cases for the System indicator

@run_tests: ubuntu_system_tests.tests.indicators.test_indicator_system ubuntu_system_tests.tests.indicators.test_indicator_datetime

To post a comment you must log in.
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
522. By Santiago Baldassin

More test cases

523. By Santiago Baldassin

Fixing flake8 issues

Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Needs Fixing (continuous-integration)
524. By Santiago Baldassin

more tests

525. By Santiago Baldassin

fixing flake8 issues

Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
526. By Santiago Baldassin

New tests

Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
527. By Santiago Baldassin

Adding datetime test cases

528. By Santiago Baldassin

Minor fix

Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Needs Fixing (continuous-integration)
529. By Santiago Baldassin

Minor fix

Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Needs Fixing (continuous-integration)
530. By Santiago Baldassin

Skipping unstable test

Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
531. By Santiago Baldassin

Adding a couple of test cases

Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Richard Huddie (rhuddie) wrote :

Please can you merge this with trunk as there are conflicts showing.

532. By Santiago Baldassin

Merge from trunk

533. By Santiago Baldassin

Removing code left by the merge

534. By Santiago Baldassin

Fixing flake8

Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Richard Huddie (rhuddie) wrote :

I saw a couple of failures running these: http://pastebin.ubuntu.com/24311986/

Also we can remove the process name parameters as we discussed on other mp to continue using the app launch helpers to get the pid.

I see there are 4 tests that are skipped with either unstable or not working. Are these genuine failures where the indicator is not behaving in reliable way? It would be good to know the root cause and either let the tests fail with a bug or try and remove the instability from the test.

review: Needs Fixing
Revision history for this message
Santiago Baldassin (sbaldassin) wrote :

> I saw a couple of failures running these: http://pastebin.ubuntu.com/24311986/
>
Fixed one of the failures and removed the other test as the Lock functionality was removed from the logout dialog

> Also we can remove the process name parameters as we discussed on other mp to
> continue using the app launch helpers to get the pid.
Done
>
> I see there are 4 tests that are skipped with either unstable or not working.
> Are these genuine failures where the indicator is not behaving in reliable
> way? It would be good to know the root cause and either let the tests fail
> with a bug or try and remove the instability from the test.
Two of them are genuine failures (unable to open the calendar and the clock from the indicators.) and the other two need some investigation. I'd rather leave them as Skip and add a card to debug them later

535. By Santiago Baldassin

Addressing comments from the reviews

536. By Santiago Baldassin

Fixing flake8 issues

537. By Santiago Baldassin

Merge from parent

Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Needs Fixing (continuous-integration)
538. By Santiago Baldassin

Fixing flake8 issues

Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Richard Huddie (rhuddie) wrote :

This is now showing conflicts with trunk, could you merge trunk to resolve.

539. By Santiago Baldassin

Merge from parent branch

Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Needs Fixing (continuous-integration)
540. By Santiago Baldassin

Merge from parent

Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Needs Fixing (continuous-integration)
541. By Santiago Baldassin

Skipping failing test case

Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Richard Huddie (rhuddie) wrote :

Tests working fine, but couple of comments below about the process_name parameter and import error.

Also, can you add the cards to the backlog to investigate the issues with the skipped tests you mentioned above?

review: Needs Fixing
542. By Santiago Baldassin

Addressing comments from the reviews

Revision history for this message
Santiago Baldassin (sbaldassin) wrote :

Thanks for the feedback Richard. All comments were addressed and cards created in Trello

Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Needs Fixing (continuous-integration)
543. By Santiago Baldassin

Removing process name

Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Needs Fixing (continuous-integration)
544. By Santiago Baldassin

Skipping test due to a genuine failure

Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

544. By Santiago Baldassin

Skipping test due to a genuine failure

543. By Santiago Baldassin

Removing process name

542. By Santiago Baldassin

Addressing comments from the reviews

541. By Santiago Baldassin

Skipping failing test case

540. By Santiago Baldassin

Merge from parent

539. By Santiago Baldassin

Merge from parent branch

538. By Santiago Baldassin

Fixing flake8 issues

537. By Santiago Baldassin

Merge from parent

536. By Santiago Baldassin

Fixing flake8 issues

535. By Santiago Baldassin

Addressing comments from the reviews

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_system_tests/helpers/application.py'
2--- ubuntu_system_tests/helpers/application.py 2017-04-04 11:38:15 +0000
3+++ ubuntu_system_tests/helpers/application.py 2017-04-05 14:24:21 +0000
4@@ -81,8 +81,7 @@
5
6 def _get_stop_command(self):
7 """Return command to stop application."""
8- id = self._get_app_rev_id()
9- return [self._get_cmd_prefix() + 'ubuntu-app-stop', id]
10+ return [self._get_cmd_prefix() + 'ubuntu-app-stop', self.app_id]
11
12 def _get_pid_command(self):
13 """Return command to get application process ID."""
14
15=== modified file 'ubuntu_system_tests/helpers/calendar/app.py'
16--- ubuntu_system_tests/helpers/calendar/app.py 2017-03-10 17:46:30 +0000
17+++ ubuntu_system_tests/helpers/calendar/app.py 2017-04-05 14:24:21 +0000
18@@ -22,12 +22,13 @@
19
20 APP_NAME = 'Calendar'
21 APP_ID = 'ubuntu-calendar-app'
22+PROCESS_NAME = 'ubuntu-calendar-app'
23
24
25 class Calendar(Snap):
26
27 def __init__(self):
28- super().__init__(APP_NAME, APP_ID)
29+ super().__init__(APP_NAME, APP_ID, PROCESS_NAME)
30
31 def get_main_view(self):
32 from ubuntu_system_tests.helpers.clock.cpo import MainView # NOQA
33
34=== modified file 'ubuntu_system_tests/helpers/clock/app.py'
35--- ubuntu_system_tests/helpers/clock/app.py 2017-03-10 17:46:30 +0000
36+++ ubuntu_system_tests/helpers/clock/app.py 2017-04-05 14:24:21 +0000
37@@ -21,12 +21,13 @@
38
39 APP_NAME = 'Clock'
40 APP_ID = 'ubuntu-clock-app'
41+PROCESS_NAME = 'ubuntu-clock-app'
42
43
44 class Clock(Snap):
45
46 def __init__(self):
47- super().__init__(APP_NAME, APP_ID)
48+ super().__init__(APP_NAME, APP_ID, PROCESS_NAME)
49
50 def get_main_view(self):
51 from ubuntu_system_tests.helpers.clock.cpo import MainView # NOQA
52
53=== modified file 'ubuntu_system_tests/helpers/gsettings.py'
54--- ubuntu_system_tests/helpers/gsettings.py 2016-11-16 18:08:35 +0000
55+++ ubuntu_system_tests/helpers/gsettings.py 2017-04-05 14:24:21 +0000
56@@ -25,3 +25,10 @@
57 command = 'gsettings set {schema} {key} {value}'.format(
58 schema=schema, key=key, value=value)
59 subprocess.check_call(shlex.split(command))
60+
61+
62+def get_key(schema, key):
63+ command = 'gsettings get {schema} {key}'.format(
64+ schema=schema, key=key)
65+ return subprocess.check_output(shlex.split(command)).decode(
66+ 'utf-8').strip()
67
68=== modified file 'ubuntu_system_tests/helpers/indicators/datetime.py'
69--- ubuntu_system_tests/helpers/indicators/datetime.py 2017-03-21 01:27:44 +0000
70+++ ubuntu_system_tests/helpers/indicators/datetime.py 2017-04-05 14:24:21 +0000
71@@ -15,7 +15,8 @@
72 #
73 # You should have received a copy of the GNU General Public License
74 # along with this program. If not, see <http://www.gnu.org/licenses/>.
75-
76+from ubuntu_system_tests.helpers.calendar.app import Calendar
77+from ubuntu_system_tests.helpers.clock import Clock
78 from ubuntu_system_tests.helpers.indicators.cpo import (
79 IndicatorPage, INDICATOR_PAGE_PATH)
80 from ubuntu_system_tests.helpers.autopilot import validate_dbus_object
81@@ -45,3 +46,41 @@
82 menu_item = self._get_datetime_settings_menu_item()
83 menu_item.swipe_into_view()
84 input_manager.pointer.click_object(menu_item)
85+
86+ def get_location(self):
87+ location = self.select_single(
88+ objectName='indicator.set-location', visible=True)
89+ assert(location.get_properties()['text'] ==
90+ location.get_properties()['city'])
91+ return _Location(location.get_properties()['time'],
92+ location.get_properties()['tz'],
93+ location.get_properties()['text'])
94+
95+ def get_selected_date(self):
96+ calendar = self.select_single(objectName='indicator.calendar')
97+ return calendar.get_properties()['selectedDate']
98+
99+ def get_calendar_displayed_date(self):
100+ calendar_indicator = self.select_single(
101+ objectName='indicator.phone.open-calendar-app')
102+ return calendar_indicator.get_properties()['text']
103+
104+ def open_clock(self):
105+ clock_btn = self.select_single(
106+ objectName='indicator.phone.open-alarm-app')
107+ input_manager.pointer.click_object(clock_btn)
108+ return Clock().get_main_view()
109+
110+ def open_calendar(self):
111+ calendar_btn = self.select_single(
112+ objectName='indicator.phone.open-calendar-app')
113+ input_manager.pointer.click_object(calendar_btn)
114+ return Calendar().get_main_view()
115+
116+
117+class _Location:
118+
119+ def __init__(self, time, time_zone, city):
120+ self.time = time
121+ self.time_zone = time_zone
122+ self.city = city
123
124=== modified file 'ubuntu_system_tests/helpers/indicators/indicators.py'
125--- ubuntu_system_tests/helpers/indicators/indicators.py 2017-03-30 13:01:17 +0000
126+++ ubuntu_system_tests/helpers/indicators/indicators.py 2017-04-05 14:24:21 +0000
127@@ -15,9 +15,7 @@
128 #
129 # You should have received a copy of the GNU General Public License
130 # along with this program. If not, see <http://www.gnu.org/licenses/>.
131-
132 from autopilot.input import get_center_point
133-
134 from ubuntu_system_tests.helpers import context
135 from ubuntu_system_tests.helpers.autopilot import validate_dbus_object
136 from ubuntu_system_tests.helpers.input_manager import input_manager
137
138=== added file 'ubuntu_system_tests/helpers/indicators/system.py'
139--- ubuntu_system_tests/helpers/indicators/system.py 1970-01-01 00:00:00 +0000
140+++ ubuntu_system_tests/helpers/indicators/system.py 2017-04-05 14:24:21 +0000
141@@ -0,0 +1,107 @@
142+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
143+
144+# Ubuntu System Tests
145+# Copyright (C) 2017 Canonical
146+#
147+# This program is free software: you can redistribute it and/or modify
148+# it under the terms of the GNU General Public License as published by
149+# the Free Software Foundation, either version 3 of the License, or
150+# (at your option) any later version.
151+#
152+# This program is distributed in the hope that it will be useful,
153+# but WITHOUT ANY WARRANTY; without even the implied warranty of
154+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
155+# GNU General Public License for more details.
156+#
157+# You should have received a copy of the GNU General Public License
158+# along with this program. If not, see <http://www.gnu.org/licenses/>.
159+from ubuntu_system_tests.common.config import get_device_config_stack
160+from ubuntu_system_tests.helpers import context
161+from ubuntu_system_tests.helpers.indicators.cpo import (IndicatorPage,
162+ INDICATOR_PAGE_PATH)
163+from ubuntu_system_tests.helpers.autopilot import validate_dbus_object
164+from ubuntu_system_tests.helpers.input_manager import input_manager
165+from ubuntu_system_tests.helpers.system_settings.app import get_system_settings_app
166+from ubuntu_system_tests.helpers.ubuntuuitools.cpo.common import CustomProxyObjectBase
167+from ubuntu_system_tests.helpers.unity8.utils import UNITY8_PATH_ROOT
168+from ubuntu_system_tests.helpers.webbrowser import WebBrowser
169+
170+
171+class SystemIndicatorPage(IndicatorPage):
172+ """Autopilot helper for the system indicator page."""
173+
174+ name = 'indicator-session'
175+
176+ @classmethod
177+ def validate_dbus_object(cls, path, state):
178+ return validate_dbus_object(
179+ path, state, UNITY8_PATH_ROOT, INDICATOR_PAGE_PATH,
180+ objectName='indicator-session-page')
181+
182+ def open_about_page(self):
183+ indicator_about = self.select_single(
184+ objectName="indicator.about")
185+ input_manager.pointer.click_object(indicator_about)
186+ config_stack = get_device_config_stack()
187+ app = get_system_settings_app(config_stack.get('unity8_mode'))()
188+ return app.get_main_view().wait_select_single(
189+ objectName='aboutPage', visible=True)
190+
191+ def open_help_page(self):
192+ indicator_about = self.select_single(
193+ objectName="indicator.help")
194+ input_manager.pointer.click_object(indicator_about)
195+ web_browser = WebBrowser()
196+ return web_browser.get_main_view()
197+
198+ def switch_desktop_mode(self):
199+ desktop_mode_switcher = self.select_single(
200+ objectName='indicator.usage-mode')
201+ input_manager.pointer.click_object(desktop_mode_switcher)
202+
203+ def is_desktop_mode_enabled(self):
204+ return self.select_single(
205+ objectName='indicator.usage-mode').get_properties()['checked']
206+
207+ def lock(self):
208+ lock_btn = self.select_single(
209+ objectName='indicator.switch-to-screensaver')
210+ input_manager.pointer.click_object(lock_btn)
211+
212+ def logout(self):
213+ power_off = self.select_single(
214+ objectName='indicator.power-off')
215+ input_manager.pointer.click_object(power_off)
216+ return context.shared.unity.main_window.wait_select_single(
217+ "ShellDialog", visible=True, enabled=True)
218+
219+ def open_system_settings(self):
220+ settings_indicator = self.select_single(objectName='indicator.settings')
221+ input_manager.pointer.click_object(settings_indicator)
222+ config_stack = get_device_config_stack()
223+ app = get_system_settings_app(config_stack.get('unity8_mode'))()
224+ return app.get_main_view()
225+
226+
227+class ShellDialog(CustomProxyObjectBase):
228+
229+ @classmethod
230+ def validate_dbus_object(cls, path, state):
231+ return validate_dbus_object(
232+ path, state, UNITY8_PATH_ROOT, b"ShellDialog")
233+
234+ def lock(self):
235+ lock_btn = self.select_single("Button", text='Lock')
236+ input_manager.pointer.click_object(lock_btn)
237+ self.wait_until_destroyed()
238+
239+ def cancel(self):
240+ cancel_btn = self.select_single("Button", text='Cancel',
241+ visible=True, enabled=True)
242+ input_manager.pointer.click_object(cancel_btn)
243+ self.wait_until_destroyed()
244+
245+ def logout(self):
246+ logout_btn = self.select_single("Button", text='Log Out')
247+ input_manager.pointer.click_object(logout_btn)
248+ self.wait_until_destroyed()
249
250=== modified file 'ubuntu_system_tests/helpers/timedate.py'
251--- ubuntu_system_tests/helpers/timedate.py 2016-09-21 14:32:48 +0000
252+++ ubuntu_system_tests/helpers/timedate.py 2017-04-05 14:24:21 +0000
253@@ -29,9 +29,15 @@
254 return datetime.now().strftime('%d')
255
256
257-def get_current_day_name():
258+def get_current_year():
259+ """Return current day of month 0-31."""
260+ return datetime.now().strftime('%Y')
261+
262+
263+def get_current_day_name(short=False):
264 """Return current day name."""
265- return datetime.now().strftime('%A')
266+ format = '%a' if short else '%A'
267+ return datetime.now().strftime(format)
268
269
270 def get_current_month_name():
271@@ -90,3 +96,17 @@
272 """Retrieve the currently set system timezone."""
273 time.tzset()
274 return time.tzname[0]
275+
276+
277+def get_current_time():
278+ hour = time.localtime().tm_hour
279+ minutes = time.localtime().tm_min
280+ if minutes < 10:
281+ minutes = '0{}'.format(minutes)
282+ return "{hour}:{minutes}".format(hour=hour, minutes=minutes)
283+
284+
285+def get_current_date():
286+ now = datetime.now()
287+ return '{year}-{month}-{day}'.format(
288+ year=now.year, month=now.month, day=now.day)
289
290=== modified file 'ubuntu_system_tests/helpers/unity8/greeter.py'
291--- ubuntu_system_tests/helpers/unity8/greeter.py 2016-11-22 13:58:43 +0000
292+++ ubuntu_system_tests/helpers/unity8/greeter.py 2017-04-05 14:24:21 +0000
293@@ -24,10 +24,10 @@
294
295
296 def wait_for_greeter():
297- Eventually(Equals(True), timeout=300).match(_is_greeter_active)
298-
299-
300-def _is_greeter_active():
301+ Eventually(Equals(True), timeout=300).match(is_greeter_active)
302+
303+
304+def is_greeter_active():
305 try:
306 dbus_proxy = _get_greeter_dbus_proxy()
307 return dbus_proxy.Get('com.canonical.UnityGreeter', 'IsActive')
308@@ -42,15 +42,15 @@
309
310 def hide_greeter_with_dbus():
311 dbus_proxy = _get_greeter_dbus_proxy()
312- if _is_greeter_active():
313+ if is_greeter_active():
314 dbus_proxy.HideGreeter()
315
316
317 def show_greeter_with_dbus():
318 dbus_proxy = _get_greeter_dbus_proxy()
319- if not _is_greeter_active():
320+ if not is_greeter_active():
321 dbus_proxy.ShowGreeter()
322
323
324 def wait_for_greeter_gone():
325- Eventually(Equals(False), timeout=300).match(_is_greeter_active)
326+ Eventually(Equals(False), timeout=300).match(is_greeter_active)
327
328=== modified file 'ubuntu_system_tests/helpers/unity8/shell_view.py'
329--- ubuntu_system_tests/helpers/unity8/shell_view.py 2017-04-03 10:32:39 +0000
330+++ ubuntu_system_tests/helpers/unity8/shell_view.py 2017-04-05 14:24:21 +0000
331@@ -130,8 +130,8 @@
332 objectName=indicator_name + '-panelItem')
333 return item.hidden
334
335- def get_greeter(self):
336- return self.select_single('Greeter')
337+ def get_greeter(self, visible=True):
338+ return self.wait_select_single('Greeter', visible=visible)
339
340 def get_login_loader(self):
341 return self.select_single("QQuickLoader", objectName="loginLoader")
342
343=== modified file 'ubuntu_system_tests/tests/base.py'
344--- ubuntu_system_tests/tests/base.py 2017-04-04 11:50:29 +0000
345+++ ubuntu_system_tests/tests/base.py 2017-04-05 14:24:21 +0000
346@@ -47,6 +47,7 @@
347 from ubuntu_system_tests.helpers.location.fixture_setup import (
348 SetLocationAccessRequests)
349 from ubuntu_system_tests.helpers.processes import ensure_all_apps_closed
350+from ubuntu_system_tests.helpers.unity8.greeter import hide_greeter_with_dbus
351 from ubuntu_system_tests.helpers.unity8.job import Unity8Job
352 from ubuntu_system_tests.helpers.timeout import timeout
353 from ubuntu_system_tests.helpers.unity8.fixture_setup import (
354@@ -108,6 +109,7 @@
355 # coordinates relative to the screen for a windows using
356 # MIR display on desktop
357 self.__focus_and_change_usage()
358+ hide_greeter_with_dbus()
359
360 def __focus_and_change_usage(self):
361 if model() == DESKTOP_PLATFORM_NAME and get_display_server() == 'MIR':
362
363=== modified file 'ubuntu_system_tests/tests/indicators/test_indicator_datetime.py'
364--- ubuntu_system_tests/tests/indicators/test_indicator_datetime.py 2017-03-21 13:40:48 +0000
365+++ ubuntu_system_tests/tests/indicators/test_indicator_datetime.py 2017-04-05 14:24:21 +0000
366@@ -17,14 +17,25 @@
367 # You should have received a copy of the GNU General Public License
368 # along with this program. If not, see <http://www.gnu.org/licenses/>.
369 #
370-
371+from datetime import datetime
372+
373+from testtools import skip
374+
375+from ubuntu_system_tests.common.config import get_device_config_stack
376 from ubuntu_system_tests.helpers import system_settings
377+from ubuntu_system_tests.helpers.gsettings import get_key
378 from ubuntu_system_tests.helpers.indicators.datetime import (
379 DateTimeIndicatorPage)
380+from ubuntu_system_tests.helpers.system_settings.app import get_system_settings_app
381+from ubuntu_system_tests.helpers.timedate import (
382+ get_current_day_name, get_current_time, get_current_day_of_month,
383+ get_current_month_name, get_current_year)
384 from ubuntu_system_tests.tests.indicators import base
385
386
387 DATETIME_SETTINGS_PAGE = 'timeDatePage'
388+SCHEMA = 'com.canonical.indicator.datetime'
389+TIME_ZONE_KEY = 'timezone-name'
390
391
392 class DateTimeIndicatorTestCase(base.IndicatorTestCaseBase):
393@@ -32,6 +43,7 @@
394 def setUp(self):
395 super().setUp(DateTimeIndicatorPage.name)
396
397+ @skip("System settings application is not opened form the indicators")
398 def test_date_time_settings_item_open_correct_page(self):
399 """
400 1. Drag down date time indicator
401@@ -39,6 +51,46 @@
402 3. Ensure date time settings open.
403 """
404 self.indicator_page.open_date_time_settings()
405- settings_app = system_settings.get_system_settings_proxy()
406- system_settings.ensure_settings_page_visible(settings_app,
407+ self.config_stack = get_device_config_stack()
408+ self.app = get_system_settings_app(
409+ self.config_stack.get('unity8_mode'))()
410+ main_view = self.app.get_main_view()
411+ system_settings.ensure_settings_page_visible(main_view,
412 DATETIME_SETTINGS_PAGE)
413+
414+ @skip("Unstable test")
415+ def test_location_and_time_displayed(self):
416+ location = self.indicator_page.get_location()
417+ expected_time = "{day} {time}".format(
418+ day=get_current_day_name(short=True), time=get_current_time())
419+ self.assertEquals(expected_time, location.time)
420+ current_location = get_key(SCHEMA, TIME_ZONE_KEY)
421+ self.assertIn(location.city, current_location)
422+
423+ def test_selected_date(self):
424+ selected_date = self.indicator_page.get_selected_date()
425+ self.assertEquals(selected_date.year, datetime.now().year)
426+ self.assertEquals(selected_date.month, datetime.now().month)
427+ self.assertEquals(selected_date.day, datetime.now().day)
428+
429+ def test_complete_date_is_displayed(self):
430+ displayed_date = self.indicator_page.get_calendar_displayed_date()
431+ day_number = get_current_day_of_month()
432+ if str(day_number).startswith('0'):
433+ day_number = day_number.replace('0', '')
434+ expeced_date = '{day_name}, {day_number} {month} {year}'.format(
435+ day_name=get_current_day_name(),
436+ day_number=day_number,
437+ month=get_current_month_name(),
438+ year=get_current_year())
439+ self.assertEquals(displayed_date, expeced_date)
440+
441+ @skip("Clock application is not opened")
442+ def test_open_clock(self):
443+ clock = self.indicator_page.open_clock()
444+ self.assertIsNotNone(clock)
445+
446+ @skip("Calendar application is not opened")
447+ def test_open_calendar(self):
448+ calendar = self.indicator_page.open_calendar()
449+ self.assertIsNotNone(calendar)
450
451=== added file 'ubuntu_system_tests/tests/indicators/test_indicator_system.py'
452--- ubuntu_system_tests/tests/indicators/test_indicator_system.py 1970-01-01 00:00:00 +0000
453+++ ubuntu_system_tests/tests/indicators/test_indicator_system.py 2017-04-05 14:24:21 +0000
454@@ -0,0 +1,97 @@
455+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
456+
457+# Ubuntu System Tests
458+# Copyright (C) 2017 Canonical
459+#
460+# This program is free software: you can redistribute it and/or modify
461+# it under the terms of the GNU General Public License as published by
462+# the Free Software Foundation, either version 3 of the License, or
463+# (at your option) any later version.
464+#
465+# This program is distributed in the hope that it will be useful,
466+# but WITHOUT ANY WARRANTY; without even the implied warranty of
467+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
468+# GNU General Public License for more details.
469+#
470+# You should have received a copy of the GNU General Public License
471+# along with this program. If not, see <http://www.gnu.org/licenses/>.
472+from time import sleep
473+
474+from testtools import skip
475+
476+from ubuntu_system_tests.helpers.gsettings import get_key, set_key
477+from ubuntu_system_tests.helpers.indicators.indicators import IndicatorsFactory
478+from ubuntu_system_tests.helpers.indicators.system import SystemIndicatorPage
479+from ubuntu_system_tests.tests.indicators import base
480+
481+ASK_UBUNTU_URL = 'http://www.askubuntu.com/'
482+UNITY8_SCHEMA = 'com.canonical.Unity8'
483+USAGE_MODE = 'usage-mode'
484+
485+
486+class SystemIndicatorTestCase(base.IndicatorTestCaseBase):
487+
488+ def setUp(self):
489+ super().setUp(SystemIndicatorPage.name)
490+
491+ def test_about_this_device_opens_about_page(self):
492+ """
493+ 1. Drag down the indicators
494+ 2. Click System'
495+ 3. Click About this device
496+ """
497+ about_page = self.indicator_page.open_about_page()
498+ self.assertIsNotNone(about_page)
499+
500+ @skip("Web browser app is not oppened")
501+ def test_ubuntu_help_opens_ask_ubuntu(self):
502+ help_page = self.indicator_page.open_help_page()
503+ current_url = help_page.get_current_url()
504+ self.assertEquals(current_url, ASK_UBUNTU_URL)
505+
506+ def test_switch_windowed_mode(self):
507+ desktop_mode = get_key(UNITY8_SCHEMA, USAGE_MODE).replace('\'', '')
508+ self.addCleanup(set_key, UNITY8_SCHEMA, USAGE_MODE, desktop_mode)
509+
510+ if not desktop_mode == 'Staged':
511+ set_key(UNITY8_SCHEMA, USAGE_MODE, 'Staged')
512+
513+ self.assertFalse(self.indicator_page.is_desktop_mode_enabled())
514+ self.indicator_page.switch_desktop_mode()
515+ self.assertTrue(self.indicator_page.is_desktop_mode_enabled())
516+ self.assertEquals('Windowed', get_key(
517+ UNITY8_SCHEMA, USAGE_MODE).replace('\'', ''))
518+
519+ def test_switch_staged_mode(self):
520+ desktop_mode = get_key(UNITY8_SCHEMA, USAGE_MODE).replace('\'', '')
521+ self.addCleanup(set_key, UNITY8_SCHEMA, USAGE_MODE, desktop_mode)
522+
523+ if not desktop_mode == 'Windowed':
524+ set_key(UNITY8_SCHEMA, USAGE_MODE, 'Windowed')
525+
526+ sleep(10)
527+
528+ self.indicator_page = IndicatorsFactory.get_indicators_page(
529+ SystemIndicatorPage.name)
530+
531+ self.assertTrue(self.indicator_page.is_desktop_mode_enabled())
532+ self.indicator_page.switch_desktop_mode()
533+ self.assertFalse(self.indicator_page.is_desktop_mode_enabled())
534+ self.assertEquals('Staged', get_key(
535+ UNITY8_SCHEMA, USAGE_MODE).replace('\'', ''))
536+
537+ @skip("Unstable test")
538+ def test_unity8_lock(self):
539+ self.indicator_page.lock()
540+ greeter = self.shell.get_greeter()
541+ self.assertIsNotNone(greeter)
542+
543+ def test_cancel_logout(self):
544+ self.assertTrue(self.indicator_page.get_properties()['enabled'])
545+ logout_dialog = self.indicator_page.logout()
546+ logout_dialog.cancel()
547+ self.assertTrue(self.indicator_page.get_properties()['enabled'])
548+
549+ def test_open_system_settings(self):
550+ page = self.indicator_page.open_system_settings()
551+ self.assertTrue(page.get_properties()['visible'])

Subscribers

People subscribed via source and target branches