Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: device/generic_sensor/platform_sensor_provider_unittest.cc

Issue 2368193003: [sensors] Introduce asynchronous way to create sensors. (Closed)
Patch Set: A comment from Mikhail Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h"
6 #include "base/message_loop/message_loop.h"
7 #include "base/run_loop.h"
8
5 #include "device/generic_sensor/fake_platform_sensor.h" 9 #include "device/generic_sensor/fake_platform_sensor.h"
6 #include "device/generic_sensor/fake_platform_sensor_provider.h" 10 #include "device/generic_sensor/fake_platform_sensor_provider.h"
7 #include "device/generic_sensor/public/interfaces/sensor_provider.mojom.h" 11 #include "device/generic_sensor/public/interfaces/sensor_provider.mojom.h"
8 12
9 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
10 14
11 namespace device { 15 namespace device {
12 16
13 using mojom::SensorInitParams; 17 using mojom::SensorInitParams;
14 using mojom::SensorType; 18 using mojom::SensorType;
15 19
16 namespace { 20 namespace {
17 21
18 uint64_t GetBufferOffset(mojom::SensorType type) { 22 uint64_t GetBufferOffset(mojom::SensorType type) {
19 return (static_cast<uint64_t>(SensorType::LAST) - 23 return (static_cast<uint64_t>(SensorType::LAST) -
20 static_cast<uint64_t>(type)) * 24 static_cast<uint64_t>(type)) *
21 SensorInitParams::kReadBufferSize; 25 SensorInitParams::kReadBufferSize;
22 } 26 }
23 27
28 using CreateSensorCallback =
29 base::Callback<void(scoped_refptr<PlatformSensor>)>;
30 ;
31
24 } // namespace 32 } // namespace
25 33
34 class TestSensorCreateCallback {
35 public:
36 TestSensorCreateCallback()
37 : callback_(base::Bind(&TestSensorCreateCallback::SetResult,
38 base::Unretained(this))) {}
39
40 scoped_refptr<PlatformSensor> WaitForResult() {
41 run_loop_.Run();
42 scoped_refptr<PlatformSensor> sensor = sensor_;
43 sensor_ = nullptr;
44 return sensor;
45 }
46
47 const CreateSensorCallback& callback() const { return callback_; }
48
49 private:
50 void SetResult(scoped_refptr<PlatformSensor> sensor) {
51 sensor_ = sensor;
52 run_loop_.Quit();
53 }
54
55 const CreateSensorCallback callback_;
56 base::RunLoop run_loop_;
57 scoped_refptr<PlatformSensor> sensor_;
58 };
59
26 class PlatformSensorTestClient : public PlatformSensor::Client { 60 class PlatformSensorTestClient : public PlatformSensor::Client {
27 public: 61 public:
28 PlatformSensorTestClient() 62 PlatformSensorTestClient()
29 : notification_suspended_(false), 63 : notification_suspended_(false),
30 sensor_reading_changed_(false), 64 sensor_reading_changed_(false),
31 sensor_error_(false) {} 65 sensor_error_(false) {}
32 66
33 ~PlatformSensorTestClient() override { 67 ~PlatformSensorTestClient() override {
34 if (sensor_) 68 if (sensor_)
35 sensor_->RemoveClient(this); 69 sensor_->RemoveClient(this);
(...skipping 22 matching lines...) Expand all
58 private: 92 private:
59 scoped_refptr<PlatformSensor> sensor_; 93 scoped_refptr<PlatformSensor> sensor_;
60 bool notification_suspended_; 94 bool notification_suspended_;
61 bool sensor_reading_changed_; 95 bool sensor_reading_changed_;
62 bool sensor_error_; 96 bool sensor_error_;
63 }; 97 };
64 98
65 class PlatformSensorProviderTest : public ::testing::Test { 99 class PlatformSensorProviderTest : public ::testing::Test {
66 public: 100 public:
67 PlatformSensorProviderTest() 101 PlatformSensorProviderTest()
68 : sensor_client_(new PlatformSensorTestClient()) {} 102 : sensor_client_(new PlatformSensorTestClient()) {
103 message_loop_.reset(new base::MessageLoopForIO);
104 }
69 105
70 protected: 106 protected:
71 scoped_refptr<PlatformSensor> CreateSensor(mojom::SensorType type) { 107 scoped_refptr<PlatformSensor> CreateSensor(
72 return FakePlatformSensorProvider::GetInstance()->CreateSensor( 108 mojom::SensorType type,
73 type, SensorInitParams::kReadBufferSize, GetBufferOffset(type)); 109 TestSensorCreateCallback* callback) {
110 FakePlatformSensorProvider::GetInstance()->CreateSensor(
111 type, SensorInitParams::kReadBufferSize, GetBufferOffset(type),
112 callback->callback());
113 return callback->WaitForResult();
74 } 114 }
75 115
76 std::unique_ptr<PlatformSensorTestClient> sensor_client_; 116 std::unique_ptr<PlatformSensorTestClient> sensor_client_;
117 std::unique_ptr<base::MessageLoop> message_loop_;
77 }; 118 };
78 119
79 TEST_F(PlatformSensorProviderTest, CreateSensorsAndCheckType) { 120 TEST_F(PlatformSensorProviderTest, CreateSensorsAndCheckType) {
121 TestSensorCreateCallback callback1;
80 scoped_refptr<PlatformSensor> sensor1 = 122 scoped_refptr<PlatformSensor> sensor1 =
81 CreateSensor(SensorType::AMBIENT_LIGHT); 123 CreateSensor(SensorType::AMBIENT_LIGHT, &callback1);
82 EXPECT_TRUE(sensor1); 124 EXPECT_TRUE(sensor1);
83 EXPECT_EQ(SensorType::AMBIENT_LIGHT, sensor1->GetType()); 125 EXPECT_EQ(SensorType::AMBIENT_LIGHT, sensor1->GetType());
84 126
85 scoped_refptr<PlatformSensor> sensor2 = CreateSensor(SensorType::PROXIMITY); 127 TestSensorCreateCallback callback2;
128 scoped_refptr<PlatformSensor> sensor2 =
129 CreateSensor(SensorType::PROXIMITY, &callback2);
86 EXPECT_TRUE(sensor2); 130 EXPECT_TRUE(sensor2);
87 EXPECT_EQ(SensorType::PROXIMITY, sensor2->GetType()); 131 EXPECT_EQ(SensorType::PROXIMITY, sensor2->GetType());
88 132
133 TestSensorCreateCallback callback3;
89 scoped_refptr<PlatformSensor> sensor3 = 134 scoped_refptr<PlatformSensor> sensor3 =
90 CreateSensor(SensorType::ACCELEROMETER); 135 CreateSensor(SensorType::ACCELEROMETER, &callback3);
91 EXPECT_TRUE(sensor3); 136 EXPECT_TRUE(sensor3);
92 EXPECT_EQ(SensorType::ACCELEROMETER, sensor3->GetType()); 137 EXPECT_EQ(SensorType::ACCELEROMETER, sensor3->GetType());
93 138
94 scoped_refptr<PlatformSensor> sensor4 = CreateSensor(SensorType::GYROSCOPE); 139 TestSensorCreateCallback callback4;
140 scoped_refptr<PlatformSensor> sensor4 =
141 CreateSensor(SensorType::GYROSCOPE, &callback4);
95 EXPECT_TRUE(sensor4); 142 EXPECT_TRUE(sensor4);
96 EXPECT_EQ(SensorType::GYROSCOPE, sensor4->GetType()); 143 EXPECT_EQ(SensorType::GYROSCOPE, sensor4->GetType());
97 144
98 scoped_refptr<PlatformSensor> sensor5 = CreateSensor(SensorType::PRESSURE); 145 TestSensorCreateCallback callback5;
146 scoped_refptr<PlatformSensor> sensor5 =
147 CreateSensor(SensorType::PRESSURE, &callback5);
99 EXPECT_TRUE(sensor5); 148 EXPECT_TRUE(sensor5);
100 EXPECT_EQ(SensorType::PRESSURE, sensor5->GetType()); 149 EXPECT_EQ(SensorType::PRESSURE, sensor5->GetType());
101 } 150 }
102 151
103 TEST_F(PlatformSensorProviderTest, CreateAndGetSensor) { 152 TEST_F(PlatformSensorProviderTest, CreateAndGetSensor) {
104 PlatformSensorProvider* sensor_provider = 153 PlatformSensorProvider* sensor_provider =
105 FakePlatformSensorProvider::GetInstance(); 154 FakePlatformSensorProvider::GetInstance();
106 155
107 // Create Ambient Light sensor. 156 // Create Ambient Light sensor.
157 TestSensorCreateCallback callback1;
108 scoped_refptr<PlatformSensor> sensor1 = 158 scoped_refptr<PlatformSensor> sensor1 =
109 CreateSensor(SensorType::AMBIENT_LIGHT); 159 CreateSensor(SensorType::AMBIENT_LIGHT, &callback1);
110 EXPECT_TRUE(sensor1); 160 EXPECT_TRUE(sensor1);
111 EXPECT_EQ(SensorType::AMBIENT_LIGHT, sensor1->GetType()); 161 EXPECT_EQ(SensorType::AMBIENT_LIGHT, sensor1->GetType());
112 162
113 // Try to get Gyroscope sensor, which has not been created yet. 163 // Try to get Gyroscope sensor, which has not been created yet.
114 scoped_refptr<PlatformSensor> sensor2 = 164 scoped_refptr<PlatformSensor> sensor2 =
115 sensor_provider->GetSensor(SensorType::GYROSCOPE); 165 sensor_provider->GetSensor(SensorType::GYROSCOPE);
116 EXPECT_FALSE(sensor2); 166 EXPECT_FALSE(sensor2);
117 167
118 // Get Ambient Light sensor. 168 // Get Ambient Light sensor.
119 scoped_refptr<PlatformSensor> sensor3 = 169 scoped_refptr<PlatformSensor> sensor3 =
120 sensor_provider->GetSensor(SensorType::AMBIENT_LIGHT); 170 sensor_provider->GetSensor(SensorType::AMBIENT_LIGHT);
121 EXPECT_TRUE(sensor3); 171 EXPECT_TRUE(sensor3);
122 172
123 EXPECT_EQ(sensor1->GetType(), sensor3->GetType()); 173 EXPECT_EQ(sensor1->GetType(), sensor3->GetType());
124 174
125 // Try to create a sensor with zero buffer and offset. 175 // Try to create a sensor with zero buffer and offset.
126 scoped_refptr<PlatformSensor> sensor4 = 176 TestSensorCreateCallback callback4;
127 sensor_provider->CreateSensor(SensorType::GYROSCOPE, 0, 0); 177 sensor_provider->CreateSensor(SensorType::GYROSCOPE, 0, 0,
178 callback4.callback());
179 scoped_refptr<PlatformSensor> sensor4 = callback4.WaitForResult();
128 EXPECT_FALSE(sensor4); 180 EXPECT_FALSE(sensor4);
129 181
130 scoped_refptr<PlatformSensor> sensor5 = 182 scoped_refptr<PlatformSensor> sensor5 =
131 sensor_provider->GetSensor(SensorType::GYROSCOPE); 183 sensor_provider->GetSensor(SensorType::GYROSCOPE);
132 EXPECT_FALSE(sensor5); 184 EXPECT_FALSE(sensor5);
133 } 185 }
134 186
135 TEST_F(PlatformSensorProviderTest, TestSensorLeaks) { 187 TEST_F(PlatformSensorProviderTest, TestSensorLeaks) {
136 PlatformSensorProvider* sensor_provider = 188 PlatformSensorProvider* sensor_provider =
137 FakePlatformSensorProvider::GetInstance(); 189 FakePlatformSensorProvider::GetInstance();
138 190
139 // Create Ambient Light sensor. 191 // Create Ambient Light sensor.
192 TestSensorCreateCallback callback1;
140 scoped_refptr<PlatformSensor> sensor1 = 193 scoped_refptr<PlatformSensor> sensor1 =
141 CreateSensor(SensorType::AMBIENT_LIGHT); 194 CreateSensor(SensorType::AMBIENT_LIGHT, &callback1);
142 EXPECT_TRUE(sensor1); 195 EXPECT_TRUE(sensor1);
143 EXPECT_EQ(SensorType::AMBIENT_LIGHT, sensor1->GetType()); 196 EXPECT_EQ(SensorType::AMBIENT_LIGHT, sensor1->GetType());
144 197
145 // Sensor should be automatically destroyed. 198 // Sensor should be automatically destroyed.
146 sensor1 = nullptr; 199 sensor1 = nullptr;
147 scoped_refptr<PlatformSensor> sensor2 = 200 scoped_refptr<PlatformSensor> sensor2 =
148 sensor_provider->GetSensor(SensorType::AMBIENT_LIGHT); 201 sensor_provider->GetSensor(SensorType::AMBIENT_LIGHT);
149 EXPECT_FALSE(sensor2); 202 EXPECT_FALSE(sensor2);
150 } 203 }
151 204
152 // This test assumes that a mock sensor has a constant maximum frequency value 205 // This test assumes that a mock sensor has a constant maximum frequency value
153 // of 50 hz (different from the base sensor class that has a range from 0 to 206 // of 50 hz (different from the base sensor class that has a range from 0 to
154 // 60) and tests whether a mock sensor can be started with a value range from 0 207 // 60) and tests whether a mock sensor can be started with a value range from 0
155 // to 60. 208 // to 60.
156 TEST_F(PlatformSensorProviderTest, StartListeningWithDifferentParameters) { 209 TEST_F(PlatformSensorProviderTest, StartListeningWithDifferentParameters) {
157 const double too_high_frequency = 60; 210 const double too_high_frequency = 60;
158 const double normal_frequency = 39; 211 const double normal_frequency = 39;
212 TestSensorCreateCallback callback;
159 scoped_refptr<PlatformSensor> sensor = 213 scoped_refptr<PlatformSensor> sensor =
160 CreateSensor(SensorType::AMBIENT_LIGHT); 214 CreateSensor(SensorType::AMBIENT_LIGHT, &callback);
161 FakePlatformSensor* fake_sensor = 215 FakePlatformSensor* fake_sensor =
162 static_cast<FakePlatformSensor*>(sensor.get()); 216 static_cast<FakePlatformSensor*>(sensor.get());
163 EXPECT_TRUE(fake_sensor); 217 EXPECT_TRUE(fake_sensor);
164 sensor_client_->SetSensor(sensor); 218 sensor_client_->SetSensor(sensor);
165 219
166 PlatformSensorConfiguration config(too_high_frequency); 220 PlatformSensorConfiguration config(too_high_frequency);
167 EXPECT_EQ(too_high_frequency, config.frequency()); 221 EXPECT_EQ(too_high_frequency, config.frequency());
168 EXPECT_FALSE(fake_sensor->StartListening(sensor_client_.get(), config)); 222 EXPECT_FALSE(fake_sensor->StartListening(sensor_client_.get(), config));
169 EXPECT_FALSE(fake_sensor->started()); 223 EXPECT_FALSE(fake_sensor->started());
170 224
171 config.set_frequency(normal_frequency); 225 config.set_frequency(normal_frequency);
172 EXPECT_EQ(normal_frequency, config.frequency()); 226 EXPECT_EQ(normal_frequency, config.frequency());
173 EXPECT_TRUE(fake_sensor->StartListening(sensor_client_.get(), config)); 227 EXPECT_TRUE(fake_sensor->StartListening(sensor_client_.get(), config));
174 EXPECT_TRUE(fake_sensor->started()); 228 EXPECT_TRUE(fake_sensor->started());
175 229
176 EXPECT_TRUE(fake_sensor->StopListening(sensor_client_.get(), config)); 230 EXPECT_TRUE(fake_sensor->StopListening(sensor_client_.get(), config));
177 EXPECT_FALSE(fake_sensor->started()); 231 EXPECT_FALSE(fake_sensor->started());
178 } 232 }
179 233
180 // If a client is in a suspended mode, a NotifySensorReadingChanged() 234 // If a client is in a suspended mode, a NotifySensorReadingChanged()
181 // notification must not be sent to the client but NotifySensorError() must be. 235 // notification must not be sent to the client but NotifySensorError() must be.
182 TEST_F(PlatformSensorProviderTest, TestNotificationSuspended) { 236 TEST_F(PlatformSensorProviderTest, TestNotificationSuspended) {
183 const int num = 5; 237 const int num = 5;
184 scoped_refptr<PlatformSensor> sensor = CreateSensor(SensorType::GYROSCOPE); 238 TestSensorCreateCallback callback;
239 scoped_refptr<PlatformSensor> sensor =
240 CreateSensor(SensorType::GYROSCOPE, &callback);
185 FakePlatformSensor* fake_sensor = 241 FakePlatformSensor* fake_sensor =
186 static_cast<FakePlatformSensor*>(sensor.get()); 242 static_cast<FakePlatformSensor*>(sensor.get());
187 243
188 std::vector<std::unique_ptr<PlatformSensorTestClient>> clients; 244 std::vector<std::unique_ptr<PlatformSensorTestClient>> clients;
189 for (int i = 0; i < num; i++) { 245 for (int i = 0; i < num; i++) {
190 std::unique_ptr<PlatformSensorTestClient> client( 246 std::unique_ptr<PlatformSensorTestClient> client(
191 new PlatformSensorTestClient()); 247 new PlatformSensorTestClient());
192 client->SetSensor(fake_sensor); 248 client->SetSensor(fake_sensor);
193 clients.push_back(std::move(client)); 249 clients.push_back(std::move(client));
194 } 250 }
(...skipping 17 matching lines...) Expand all
212 for (auto const& client : clients) { 268 for (auto const& client : clients) {
213 EXPECT_TRUE(client->sensor_reading_changed()); 269 EXPECT_TRUE(client->sensor_reading_changed());
214 EXPECT_TRUE(client->sensor_error()); 270 EXPECT_TRUE(client->sensor_error());
215 } 271 }
216 } 272 }
217 273
218 // Tests that when all clients are removed, config maps are removed as well. 274 // Tests that when all clients are removed, config maps are removed as well.
219 TEST_F(PlatformSensorProviderTest, TestAddRemoveClients) { 275 TEST_F(PlatformSensorProviderTest, TestAddRemoveClients) {
220 const int num = 5; 276 const int num = 5;
221 277
278 TestSensorCreateCallback callback;
222 scoped_refptr<PlatformSensor> sensor = 279 scoped_refptr<PlatformSensor> sensor =
223 CreateSensor(SensorType::AMBIENT_LIGHT); 280 CreateSensor(SensorType::AMBIENT_LIGHT, &callback);
224 FakePlatformSensor* fake_sensor = 281 FakePlatformSensor* fake_sensor =
225 static_cast<FakePlatformSensor*>(sensor.get()); 282 static_cast<FakePlatformSensor*>(sensor.get());
226 EXPECT_TRUE(fake_sensor->config_map().empty()); 283 EXPECT_TRUE(fake_sensor->config_map().empty());
227 284
228 std::vector<std::unique_ptr<PlatformSensorTestClient>> clients; 285 std::vector<std::unique_ptr<PlatformSensorTestClient>> clients;
229 PlatformSensorConfiguration config(30); 286 PlatformSensorConfiguration config(30);
230 for (int i = 0; i < num; i++) { 287 for (int i = 0; i < num; i++) {
231 std::unique_ptr<PlatformSensorTestClient> client( 288 std::unique_ptr<PlatformSensorTestClient> client(
232 new PlatformSensorTestClient()); 289 new PlatformSensorTestClient());
233 client->SetSensor(fake_sensor); 290 client->SetSensor(fake_sensor);
234 EXPECT_TRUE(fake_sensor->StartListening(client.get(), config)); 291 EXPECT_TRUE(fake_sensor->StartListening(client.get(), config));
235 EXPECT_TRUE(fake_sensor->started()); 292 EXPECT_TRUE(fake_sensor->started());
236 293
237 clients.push_back(std::move(client)); 294 clients.push_back(std::move(client));
238 } 295 }
239 EXPECT_FALSE(fake_sensor->config_map().empty()); 296 EXPECT_FALSE(fake_sensor->config_map().empty());
240 297
241 for (const auto& client : clients) 298 for (const auto& client : clients)
242 fake_sensor->RemoveClient(client.get()); 299 fake_sensor->RemoveClient(client.get());
243 300
244 EXPECT_TRUE(fake_sensor->config_map().empty()); 301 EXPECT_TRUE(fake_sensor->config_map().empty());
245 } 302 }
246 303
247 // Tests a sensor cannot be updated if it has one suspended client. 304 // Tests a sensor cannot be updated if it has one suspended client.
248 TEST_F(PlatformSensorProviderTest, TestUpdateSensorOneClient) { 305 TEST_F(PlatformSensorProviderTest, TestUpdateSensorOneClient) {
306 TestSensorCreateCallback callback;
249 scoped_refptr<PlatformSensor> sensor = 307 scoped_refptr<PlatformSensor> sensor =
250 CreateSensor(SensorType::AMBIENT_LIGHT); 308 CreateSensor(SensorType::AMBIENT_LIGHT, &callback);
251 FakePlatformSensor* fake_sensor = 309 FakePlatformSensor* fake_sensor =
252 static_cast<FakePlatformSensor*>(sensor.get()); 310 static_cast<FakePlatformSensor*>(sensor.get());
253 EXPECT_TRUE(fake_sensor->config_map().empty()); 311 EXPECT_TRUE(fake_sensor->config_map().empty());
254 312
255 sensor_client_->SetSensor(fake_sensor); 313 sensor_client_->SetSensor(fake_sensor);
256 314
257 PlatformSensorConfiguration config(30); 315 PlatformSensorConfiguration config(30);
258 fake_sensor->StartListening(sensor_client_.get(), config); 316 fake_sensor->StartListening(sensor_client_.get(), config);
259 317
260 sensor_client_->set_notification_suspended(true); 318 sensor_client_->set_notification_suspended(true);
261 EXPECT_TRUE(sensor_client_->IsNotificationSuspended()); 319 EXPECT_TRUE(sensor_client_->IsNotificationSuspended());
262 320
263 fake_sensor->UpdateSensor(); 321 fake_sensor->UpdateSensor();
264 EXPECT_FALSE(fake_sensor->started()); 322 EXPECT_FALSE(fake_sensor->started());
265 323
266 sensor_client_->set_notification_suspended(false); 324 sensor_client_->set_notification_suspended(false);
267 EXPECT_FALSE(sensor_client_->IsNotificationSuspended()); 325 EXPECT_FALSE(sensor_client_->IsNotificationSuspended());
268 326
269 fake_sensor->UpdateSensor(); 327 fake_sensor->UpdateSensor();
270 EXPECT_TRUE(fake_sensor->started()); 328 EXPECT_TRUE(fake_sensor->started());
271 } 329 }
272 330
273 // Tests a sensor can be updated if it has one suspended client and other 331 // Tests a sensor can be updated if it has one suspended client and other
274 // clients are not suspended. 332 // clients are not suspended.
275 TEST_F(PlatformSensorProviderTest, TestUpdateSensorManyClients) { 333 TEST_F(PlatformSensorProviderTest, TestUpdateSensorManyClients) {
276 const int num = 5; 334 const int num = 5;
277 335
336 TestSensorCreateCallback callback;
278 scoped_refptr<PlatformSensor> sensor = 337 scoped_refptr<PlatformSensor> sensor =
279 CreateSensor(SensorType::AMBIENT_LIGHT); 338 CreateSensor(SensorType::AMBIENT_LIGHT, &callback);
280 FakePlatformSensor* fake_sensor = 339 FakePlatformSensor* fake_sensor =
281 static_cast<FakePlatformSensor*>(sensor.get()); 340 static_cast<FakePlatformSensor*>(sensor.get());
282 EXPECT_TRUE(fake_sensor->config_map().empty()); 341 EXPECT_TRUE(fake_sensor->config_map().empty());
283 342
284 sensor_client_->SetSensor(fake_sensor); 343 sensor_client_->SetSensor(fake_sensor);
285 std::vector<std::unique_ptr<PlatformSensorTestClient>> clients; 344 std::vector<std::unique_ptr<PlatformSensorTestClient>> clients;
286 for (int i = 0; i < num; i++) { 345 for (int i = 0; i < num; i++) {
287 std::unique_ptr<PlatformSensorTestClient> client( 346 std::unique_ptr<PlatformSensorTestClient> client(
288 new PlatformSensorTestClient()); 347 new PlatformSensorTestClient());
289 client->SetSensor(fake_sensor); 348 client->SetSensor(fake_sensor);
(...skipping 19 matching lines...) Expand all
309 sensor_client_->set_notification_suspended(false); 368 sensor_client_->set_notification_suspended(false);
310 EXPECT_FALSE(sensor_client_->IsNotificationSuspended()); 369 EXPECT_FALSE(sensor_client_->IsNotificationSuspended());
311 for (const auto& client : clients) 370 for (const auto& client : clients)
312 EXPECT_FALSE(client->IsNotificationSuspended()); 371 EXPECT_FALSE(client->IsNotificationSuspended());
313 372
314 fake_sensor->UpdateSensor(); 373 fake_sensor->UpdateSensor();
315 EXPECT_TRUE(fake_sensor->started()); 374 EXPECT_TRUE(fake_sensor->started());
316 } 375 }
317 376
318 } // namespace device 377 } // namespace device
OLDNEW
« no previous file with comments | « device/generic_sensor/platform_sensor_provider_base.cc ('k') | device/generic_sensor/sensor_provider_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698