Merge lp:~laney/ubuntu-system-settings/autopilot-datetime into lp:ubuntu-system-settings

Proposed by Iain Lane
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 531
Merged at revision: 596
Proposed branch: lp:~laney/ubuntu-system-settings/autopilot-datetime
Merge into: lp:ubuntu-system-settings
Diff against target: 201 lines (+115/-3)
5 files modified
debian/control (+1/-1)
plugins/time-date/ChooseTimeZone.qml (+3/-0)
plugins/time-date/PageComponent.qml (+4/-0)
plugins/time-date/timedate.cpp (+5/-2)
tests/autopilot/ubuntu_system_settings/tests/test_datetime.py (+102/-0)
To merge this branch: bzr merge lp:~laney/ubuntu-system-settings/autopilot-datetime
Reviewer Review Type Date Requested Status
Sebastien Bacher (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+203954@code.launchpad.net

Commit message

Add some initial tests for the datetime panel

Description of the change

Add some initial tests for the datetime panel

Some are skipped currently because they need the timedated mock to emit PropertiesChanged

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
531. By Iain Lane

Enable all tests; bump dbusmock version; don't use scroll_to_and_click where it's not necessary

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

Looks good and run without issues on both desktop and phone configs!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2014-01-30 11:32:47 +0000
3+++ debian/control 2014-01-30 16:43:15 +0000
4@@ -90,7 +90,7 @@
5 Architecture: all
6 Depends: ubuntu-system-settings,
7 python-autopilot,
8- python-dbusmock (>= 0.9.2),
9+ python-dbusmock (>= 0.10.1),
10 libautopilot-qt,
11 ubuntu-ui-toolkit-autopilot,
12 dpkg-dev,
13
14=== modified file 'plugins/time-date/ChooseTimeZone.qml'
15--- plugins/time-date/ChooseTimeZone.qml 2014-01-27 17:09:51 +0000
16+++ plugins/time-date/ChooseTimeZone.qml 2014-01-30 16:43:15 +0000
17@@ -65,6 +65,7 @@
18 margins: units.gu(2)
19 }
20 id: filterCities
21+ objectName: "selectTimeZoneField"
22 onTextChanged: timeDatePanel.filter = text
23 visible: setTimeZoneSelector.selectedIndex == 1 // Manually
24 Component.onCompleted: forceActiveFocus()
25@@ -80,6 +81,7 @@
26
27 ListView {
28 id: locationsListView
29+ objectName: "locationsListView"
30 clip: true
31 anchors {
32 top: filterCities.bottom
33@@ -108,6 +110,7 @@
34 }
35
36 Label {
37+ objectName: "nothingLabel"
38 anchors.centerIn: parent
39 visible: setTimeZoneSelector.selectedIndex ==1 &&
40 locationsListView.count == 0
41
42=== modified file 'plugins/time-date/PageComponent.qml'
43--- plugins/time-date/PageComponent.qml 2013-09-25 16:39:54 +0000
44+++ plugins/time-date/PageComponent.qml 2014-01-30 16:43:15 +0000
45@@ -27,6 +27,7 @@
46
47 ItemPage {
48 title: i18n.tr("Time & Date")
49+ objectName: "timeDatePage"
50
51 function getUTCOffset() {
52 // We get the difference in minutes between UTC and our TZ (UTC - TZ)
53@@ -52,6 +53,7 @@
54 ListItem.Standard { text: i18n.tr ("Time zone:") }
55
56 ListItem.SingleValue {
57+ objectName: "timeZone"
58 id: timeZone
59 //e.g. America/New_York -> America/New York
60 text: timeDatePanel.timeZone.replace("_", " ")
61@@ -62,6 +64,7 @@
62
63 ListItem.ItemSelector {
64 id: setTimeAutomatically
65+ objectName: "timeItemSelector"
66 text: i18n.tr ("Set the time and date:")
67 model: [ i18n.tr("Automatically") , i18n.tr("Manually")]
68 expanded: true
69@@ -93,6 +96,7 @@
70
71 ListItem.Standard {
72 id: currentTime
73+ objectName: "currentTime"
74 progression: setTimeAutomatically.selectedIndex === 1 // Manually
75 enabled: progression
76 onClicked: {
77
78=== modified file 'plugins/time-date/timedate.cpp'
79--- plugins/time-date/timedate.cpp 2013-10-07 11:08:09 +0000
80+++ plugins/time-date/timedate.cpp 2014-01-30 16:43:15 +0000
81@@ -106,8 +106,11 @@
82 Q_UNUSED (changed_properties);
83
84 if (invalidated_properties.contains("Timezone")) {
85- m_currentTimeZone = getTimeZone();
86- Q_EMIT timeZoneChanged();
87+ QString tz(getTimeZone());
88+ if (tz != m_currentTimeZone) {
89+ m_currentTimeZone = tz;
90+ Q_EMIT timeZoneChanged();
91+ }
92 }
93
94 if (invalidated_properties.contains("NTP")) {
95
96=== added file 'tests/autopilot/ubuntu_system_settings/tests/test_datetime.py'
97--- tests/autopilot/ubuntu_system_settings/tests/test_datetime.py 1970-01-01 00:00:00 +0000
98+++ tests/autopilot/ubuntu_system_settings/tests/test_datetime.py 2014-01-30 16:43:15 +0000
99@@ -0,0 +1,102 @@
100+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
101+# Copyright 2013 Canonical
102+#
103+# This program is free software: you can redistribute it and/or modify it
104+# under the terms of the GNU General Public License version 3, as published
105+# by the Free Software Foundation.
106+
107+import dbus
108+import dbusmock
109+import subprocess
110+from time import sleep
111+
112+from autopilot.platform import model
113+from autopilot.matchers import Eventually
114+from testtools.matchers import Equals, NotEquals, GreaterThan
115+
116+from ubuntu_system_settings.tests import UbuntuSystemSettingsTestCase
117+from ubuntu_system_settings.utils.i18n import ugettext as _
118+
119+from ubuntuuitoolkit import emulators as toolkit_emulators
120+
121+class TimeDateTestCase(UbuntuSystemSettingsTestCase,
122+ dbusmock.DBusTestCase):
123+ """ Tests for the Time & Date Page """
124+
125+ @classmethod
126+ def setUpClass(klass):
127+ klass.start_system_bus()
128+ klass.dbus_con = klass.get_dbus(True)
129+ (klass.p_mock,klass.obj_timedate1) = klass.spawn_server_template(
130+ 'timedated', {}, stdout=subprocess.PIPE)
131+
132+ def setUp(self):
133+ """ Go to Time & Date page """
134+ self.obj_timedate1.Reset()
135+ super(TimeDateTestCase, self).setUp("time-date")
136+
137+ @property
138+ def time_date_page(self):
139+ return self.main_view.select_single(objectName='timeDatePage')
140+
141+ @property
142+ def tz_page(self):
143+ return self.main_view.select_single(objectName='timeZone')
144+
145+ def click_tz_search_field(self):
146+ self.scroll_to_and_click(self.tz_page)
147+ text_field = self.main_view.select_single(objectName='selectTimeZoneField')
148+ self.pointer.move_to_object(text_field)
149+
150+ def test_time_date_page(self):
151+ """ Checks whether Time & Date page is available """
152+ self.assertThat(self.time_date_page, NotEquals(None))
153+ self.assertThat(self.time_date_page.title, Equals(_('Time & Date')))
154+
155+ def test_tz_list_initially_empty(self):
156+ """ Checks that no list is displayed initially """
157+ self.scroll_to_and_click(self.tz_page)
158+ labelVisible = self.main_view.select_single(objectName='nothingLabel').visible
159+ self.assertThat(labelVisible, Equals(True))
160+
161+ def test_searching_tz(self):
162+ """ Check that searching for a valid location shows something """
163+ self.click_tz_search_field()
164+ self.keyboard.type('London, United Kingdom')
165+ listview = self.main_view.select_single(objectName='locationsListView')
166+ self.assertThat(listview.count, GreaterThan(0))
167+
168+ def test_searching_tz_not_found(self):
169+ """ Check that searching for an invalid location shows nothing """
170+ self.click_tz_search_field()
171+ self.keyboard.type('Oh no you don\'t!')
172+ listview = self.main_view.select_single(objectName='locationsListView')
173+ self.assertThat(listview.count, Equals(0))
174+ labelVisible = self.main_view.select_single(objectName='nothingLabel').visible
175+ self.assertThat(labelVisible, Equals(True))
176+
177+ def test_manual_tz_selection(self):
178+ """ Check that manually selecting a timezone sets it properly """
179+ self.click_tz_search_field()
180+ self.keyboard.type('London, United Kingdom')
181+ listview = self.main_view.select_single(objectName='locationsListView')
182+ london = listview.select_many(toolkit_emulators.Standard)[0]
183+ self.pointer.click_object(london)
184+ header = self.main_view.select_single(objectName='MainView_Header')
185+ self.assertThat(header.title, Eventually(Equals(_('Time & Date'))))
186+ self.assertThat(self.tz_page.text, Equals('Europe/London'))
187+
188+ def test_same_tz_selection(self):
189+ """ Check that manually setting a timezone then setting the same one doesn't
190+ take you back to the index """
191+ self.test_manual_tz_selection()
192+ self.click_tz_search_field()
193+ # This is also in Europe/London
194+ self.keyboard.type('Preston, United Kingdom')
195+ listview = self.main_view.select_single(objectName='locationsListView')
196+ preston = listview.select_many(toolkit_emulators.Standard)[0]
197+ self.pointer.click_object(preston)
198+ # The timer is 1 second, wait and see that we haven't moved pages
199+ sleep(2)
200+ header = self.main_view.select_single(objectName='MainView_Header')
201+ self.assertThat(header.title, Eventually(Equals(_('Time zone'))))

Subscribers

People subscribed via source and target branches