on xenial help sign in
add timezone page test
commit610af511f1b75b3ddb10380cc8d706451041ebca authorLukáš Tinkl <lukas.tinkl@canonical.com> dateSun 6 Dec 2015, 15:58 (11 years ago) parent1ef2fcb
3 files changed+40−5
qml/Wizard/Pages/50-timezone.qml+6−3 tests/mocks/Ubuntu/SystemSettings/TimeDate/MockTimeDate.qml+1−1 tests/qmltests/Wizard/tst_Wizard.qml+33−1
qml/Wizard/Pages/50-timezone.qml+6−3
@@ -30,6 +30,9 @@ LocalComponents.Page {
3030
3131 property string selectedTimeZone: ""
3232
33+ // for testing
34+ readonly property alias tdModule: timeDatePanel
35+
3336 UbuntuTimeDatePanel {
3437 id: timeDatePanel
3538 }
@@ -61,7 +64,7 @@ LocalComponents.Page {
6164 id: tzComponent
6265 ListItem {
6366 id: tz
64− objectName: "tz"
67+ objectName: "tz" + index
6568 highlightColor: backgroundColor
6669 divider.colorFrom: dividerColor
6770 divider.colorTo: backgroundColor
@@ -106,8 +109,8 @@ LocalComponents.Page {
106109 }
107110
108111 onClicked: {
109− ListView.view.currentIndex = index
110− selectedTimeZone = timeZone
112+ ListView.view.currentIndex = index;
113+ selectedTimeZone = timeZone;
111114 }
112115 }
113116 }
tests/mocks/Ubuntu/SystemSettings/TimeDate/MockTimeDate.qml+1−1
@@ -21,5 +21,5 @@ Item {
2121 property string timeZone: "Europe/Prague"
2222 onTimeZoneChanged: root.timeZoneChangedCalled(root.timeZone);
2323
24− signal timeZoneChangedCalled(string tz)
24+ signal timeZoneChangedCalled(string tz);
2525}
tests/qmltests/Wizard/tst_Wizard.qml+33−1
@@ -21,6 +21,7 @@ import MeeGo.QOfono 0.2
2121import QMenuModel 0.1
2222import Ubuntu.Components 1.3
2323import Ubuntu.SystemSettings.SecurityPrivacy 1.0
24+import Ubuntu.SystemSettings.TimeDate 1.0
2425import Unity.Test 0.1 as UT
2526import Wizard 0.1
2627import "../../../qml/Wizard"
@@ -68,6 +69,11 @@ Item {
6869 signalName: "activated"
6970 }
7071
72+ SignalSpy {
73+ id: timezoneSpy
74+ signalName: "timeZoneChangedCalled"
75+ }
76+
7177 function setup() {
7278 AccountsService.hereEnabled = false;
7379 AccountsService.hereLicensePath = Qt.resolvedUrl("licenses");
@@ -81,6 +87,7 @@ Item {
8187 setSecuritySpy.clear();
8288 activateLocationSpy.clear();
8389 activateGPSSpy.clear();
90+ timezoneSpy.clear();
8491
8592 ActionData.data = {
8693 "location-detection-enabled": {
@@ -193,7 +200,7 @@ Item {
193200 var tzList = findChild(page, "tzList");
194201 verify(tzList);
195202 waitForRendering(tzList);
196− tzList.currentIndex = 0; // FIXME make it more generic
203+ tzList.currentIndex = 0;
197204 page.selectedTimeZone = "Pacific/Honolulu";
198205 tap(findChild(page, "forwardButton"));
199206
@@ -451,5 +458,30 @@ Item {
451458 tryCompare(activateLocationSpy, "count", 1);
452459 tryCompare(activateGPSSpy, "count", 1);
453460 }
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+ }
454486 }
455487}