Merge lp:~nik90/ubuntu-clock-app/transition-worldclock-u1db into lp:ubuntu-clock-app/saucy

Proposed by Nekhelesh Ramananthan
Status: Merged
Approved by: Nekhelesh Ramananthan
Approved revision: 331
Merged at revision: 329
Proposed branch: lp:~nik90/ubuntu-clock-app/transition-worldclock-u1db
Merge into: lp:ubuntu-clock-app/saucy
Diff against target: 540 lines (+106/-255)
6 files modified
clock/ClockPage.qml (+80/-31)
clock/WorldClock.qml (+5/-4)
clock/WorldClockModel.qml (+0/-199)
tests/autopilot/ubuntu_clock_app/emulators.py (+1/-1)
tests/autopilot/ubuntu_clock_app/tests/test_clock.py (+20/-12)
ubuntu-clock-app.qml (+0/-8)
To merge this branch: bzr merge lp:~nik90/ubuntu-clock-app/transition-worldclock-u1db
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Riccardo Padovani Approve
Andrew Hayzen u1db Pending
Ubuntu Clock Developers Pending
Review via email: mp+204967@code.launchpad.net

Commit message

Transitions the storage of world clocks and current location of user from LocalStorage to U1db.

Description of the change

Transitions the storage of world clocks and current location of user from LocalStorage to U1db. With this the clock app uses U1db entirely.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Riccardo Padovani (rpadovani) wrote :

Autopilot tests work as expected!

review: Approve
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Approving MP since a preliminary u1db code review was done by christian.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Random AP failure, approving again.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'clock/ClockPage.qml'
--- clock/ClockPage.qml 2014-02-03 13:15:46 +0000
+++ clock/ClockPage.qml 2014-02-05 16:44:42 +0000
@@ -19,9 +19,10 @@
19 */19 */
2020
21import QtQuick 2.021import QtQuick 2.0
22import U1db 1.0 as U1db
22import Ubuntu.Components 0.123import Ubuntu.Components 0.1
24import QtQuick.XmlListModel 2.0
23import Ubuntu.Components.ListItems 0.1 as ListItem25import Ubuntu.Components.ListItems 0.1 as ListItem
24import QtQuick.XmlListModel 2.0
25import "../common/ClockUtils.js" as Utils26import "../common/ClockUtils.js" as Utils
26import "../common"27import "../common"
2728
@@ -32,22 +33,47 @@
32 property string currentTimeFormatted33 property string currentTimeFormatted
33 property real currentUTCTime34 property real currentUTCTime
34 property real diff: new Date().getTimezoneOffset()35 property real diff: new Date().getTimezoneOffset()
35 property alias currentCity: currentLocationCity.text36
36 property alias currentLat: easterEggCircle.latitude37 // Property to store the user location (city, longitude, latitude)
37 property alias currentLng: easterEggCircle.longitude38 property var userLocation: { "city": i18n.tr("Retrieving current location..."), "lng": 200, "lat": 200 }
39
40 // U1dB document to store the current location of the user
41 U1db.Document {
42 id: currentLocation
43 database: db
44 create: true
45 docId: "currentUserLocation"
46 defaults: { "city": "undefined", "lat": 200, "lng": 200 }
47 }
48
49 // U1db Index to index all documents storing the world location details
50 U1db.Index {
51 database: db
52 id: by_worldclock
53 expression: ["worldlocation.city", "worldlocation.rawOffSet", "worldlocation.longitude", "worldlocation.latitude"]
54 }
55
56 U1db.Query {
57 id: worldClock
58 index: by_worldclock
59 query: ["*","*", "*", "*"]
60 }
3861
39 Component.onCompleted: {62 Component.onCompleted: {
40 // TODO: Query GPS for location data
41 Utils.log("ClockPage loaded");63 Utils.log("ClockPage loaded");
42 if (worldModel.city !== "undefined") {
43 currentCity = worldModel.city;
44 currentLng = worldModel.longitude;
45 currentLat = worldModel.latitude;
46 }
47 Utils.log("Saved Current Location: " + worldModel.city);
48 Utils.log("Saved Current Location Coordinates: " + currentLng + "," + currentLat)
49 currentTimeFormatted = Utils.convertTime(new Date().getHours(), new Date().getMinutes(), new Date().getUTCSeconds(), appSetting.contents.timeFormat)64 currentTimeFormatted = Utils.convertTime(new Date().getHours(), new Date().getMinutes(), new Date().getUTCSeconds(), appSetting.contents.timeFormat)
50 updateTime();65 updateTime();
66
67 if (currentLocation.contents.city !== "undefined") {
68 userLocation = {
69 city: currentLocation.contents.city,
70 lng: currentLocation.contents.lng,
71 lat: currentLocation.contents.lat
72 }
73 }
74
75 Utils.log("Saved Current Location: " + currentLocation.contents.city);
76 Utils.log("Saved Current Location Coordinates: " + currentLocation.contents.lng + "," + currentLocation.contents.lat)
51 }77 }
5278
53 actions: [79 actions: [
@@ -62,6 +88,27 @@
62 }88 }
63 ]89 ]
6490
91 // Function to save a world location to u1db database
92 function addWorldLocation(cityName, diff, longitude, latitude) {
93 Utils.log("Adding world location")
94 db.putDoc({ "worldlocation": { "city": cityName, "rawOffSet": diff, "longitude": longitude, "latitude": latitude }}, encodeURIComponent(cityName+"_"+longitude+"_"+latitude))
95 }
96
97 // Function to update current location of the userand save it to the database
98 function updateCurrentLocation(cityname, longitude, latitude) {
99 currentLocation.contents = {
100 city: cityname,
101 lng: longitude,
102 lat: latitude
103 }
104
105 userLocation = {
106 city: cityname,
107 lng: longitude,
108 lat: latitude
109 }
110 }
111
65 // Function which runs every second to update the clock label112 // Function which runs every second to update the clock label
66 function onTimerUpdate(now) {113 function onTimerUpdate(now) {
67 currentTimeFormatted = Utils.convertTime(now.getHours(), now.getMinutes(), now.getUTCSeconds(), appSetting.contents.timeFormat)114 currentTimeFormatted = Utils.convertTime(now.getHours(), now.getMinutes(), now.getUTCSeconds(), appSetting.contents.timeFormat)
@@ -91,23 +138,20 @@
91 GeoIPModel {138 GeoIPModel {
92 id: geoIP139 id: geoIP
93 onStatusChanged: {140 onStatusChanged: {
94 if (status == XmlListModel.Ready && geoIP.get(0).city != worldModel.city && geoIP.get(0).city != "None") {141 if (status == XmlListModel.Ready && geoIP.get(0).city !== currentLocation.contents.city && geoIP.get(0).city !== "None") {
95 Utils.log("Retrieved current location using GeoIP. Writing into database and setting it as current location")142 Utils.log("Retrieved current location using GeoIP. Writing into database and setting it as current location")
96 currentCity = geoIP.get(0).city143 updateCurrentLocation(geoIP.get(0).city, geoIP.get(0).lng, geoIP.get(0).lat);
97 currentLng = geoIP.get(0).lng
98 currentLat = geoIP.get(0).lat
99 worldModel.appendCurrentLocation(currentCity, currentLng, currentLat);
100 }144 }
101 else if (status == XmlListModel.Ready && geoIP.get(0).city == "None") {145 else if (status == XmlListModel.Ready && geoIP.get(0).city === "None") {
102 if (worldModel.city == "undefined") {146 if (currentLocation.contents.city === "undefined") {
103 currentCity = i18n.tr("Set current location name")147 userLocation.city = i18n.tr("Set current location name")
104 currentLocation.progression = true148 currentLocation.progression = true
105 }149 }
106 }150 }
107 else if(status == XmlListModel.Error) {151 else if(status == XmlListModel.Error) {
108 Utils.error("Unable to retrieve GeoIP Data -> " + geoIP.errorString())152 Utils.error("Unable to retrieve GeoIP Data -> " + geoIP.errorString())
109 if (worldModel.city == "undefined") {153 if (currentLocation.contents.city === "undefined") {
110 currentCity = i18n.tr("Set current location name")154 userLocation.city = i18n.tr("Set current location name")
111 currentLocation.progression = true155 currentLocation.progression = true
112 }156 }
113 }157 }
@@ -147,7 +191,7 @@
147 }191 }
148192
149 onClicked: {193 onClicked: {
150 if (easterEggCircle.isReady == XmlListModel.Ready && worldModel.city !== "undefined")194 if (easterEggCircle.isReady == XmlListModel.Ready && currentLocation.contents.city !== "undefined")
151 clockFace.state == "" ? clockFace.state = "easteregg" : clockFace.state = "";195 clockFace.state == "" ? clockFace.state = "easteregg" : clockFace.state = "";
152 else196 else
153 Utils.error("Sunrise/Sunset times cannot be loaded without setting the current location or without a internet connection.")197 Utils.error("Sunrise/Sunset times cannot be loaded without setting the current location or without a internet connection.")
@@ -159,6 +203,8 @@
159 anchors.centerIn: parent203 anchors.centerIn: parent
160 width: clockFace.centerItem.width; height: width;204 width: clockFace.centerItem.width; height: width;
161 radius: width / 2;205 radius: width / 2;
206 latitude: userLocation.lat
207 longitude: userLocation.lng
162 }208 }
163209
164 states: [210 states: [
@@ -198,11 +244,9 @@
198 }244 }
199245
200 ListItem.Standard {246 ListItem.Standard {
201 id: currentLocation
202
203 Label {247 Label {
204 id: currentLocationCity248 id: currentLocationCity
205 text: i18n.tr("Retrieving current location...")249 text: userLocation.city
206 elide: Text.ElideRight250 elide: Text.ElideRight
207 anchors { verticalCenter: parent.verticalCenter; left: parent.left; right: currentLocationTime.left; margins: units.gu(3) }251 anchors { verticalCenter: parent.verticalCenter; left: parent.left; right: currentLocationTime.left; margins: units.gu(3) }
208 color: Theme.palette.normal.baseText252 color: Theme.palette.normal.baseText
@@ -210,7 +254,7 @@
210 }254 }
211 Label {255 Label {
212 id: currentLocationTime256 id: currentLocationTime
213 visible: worldModel.city !== "undefined" ? true : false257 visible: currentLocation.contents.city !== "undefined" ? true : false
214 text: currentTimeFormatted258 text: currentTimeFormatted
215 anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: currentLocation.progression == true ? units.gu(6) : units.gu(2) }259 anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: currentLocation.progression == true ? units.gu(6) : units.gu(2) }
216 color: Theme.palette.normal.baseText260 color: Theme.palette.normal.baseText
@@ -236,14 +280,14 @@
236 clip: true280 clip: true
237 anchors { left: parent.left; right: parent.right }281 anchors { left: parent.left; right: parent.right }
238 height: 3 * units.gu(6) + units.gu(1) // height is defined to show 3 items by default with a small margin282 height: 3 * units.gu(6) + units.gu(1) // height is defined to show 3 items by default with a small margin
239 model: worldModel283 model: worldClock
240 currentIndex: -1284 currentIndex: -1
241285
242 delegate: ListItem.Standard {286 delegate: ListItem.Standard {
243 objectName: "savedworldcity" + index287 objectName: "savedworldcity" + index
244 Label {288 Label {
245 id: worldCityName289 id: worldCityName
246 text: cityName290 text: model.contents.city
247 objectName: "city_name"291 objectName: "city_name"
248 elide: Text.ElideRight292 elide: Text.ElideRight
249 anchors { verticalCenter: parent.verticalCenter; left: parent.left; right: worldCityTime.left; margins: units.gu(3) }293 anchors { verticalCenter: parent.verticalCenter; left: parent.left; right: worldCityTime.left; margins: units.gu(3) }
@@ -253,7 +297,7 @@
253297
254 Label {298 Label {
255 id: worldCityTime299 id: worldCityTime
256 text: appSetting.contents.timeFormat === "12-hour" ? Qt.formatTime(new Date(currentUTCTime + (rawOffSet * 60000)), "h:mm AP") : Qt.formatTime(new Date(currentUTCTime + (rawOffSet * 60000)), "hh:mm")300 text: appSetting.contents.timeFormat === "12-hour" ? Qt.formatTime(new Date(currentUTCTime + (model.contents.rawOffSet * 60000)), "h:mm AP") : Qt.formatTime(new Date(currentUTCTime + (model.contents.rawOffSet * 60000)), "hh:mm")
257 anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: units.gu(2) }301 anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: units.gu(2) }
258 color: Theme.palette.normal.baseText302 color: Theme.palette.normal.baseText
259 fontSize: "large"303 fontSize: "large"
@@ -263,7 +307,12 @@
263 removable: true307 removable: true
264 confirmRemoval: true308 confirmRemoval: true
265309
266 onItemRemoved: worldModel.removePreset(index);310 onItemRemoved: {
311 // NOTE: This causes the document to be deleted twice resulting in an error.
312 // The bug has been reported at https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1276118
313 Utils.log("Deleting world location: " + model.contents.cityname)
314 db.putDoc("", model.docId)
315 }
267 }316 }
268 }317 }
269 }318 }
270319
=== modified file 'clock/WorldClock.qml'
--- clock/WorldClock.qml 2014-02-01 15:30:26 +0000
+++ clock/WorldClock.qml 2014-02-05 16:44:42 +0000
@@ -18,8 +18,9 @@
1818
19import QtQuick 2.019import QtQuick 2.0
20import Ubuntu.Components 0.120import Ubuntu.Components 0.1
21import QtQuick.XmlListModel 2.0
21import Ubuntu.Components.ListItems 0.1 as ListItem22import Ubuntu.Components.ListItems 0.1 as ListItem
22import QtQuick.XmlListModel 2.023import "../common/ClockUtils.js" as Utils
2324
24// Page to to search a world city and add it to the world clocks25// Page to to search a world city and add it to the world clocks
25Page {26Page {
@@ -32,7 +33,7 @@
32 property alias setFocus: searchBox.setFocus33 property alias setFocus: searchBox.setFocus
3334
34 visible: false;35 visible: false;
35 title: isWorldCity ? i18n.tr("Add City") : i18n.tr("Edit Current Location")36 title: isWorldCity ? i18n.tr("Add City") : i18n.tr("Edit Current Location")
3637
37 Column {38 Column {
38 id: worldClocks39 id: worldClocks
@@ -65,9 +66,9 @@
65 onStatusChanged: {66 onStatusChanged: {
66 if(status == XmlListModel.Ready && worldClocks.city != "null") {67 if(status == XmlListModel.Ready && worldClocks.city != "null") {
67 if (isWorldCity)68 if (isWorldCity)
68 worldModel.appendPreset(worldClocks.city, getTimeDifference(cityDetailsModel.get(0).time), worldClocks.lng, worldClocks.lat);69 clockPage.addWorldLocation(worldClocks.city, getTimeDifference(cityDetailsModel.get(0).time), worldClocks.lng, worldClocks.lat)
69 else70 else
70 worldModel.appendCurrentLocation(worldClocks.city, worldClocks.lng, worldClocks.lat);71 clockPage.updateCurrentLocation(worldClocks.city, worldClocks.lng, worldClocks.lat)
71 worldClocks.clearUserSearch();72 worldClocks.clearUserSearch();
72 pageStack.pop()73 pageStack.pop()
73 }74 }
7475
=== removed file 'clock/WorldClockModel.qml'
--- clock/WorldClockModel.qml 2014-02-01 15:43:50 +0000
+++ clock/WorldClockModel.qml 1970-01-01 00:00:00 +0000
@@ -1,199 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
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.
12 *
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/>.
15 *
16 * Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
17 */
18
19import QtQuick 2.0
20import QtQuick.LocalStorage 2.0
21import "../common/ClockUtils.js" as Utils
22
23ListModel {
24 id: model
25
26 readonly property string dbName: "ubuntu-clock-app"
27 readonly property string dbDescription: "World Clock"
28
29 property string city: "undefined";
30 property real longitude: 200;
31 property real latitude: 200;
32
33 property var _db: null
34
35 function appendCurrentLocation(cityname, longitude, latitude)
36 {
37 try {
38 _db.transaction(function(tx){
39 var currentValue;
40 var res = tx.executeSql('SELECT * FROM CurrentClock');
41
42 if (res.rows.length > 0)
43 currentValue = res.rows.item(0).cityName;
44
45 if (currentValue !== undefined) // Update existing value or insert if none
46 res = tx.executeSql('UPDATE CurrentClock SET cityName = ?, longitude = ?, latitude = ?', [cityname, longitude, latitude]);
47 else
48 res = tx.executeSql('INSERT INTO CurrentClock VALUES(?, ?, ?)', [cityname, longitude, latitude]);
49
50 clockPage.currentCity = model.city = cityname
51 clockPage.currentLng = model.longitude = longitude
52 clockPage.currentLat = model.latitude = latitude
53 Utils.log("Updating current location (manually)")
54 });
55 } catch (err) {
56 Utils.error("Error setting current location '" + "': " + err);
57 return false;
58 }
59 }
60
61 function indexOf(cityName)
62 {
63 for(var i = 0; i < model.count; i++) {
64 var element = model.get(i);
65
66 if(element.cityName == cityName) {
67 return i;
68 }
69 }
70
71 return -1;
72 }
73
74 function appendPreset(cityName, rawOffSet, longitude, latitude)
75 {
76 if (_appendDB(cityName, rawOffSet, longitude, latitude)) {
77 var index = indexOf(cityName);
78 var location = {"cityName" : cityName, "rawOffSet" : rawOffSet, "longitude" : longitude, "latitude" : latitude}
79
80 if(index != -1) {
81 model.set(index, location);
82 } else {
83 model.append(location);
84 }
85 }
86 }
87
88 function removePreset(index)
89 {
90 var cityName = get(index).cityName
91 if (_removeDB(cityName)) {
92 model.remove(index);
93 }
94 }
95
96 function _createDB() {
97 if (_db == null) return false;
98 try {
99 _db.transaction(function(tx){
100 tx.executeSql('CREATE TABLE IF NOT EXISTS WorldClock(cityName TEXT, rawOffSet REAL, longitude REAL, latitude REAL)');
101 });
102 } catch (err) {
103 Utils.error("Error creating WorldClock table in db:" + err);
104 return false;
105 }
106 try {
107 _db.transaction(function(tx){
108 tx.executeSql('CREATE TABLE IF NOT EXISTS CurrentClock(cityName TEXT, longitude REAL, latitude REAL)');
109 });
110 } catch (err) {
111 Utils.error("Error creating CurrentClock table in db:" + err);
112 return false;
113 }
114 return true;
115 }
116
117 function _loadDB() {
118 _db = LocalStorage.openDatabaseSync(model.dbName, "", model.dbDescription, 1000);
119 if (_db == null) return false;
120 if (!_createDB()) {
121 _db = null;
122 return false;
123 }
124 try {
125 _db.readTransaction(function(tx){
126 var res = tx.executeSql('SELECT * FROM WorldClock');
127 if (res.rows.length > 0) {
128 for (var i = 0; i < res.rows.length; i++) {
129 model.append({"cityName" : res.rows.item(i).cityName,
130 "rawOffSet": res.rows.item(i).rawOffSet,
131 "longitude": res.rows.item(i).longitude,
132 "latitude" : res.rows.item(i).latitude
133 });
134 }
135 }
136 });
137 } catch (err) {
138 Utils.error("Error opening WorldClock database (" + err + ")");
139 _db = null
140 return false;
141 }
142 try {
143 _db.readTransaction(function(tx){
144 var currentstate = tx.executeSql('SELECT * FROM CurrentClock ORDER BY cityName');
145 if (currentstate.rows.length > 0) {
146 city = currentstate.rows.item(0).cityName;
147 longitude = currentstate.rows.item(0).longitude;
148 latitude = currentstate.rows.item(0).latitude;
149 }
150 });
151 } catch (err) {
152 Utils.error("Error opening CurrentLocation database (" + err + ")");
153 _db = null
154 return false;
155 }
156 return true;
157 }
158
159 function _appendDB(cityName, rawOffSet, longitude, latitude) {
160 if (_db == null) return false;
161
162 try {
163 _db.transaction(function(tx){
164 var currentValue;
165 var res = tx.executeSql('SELECT rawOffSet FROM WorldClock WHERE cityName=?', cityName);
166 if (res.rows.length > 0) {
167 currentValue = res.rows.item(0).rawOffSet;
168 }
169
170 if (currentValue !== rawOffSet) {
171 // Update existing value or insert if none
172 if (currentValue !== undefined) {
173 res = tx.executeSql('UPDATE WorldClock SET rawOffSet = ?, longitude = ?, latitude = ? WHERE cityName = ?', [rawOffSet, longitude, latitude, cityName]);
174 } else {
175 res = tx.executeSql('INSERT INTO WorldClock VALUES(?, ?, ?, ?)', [cityName, rawOffSet, longitude, latitude]);
176 }
177 }
178 });
179 } catch (err) {
180 Utils.error("Error setting labeltxt '"+ label + "': " + err);
181 return false;
182 }
183 return true;
184 }
185
186 function _removeDB(cityName) {
187 if (_db == null) return false;
188
189 try {
190 _db.transaction(function(tx){
191 tx.executeSql('DELETE FROM WorldClock WHERE cityName = ?', [cityName]);
192 });
193 } catch (err) {
194 Utils.error("Error delete WorldClock'" + cityName + "': " + err);
195 return false;
196 }
197 return true;
198 }
199}
2000
=== modified file 'tests/autopilot/ubuntu_clock_app/emulators.py'
--- tests/autopilot/ubuntu_clock_app/emulators.py 2014-01-17 16:20:58 +0000
+++ tests/autopilot/ubuntu_clock_app/emulators.py 2014-02-05 16:44:42 +0000
@@ -83,7 +83,7 @@
8383
84 def get_city_name(self, city):84 def get_city_name(self, city):
85 """Return the name of the city passed as argument"""85 """Return the name of the city passed as argument"""
86 return city.select_single('Label', objectName='city_name').text86 return city.wait_select_single('Label', objectName='city_name').text
8787
88 def get_saved_cities_list(self):88 def get_saved_cities_list(self):
89 """Return the component containing list of user saved world city locations."""89 """Return the component containing list of user saved world city locations."""
9090
=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_clock.py'
--- tests/autopilot/ubuntu_clock_app/tests/test_clock.py 2014-01-06 20:53:01 +0000
+++ tests/autopilot/ubuntu_clock_app/tests/test_clock.py 2014-02-05 16:44:42 +0000
@@ -47,6 +47,21 @@
47 def tearDown(self):47 def tearDown(self):
48 super(TestClock, self).tearDown()48 super(TestClock, self).tearDown()
4949
50 def add_local_world_city(self):
51 # Open clock toolbar
52 self.main_view.open_toolbar()
53
54 # Click add city toolbar button
55 self.main_view.get_toolbar().click_button('addCityAction')
56
57 # Click on first city in the list shown and ensure that it was saved
58 city = self.main_view.grab_first_listed_city()
59
60 city_name = self.main_view.get_city_name(city)
61 self.main_view.select_city(city)
62
63 return city_name
64
50 def test_label_value(self):65 def test_label_value(self):
51 """The clock label must contain the correct time."""66 """The clock label must contain the correct time."""
5267
@@ -59,24 +74,17 @@
59 def test_add_local_world_city(self):74 def test_add_local_world_city(self):
60 """Test to check if adding a local listed world city works"""75 """Test to check if adding a local listed world city works"""
6176
62 # Open clock toolbar 77 # Add a local world city
63 self.main_view.open_toolbar()78 city_name = self.add_local_world_city()
6479
65 # Click add city toolbar button
66 self.main_view.get_toolbar().click_button('addCityAction')
67
68 # Click on first city in the list shown and ensure that it was saved
69 city = self.main_view.grab_first_listed_city()
70 city_name = self.main_view.get_city_name(city)
71 self.main_view.select_city(city)
72 saved_city_name = self.main_view.get_city_name(self.main_view.grab_first_saved_city())80 saved_city_name = self.main_view.get_city_name(self.main_view.grab_first_saved_city())
73 self.assertThat(saved_city_name, Eventually(Equals(city_name))) 81 self.assertThat(saved_city_name, Eventually(Equals(city_name)))
74 82
75 def test_delete_local_world_city(self):83 def test_delete_local_world_city(self):
76 """Test to check if deleting a saved local world city works"""84 """Test to check if deleting a saved local world city works"""
7785
78 # Add a local world city 86 # Add a local world city
79 self.test_add_local_world_city()87 city_name = self.add_local_world_city()
8088
81 # Close toolbar and drag page up to see the saved world city list 89 # Close toolbar and drag page up to see the saved world city list
82 self.main_view.close_toolbar()90 self.main_view.close_toolbar()
8391
=== modified file 'ubuntu-clock-app.qml'
--- ubuntu-clock-app.qml 2014-02-04 11:38:16 +0000
+++ ubuntu-clock-app.qml 2014-02-05 16:44:42 +0000
@@ -150,14 +150,6 @@
150 // Tab content begins here150 // Tab content begins here
151 page: ClockPage {151 page: ClockPage {
152 id: clockPage152 id: clockPage
153
154 WorldClockModel {
155 id: worldModel;
156 Component.onCompleted: {
157 _loadDB();
158 Utils.log("Clock Database loaded")
159 }
160 }
161 }153 }
162 }154 }
163155

Subscribers

People subscribed via source and target branches