43
"actionState": { "label": Qt.formatTime(new Date("October 13, 1975 11:13:00")) }
39
function updateDatetimeModelTime(label) {
40
Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicator/datetime/phone",
43
"actionState": { "label": label }
52
var cachedModel = findChild(clock, "timeModel");
53
verify(cachedModel !== undefined);
54
cachedModel.model = menuModel;
57
function test_customDate() {
58
var dateObj = new Date("October 13, 1975 11:13:00")
59
var dateString = Qt.formatDate(dateObj, Qt.DefaultLocaleLongDate)
60
var timeString = Qt.formatTime(dateObj)
62
clock.currentDate = dateObj
63
var dateLabel = findChild(clock, "dateLabel")
64
compare(dateLabel.text, dateString, "Not the expected date")
65
var timeLabel = findChild(clock, "timeLabel")
66
compare(timeLabel.text, timeString, "Not the expected time")
69
function test_dateUpdate() {
70
var dateObj = new Date("October 13, 1975 11:13:00")
71
var dateString = Qt.formatDate(dateObj, Qt.DefaultLocaleLongDate)
72
var timeString = Qt.formatTime(dateObj)
53
updateDatetimeModelTime(Qt.formatTime(new Date("October 13, 1975 12:14:00")));
57
// Test that the date portion of the clock updates with custom value.
58
// Time portion is controlled by indicators
59
function test_updateDate() {
60
var dateLabel = findChild(clock, "dateLabel");
61
var timeLabel = findChild(clock, "timeLabel");
63
var timeString = Qt.formatTime(new Date("October 13, 1975 12:14:00"));
66
var dateObj = new Date("October 13, 1975 11:13:00");
67
var dateString = Qt.formatDate(dateObj, Qt.DefaultLocaleLongDate);
68
clock.currentDate = dateObj;
70
compare(dateLabel.text, dateString, "Not the expected date");
71
compare(timeLabel.text, timeString, "Time should come from indicators");
74
var dateObj2 = new Date("October 14, 1976 13:15:00");
75
var dateString2 = Qt.formatDate(dateObj2, Qt.DefaultLocaleLongDate);
76
clock.currentDate = dateObj2;
78
compare(dateLabel.text, dateString2, "Not the expected date");
79
compare(timeLabel.text,timeString, "Time should come from indicators");
82
// Test that the date portion of the clock updates with custom value.
83
// Time portion is controlled by indicators
84
function test_updateTime() {
85
var timeLabel = findChild(clock, "timeLabel");
87
var timeString1 = Qt.formatTime(new Date("October 13, 1975 11:15:00"));
88
var timeString2 = Qt.formatTime(new Date("October 14, 1976 12:16:00"));
90
updateDatetimeModelTime(timeString1);
91
compare(timeLabel.text, timeString1, "Time should come from indicators");
93
updateDatetimeModelTime(timeString2);
94
compare(timeLabel.text, timeString2, "Time should come from indicators");
97
function test_indicatorDisconnect() {
74
98
clock.visible = false
75
99
var timeModel = findInvisibleChild(clock, "timeModel")
77
100
compare(timeModel.menuObjectPath, "", "Clock shouldn't be connected to Indicators when not visible.")
79
clock.currentDate = dateObj
81
var dateLabel = findChild(clock, "dateLabel")
82
compare(dateLabel.text, dateString, "Not the expected date")
83
var timeLabel = findChild(clock, "timeLabel")
84
compare(timeLabel.text, timeString, "Not the expected time")
86
102
clock.visible = true
88
verify(timeModel.menuObjectPath != "", "Should be connected to Indicators.")
103
verify(timeModel.menuObjectPath !== "", "Should be connected to Indicators.")