Merge lp:~mzanetti/unity8/fix-greeter-time-update into lp:unity8

Proposed by Michael Zanetti
Status: Merged
Approved by: Mirco Müller
Approved revision: 437
Merged at revision: 444
Proposed branch: lp:~mzanetti/unity8/fix-greeter-time-update
Merge into: lp:unity8
Diff against target: 144 lines (+41/-36)
3 files modified
Greeter/Clock.qml (+32/-13)
tests/qmltests/CMakeLists.txt (+1/-1)
tests/qmltests/Greeter/tst_Clock.qml (+8/-22)
To merge this branch: bzr merge lp:~mzanetti/unity8/fix-greeter-time-update
Reviewer Review Type Date Requested Status
Mirco Müller (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+190636@code.launchpad.net

Commit message

make the greeter's clock update in sync with the indicators.

This gets rid of the timer in the greeter as the indicator fires signals when it's time to update.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:437
http://jenkins.qa.ubuntu.com/job/unity8-ci/1366/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy/4945/console
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/2844
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-saucy/2232
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-amd64-ci/389
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-armhf-ci/1366
        deb: http://jenkins.qa.ubuntu.com/job/unity8-saucy-armhf-ci/1366/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-i386-ci/1365
    ABORTED: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-saucy/1121/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-amd64/820
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-amd64/820/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/2846
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/2846/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2366
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2406

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/unity8-ci/1366/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mirco Müller (macslow) wrote :

Looks ok, works fine. Approved.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Greeter/Clock.qml'
2--- Greeter/Clock.qml 2013-06-05 22:03:08 +0000
3+++ Greeter/Clock.qml 2013-10-11 12:16:27 +0000
4@@ -16,6 +16,7 @@
5
6 import QtQuick 2.0
7 import Ubuntu.Components 0.1
8+import Unity.Indicators 0.1 as Indicators
9
10 Item {
11 id: clock
12@@ -23,17 +24,35 @@
13 implicitWidth: childrenRect.width
14 implicitHeight: childrenRect.height
15
16- property date __date
17- property alias __timerInterval: timer.interval
18- readonly property bool __timerRunning: timer.running
19-
20- Timer {
21- id: timer
22- interval: 1000 * 60
23- running: clock.enabled && clock.visible && clock.opacity != 0
24- repeat: true
25- triggeredOnStart: true
26- onTriggered: __date = new Date
27+ // Allows to set the current Date. Will be overwritten if active
28+ property date currentDate
29+
30+ // If active, time will be updated through the indicators service
31+ property bool active: clock.enabled && clock.visible
32+
33+ Component.onCompleted: {
34+ if (active) {
35+ currentDate = new Date()
36+ }
37+ }
38+
39+ Indicators.CachedUnityMenuModel {
40+ id: timeModel
41+ objectName: "timeModel"
42+
43+ busName: "com.canonical.indicator.datetime"
44+ actionsObjectPath: "/com/canonical/indicator/datetime"
45+ menuObjectPath: clock.active ? "/com/canonical/indicator/datetime/phone" : ""
46+
47+ Indicators.RootActionState {
48+ menu: timeModel.model
49+ onUpdated: {
50+ if (timeLabel.text != rightLabel) {
51+ timeLabel.text = rightLabel;
52+ clock.currentDate = new Date();
53+ }
54+ }
55+ }
56 }
57
58 Column {
59@@ -47,7 +66,7 @@
60 font.pixelSize: units.gu(7.5)
61 color: "white"
62 opacity: 0.5
63- text: Qt.formatTime(__date)
64+ text: Qt.formatTime(clock.currentDate)
65 font.weight: Font.Light
66 }
67
68@@ -59,7 +78,7 @@
69 fontSize: "medium"
70 color: "white"
71 opacity: 0.5
72- text: Qt.formatDate(__date, Qt.DefaultLocaleLongDate)
73+ text: Qt.formatDate(clock.currentDate, Qt.DefaultLocaleLongDate)
74 font.weight: Font.Light
75 }
76 }
77
78=== modified file 'tests/qmltests/CMakeLists.txt'
79--- tests/qmltests/CMakeLists.txt 2013-10-08 12:50:52 +0000
80+++ tests/qmltests/CMakeLists.txt 2013-10-11 12:16:27 +0000
81@@ -17,7 +17,7 @@
82 add_qml_test(Components OpenEffect)
83 add_qml_test(Components RatingStars)
84 add_qml_test(Components TimeLocal)
85-add_qml_test(Greeter Clock)
86+add_qml_test(Greeter Clock IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
87 add_qml_test(Panel IndicatorItem)
88 add_qml_test(utils/Unity/Test UnityTest)
89
90
91=== modified file 'tests/qmltests/Greeter/tst_Clock.qml'
92--- tests/qmltests/Greeter/tst_Clock.qml 2013-08-21 09:29:44 +0000
93+++ tests/qmltests/Greeter/tst_Clock.qml 2013-10-11 12:16:27 +0000
94@@ -43,8 +43,7 @@
95 var dateString = Qt.formatDate(dateObj, Qt.DefaultLocaleLongDate)
96 var timeString = Qt.formatTime(dateObj)
97
98- clock.__timerInterval = 60000
99- clock.__date = dateObj
100+ clock.currentDate = dateObj
101 var dateLabel = findChild(clock, "dateLabel")
102 compare(dateLabel.text, dateString, "Not the expected date")
103 var timeLabel = findChild(clock, "timeLabel")
104@@ -57,33 +56,20 @@
105 var timeString = Qt.formatTime(dateObj)
106
107 clock.enabled = false
108- compare(clock.__timerRunning, false, "Timer should not be running")
109- clock.__date = dateObj
110- clock.__timerInterval = 5
111- wait(5) // spin event loop (only that would trigger the timer and reveal eventual bugs)
112+ var timeModel = findInvisibleChild(clock, "timeModel")
113+
114+ compare(timeModel.menuObjectPath, "", "Clock shouldn't be connected to Indicators when not active.")
115+
116+ clock.currentDate = dateObj
117+
118 var dateLabel = findChild(clock, "dateLabel")
119 compare(dateLabel.text, dateString, "Not the expected date")
120 var timeLabel = findChild(clock, "timeLabel")
121 compare(timeLabel.text, timeString, "Not the expected time")
122
123 clock.enabled = true
124- compare(clock.__timerRunning, true, "Timer should be running")
125- wait(0) // spin event loop to trigger the timer
126- verify(dateLabel.text !== dateString)
127- if (timeLabel.text.indexOf("11:13") != -1) wait(60000) // next test will fail at 11:13, wait 1 minute
128- verify(timeLabel.text !== timeString)
129- }
130
131- function test_timerRunning() {
132- // tests for clock.enabled property are already in test_dateUpdate()
133- clock.opacity = 0.0
134- compare(clock.__timerRunning, false, "Timer should not be running")
135- clock.opacity = 1.0
136- compare(clock.__timerRunning, true, "Timer should be running")
137- clock.visible = false
138- compare(clock.__timerRunning, false, "Timer should not be running")
139- clock.visible = true
140- compare(clock.__timerRunning, true, "Timer should be running")
141+ verify(timeModel.menuObjectPath != "", "Should be connected to Indicators.")
142 }
143 }
144 }

Subscribers

People subscribed via source and target branches