Merge lp:~thomas-voss/location-service/deliver-updates-to-visible-satellites into lp:location-service/15.04

Proposed by Thomas Voß
Status: Superseded
Proposed branch: lp:~thomas-voss/location-service/deliver-updates-to-visible-satellites
Merge into: lp:location-service/15.04
Diff against target: 240 lines (+161/-8)
3 files modified
include/location_service/com/ubuntu/location/service/skeleton.h (+3/-0)
src/location_service/com/ubuntu/location/service/skeleton.cpp (+21/-0)
tests/acceptance_tests.cpp (+137/-8)
To merge this branch: bzr merge lp:~thomas-voss/location-service/deliver-updates-to-visible-satellites
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+279681@code.launchpad.net

This proposal has been superseded by a proposal from 2015-12-06.

Commit message

Deliver updates to visible satellites.

Description of the change

Deliver updates to visible satellites.

To post a comment you must log in.
210. By Thomas Voß

Account for API changes in platform api's hw gps component.

Unmerged revisions

210. By Thomas Voß

Account for API changes in platform api's hw gps component.

209. By Thomas Voß

Deliver updates to visible satellites.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/location_service/com/ubuntu/location/service/skeleton.h'
2--- include/location_service/com/ubuntu/location/service/skeleton.h 2015-02-13 13:19:18 +0000
3+++ include/location_service/com/ubuntu/location/service/skeleton.h 2015-12-05 22:04:55 +0000
4@@ -137,6 +137,8 @@
5 void on_does_report_cell_and_wifi_ids_changed(bool value);
6 // Called whenever the value of the respective property changes.
7 void on_is_online_changed(bool value);
8+ // Called when the visible space vehicles as observed by gps/glonass/galileo/etc. providers has changed.
9+ void on_visible_space_vehicles_changed(const std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle>& svs);
10
11 // Stores the configuration passed in at creation time.
12 Configuration configuration;
13@@ -165,6 +167,7 @@
14 core::ScopedConnection does_satellite_based_positioning;
15 core::ScopedConnection does_report_cell_and_wifi_ids;
16 core::ScopedConnection is_online;
17+ core::ScopedConnection visible_space_vehicles;
18 } connections;
19 // Guards the session store.
20 std::mutex guard;
21
22=== modified file 'src/location_service/com/ubuntu/location/service/skeleton.cpp'
23--- src/location_service/com/ubuntu/location/service/skeleton.cpp 2015-02-13 13:19:18 +0000
24+++ src/location_service/com/ubuntu/location/service/skeleton.cpp 2015-12-05 22:04:55 +0000
25@@ -91,6 +91,10 @@
26 properties.is_online->changed().connect([this](bool value)
27 {
28 on_is_online_changed(value);
29+ }),
30+ properties.visible_space_vehicles->changed().connect([this](const std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle> & svs)
31+ {
32+ on_visible_space_vehicles_changed(svs);
33 })
34 }
35 {
36@@ -258,6 +262,23 @@
37 the_empty_array_of_invalidated_properties()));
38 }
39
40+void culs::Skeleton::on_visible_space_vehicles_changed(const std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle> & value)
41+{
42+ std::map<std::string, core::dbus::types::Variant> dict
43+ {
44+ {
45+ culs::Interface::Properties::VisibleSpaceVehicles::name(),
46+ core::dbus::types::Variant::encode(value)
47+ }
48+ };
49+
50+ properties_changed->emit(
51+ std::tie(
52+ core::dbus::traits::Service<culs::Interface>::interface_name(),
53+ dict,
54+ the_empty_array_of_invalidated_properties()));
55+}
56+
57 core::Property<bool>& culs::Skeleton::does_satellite_based_positioning()
58 {
59 return *properties.does_satellite_based_positioning;
60
61=== modified file 'tests/acceptance_tests.cpp'
62--- tests/acceptance_tests.cpp 2015-11-27 13:00:31 +0000
63+++ tests/acceptance_tests.cpp 2015-12-05 22:04:55 +0000
64@@ -75,6 +75,22 @@
65
66 static const bool trust_store_is_set_up_for_testing = setup_trust_store_permission_manager_for_testing();
67
68+class AutoJoiningThread
69+{
70+public:
71+ AutoJoiningThread(std::function<void()> task) : worker{task}
72+ {
73+ }
74+
75+ ~AutoJoiningThread()
76+ {
77+ if (worker.joinable())
78+ worker.join();
79+ }
80+
81+ std::thread worker;
82+};
83+
84 struct NullReporter : public culs::Harvester::Reporter
85 {
86 NullReporter() = default;
87@@ -621,12 +637,13 @@
88 std::make_shared<NullReporter>()
89 }
90 };
91+
92 auto location_service = std::make_shared<cul::service::Implementation>(configuration);
93
94 configuration.engine->updates.visible_space_vehicles.set(visible_space_vehicles);
95
96- std::thread t1{[incoming](){incoming->run();}};
97- std::thread t2{[outgoing](){outgoing->run();}};
98+ AutoJoiningThread t1{[incoming](){incoming->run();}};
99+ AutoJoiningThread t2{[outgoing](){outgoing->run();}};
100
101 sync_start.try_signal_ready_for(std::chrono::milliseconds{500});
102
103@@ -635,12 +652,6 @@
104 incoming->stop();
105 outgoing->stop();
106
107- if (t1.joinable())
108- t1.join();
109-
110- if (t2.joinable())
111- t2.join();
112-
113 return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success;
114 };
115
116@@ -665,6 +676,124 @@
117 EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(server, client));
118 }
119
120+TEST_F(LocationServiceStandalone, VisibleSpaceVehiclesAreUpdated)
121+{
122+ EXPECT_TRUE(trust_store_is_set_up_for_testing);
123+
124+ core::testing::CrossProcessSync sync_start;
125+
126+ cul::SpaceVehicle sv1;
127+ sv1.key.type = cul::SpaceVehicle::Type::gps;
128+ sv1.has_ephimeris_data = true;
129+ auto sv2 = sv1;
130+ sv2.key.id = 1;
131+
132+ static const std::map<cul::SpaceVehicle::Key, cul::SpaceVehicle> vsv1
133+ {
134+ {sv1.key, sv1}
135+ };
136+
137+ static const std::map<cul::SpaceVehicle::Key, cul::SpaceVehicle> vsv2
138+ {
139+ {sv1.key, sv1}, {sv2.key, sv2}
140+ };
141+
142+ auto server = [this, &sync_start]()
143+ {
144+ SCOPED_TRACE("Server");
145+
146+ auto trap = core::posix::trap_signals_for_all_subsequent_threads({core::posix::Signal::sig_term});
147+ trap->signal_raised().connect([trap](core::posix::Signal)
148+ {
149+ trap->stop();
150+ });
151+
152+ auto incoming = session_bus();
153+ auto outgoing = session_bus();
154+
155+ incoming->install_executor(core::dbus::asio::make_executor(incoming));
156+ outgoing->install_executor(core::dbus::asio::make_executor(outgoing));
157+
158+ auto dummy = new DummyProvider();
159+ cul::Provider::Ptr helper(dummy);
160+
161+ cul::service::DefaultConfiguration config;
162+ cul::service::Implementation::Configuration configuration
163+ {
164+ incoming,
165+ outgoing,
166+ config.the_engine(config.the_provider_set(helper), config.the_provider_selection_policy(), null_settings()),
167+ config.the_permission_manager(incoming),
168+ cul::service::Harvester::Configuration
169+ {
170+ cul::connectivity::platform_default_manager(),
171+ std::make_shared<NullReporter>()
172+ }
173+ };
174+
175+ auto location_service = std::make_shared<cul::service::Implementation>(configuration);
176+
177+ bool stop_requested = false;
178+ AutoJoiningThread updater{[&configuration, &stop_requested]()
179+ {
180+ int counter = 0;
181+ while (not stop_requested)
182+ {
183+ configuration.engine->updates.visible_space_vehicles.set(++counter % 2 == 0 ? vsv1 : vsv2);
184+ std::this_thread::sleep_for(std::chrono::milliseconds{10});
185+ }
186+ }};
187+
188+ AutoJoiningThread t1{[incoming](){incoming->run();}};
189+ AutoJoiningThread t2{[outgoing](){outgoing->run();}};
190+
191+ sync_start.try_signal_ready_for(std::chrono::milliseconds{500});
192+
193+ trap->run();
194+
195+ stop_requested = true;
196+ incoming->stop();
197+ outgoing->stop();
198+
199+ return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success;
200+ };
201+
202+ auto client = [this, &sync_start]()
203+ {
204+ SCOPED_TRACE("Client");
205+
206+ EXPECT_EQ(1, sync_start.wait_for_signal_ready_for(std::chrono::milliseconds{500}));
207+
208+ auto bus = session_bus();
209+ auto location_service = dbus::resolve_service_on_bus<
210+ cul::service::Interface,
211+ cul::service::Stub>(bus);
212+
213+ bus->install_executor(core::dbus::asio::make_executor(bus));
214+ AutoJoiningThread worker{[bus]() { bus->run(); }};
215+
216+ bool updated{false};
217+ std::mutex guard;
218+ std::condition_variable cv;
219+
220+ location_service->visible_space_vehicles().changed().connect([&updated, &guard, &cv](const std::map<cul::SpaceVehicle::Key, cul::SpaceVehicle>& svs)
221+ {
222+ std::unique_lock<std::mutex> ul{guard};
223+ updated = true;
224+ cv.notify_all();
225+ });
226+
227+ std::unique_lock<std::mutex> ul{guard};
228+ EXPECT_TRUE(cv.wait_for(ul, std::chrono::seconds{2}, [&updated]() { return updated; }));
229+
230+ bus->stop();
231+
232+ return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success;
233+ };
234+
235+ EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(server, client));
236+}
237+
238 TEST_F(LocationServiceStandalone, NewSessionsGetLastKnownPosition)
239 {
240 core::testing::CrossProcessSync sync_start;

Subscribers

People subscribed via source and target branches