Merge lp:~elopio/ubuntu-weather-app/fix1248648-options_object_names into lp:ubuntu-weather-app/obsolete.trunk

Proposed by Leo Arias
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 156
Merged at revision: 155
Proposed branch: lp:~elopio/ubuntu-weather-app/fix1248648-options_object_names
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Diff against target: 141 lines (+49/-15)
2 files modified
components/SettingsSheet.qml (+38/-6)
tests/autopilot/ubuntu_weather_app/tests/test_settings.py (+11/-9)
To merge this branch: bzr merge lp:~elopio/ubuntu-weather-app/fix1248648-options_object_names
Reviewer Review Type Date Requested Status
Martin Borho Approve
Chris Gagnon (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Ubuntu Weather Developers Pending
Review via email: mp+194217@code.launchpad.net

Commit message

Set the objectNames for the settings options.

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: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Thanks Le. We'll do the conversion to wait_select_single separately.

Revision history for this message
Chris Gagnon (chris.gagnon) :
review: Approve
Revision history for this message
Martin Borho (martin-borho) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'components/SettingsSheet.qml'
--- components/SettingsSheet.qml 2013-09-29 14:26:37 +0000
+++ components/SettingsSheet.qml 2013-11-06 19:41:29 +0000
@@ -30,25 +30,57 @@
30 container: Column {30 container: Column {
31 anchors.left: parent.left31 anchors.left: parent.left
32 anchors.right: parent.right32 anchors.right: parent.right
33
34 Component {
35 id: unitsSelectorDelegate
36 OptionSelectorDelegate {
37 text: i18n.tr(label)
38 objectName: name
39 }
40 }
41
42 ListModel {
43 id: temperatureUnitsSelectorModel
44 ListElement { name: "celsiusOption"; label: "Celsius"; }
45 ListElement { name: "fahrenheitOption"; label: "Fahrenheit"; }
46 }
47
33 OptionSelector {48 OptionSelector {
34 id: unitsSelector49 id: temperatureUnitsSelector
35 objectName: "UnitsSelector"50 objectName: "TemperatureUnitsSelector"
36 text: i18n.tr("Temperature units")51 text: i18n.tr("Temperature units")
37 model: [i18n.tr("Celsius"), i18n.tr("Fahrenheit")]52 delegate: unitsSelectorDelegate
53 model: temperatureUnitsSelectorModel
38 selectedIndex: (settings["units"] === "imperial") ? 1 : 0;54 selectedIndex: (settings["units"] === "imperial") ? 1 : 0;
39 }55 }
56
57 ListModel {
58 id: windUnitsSelectorModel
59 ListElement { name: "kmhOption"; label: "Kilometers per hour" }
60 ListElement { name: "mphOption"; label: "Miles per hour" }
61 }
62
40 OptionSelector {63 OptionSelector {
41 id: windUnitsSelector64 id: windUnitsSelector
42 objectName: "WindUnitsSelector"65 objectName: "WindUnitsSelector"
43 text: i18n.tr("Wind speed units")66 text: i18n.tr("Wind speed units")
44 model: [i18n.tr("Kilometers per hour"), i18n.tr("Miles per hour")]67 delegate: unitsSelectorDelegate
68 model: windUnitsSelectorModel
45 selectedIndex: (settings["wind_units"] === "mph") ? 1 : 0;69 selectedIndex: (settings["wind_units"] === "mph") ? 1 : 0;
46 }70 }
71
72 ListModel {
73 id: precipitationUnitsSelectorModel
74 ListElement { name: "millimetersOption"; label: "Millimeters" }
75 ListElement { name: "inchesOption"; label: "Inches" }
76 }
77
47 OptionSelector {78 OptionSelector {
48 id: precipitationUnitsSelector79 id: precipitationUnitsSelector
49 objectName: "PrecipitationUnitsSelector"80 objectName: "PrecipitationUnitsSelector"
50 text: i18n.tr("Precipitation units")81 text: i18n.tr("Precipitation units")
51 model: [i18n.tr("Millimeters"), i18n.tr("Inches")]82 delegate: unitsSelectorDelegate
83 model: precipitationUnitsSelectorModel
52 selectedIndex: (settings["precip_units"] === "in") ? 1 : 0;84 selectedIndex: (settings["precip_units"] === "in") ? 1 : 0;
53 }85 }
54 }86 }
@@ -59,7 +91,7 @@
5991
60 onConfirmClicked: {92 onConfirmClicked: {
61 var refresh = false,93 var refresh = false,
62 selectedUnit = (unitsSelector.selectedIndex === 0) ? "metric" : "imperial",94 selectedUnit = (temperatureUnitsSelector.selectedIndex === 0) ? "metric" : "imperial",
63 selectedWindUnit = (windUnitsSelector.selectedIndex === 0) ? "kmh" : "mph",95 selectedWindUnit = (windUnitsSelector.selectedIndex === 0) ? "kmh" : "mph",
64 selectedPrecipUnit = (precipitationUnitsSelector.selectedIndex === 0) ? "mm" : "in";96 selectedPrecipUnit = (precipitationUnitsSelector.selectedIndex === 0) ? "mm" : "in";
65 // check if temperaure scale was changed97 // check if temperaure scale was changed
6698
=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_settings.py'
--- tests/autopilot/ubuntu_weather_app/tests/test_settings.py 2013-11-05 23:27:52 +0000
+++ tests/autopilot/ubuntu_weather_app/tests/test_settings.py 2013-11-06 19:41:29 +0000
@@ -102,8 +102,8 @@
102 self._open_settings_sheet()102 self._open_settings_sheet()
103103
104 # open the value selector104 # open the value selector
105 self.assertThat(lambda: self.main_window.select_single('OptionSelector', objectName='UnitsSelector'), Eventually(Not(Is(None))))105 self.assertThat(lambda: self.main_window.select_single('OptionSelector', objectName='TemperatureUnitsSelector'), Eventually(Not(Is(None))))
106 units_selector = self.main_window.select_single('OptionSelector', objectName="UnitsSelector")106 units_selector = self.main_window.select_single('OptionSelector', objectName="TemperatureUnitsSelector")
107 self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))107 self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))
108 self.assertThat(lambda: units_selector.select_many('ShapeItem')[1], Eventually(Not(Is(None))))108 self.assertThat(lambda: units_selector.select_many('ShapeItem')[1], Eventually(Not(Is(None))))
109 current_option = units_selector.select_many('ShapeItem')[1]109 current_option = units_selector.select_many('ShapeItem')[1]
@@ -124,8 +124,8 @@
124124
125 # switch back to metric values again125 # switch back to metric values again
126 self._open_settings_sheet()126 self._open_settings_sheet()
127 self.assertThat(lambda: self.main_window.select_single('OptionSelector', objectName='UnitsSelector'), Eventually(Not(Is(None))))127 self.assertThat(lambda: self.main_window.select_single('OptionSelector', objectName='TemperatureUnitsSelector'), Eventually(Not(Is(None))))
128 units_selector = self.main_window.select_single('OptionSelector', objectName="UnitsSelector")128 units_selector = self.main_window.select_single('OptionSelector', objectName="TemperatureUnitsSelector")
129 self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))129 self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))
130 self.assertThat(lambda: units_selector.select_many('ShapeItem')[2], Eventually(Not(Is(None))))130 self.assertThat(lambda: units_selector.select_many('ShapeItem')[2], Eventually(Not(Is(None))))
131 current_option = units_selector.select_many('ShapeItem')[2]131 current_option = units_selector.select_many('ShapeItem')[2]
@@ -136,7 +136,8 @@
136 # click celsius option136 # click celsius option
137 self._move_pointer_around()137 self._move_pointer_around()
138 self.assertThat(lambda: units_selector.select_many('ShapeItem')[1], Eventually(Not(Is(None))))138 self.assertThat(lambda: units_selector.select_many('ShapeItem')[1], Eventually(Not(Is(None))))
139 metric_option = units_selector.select_single('Label', text='Celsius')139 metric_option = units_selector.select_single(
140 'OptionSelectorDelegate', objectName='celsiusOption')
140 self.pointing_device.click_object(metric_option)141 self.pointing_device.click_object(metric_option)
141142
142 # confirm143 # confirm
@@ -156,8 +157,8 @@
156 self._open_settings_sheet()157 self._open_settings_sheet()
157158
158 # open the temp value selector159 # open the temp value selector
159 self.assertThat(lambda: self.main_window.select_single('OptionSelector', objectName='UnitsSelector'), Eventually(Not(Is(None))))160 self.assertThat(lambda: self.main_window.select_single('OptionSelector', objectName='TemperatureUnitsSelector'), Eventually(Not(Is(None))))
160 units_selector = self.main_window.select_single('OptionSelector', objectName="UnitsSelector")161 units_selector = self.main_window.select_single('OptionSelector', objectName="TemperatureUnitsSelector")
161 self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))162 self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))
162 self.assertThat(lambda: units_selector.select_many('ShapeItem')[1], Eventually(Not(Is(None))))163 self.assertThat(lambda: units_selector.select_many('ShapeItem')[1], Eventually(Not(Is(None))))
163 current_option = units_selector.select_many('ShapeItem')[1]164 current_option = units_selector.select_many('ShapeItem')[1]
@@ -230,7 +231,7 @@
230 self._move_pointer_around()231 self._move_pointer_around()
231 self.assertThat(lambda: units_selector.select_many('ShapeItem')[1], Eventually(Not(Is(None))))232 self.assertThat(lambda: units_selector.select_many('ShapeItem')[1], Eventually(Not(Is(None))))
232 kmh_option = units_selector.select_single(233 kmh_option = units_selector.select_single(
233 'Label', text='Kilometers per hour')234 'OptionSelectorDelegate', objectName='kmhOption')
234 self.pointing_device.click_object(kmh_option)235 self.pointing_device.click_object(kmh_option)
235236
236 # confirm237 # confirm
@@ -285,7 +286,8 @@
285 self.assertThat(lambda: units_selector.select_many('ShapeItem')[1], Eventually(Not(Is(None))))286 self.assertThat(lambda: units_selector.select_many('ShapeItem')[1], Eventually(Not(Is(None))))
286 # XXX select the option by it's object name or index, using the287 # XXX select the option by it's object name or index, using the
287 # emulator from the ubuntu-ui-toolkit.288 # emulator from the ubuntu-ui-toolkit.
288 mm_option = units_selector.select_single('Label', text='Millimeters')289 mm_option = units_selector.select_single(
290 'OptionSelectorDelegate', objectName='millimetersOption')
289 self.pointing_device.click_object(mm_option)291 self.pointing_device.click_object(mm_option)
290292
291 # confirm293 # confirm

Subscribers

People subscribed via source and target branches