2
* Copyright 2013 Canonical Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
import "../../../Greeter"
21
import Ubuntu.Components 0.1
22
import Unity.Test 0.1 as UT
33
topMargin: units.gu(2)
34
horizontalCenter: parent.horizontalCenter
41
function test_customDate() {
42
var dateObj = new Date("October 13, 1975 11:13:00")
43
var dateString = Qt.formatDate(dateObj, Qt.DefaultLocaleLongDate)
44
var timeString = Qt.formatTime(dateObj)
46
clock.__timerInterval = 60000
47
clock.__date = dateObj
48
var dateLabel = findChild(clock, "dateLabel")
49
compare(dateLabel.text, dateString, "Not the expected date")
50
var timeLabel = findChild(clock, "timeLabel")
51
compare(timeLabel.text, timeString, "Not the expected time")
54
function test_dateUpdate() {
55
var dateObj = new Date("October 13, 1975 11:13:00")
56
var dateString = Qt.formatDate(dateObj, Qt.DefaultLocaleLongDate)
57
var timeString = Qt.formatTime(dateObj)
60
compare(clock.__timerRunning, false, "Timer should not be running")
61
clock.__date = dateObj
62
clock.__timerInterval = 5
63
wait(5) // spin event loop (only that would trigger the timer and reveal eventual bugs)
64
var dateLabel = findChild(clock, "dateLabel")
65
compare(dateLabel.text, dateString, "Not the expected date")
66
var timeLabel = findChild(clock, "timeLabel")
67
compare(timeLabel.text, timeString, "Not the expected time")
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 == "11:13") wait(60000) // next test will fail at 11:13, wait 1 minute
74
verify(timeLabel.text !== timeString)
77
function test_timerRunning() {
78
// tests for clock.enabled property are already in test_dateUpdate()
80
compare(clock.__timerRunning, false, "Timer should not be running")
82
compare(clock.__timerRunning, true, "Timer should be running")
84
compare(clock.__timerRunning, false, "Timer should not be running")
86
compare(clock.__timerRunning, true, "Timer should be running")