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
1=== modified file 'components/SettingsSheet.qml'
2--- components/SettingsSheet.qml 2013-09-29 14:26:37 +0000
3+++ components/SettingsSheet.qml 2013-11-06 19:41:29 +0000
4@@ -30,25 +30,57 @@
5 container: Column {
6 anchors.left: parent.left
7 anchors.right: parent.right
8+
9+ Component {
10+ id: unitsSelectorDelegate
11+ OptionSelectorDelegate {
12+ text: i18n.tr(label)
13+ objectName: name
14+ }
15+ }
16+
17+ ListModel {
18+ id: temperatureUnitsSelectorModel
19+ ListElement { name: "celsiusOption"; label: "Celsius"; }
20+ ListElement { name: "fahrenheitOption"; label: "Fahrenheit"; }
21+ }
22+
23 OptionSelector {
24- id: unitsSelector
25- objectName: "UnitsSelector"
26+ id: temperatureUnitsSelector
27+ objectName: "TemperatureUnitsSelector"
28 text: i18n.tr("Temperature units")
29- model: [i18n.tr("Celsius"), i18n.tr("Fahrenheit")]
30+ delegate: unitsSelectorDelegate
31+ model: temperatureUnitsSelectorModel
32 selectedIndex: (settings["units"] === "imperial") ? 1 : 0;
33 }
34+
35+ ListModel {
36+ id: windUnitsSelectorModel
37+ ListElement { name: "kmhOption"; label: "Kilometers per hour" }
38+ ListElement { name: "mphOption"; label: "Miles per hour" }
39+ }
40+
41 OptionSelector {
42 id: windUnitsSelector
43 objectName: "WindUnitsSelector"
44 text: i18n.tr("Wind speed units")
45- model: [i18n.tr("Kilometers per hour"), i18n.tr("Miles per hour")]
46+ delegate: unitsSelectorDelegate
47+ model: windUnitsSelectorModel
48 selectedIndex: (settings["wind_units"] === "mph") ? 1 : 0;
49 }
50+
51+ ListModel {
52+ id: precipitationUnitsSelectorModel
53+ ListElement { name: "millimetersOption"; label: "Millimeters" }
54+ ListElement { name: "inchesOption"; label: "Inches" }
55+ }
56+
57 OptionSelector {
58 id: precipitationUnitsSelector
59 objectName: "PrecipitationUnitsSelector"
60 text: i18n.tr("Precipitation units")
61- model: [i18n.tr("Millimeters"), i18n.tr("Inches")]
62+ delegate: unitsSelectorDelegate
63+ model: precipitationUnitsSelectorModel
64 selectedIndex: (settings["precip_units"] === "in") ? 1 : 0;
65 }
66 }
67@@ -59,7 +91,7 @@
68
69 onConfirmClicked: {
70 var refresh = false,
71- selectedUnit = (unitsSelector.selectedIndex === 0) ? "metric" : "imperial",
72+ selectedUnit = (temperatureUnitsSelector.selectedIndex === 0) ? "metric" : "imperial",
73 selectedWindUnit = (windUnitsSelector.selectedIndex === 0) ? "kmh" : "mph",
74 selectedPrecipUnit = (precipitationUnitsSelector.selectedIndex === 0) ? "mm" : "in";
75 // check if temperaure scale was changed
76
77=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_settings.py'
78--- tests/autopilot/ubuntu_weather_app/tests/test_settings.py 2013-11-05 23:27:52 +0000
79+++ tests/autopilot/ubuntu_weather_app/tests/test_settings.py 2013-11-06 19:41:29 +0000
80@@ -102,8 +102,8 @@
81 self._open_settings_sheet()
82
83 # open the value selector
84- self.assertThat(lambda: self.main_window.select_single('OptionSelector', objectName='UnitsSelector'), Eventually(Not(Is(None))))
85- units_selector = self.main_window.select_single('OptionSelector', objectName="UnitsSelector")
86+ self.assertThat(lambda: self.main_window.select_single('OptionSelector', objectName='TemperatureUnitsSelector'), Eventually(Not(Is(None))))
87+ units_selector = self.main_window.select_single('OptionSelector', objectName="TemperatureUnitsSelector")
88 self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))
89 self.assertThat(lambda: units_selector.select_many('ShapeItem')[1], Eventually(Not(Is(None))))
90 current_option = units_selector.select_many('ShapeItem')[1]
91@@ -124,8 +124,8 @@
92
93 # switch back to metric values again
94 self._open_settings_sheet()
95- self.assertThat(lambda: self.main_window.select_single('OptionSelector', objectName='UnitsSelector'), Eventually(Not(Is(None))))
96- units_selector = self.main_window.select_single('OptionSelector', objectName="UnitsSelector")
97+ self.assertThat(lambda: self.main_window.select_single('OptionSelector', objectName='TemperatureUnitsSelector'), Eventually(Not(Is(None))))
98+ units_selector = self.main_window.select_single('OptionSelector', objectName="TemperatureUnitsSelector")
99 self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))
100 self.assertThat(lambda: units_selector.select_many('ShapeItem')[2], Eventually(Not(Is(None))))
101 current_option = units_selector.select_many('ShapeItem')[2]
102@@ -136,7 +136,8 @@
103 # click celsius option
104 self._move_pointer_around()
105 self.assertThat(lambda: units_selector.select_many('ShapeItem')[1], Eventually(Not(Is(None))))
106- metric_option = units_selector.select_single('Label', text='Celsius')
107+ metric_option = units_selector.select_single(
108+ 'OptionSelectorDelegate', objectName='celsiusOption')
109 self.pointing_device.click_object(metric_option)
110
111 # confirm
112@@ -156,8 +157,8 @@
113 self._open_settings_sheet()
114
115 # open the temp value selector
116- self.assertThat(lambda: self.main_window.select_single('OptionSelector', objectName='UnitsSelector'), Eventually(Not(Is(None))))
117- units_selector = self.main_window.select_single('OptionSelector', objectName="UnitsSelector")
118+ self.assertThat(lambda: self.main_window.select_single('OptionSelector', objectName='TemperatureUnitsSelector'), Eventually(Not(Is(None))))
119+ units_selector = self.main_window.select_single('OptionSelector', objectName="TemperatureUnitsSelector")
120 self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))
121 self.assertThat(lambda: units_selector.select_many('ShapeItem')[1], Eventually(Not(Is(None))))
122 current_option = units_selector.select_many('ShapeItem')[1]
123@@ -230,7 +231,7 @@
124 self._move_pointer_around()
125 self.assertThat(lambda: units_selector.select_many('ShapeItem')[1], Eventually(Not(Is(None))))
126 kmh_option = units_selector.select_single(
127- 'Label', text='Kilometers per hour')
128+ 'OptionSelectorDelegate', objectName='kmhOption')
129 self.pointing_device.click_object(kmh_option)
130
131 # confirm
132@@ -285,7 +286,8 @@
133 self.assertThat(lambda: units_selector.select_many('ShapeItem')[1], Eventually(Not(Is(None))))
134 # XXX select the option by it's object name or index, using the
135 # emulator from the ubuntu-ui-toolkit.
136- mm_option = units_selector.select_single('Label', text='Millimeters')
137+ mm_option = units_selector.select_single(
138+ 'OptionSelectorDelegate', objectName='millimetersOption')
139 self.pointing_device.click_object(mm_option)
140
141 # confirm

Subscribers

People subscribed via source and target branches