on xenial help sign in
add timezone page test
610af51Lukáš Tinkl
qml/Wizard/Pages/50-timezone.qml+6−3
@@ -30,6 +30,9 @@ LocalComponents.Page {
30
30
31 property string selectedTimeZone: ""
31 property string selectedTimeZone: ""
32
32
33+ // for testing
34+ readonly property alias tdModule: timeDatePanel
35+
33 UbuntuTimeDatePanel {
36 UbuntuTimeDatePanel {
34 id: timeDatePanel
37 id: timeDatePanel
35 }
38 }
@@ -61,7 +64,7 @@ LocalComponents.Page {
61 id: tzComponent
64 id: tzComponent
62 ListItem {
65 ListItem {
63 id: tz
66 id: tz
64− objectName: "tz"
67+ objectName: "tz" + index
65 highlightColor: backgroundColor
68 highlightColor: backgroundColor
66 divider.colorFrom: dividerColor
69 divider.colorFrom: dividerColor
67 divider.colorTo: backgroundColor
70 divider.colorTo: backgroundColor
@@ -106,8 +109,8 @@ LocalComponents.Page {
106 }
109 }
107
110
108 onClicked: {
111 onClicked: {
109− ListView.view.currentIndex = index
112+ ListView.view.currentIndex = index;
110− selectedTimeZone = timeZone
113+ selectedTimeZone = timeZone;
111 }
114 }
112 }
115 }
113 }
116 }
tests/mocks/Ubuntu/SystemSettings/TimeDate/MockTimeDate.qml+1−1
@@ -21,5 +21,5 @@ Item {
21 property string timeZone: "Europe/Prague"
21 property string timeZone: "Europe/Prague"
22 onTimeZoneChanged: root.timeZoneChangedCalled(root.timeZone);
22 onTimeZoneChanged: root.timeZoneChangedCalled(root.timeZone);
23
23
24− signal timeZoneChangedCalled(string tz)
24+ signal timeZoneChangedCalled(string tz);
25}
25}
tests/qmltests/Wizard/tst_Wizard.qml+33−1
@@ -21,6 +21,7 @@ import MeeGo.QOfono 0.2
21import QMenuModel 0.1
21import QMenuModel 0.1
22import Ubuntu.Components 1.3
22import Ubuntu.Components 1.3
23import Ubuntu.SystemSettings.SecurityPrivacy 1.0
23import Ubuntu.SystemSettings.SecurityPrivacy 1.0
24+import Ubuntu.SystemSettings.TimeDate 1.0
24import Unity.Test 0.1 as UT
25import Unity.Test 0.1 as UT
25import Wizard 0.1
26import Wizard 0.1
26import "../../../qml/Wizard"
27import "../../../qml/Wizard"
@@ -68,6 +69,11 @@ Item {
68 signalName: "activated"
69 signalName: "activated"
69 }
70 }
70
71
72+ SignalSpy {
73+ id: timezoneSpy
74+ signalName: "timeZoneChangedCalled"
75+ }
76+
71 function setup() {
77 function setup() {
72 AccountsService.hereEnabled = false;
78 AccountsService.hereEnabled = false;
73 AccountsService.hereLicensePath = Qt.resolvedUrl("licenses");
79 AccountsService.hereLicensePath = Qt.resolvedUrl("licenses");
@@ -81,6 +87,7 @@ Item {
81 setSecuritySpy.clear();
87 setSecuritySpy.clear();
82 activateLocationSpy.clear();
88 activateLocationSpy.clear();
83 activateGPSSpy.clear();
89 activateGPSSpy.clear();
90+ timezoneSpy.clear();
84
91
85 ActionData.data = {
92 ActionData.data = {
86 "location-detection-enabled": {
93 "location-detection-enabled": {
@@ -193,7 +200,7 @@ Item {
193 var tzList = findChild(page, "tzList");
200 var tzList = findChild(page, "tzList");
194 verify(tzList);
201 verify(tzList);
195 waitForRendering(tzList);
202 waitForRendering(tzList);
196− tzList.currentIndex = 0; // FIXME make it more generic
203+ tzList.currentIndex = 0;
197 page.selectedTimeZone = "Pacific/Honolulu";
204 page.selectedTimeZone = "Pacific/Honolulu";
198 tap(findChild(page, "forwardButton"));
205 tap(findChild(page, "forwardButton"));
199
206
@@ -451,5 +458,30 @@ Item {
451 tryCompare(activateLocationSpy, "count", 1);
458 tryCompare(activateLocationSpy, "count", 1);
452 tryCompare(activateGPSSpy, "count", 1);
459 tryCompare(activateGPSSpy, "count", 1);
453 }
460 }
461+
462+ function test_timezonePage() {
463+ var page = goToPage("tzPage");
464+ verify(page);
465+ timezoneSpy.target = page.tdModule;
466+
467+ var tzFilter = findChild(page, "tzFilter");
468+ verify(tzFilter);
469+ tap(tzFilter);
470+ typeString("London");
471+
472+ var tzList = findChild(page, "tzList");
473+ verify(tzList);
474+
475+ // test filtering works and returns some results
476+ tryCompareFunction(function() { return tzList.count > 0; }, true);
477+
478+ // just tap the first one
479+ tap(findChild(page, "tz0"));
480+
481+ // go next and verify the (mock) signal got fired
482+ tap(findChild(page, "forwardButton"));
483+ tryCompare(timezoneSpy, "count", 1);
484+ tryCompare(page.tdModule, "timeZone", timezoneSpy.signalArguments[0][0]);
485+ }
454 }
486 }
455}
487}