Merge lp:~mandel/location-service/delayed-providers into lp:location-service/15.04
- delayed-providers
- Merge into 15.04
Proposed by
Scott Sweeny
Status: | Needs review |
---|---|
Proposed branch: | lp:~mandel/location-service/delayed-providers |
Merge into: | lp:location-service/15.04 |
Diff against target: |
814 lines (+561/-22) (has conflicts) 11 files modified
data/ubuntu-location-service-trust-stored.conf.in (+4/-2) debian/changelog (+21/-0) include/location_service/com/ubuntu/location/provider.h (+43/-1) po/br.po (+28/-0) po/lb.po (+31/-0) po/zh_HK.po (+27/-0) src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp (+40/-11) src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp (+4/-0) src/location_service/com/ubuntu/location/provider.cpp (+61/-8) tests/controller_test.cpp (+213/-0) tests/mock_delayed_provider.h (+89/-0) Text conflict in debian/changelog |
To merge this branch: | bzr merge lp:~mandel/location-service/delayed-providers |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Phablet Team | Pending | ||
Review via email: mp+275377@code.launchpad.net |
Commit message
Add the concept of a delayed providers. This will allow providers that are slow to start the chance to be started and later be connected accordingly.
Description of the change
Add the concept of a delayed providers. This will allow providers that are slow to start the chance to be started and later be connected accordingly.
To post a comment you must log in.
Unmerged revisions
- 206. By Manuel de la Peña
-
Made changes according to reviews.
- 205. By Manuel de la Peña
-
Update docs.
- 204. By Manuel de la Peña
-
Made chages as per review.
- 203. By Manuel de la Peña
-
Added support for delayed providers.
- 202. By Launchpad Translations on behalf of phablet-team
-
Launchpad automatic translations update.
- 201. By Launchpad Translations on behalf of phablet-team
-
Launchpad automatic translations update.
- 200. By CI Train Bot Account
-
Releasing 2.1+15.
10.20150601. 2-0ubuntu1 - 199. By Manuel de la Peña
-
Ensure that the trust store is started when is needed.
Approved by: Michael Frey, PS Jenkins bot, Thomas Voß
- 198. By Launchpad Translations on behalf of phablet-team
-
Launchpad automatic translations update.
- 197. By CI Train Bot Account
-
Releasing 2.1+15.
10.20150528. 3-0ubuntu1
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'data/ubuntu-location-service-trust-stored.conf.in' | |||
2 | --- data/ubuntu-location-service-trust-stored.conf.in 2014-09-19 14:36:51 +0000 | |||
3 | +++ data/ubuntu-location-service-trust-stored.conf.in 2015-10-22 15:34:12 +0000 | |||
4 | @@ -4,8 +4,10 @@ | |||
5 | 4 | # starting; if dbus is available and location-service isn't or vice-versa, | 4 | # starting; if dbus is available and location-service isn't or vice-versa, |
6 | 5 | # startup will fail but the next event firing will trigger another start | 5 | # startup will fail but the next event firing will trigger another start |
7 | 6 | start on (started dbus and xsession SESSION=ubuntu-touch) or \ | 6 | start on (started dbus and xsession SESSION=ubuntu-touch) or \ |
10 | 7 | :sys:started JOB=ubuntu-location-service | 7 | dbus BUS=system SIGNAL=NameOwnerChanged INTERFACE=org.freedesktop.DBus OBJPATH=/org/freedesktop/DBus ARG0=com.ubuntu.location.Service ARG2!="" |
11 | 8 | stop on desktop-end or :sys:stopping JOB=ubuntu-location-service | 8 | |
12 | 9 | stop on desktop-end or \ | ||
13 | 10 | dbus BUS=system SIGNAL=NameOwnerChanged INTERFACE=org.freedesktop.DBus OBJPATH=/org/freedesktop/DBus ARG0=com.ubuntu.location.Service ARG2="" | ||
14 | 9 | 11 | ||
15 | 10 | respawn | 12 | respawn |
16 | 11 | 13 | ||
17 | 12 | 14 | ||
18 | === modified file 'debian/changelog' | |||
19 | --- debian/changelog 2015-10-22 07:16:50 +0000 | |||
20 | +++ debian/changelog 2015-10-22 15:34:12 +0000 | |||
21 | @@ -1,3 +1,4 @@ | |||
22 | 1 | <<<<<<< TREE | ||
23 | 1 | location-service (2.1+15.04.20151022-0ubuntu1) vivid; urgency=medium | 2 | location-service (2.1+15.04.20151022-0ubuntu1) vivid; urgency=medium |
24 | 2 | 3 | ||
25 | 3 | [ Thomas Voß ] | 4 | [ Thomas Voß ] |
26 | @@ -12,6 +13,26 @@ | |||
27 | 12 | 13 | ||
28 | 13 | -- Thomas Voß <ci-train-bot@canonical.com> Thu, 22 Oct 2015 07:16:50 +0000 | 14 | -- Thomas Voß <ci-train-bot@canonical.com> Thu, 22 Oct 2015 07:16:50 +0000 |
29 | 14 | 15 | ||
30 | 16 | ======= | ||
31 | 17 | location-service (2.1+15.10.20150601.2-0ubuntu1) wily; urgency=medium | ||
32 | 18 | |||
33 | 19 | [ CI Train Bot ] | ||
34 | 20 | * New rebuild forced. | ||
35 | 21 | |||
36 | 22 | [ Manuel de la Pena ] | ||
37 | 23 | * Ensure that the trust store is started when is needed. | ||
38 | 24 | |||
39 | 25 | -- CI Train Bot <ci-train-bot@canonical.com> Mon, 01 Jun 2015 15:13:06 +0000 | ||
40 | 26 | |||
41 | 27 | location-service (2.1+15.10.20150528.3-0ubuntu1) wily; urgency=medium | ||
42 | 28 | |||
43 | 29 | [ Thomas Voß ] | ||
44 | 30 | * Make sure we always hand a lock owning its mutex to | ||
45 | 31 | on_access_point_added. (LP: #1426307) | ||
46 | 32 | |||
47 | 33 | -- CI Train Bot <ci-train-bot@canonical.com> Thu, 28 May 2015 11:40:58 +0000 | ||
48 | 34 | |||
49 | 35 | >>>>>>> MERGE-SOURCE | ||
50 | 15 | location-service (2.1+15.04.20150427.1-0ubuntu1) vivid; urgency=medium | 36 | location-service (2.1+15.04.20150427.1-0ubuntu1) vivid; urgency=medium |
51 | 16 | 37 | ||
52 | 17 | [ CI Train Bot ] | 38 | [ CI Train Bot ] |
53 | 18 | 39 | ||
54 | === modified file 'include/location_service/com/ubuntu/location/provider.h' | |||
55 | --- include/location_service/com/ubuntu/location/provider.h 2015-01-21 20:13:28 +0000 | |||
56 | +++ include/location_service/com/ubuntu/location/provider.h 2015-10-22 15:34:12 +0000 | |||
57 | @@ -150,6 +150,8 @@ | |||
58 | 150 | friend class Provider; | 150 | friend class Provider; |
59 | 151 | explicit Controller(Provider& instance); | 151 | explicit Controller(Provider& instance); |
60 | 152 | 152 | ||
61 | 153 | virtual void on_provider_booted(bool was_booted); | ||
62 | 154 | |||
63 | 153 | private: | 155 | private: |
64 | 154 | Provider& instance; | 156 | Provider& instance; |
65 | 155 | std::atomic<int> position_updates_counter; | 157 | std::atomic<int> position_updates_counter; |
66 | @@ -172,6 +174,20 @@ | |||
67 | 172 | core::Signal<Update<std::set<SpaceVehicle>>> svs; | 174 | core::Signal<Update<std::set<SpaceVehicle>>> svs; |
68 | 173 | }; | 175 | }; |
69 | 174 | 176 | ||
70 | 177 | /** | ||
71 | 178 | * @brief Wraps al those sigals that are related to the boot of the provider. | ||
72 | 179 | */ | ||
73 | 180 | struct Signals | ||
74 | 181 | { | ||
75 | 182 | core::Signal<bool> booted; | ||
76 | 183 | }; | ||
77 | 184 | |||
78 | 185 | enum class BootState { | ||
79 | 186 | NOT_BOOTED, | ||
80 | 187 | BOOTING, | ||
81 | 188 | BOOTED | ||
82 | 189 | }; | ||
83 | 190 | |||
84 | 175 | virtual ~Provider() = default; | 191 | virtual ~Provider() = default; |
85 | 176 | 192 | ||
86 | 177 | Provider(const Provider&) = delete; | 193 | Provider(const Provider&) = delete; |
87 | @@ -189,6 +205,18 @@ | |||
88 | 189 | virtual const Controller::Ptr& state_controller() const; | 205 | virtual const Controller::Ptr& state_controller() const; |
89 | 190 | 206 | ||
90 | 191 | /** | 207 | /** |
91 | 208 | * @brief Returns the booted signal to track the booting state of the provider. | ||
92 | 209 | * @return The signal that will be triggered once the provider has booted. | ||
93 | 210 | */ | ||
94 | 211 | virtual core::Signal<bool>& booted_signal(); | ||
95 | 212 | |||
96 | 213 | /** | ||
97 | 214 | * @brief Returns the booted signal to track the booting state of the provider. | ||
98 | 215 | * @return The signal that will be triggered once the provider has booted. | ||
99 | 216 | */ | ||
100 | 217 | virtual const core::Signal<bool>& booted_signal() const; | ||
101 | 218 | |||
102 | 219 | /** | ||
103 | 192 | * @brief Checks if the provider supports a specific feature. | 220 | * @brief Checks if the provider supports a specific feature. |
104 | 193 | * @param f Feature to test for | 221 | * @param f Feature to test for |
105 | 194 | * @return true iff the provider supports the feature. | 222 | * @return true iff the provider supports the feature. |
106 | @@ -210,6 +238,18 @@ | |||
107 | 210 | virtual bool matches_criteria(const Criteria& criteria); | 238 | virtual bool matches_criteria(const Criteria& criteria); |
108 | 211 | 239 | ||
109 | 212 | /** | 240 | /** |
110 | 241 | * @brief States the booting state of the provider. | ||
111 | 242 | * @return The boot state of the provider. | ||
112 | 243 | */ | ||
113 | 244 | virtual BootState boot_state() const; | ||
114 | 245 | |||
115 | 246 | /** | ||
116 | 247 | * @brief Indicates to the provider that it should start the boot process in order to be able to | ||
117 | 248 | * be used by the engine. | ||
118 | 249 | */ | ||
119 | 250 | virtual void boot(); | ||
120 | 251 | |||
121 | 252 | /** | ||
122 | 213 | * @brief Called by the engine whenever the wifi and cell ID reporting state changes. | 253 | * @brief Called by the engine whenever the wifi and cell ID reporting state changes. |
123 | 214 | * @param state The new state. | 254 | * @param state The new state. |
124 | 215 | */ | 255 | */ |
125 | @@ -270,12 +310,14 @@ | |||
126 | 270 | */ | 310 | */ |
127 | 271 | virtual void stop_velocity_updates(); | 311 | virtual void stop_velocity_updates(); |
128 | 272 | 312 | ||
130 | 273 | private: | 313 | protected: |
131 | 314 | // protected to allow better white box testing | ||
132 | 274 | struct | 315 | struct |
133 | 275 | { | 316 | { |
134 | 276 | Features features = Features::none; | 317 | Features features = Features::none; |
135 | 277 | Requirements requirements = Requirements::none; | 318 | Requirements requirements = Requirements::none; |
136 | 278 | Updates updates; | 319 | Updates updates; |
137 | 320 | Signals signals; | ||
138 | 279 | Controller::Ptr controller = Controller::Ptr{}; | 321 | Controller::Ptr controller = Controller::Ptr{}; |
139 | 280 | } d; | 322 | } d; |
140 | 281 | }; | 323 | }; |
141 | 282 | 324 | ||
142 | === added file 'po/br.po' | |||
143 | --- po/br.po 1970-01-01 00:00:00 +0000 | |||
144 | +++ po/br.po 2015-10-22 15:34:12 +0000 | |||
145 | @@ -0,0 +1,28 @@ | |||
146 | 1 | # Breton translation for location-service | ||
147 | 2 | # Copyright (c) 2015 Rosetta Contributors and Canonical Ltd 2015 | ||
148 | 3 | # This file is distributed under the same license as the location-service package. | ||
149 | 4 | # FIRST AUTHOR <EMAIL@ADDRESS>, 2015. | ||
150 | 5 | # | ||
151 | 6 | msgid "" | ||
152 | 7 | msgstr "" | ||
153 | 8 | "Project-Id-Version: location-service\n" | ||
154 | 9 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" | ||
155 | 10 | "POT-Creation-Date: 2014-09-19 01:04+0200\n" | ||
156 | 11 | "PO-Revision-Date: 2015-06-05 06:21+0000\n" | ||
157 | 12 | "Last-Translator: Fohanno Thierry <thierry.fohanno@ofis-bzh.org>\n" | ||
158 | 13 | "Language-Team: Breton <br@li.org>\n" | ||
159 | 14 | "MIME-Version: 1.0\n" | ||
160 | 15 | "Content-Type: text/plain; charset=UTF-8\n" | ||
161 | 16 | "Content-Transfer-Encoding: 8bit\n" | ||
162 | 17 | "X-Launchpad-Export-Date: 2015-06-06 05:30+0000\n" | ||
163 | 18 | "X-Generator: Launchpad (build 17540)\n" | ||
164 | 19 | |||
165 | 20 | #: /tmp/i18n/src/location_service/com/ubuntu/location/service/trust_store_permission_manager.cpp:170 | ||
166 | 21 | msgid "An unconfined application wants to access your current location." | ||
167 | 22 | msgstr "" | ||
168 | 23 | "Fellout a ra d'un arload ha n'eo ket bac'het gouzout pelec'h emaoc'h bremañ." | ||
169 | 24 | |||
170 | 25 | #: /tmp/i18n/src/location_service/com/ubuntu/location/service/trust_store_permission_manager.cpp:173 | ||
171 | 26 | #, boost-format | ||
172 | 27 | msgid "%1% wants to access your current location." | ||
173 | 28 | msgstr "Fellout a ra da %1% gouzout pelec'h emaoc'h bremañ." | ||
174 | 0 | 29 | ||
175 | === added file 'po/lb.po' | |||
176 | --- po/lb.po 1970-01-01 00:00:00 +0000 | |||
177 | +++ po/lb.po 2015-10-22 15:34:12 +0000 | |||
178 | @@ -0,0 +1,31 @@ | |||
179 | 1 | # Luxembourgish translation for location-service | ||
180 | 2 | # Copyright (c) 2015 Rosetta Contributors and Canonical Ltd 2015 | ||
181 | 3 | # This file is distributed under the same license as the location-service package. | ||
182 | 4 | # FIRST AUTHOR <EMAIL@ADDRESS>, 2015. | ||
183 | 5 | # | ||
184 | 6 | msgid "" | ||
185 | 7 | msgstr "" | ||
186 | 8 | "Project-Id-Version: location-service\n" | ||
187 | 9 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" | ||
188 | 10 | "POT-Creation-Date: 2014-09-19 01:04+0200\n" | ||
189 | 11 | "PO-Revision-Date: 2015-05-31 16:04+0000\n" | ||
190 | 12 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
191 | 13 | "Language-Team: Luxembourgish <lb@li.org>\n" | ||
192 | 14 | "MIME-Version: 1.0\n" | ||
193 | 15 | "Content-Type: text/plain; charset=UTF-8\n" | ||
194 | 16 | "Content-Transfer-Encoding: 8bit\n" | ||
195 | 17 | "X-Launchpad-Export-Date: 2015-06-01 05:35+0000\n" | ||
196 | 18 | "X-Generator: Launchpad (build 17532)\n" | ||
197 | 19 | |||
198 | 20 | #: /tmp/i18n/src/location_service/com/ubuntu/location/service/trust_store_permission_manager.cpp:170 | ||
199 | 21 | msgid "An unconfined application wants to access your current location." | ||
200 | 22 | msgstr "" | ||
201 | 23 | "Eng Applikatioun man onageschränkten Zougrëffsrechter wëll op Äer aktuell " | ||
202 | 24 | "Positioun zougräifen. Wëllt Däer dëser Applikatioun vertrauen?" | ||
203 | 25 | |||
204 | 26 | #: /tmp/i18n/src/location_service/com/ubuntu/location/service/trust_store_permission_manager.cpp:173 | ||
205 | 27 | #, boost-format | ||
206 | 28 | msgid "%1% wants to access your current location." | ||
207 | 29 | msgstr "" | ||
208 | 30 | "%1% wëll op Äer aktuell Positioun zougräifen. Wëllt Däer dëser Applikatioun " | ||
209 | 31 | "vertrauen?" | ||
210 | 0 | 32 | ||
211 | === added file 'po/zh_HK.po' | |||
212 | --- po/zh_HK.po 1970-01-01 00:00:00 +0000 | |||
213 | +++ po/zh_HK.po 2015-10-22 15:34:12 +0000 | |||
214 | @@ -0,0 +1,27 @@ | |||
215 | 1 | # Chinese (Hong Kong) translation for location-service | ||
216 | 2 | # Copyright (c) 2015 Rosetta Contributors and Canonical Ltd 2015 | ||
217 | 3 | # This file is distributed under the same license as the location-service package. | ||
218 | 4 | # FIRST AUTHOR <EMAIL@ADDRESS>, 2015. | ||
219 | 5 | # | ||
220 | 6 | msgid "" | ||
221 | 7 | msgstr "" | ||
222 | 8 | "Project-Id-Version: location-service\n" | ||
223 | 9 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" | ||
224 | 10 | "POT-Creation-Date: 2014-09-19 01:04+0200\n" | ||
225 | 11 | "PO-Revision-Date: 2015-06-03 18:46+0000\n" | ||
226 | 12 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
227 | 13 | "Language-Team: Chinese (Hong Kong) <zh_HK@li.org>\n" | ||
228 | 14 | "MIME-Version: 1.0\n" | ||
229 | 15 | "Content-Type: text/plain; charset=UTF-8\n" | ||
230 | 16 | "Content-Transfer-Encoding: 8bit\n" | ||
231 | 17 | "X-Launchpad-Export-Date: 2015-06-04 05:34+0000\n" | ||
232 | 18 | "X-Generator: Launchpad (build 17540)\n" | ||
233 | 19 | |||
234 | 20 | #: /tmp/i18n/src/location_service/com/ubuntu/location/service/trust_store_permission_manager.cpp:170 | ||
235 | 21 | msgid "An unconfined application wants to access your current location." | ||
236 | 22 | msgstr "有一個尚未設限的應用程式想要存取你目前的位置。" | ||
237 | 23 | |||
238 | 24 | #: /tmp/i18n/src/location_service/com/ubuntu/location/service/trust_store_permission_manager.cpp:173 | ||
239 | 25 | #, boost-format | ||
240 | 26 | msgid "%1% wants to access your current location." | ||
241 | 27 | msgstr "%1% 想存取你目前的位置。" | ||
242 | 0 | 28 | ||
243 | === modified file 'src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp' | |||
244 | --- src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp 2014-08-14 20:33:37 +0000 | |||
245 | +++ src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp 2015-10-22 15:34:12 +0000 | |||
246 | @@ -18,6 +18,10 @@ | |||
247 | 18 | 18 | ||
248 | 19 | #include <com/ubuntu/location/connectivity/cached_wireless_network.h> | 19 | #include <com/ubuntu/location/connectivity/cached_wireless_network.h> |
249 | 20 | 20 | ||
250 | 21 | #include <fstream> | ||
251 | 22 | #include <sstream> | ||
252 | 23 | #include <string> | ||
253 | 24 | |||
254 | 21 | namespace connectivity = com::ubuntu::location::connectivity; | 25 | namespace connectivity = com::ubuntu::location::connectivity; |
255 | 22 | 26 | ||
256 | 23 | namespace | 27 | namespace |
257 | @@ -50,6 +54,39 @@ | |||
258 | 50 | 54 | ||
259 | 51 | return mode; | 55 | return mode; |
260 | 52 | } | 56 | } |
261 | 57 | |||
262 | 58 | // boot_time returns the time since the epoch when the system booted. | ||
263 | 59 | std::chrono::system_clock::time_point boot_time() | ||
264 | 60 | { | ||
265 | 61 | std::ifstream in{"/proc/stat"}; | ||
266 | 62 | std::string line; | ||
267 | 63 | |||
268 | 64 | while (std::getline(in, line)) | ||
269 | 65 | { | ||
270 | 66 | if (line.empty()) | ||
271 | 67 | continue; | ||
272 | 68 | |||
273 | 69 | std::stringstream ss{line}; | ||
274 | 70 | std::string name; ss >> name; | ||
275 | 71 | |||
276 | 72 | if (name != "btime") | ||
277 | 73 | continue; | ||
278 | 74 | |||
279 | 75 | std::uint64_t ts; ss >> ts; | ||
280 | 76 | return std::chrono::system_clock::time_point{std::chrono::seconds{ts}}; | ||
281 | 77 | } | ||
282 | 78 | |||
283 | 79 | // Fallback to the best estimate we can give. | ||
284 | 80 | return std::chrono::system_clock::now(); | ||
285 | 81 | } | ||
286 | 82 | |||
287 | 83 | // NetworkManager reports AP LastSeen timestamps in seconds since boot. We map that back to the epoch | ||
288 | 84 | // to keep dependent software working. | ||
289 | 85 | std::chrono::system_clock::time_point translate_time_stamp(std::uint64_t ts) | ||
290 | 86 | { | ||
291 | 87 | static const auto ts_when_booted = boot_time(); | ||
292 | 88 | return ts_when_booted + std::chrono::seconds{ts}; | ||
293 | 89 | } | ||
294 | 53 | } | 90 | } |
295 | 54 | 91 | ||
296 | 55 | const core::Property<std::chrono::system_clock::time_point>& detail::CachedWirelessNetwork::last_seen() const | 92 | const core::Property<std::chrono::system_clock::time_point>& detail::CachedWirelessNetwork::last_seen() const |
297 | @@ -88,10 +125,7 @@ | |||
298 | 88 | : device_(device), | 125 | : device_(device), |
299 | 89 | access_point_(ap) | 126 | access_point_(ap) |
300 | 90 | { | 127 | { |
305 | 91 | last_seen_ = std::chrono::system_clock::time_point | 128 | last_seen_ = translate_time_stamp(access_point_.last_seen->get()); |
302 | 92 | { | ||
303 | 93 | std::chrono::system_clock::duration{access_point_.last_seen->get()} | ||
304 | 94 | }; | ||
306 | 95 | 129 | ||
307 | 96 | bssid_ = access_point_.hw_address->get(); | 130 | bssid_ = access_point_.hw_address->get(); |
308 | 97 | ssid_ = utf8_ssid_to_string(access_point_.ssid->get()); | 131 | ssid_ = utf8_ssid_to_string(access_point_.ssid->get()); |
309 | @@ -162,13 +196,8 @@ | |||
310 | 162 | org::freedesktop::NetworkManager::AccessPoint::LastSeen::name(), | 196 | org::freedesktop::NetworkManager::AccessPoint::LastSeen::name(), |
311 | 163 | [](CachedWirelessNetwork& thiz, const core::dbus::types::Variant& value) | 197 | [](CachedWirelessNetwork& thiz, const core::dbus::types::Variant& value) |
312 | 164 | { | 198 | { |
320 | 165 | thiz.last_seen_ = std::chrono::system_clock::time_point | 199 | thiz.last_seen_ = translate_time_stamp( |
321 | 166 | { | 200 | value.as<org::freedesktop::NetworkManager::AccessPoint::LastSeen::ValueType>()); |
315 | 167 | std::chrono::system_clock::duration | ||
316 | 168 | { | ||
317 | 169 | value.as<org::freedesktop::NetworkManager::AccessPoint::LastSeen::ValueType>() | ||
318 | 170 | } | ||
319 | 171 | }; | ||
322 | 172 | } | 201 | } |
323 | 173 | } | 202 | } |
324 | 174 | }; | 203 | }; |
325 | 175 | 204 | ||
326 | === modified file 'src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp' | |||
327 | --- src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp 2015-04-27 15:44:40 +0000 | |||
328 | +++ src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp 2015-10-22 15:34:12 +0000 | |||
329 | @@ -530,6 +530,10 @@ | |||
330 | 530 | { | 530 | { |
331 | 531 | try | 531 | try |
332 | 532 | { | 532 | { |
333 | 533 | // We have to make sure that we always hand in a lock that owns the mutex. | ||
334 | 534 | if (not ul.owns_lock()) | ||
335 | 535 | ul.lock(); | ||
336 | 536 | |||
337 | 533 | on_access_point_added(path, device_path, ul); | 537 | on_access_point_added(path, device_path, ul); |
338 | 534 | } | 538 | } |
339 | 535 | catch (const std::exception& e) | 539 | catch (const std::exception& e) |
340 | 536 | 540 | ||
341 | === modified file 'src/location_service/com/ubuntu/location/provider.cpp' | |||
342 | --- src/location_service/com/ubuntu/location/provider.cpp 2015-01-23 19:07:09 +0000 | |||
343 | +++ src/location_service/com/ubuntu/location/provider.cpp 2015-10-22 15:34:12 +0000 | |||
344 | @@ -16,9 +16,11 @@ | |||
345 | 16 | * Authored by: Thomas Voß <thomas.voss@canonical.com> | 16 | * Authored by: Thomas Voß <thomas.voss@canonical.com> |
346 | 17 | */ | 17 | */ |
347 | 18 | #include <com/ubuntu/location/provider.h> | 18 | #include <com/ubuntu/location/provider.h> |
348 | 19 | #include <com/ubuntu/location/logging.h> | ||
349 | 19 | 20 | ||
350 | 20 | #include <atomic> | 21 | #include <atomic> |
351 | 21 | #include <bitset> | 22 | #include <bitset> |
352 | 23 | #include <functional> | ||
353 | 22 | #include <memory> | 24 | #include <memory> |
354 | 23 | 25 | ||
355 | 24 | namespace cul = com::ubuntu::location; | 26 | namespace cul = com::ubuntu::location; |
356 | @@ -51,12 +53,15 @@ | |||
357 | 51 | 53 | ||
358 | 52 | void cul::Provider::Controller::start_position_updates() | 54 | void cul::Provider::Controller::start_position_updates() |
359 | 53 | { | 55 | { |
361 | 54 | if (position_updates_counter < 0) | 56 | if (position_updates_counter < 0) { |
362 | 55 | return; | 57 | return; |
363 | 58 | } | ||
364 | 56 | 59 | ||
365 | 57 | if (++position_updates_counter == 1) | 60 | if (++position_updates_counter == 1) |
366 | 58 | { | 61 | { |
368 | 59 | instance.start_position_updates(); | 62 | if (instance.boot_state() == BootState::BOOTED) { |
369 | 63 | instance.start_position_updates(); | ||
370 | 64 | } | ||
371 | 60 | } | 65 | } |
372 | 61 | } | 66 | } |
373 | 62 | 67 | ||
374 | @@ -67,7 +72,8 @@ | |||
375 | 67 | 72 | ||
376 | 68 | if (--position_updates_counter == 0) | 73 | if (--position_updates_counter == 0) |
377 | 69 | { | 74 | { |
379 | 70 | instance.stop_position_updates(); | 75 | if (instance.boot_state() == BootState::BOOTED) |
380 | 76 | instance.stop_position_updates(); | ||
381 | 71 | } | 77 | } |
382 | 72 | } | 78 | } |
383 | 73 | 79 | ||
384 | @@ -83,7 +89,8 @@ | |||
385 | 83 | 89 | ||
386 | 84 | if (++heading_updates_counter == 1) | 90 | if (++heading_updates_counter == 1) |
387 | 85 | { | 91 | { |
389 | 86 | instance.start_heading_updates(); | 92 | if (instance.boot_state() == BootState::BOOTED) |
390 | 93 | instance.start_heading_updates(); | ||
391 | 87 | } | 94 | } |
392 | 88 | } | 95 | } |
393 | 89 | 96 | ||
394 | @@ -94,7 +101,8 @@ | |||
395 | 94 | 101 | ||
396 | 95 | if (--heading_updates_counter == 0) | 102 | if (--heading_updates_counter == 0) |
397 | 96 | { | 103 | { |
399 | 97 | instance.stop_heading_updates(); | 104 | if (instance.boot_state() == BootState::BOOTED) |
400 | 105 | instance.stop_heading_updates(); | ||
401 | 98 | } | 106 | } |
402 | 99 | } | 107 | } |
403 | 100 | 108 | ||
404 | @@ -110,7 +118,8 @@ | |||
405 | 110 | 118 | ||
406 | 111 | if (++velocity_updates_counter == 1) | 119 | if (++velocity_updates_counter == 1) |
407 | 112 | { | 120 | { |
409 | 113 | instance.start_velocity_updates(); | 121 | if (instance.boot_state() == BootState::BOOTED) |
410 | 122 | instance.start_velocity_updates(); | ||
411 | 114 | } | 123 | } |
412 | 115 | } | 124 | } |
413 | 116 | 125 | ||
414 | @@ -121,7 +130,8 @@ | |||
415 | 121 | 130 | ||
416 | 122 | if (--velocity_updates_counter == 0) | 131 | if (--velocity_updates_counter == 0) |
417 | 123 | { | 132 | { |
419 | 124 | instance.stop_velocity_updates(); | 133 | if (instance.boot_state() == BootState::BOOTED) |
420 | 134 | instance.stop_velocity_updates(); | ||
421 | 125 | } | 135 | } |
422 | 126 | } | 136 | } |
423 | 127 | 137 | ||
424 | @@ -130,12 +140,38 @@ | |||
425 | 130 | return velocity_updates_counter > 0; | 140 | return velocity_updates_counter > 0; |
426 | 131 | } | 141 | } |
427 | 132 | 142 | ||
428 | 143 | void cul::Provider::Controller::on_provider_booted(bool was_booted) | ||
429 | 144 | { | ||
430 | 145 | if (!was_booted) | ||
431 | 146 | return; | ||
432 | 147 | |||
433 | 148 | // we need to propagate the state of the provider using the internal counters as references | ||
434 | 149 | if (position_updates_counter > 0) { | ||
435 | 150 | instance.start_position_updates(); | ||
436 | 151 | } | ||
437 | 152 | if (heading_updates_counter > 0) { | ||
438 | 153 | instance.start_heading_updates(); | ||
439 | 154 | } | ||
440 | 155 | if (velocity_updates_counter > 0) { | ||
441 | 156 | instance.start_velocity_updates(); | ||
442 | 157 | } | ||
443 | 158 | } | ||
444 | 159 | |||
445 | 133 | cul::Provider::Controller::Controller(cul::Provider& instance) | 160 | cul::Provider::Controller::Controller(cul::Provider& instance) |
446 | 134 | : instance(instance), | 161 | : instance(instance), |
447 | 135 | position_updates_counter(0), | 162 | position_updates_counter(0), |
448 | 136 | heading_updates_counter(0), | 163 | heading_updates_counter(0), |
449 | 137 | velocity_updates_counter(0) | 164 | velocity_updates_counter(0) |
451 | 138 | { | 165 | { |
452 | 166 | using namespace std::placeholders; | ||
453 | 167 | |||
454 | 168 | if (instance.boot_state() != BootState::BOOTED) { | ||
455 | 169 | // if the instance has not booted and is delayed we need to keep track of its booting state | ||
456 | 170 | instance.booted_signal().connect(std::bind(&Controller::on_provider_booted, this, _1)); | ||
457 | 171 | if (instance.boot_state() != BootState::BOOTING) { | ||
458 | 172 | instance.boot(); | ||
459 | 173 | } | ||
460 | 174 | } | ||
461 | 139 | } | 175 | } |
462 | 140 | 176 | ||
463 | 141 | const cul::Provider::Controller::Ptr& cul::Provider::state_controller() const | 177 | const cul::Provider::Controller::Ptr& cul::Provider::state_controller() const |
464 | @@ -158,11 +194,28 @@ | |||
465 | 158 | return false; | 194 | return false; |
466 | 159 | } | 195 | } |
467 | 160 | 196 | ||
468 | 197 | cul::Provider::BootState cul::Provider::boot_state() const | ||
469 | 198 | { | ||
470 | 199 | return cul::Provider::BootState::BOOTED; | ||
471 | 200 | } | ||
472 | 201 | |||
473 | 202 | void cul::Provider::boot() { } | ||
474 | 203 | |||
475 | 161 | const cul::Provider::Updates& cul::Provider::updates() const | 204 | const cul::Provider::Updates& cul::Provider::updates() const |
476 | 162 | { | 205 | { |
477 | 163 | return d.updates; | 206 | return d.updates; |
478 | 164 | } | 207 | } |
479 | 165 | 208 | ||
480 | 209 | core::Signal<bool>& cul::Provider::booted_signal() | ||
481 | 210 | { | ||
482 | 211 | return d.signals.booted; | ||
483 | 212 | } | ||
484 | 213 | |||
485 | 214 | const core::Signal<bool>& cul::Provider::booted_signal() const | ||
486 | 215 | { | ||
487 | 216 | return d.signals.booted; | ||
488 | 217 | } | ||
489 | 218 | |||
490 | 166 | cul::Provider::Provider( | 219 | cul::Provider::Provider( |
491 | 167 | const cul::Provider::Features& features, | 220 | const cul::Provider::Features& features, |
492 | 168 | const cul::Provider::Requirements& requirements) | 221 | const cul::Provider::Requirements& requirements) |
493 | 169 | 222 | ||
494 | === modified file 'tests/controller_test.cpp' | |||
495 | --- tests/controller_test.cpp 2014-09-10 19:34:09 +0000 | |||
496 | +++ tests/controller_test.cpp 2015-10-22 15:34:12 +0000 | |||
497 | @@ -18,6 +18,7 @@ | |||
498 | 18 | #include <com/ubuntu/location/provider.h> | 18 | #include <com/ubuntu/location/provider.h> |
499 | 19 | 19 | ||
500 | 20 | #include "mock_provider.h" | 20 | #include "mock_provider.h" |
501 | 21 | #include "mock_delayed_provider.h" | ||
502 | 21 | 22 | ||
503 | 22 | #include <gmock/gmock.h> | 23 | #include <gmock/gmock.h> |
504 | 23 | #include <gtest/gtest.h> | 24 | #include <gtest/gtest.h> |
505 | @@ -130,3 +131,215 @@ | |||
506 | 130 | EXPECT_FALSE(controller->are_velocity_updates_running()); | 131 | EXPECT_FALSE(controller->are_velocity_updates_running()); |
507 | 131 | EXPECT_FALSE(controller->are_heading_updates_running()); | 132 | EXPECT_FALSE(controller->are_heading_updates_running()); |
508 | 132 | } | 133 | } |
509 | 134 | |||
510 | 135 | TEST(Controller, controller_resumes_state_after_boot) { | ||
511 | 136 | using namespace ::testing; | ||
512 | 137 | using ::testing::Mock; | ||
513 | 138 | |||
514 | 139 | MockDelayedProvider provider; | ||
515 | 140 | |||
516 | 141 | // ignore what ever was performed on construction | ||
517 | 142 | Mock::VerifyAndClear(&provider); | ||
518 | 143 | |||
519 | 144 | } | ||
520 | 145 | |||
521 | 146 | TEST(Controller, controller_does_not_call_start_position_if_not_booted) { | ||
522 | 147 | using namespace ::testing; | ||
523 | 148 | using ::testing::Mock; | ||
524 | 149 | |||
525 | 150 | MockDelayedProvider provider; | ||
526 | 151 | |||
527 | 152 | // ignore what ever was performed on construction | ||
528 | 153 | Mock::VerifyAndClear(&provider); | ||
529 | 154 | // use a mock controller | ||
530 | 155 | auto controller = provider.state_controller(); | ||
531 | 156 | |||
532 | 157 | EXPECT_CALL(provider, boot_state()).Times(Exactly(1)) | ||
533 | 158 | .WillOnce(Return(cul::Provider::BootState::NOT_BOOTED)); | ||
534 | 159 | EXPECT_CALL(provider, start_position_updates()).Times(Exactly(0)); | ||
535 | 160 | |||
536 | 161 | controller->start_position_updates(); | ||
537 | 162 | controller->start_position_updates(); | ||
538 | 163 | } | ||
539 | 164 | |||
540 | 165 | TEST(Controller, controller_does_not_call_start_position_if_booting) { | ||
541 | 166 | using namespace ::testing; | ||
542 | 167 | using ::testing::Mock; | ||
543 | 168 | |||
544 | 169 | MockDelayedProvider provider; | ||
545 | 170 | |||
546 | 171 | // ignore what ever was performed on construction | ||
547 | 172 | Mock::VerifyAndClear(&provider); | ||
548 | 173 | // use a mock controller | ||
549 | 174 | auto controller = provider.state_controller(); | ||
550 | 175 | |||
551 | 176 | EXPECT_CALL(provider, boot_state()).Times(Exactly(1)) | ||
552 | 177 | .WillOnce(Return(cul::Provider::BootState::BOOTING)); | ||
553 | 178 | EXPECT_CALL(provider, start_position_updates()).Times(Exactly(0)); | ||
554 | 179 | |||
555 | 180 | controller->start_position_updates(); | ||
556 | 181 | } | ||
557 | 182 | |||
558 | 183 | TEST(Controller, controller_does_not_call_start_heading_if_not_booted) { | ||
559 | 184 | using namespace ::testing; | ||
560 | 185 | using ::testing::Mock; | ||
561 | 186 | |||
562 | 187 | MockDelayedProvider provider; | ||
563 | 188 | EXPECT_CALL(provider, has_delayed_boot()).WillRepeatedly(Return(true)); | ||
564 | 189 | |||
565 | 190 | // ignore what ever was performed on construction | ||
566 | 191 | Mock::VerifyAndClear(&provider); | ||
567 | 192 | // use a mock controller | ||
568 | 193 | auto controller = provider.state_controller(); | ||
569 | 194 | |||
570 | 195 | EXPECT_CALL(provider, boot_state()).Times(Exactly(1)) | ||
571 | 196 | .WillOnce(Return(cul::Provider::BootState::NOT_BOOTED)); | ||
572 | 197 | EXPECT_CALL(provider, start_heading_updates()).Times(Exactly(0)); | ||
573 | 198 | |||
574 | 199 | controller->start_heading_updates(); | ||
575 | 200 | } | ||
576 | 201 | |||
577 | 202 | TEST(Controller, controller_does_not_call_start_heading_if_booting) { | ||
578 | 203 | using namespace ::testing; | ||
579 | 204 | using ::testing::Mock; | ||
580 | 205 | |||
581 | 206 | MockDelayedProvider provider; | ||
582 | 207 | EXPECT_CALL(provider, has_delayed_boot()).WillRepeatedly(Return(true)); | ||
583 | 208 | |||
584 | 209 | // ignore what ever was performed on construction | ||
585 | 210 | Mock::VerifyAndClear(&provider); | ||
586 | 211 | // use a mock controller | ||
587 | 212 | auto controller = provider.state_controller(); | ||
588 | 213 | |||
589 | 214 | EXPECT_CALL(provider, boot_state()).Times(Exactly(1)) | ||
590 | 215 | .WillOnce(Return(cul::Provider::BootState::BOOTING)); | ||
591 | 216 | EXPECT_CALL(provider, start_heading_updates()).Times(Exactly(0)); | ||
592 | 217 | |||
593 | 218 | controller->start_heading_updates(); | ||
594 | 219 | } | ||
595 | 220 | |||
596 | 221 | TEST(Controller, controller_does_not_call_start_velocity_if_not_booted) { | ||
597 | 222 | using namespace ::testing; | ||
598 | 223 | using ::testing::Mock; | ||
599 | 224 | |||
600 | 225 | MockDelayedProvider provider; | ||
601 | 226 | EXPECT_CALL(provider, has_delayed_boot()).WillRepeatedly(Return(true)); | ||
602 | 227 | |||
603 | 228 | // ignore what ever was performed on construction | ||
604 | 229 | Mock::VerifyAndClear(&provider); | ||
605 | 230 | // use a mock controller | ||
606 | 231 | auto controller = provider.state_controller(); | ||
607 | 232 | |||
608 | 233 | EXPECT_CALL(provider, boot_state()).Times(Exactly(1)) | ||
609 | 234 | .WillOnce(Return(cul::Provider::BootState::NOT_BOOTED)); | ||
610 | 235 | EXPECT_CALL(provider, start_heading_updates()).Times(Exactly(0)); | ||
611 | 236 | |||
612 | 237 | controller->start_velocity_updates(); | ||
613 | 238 | } | ||
614 | 239 | |||
615 | 240 | TEST(Controller, controller_does_not_call_start_velocity_if_booting) { | ||
616 | 241 | using namespace ::testing; | ||
617 | 242 | using ::testing::Mock; | ||
618 | 243 | |||
619 | 244 | MockDelayedProvider provider; | ||
620 | 245 | EXPECT_CALL(provider, has_delayed_boot()).WillRepeatedly(Return(true)); | ||
621 | 246 | |||
622 | 247 | // ignore what ever was performed on construction | ||
623 | 248 | Mock::VerifyAndClear(&provider); | ||
624 | 249 | // use a mock controller | ||
625 | 250 | auto controller = provider.state_controller(); | ||
626 | 251 | |||
627 | 252 | EXPECT_CALL(provider, boot_state()).Times(Exactly(1)) | ||
628 | 253 | .WillOnce(Return(cul::Provider::BootState::BOOTING)); | ||
629 | 254 | EXPECT_CALL(provider, start_heading_updates()).Times(Exactly(0)); | ||
630 | 255 | |||
631 | 256 | controller->start_velocity_updates(); | ||
632 | 257 | } | ||
633 | 258 | |||
634 | 259 | TEST(Controller, controller_does_not_call_stop_position_if_not_booted) { | ||
635 | 260 | using namespace ::testing; | ||
636 | 261 | using ::testing::Mock; | ||
637 | 262 | |||
638 | 263 | MockDelayedProvider provider; | ||
639 | 264 | EXPECT_CALL(provider, has_delayed_boot()).WillRepeatedly(Return(true)); | ||
640 | 265 | |||
641 | 266 | // ignore what ever was performed on construction | ||
642 | 267 | Mock::VerifyAndClear(&provider); | ||
643 | 268 | // use a mock controller | ||
644 | 269 | auto controller = provider.state_controller(); | ||
645 | 270 | |||
646 | 271 | EXPECT_CALL(provider, boot_state()).Times(Exactly(2)) | ||
647 | 272 | .WillOnce(Return(cul::Provider::BootState::BOOTED)) | ||
648 | 273 | .WillOnce(Return(cul::Provider::BootState::NOT_BOOTED)); | ||
649 | 274 | EXPECT_CALL(provider, start_position_updates()).Times(Exactly(1)); | ||
650 | 275 | EXPECT_CALL(provider, stop_position_updates()).Times(Exactly(0)); | ||
651 | 276 | |||
652 | 277 | controller->start_position_updates(); | ||
653 | 278 | controller->stop_position_updates(); | ||
654 | 279 | } | ||
655 | 280 | |||
656 | 281 | TEST(Controller, controller_does_not_call_stop_position_if_booting) { | ||
657 | 282 | using namespace ::testing; | ||
658 | 283 | using ::testing::Mock; | ||
659 | 284 | |||
660 | 285 | MockDelayedProvider provider; | ||
661 | 286 | EXPECT_CALL(provider, has_delayed_boot()).WillRepeatedly(Return(true)); | ||
662 | 287 | |||
663 | 288 | // ignore what ever was performed on construction | ||
664 | 289 | Mock::VerifyAndClear(&provider); | ||
665 | 290 | // use a mock controller | ||
666 | 291 | auto controller = provider.state_controller(); | ||
667 | 292 | |||
668 | 293 | EXPECT_CALL(provider, boot_state()).Times(Exactly(2)) | ||
669 | 294 | .WillOnce(Return(cul::Provider::BootState::BOOTED)) | ||
670 | 295 | .WillOnce(Return(cul::Provider::BootState::BOOTING)); | ||
671 | 296 | EXPECT_CALL(provider, start_position_updates()).Times(Exactly(1)); | ||
672 | 297 | EXPECT_CALL(provider, stop_position_updates()).Times(Exactly(0)); | ||
673 | 298 | |||
674 | 299 | controller->start_position_updates(); | ||
675 | 300 | controller->stop_position_updates(); | ||
676 | 301 | } | ||
677 | 302 | |||
678 | 303 | TEST(Controller, controller_does_not_call_stop_heading_if_not_booted) { | ||
679 | 304 | using namespace ::testing; | ||
680 | 305 | using ::testing::Mock; | ||
681 | 306 | |||
682 | 307 | MockDelayedProvider provider; | ||
683 | 308 | EXPECT_CALL(provider, has_delayed_boot()).WillRepeatedly(Return(true)); | ||
684 | 309 | |||
685 | 310 | // ignore what ever was performed on construction | ||
686 | 311 | Mock::VerifyAndClear(&provider); | ||
687 | 312 | // use a mock controller | ||
688 | 313 | auto controller = provider.state_controller(); | ||
689 | 314 | |||
690 | 315 | EXPECT_CALL(provider, boot_state()).Times(Exactly(2)) | ||
691 | 316 | .WillOnce(Return(cul::Provider::BootState::BOOTED)) | ||
692 | 317 | .WillOnce(Return(cul::Provider::BootState::BOOTING)); | ||
693 | 318 | EXPECT_CALL(provider, start_heading_updates()).Times(Exactly(1)); | ||
694 | 319 | EXPECT_CALL(provider, stop_heading_updates()).Times(Exactly(0)); | ||
695 | 320 | |||
696 | 321 | controller->start_heading_updates(); | ||
697 | 322 | controller->stop_heading_updates(); | ||
698 | 323 | } | ||
699 | 324 | |||
700 | 325 | TEST(Controller, controller_does_not_call_stop_velocity_if_not_booted) { | ||
701 | 326 | using namespace ::testing; | ||
702 | 327 | using ::testing::Mock; | ||
703 | 328 | |||
704 | 329 | MockDelayedProvider provider; | ||
705 | 330 | EXPECT_CALL(provider, has_delayed_boot()).WillRepeatedly(Return(true)); | ||
706 | 331 | |||
707 | 332 | // ignore what ever was performed on construction | ||
708 | 333 | Mock::VerifyAndClear(&provider); | ||
709 | 334 | // use a mock controller | ||
710 | 335 | auto controller = provider.state_controller(); | ||
711 | 336 | |||
712 | 337 | EXPECT_CALL(provider, boot_state()).Times(Exactly(2)) | ||
713 | 338 | .WillOnce(Return(cul::Provider::BootState::BOOTED)) | ||
714 | 339 | .WillOnce(Return(cul::Provider::BootState::BOOTING)); | ||
715 | 340 | EXPECT_CALL(provider, start_velocity_updates()).Times(Exactly(1)); | ||
716 | 341 | EXPECT_CALL(provider, stop_velocity_updates()).Times(Exactly(0)); | ||
717 | 342 | |||
718 | 343 | controller->start_velocity_updates(); | ||
719 | 344 | controller->stop_velocity_updates(); | ||
720 | 345 | } | ||
721 | 133 | 346 | ||
722 | === added file 'tests/mock_delayed_provider.h' | |||
723 | --- tests/mock_delayed_provider.h 1970-01-01 00:00:00 +0000 | |||
724 | +++ tests/mock_delayed_provider.h 2015-10-22 15:34:12 +0000 | |||
725 | @@ -0,0 +1,89 @@ | |||
726 | 1 | /* | ||
727 | 2 | * Copyright © 2014 Canonical Ltd. | ||
728 | 3 | * | ||
729 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
730 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
731 | 6 | * as published by the Free Software Foundation. | ||
732 | 7 | * | ||
733 | 8 | * This program is distributed in the hope that it will be useful, | ||
734 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
735 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
736 | 11 | * GNU Lesser General Public License for more details. | ||
737 | 12 | * | ||
738 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
739 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
740 | 15 | * | ||
741 | 16 | * Authored by: M | ||
742 | 17 | */ | ||
743 | 18 | #ifndef MOCK_DELAYED_PROVIDER_H_ | ||
744 | 19 | #define MOCK_DELAYED_PROVIDER_H_ | ||
745 | 20 | |||
746 | 21 | #include <com/ubuntu/location/provider.h> | ||
747 | 22 | #include <com/ubuntu/location/logging.h> | ||
748 | 23 | |||
749 | 24 | #include <gmock/gmock.h> | ||
750 | 25 | |||
751 | 26 | struct PublicController : public com::ubuntu::location::Provider::Controller | ||
752 | 27 | { | ||
753 | 28 | |||
754 | 29 | explicit PublicController(com::ubuntu::location::Provider& instance) | ||
755 | 30 | : com::ubuntu::location::Provider::Controller(instance) {} | ||
756 | 31 | }; | ||
757 | 32 | |||
758 | 33 | struct MockDelayedProvider : public com::ubuntu::location::Provider | ||
759 | 34 | { | ||
760 | 35 | MockDelayedProvider() : com::ubuntu::location::Provider() | ||
761 | 36 | { | ||
762 | 37 | } | ||
763 | 38 | |||
764 | 39 | MOCK_METHOD1(matches_criteria, bool(const com::ubuntu::location::Criteria&)); | ||
765 | 40 | |||
766 | 41 | MOCK_CONST_METHOD1(supports, bool(const com::ubuntu::location::Provider::Features&)); | ||
767 | 42 | MOCK_CONST_METHOD1(requires, bool(const com::ubuntu::location::Provider::Requirements&)); | ||
768 | 43 | |||
769 | 44 | // Called by the engine whenever the wifi and cell ID reporting state changes. | ||
770 | 45 | MOCK_METHOD1(on_wifi_and_cell_reporting_state_changed, void(com::ubuntu::location::WifiAndCellIdReportingState state)); | ||
771 | 46 | |||
772 | 47 | // Called by the engine whenever the reference location changed. | ||
773 | 48 | MOCK_METHOD1(on_reference_location_updated, void(const com::ubuntu::location::Update<com::ubuntu::location::Position>& position)); | ||
774 | 49 | |||
775 | 50 | // Called by the engine whenever the reference velocity changed. | ||
776 | 51 | MOCK_METHOD1(on_reference_velocity_updated, void(const com::ubuntu::location::Update<com::ubuntu::location::Velocity>& velocity)); | ||
777 | 52 | |||
778 | 53 | // Called by the engine whenever the reference heading changed. | ||
779 | 54 | MOCK_METHOD1(on_reference_heading_updated, void(const com::ubuntu::location::Update<com::ubuntu::location::Heading>& heading)); | ||
780 | 55 | |||
781 | 56 | MOCK_METHOD0(start_position_updates, void()); | ||
782 | 57 | MOCK_METHOD0(stop_position_updates, void()); | ||
783 | 58 | |||
784 | 59 | MOCK_METHOD0(start_heading_updates, void()); | ||
785 | 60 | MOCK_METHOD0(stop_heading_updates, void()); | ||
786 | 61 | |||
787 | 62 | MOCK_METHOD0(start_velocity_updates, void()); | ||
788 | 63 | MOCK_METHOD0(stop_velocity_updates, void()); | ||
789 | 64 | |||
790 | 65 | MOCK_CONST_METHOD0(has_delayed_boot, bool()); | ||
791 | 66 | MOCK_CONST_METHOD0(boot_state, BootState()); | ||
792 | 67 | MOCK_CONST_METHOD0(boot, void()); | ||
793 | 68 | |||
794 | 69 | |||
795 | 70 | // Inject a position update from the outside. | ||
796 | 71 | void inject_update(const com::ubuntu::location::Update<com::ubuntu::location::Position>& update) | ||
797 | 72 | { | ||
798 | 73 | mutable_updates().position(update); | ||
799 | 74 | } | ||
800 | 75 | |||
801 | 76 | // Inject a velocity update from the outside. | ||
802 | 77 | void inject_update(const com::ubuntu::location::Update<com::ubuntu::location::Velocity>& update) | ||
803 | 78 | { | ||
804 | 79 | mutable_updates().velocity(update); | ||
805 | 80 | } | ||
806 | 81 | |||
807 | 82 | // Inject a heading update from the outside. | ||
808 | 83 | void inject_update(const com::ubuntu::location::Update<com::ubuntu::location::Heading>& update) | ||
809 | 84 | { | ||
810 | 85 | mutable_updates().heading(update); | ||
811 | 86 | } | ||
812 | 87 | }; | ||
813 | 88 | |||
814 | 89 | #endif // MOCK_PROVIDER_H_ |