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
=== modified file 'Greeter/Clock.qml'
--- Greeter/Clock.qml 2013-06-05 22:03:08 +0000
+++ Greeter/Clock.qml 2013-10-11 12:16:27 +0000
@@ -16,6 +16,7 @@
1616
17import QtQuick 2.017import QtQuick 2.0
18import Ubuntu.Components 0.118import Ubuntu.Components 0.1
19import Unity.Indicators 0.1 as Indicators
1920
20Item {21Item {
21 id: clock22 id: clock
@@ -23,17 +24,35 @@
23 implicitWidth: childrenRect.width24 implicitWidth: childrenRect.width
24 implicitHeight: childrenRect.height25 implicitHeight: childrenRect.height
2526
26 property date __date27 // Allows to set the current Date. Will be overwritten if active
27 property alias __timerInterval: timer.interval28 property date currentDate
28 readonly property bool __timerRunning: timer.running29
2930 // If active, time will be updated through the indicators service
30 Timer {31 property bool active: clock.enabled && clock.visible
31 id: timer32
32 interval: 1000 * 6033 Component.onCompleted: {
33 running: clock.enabled && clock.visible && clock.opacity != 034 if (active) {
34 repeat: true35 currentDate = new Date()
35 triggeredOnStart: true36 }
36 onTriggered: __date = new Date37 }
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 }
37 }56 }
3857
39 Column {58 Column {
@@ -47,7 +66,7 @@
47 font.pixelSize: units.gu(7.5)66 font.pixelSize: units.gu(7.5)
48 color: "white"67 color: "white"
49 opacity: 0.568 opacity: 0.5
50 text: Qt.formatTime(__date)69 text: Qt.formatTime(clock.currentDate)
51 font.weight: Font.Light70 font.weight: Font.Light
52 }71 }
5372
@@ -59,7 +78,7 @@
59 fontSize: "medium"78 fontSize: "medium"
60 color: "white"79 color: "white"
61 opacity: 0.580 opacity: 0.5
62 text: Qt.formatDate(__date, Qt.DefaultLocaleLongDate)81 text: Qt.formatDate(clock.currentDate, Qt.DefaultLocaleLongDate)
63 font.weight: Font.Light82 font.weight: Font.Light
64 }83 }
65 }84 }
6685
=== modified file 'tests/qmltests/CMakeLists.txt'
--- tests/qmltests/CMakeLists.txt 2013-10-08 12:50:52 +0000
+++ tests/qmltests/CMakeLists.txt 2013-10-11 12:16:27 +0000
@@ -17,7 +17,7 @@
17add_qml_test(Components OpenEffect)17add_qml_test(Components OpenEffect)
18add_qml_test(Components RatingStars)18add_qml_test(Components RatingStars)
19add_qml_test(Components TimeLocal)19add_qml_test(Components TimeLocal)
20add_qml_test(Greeter Clock)20add_qml_test(Greeter Clock IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
21add_qml_test(Panel IndicatorItem)21add_qml_test(Panel IndicatorItem)
22add_qml_test(utils/Unity/Test UnityTest)22add_qml_test(utils/Unity/Test UnityTest)
2323
2424
=== modified file 'tests/qmltests/Greeter/tst_Clock.qml'
--- tests/qmltests/Greeter/tst_Clock.qml 2013-08-21 09:29:44 +0000
+++ tests/qmltests/Greeter/tst_Clock.qml 2013-10-11 12:16:27 +0000
@@ -43,8 +43,7 @@
43 var dateString = Qt.formatDate(dateObj, Qt.DefaultLocaleLongDate)43 var dateString = Qt.formatDate(dateObj, Qt.DefaultLocaleLongDate)
44 var timeString = Qt.formatTime(dateObj)44 var timeString = Qt.formatTime(dateObj)
4545
46 clock.__timerInterval = 6000046 clock.currentDate = dateObj
47 clock.__date = dateObj
48 var dateLabel = findChild(clock, "dateLabel")47 var dateLabel = findChild(clock, "dateLabel")
49 compare(dateLabel.text, dateString, "Not the expected date")48 compare(dateLabel.text, dateString, "Not the expected date")
50 var timeLabel = findChild(clock, "timeLabel")49 var timeLabel = findChild(clock, "timeLabel")
@@ -57,33 +56,20 @@
57 var timeString = Qt.formatTime(dateObj)56 var timeString = Qt.formatTime(dateObj)
5857
59 clock.enabled = false58 clock.enabled = false
60 compare(clock.__timerRunning, false, "Timer should not be running")59 var timeModel = findInvisibleChild(clock, "timeModel")
61 clock.__date = dateObj60
62 clock.__timerInterval = 561 compare(timeModel.menuObjectPath, "", "Clock shouldn't be connected to Indicators when not active.")
63 wait(5) // spin event loop (only that would trigger the timer and reveal eventual bugs)62
63 clock.currentDate = dateObj
64
64 var dateLabel = findChild(clock, "dateLabel")65 var dateLabel = findChild(clock, "dateLabel")
65 compare(dateLabel.text, dateString, "Not the expected date")66 compare(dateLabel.text, dateString, "Not the expected date")
66 var timeLabel = findChild(clock, "timeLabel")67 var timeLabel = findChild(clock, "timeLabel")
67 compare(timeLabel.text, timeString, "Not the expected time")68 compare(timeLabel.text, timeString, "Not the expected time")
6869
69 clock.enabled = true70 clock.enabled = true
70 compare(clock.__timerRunning, true, "Timer should be running")
71 wait(0) // spin event loop to trigger the timer
72 verify(dateLabel.text !== dateString)
73 if (timeLabel.text.indexOf("11:13") != -1) wait(60000) // next test will fail at 11:13, wait 1 minute
74 verify(timeLabel.text !== timeString)
75 }
7671
77 function test_timerRunning() {72 verify(timeModel.menuObjectPath != "", "Should be connected to Indicators.")
78 // tests for clock.enabled property are already in test_dateUpdate()
79 clock.opacity = 0.0
80 compare(clock.__timerRunning, false, "Timer should not be running")
81 clock.opacity = 1.0
82 compare(clock.__timerRunning, true, "Timer should be running")
83 clock.visible = false
84 compare(clock.__timerRunning, false, "Timer should not be running")
85 clock.visible = true
86 compare(clock.__timerRunning, true, "Timer should be running")
87 }73 }
88 }74 }
89}75}

Subscribers

People subscribed via source and target branches