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

Side by Side Diff: content/browser/device_orientation/provider_unittest.cc

Issue 10755002: Refactors DeviceOrientation to make it more extensible (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Handles null device_data in observer Created 8 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <queue> 5 #include <queue>
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/synchronization/lock.h" 8 #include "base/synchronization/lock.h"
9 #include "content/browser/device_orientation/data_fetcher.h" 9 #include "content/browser/device_orientation/data_fetcher.h"
10 #include "content/browser/device_orientation/device_data.h"
10 #include "content/browser/device_orientation/orientation.h" 11 #include "content/browser/device_orientation/orientation.h"
11 #include "content/browser/device_orientation/provider.h" 12 #include "content/browser/device_orientation/provider.h"
12 #include "content/browser/device_orientation/provider_impl.h" 13 #include "content/browser/device_orientation/provider_impl.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace device_orientation { 16 namespace device_orientation {
16 namespace { 17 namespace {
17 18
18 // Class for checking expectations on orientation updates from the Provider. 19 // Class for checking expectations on orientation updates from the Provider.
19 class UpdateChecker : public Provider::Observer { 20 class OrientationUpdateChecker : public Provider::Observer {
20 public: 21 public:
21 explicit UpdateChecker(int* expectations_count_ptr) 22 explicit OrientationUpdateChecker(int* expectations_count_ptr)
22 : expectations_count_ptr_(expectations_count_ptr) { 23 : Observer(DeviceData::kTypeOrientation),
24 expectations_count_ptr_(expectations_count_ptr) {
23 } 25 }
24 26
25 virtual ~UpdateChecker() {} 27 virtual ~OrientationUpdateChecker() {}
26 28
27 // From Provider::Observer. 29 // From Provider::Observer.
28 virtual void OnOrientationUpdate(const Orientation& orientation) { 30 virtual void OnDeviceDataUpdate(const DeviceData* device_data,
31 DeviceData::Type device_data_type) {
29 ASSERT_FALSE(expectations_queue_.empty()); 32 ASSERT_FALSE(expectations_queue_.empty());
30 33
34 const Orientation* orientation = static_cast<const Orientation*>(
35 device_data);
36 const Orientation empty_orientation;
37 if (orientation == NULL && device_data_type == DeviceData::kTypeOrientation)
38 orientation = &empty_orientation;
39 else
40 ASSERT_FALSE(orientation == NULL);
41
31 Orientation expected = expectations_queue_.front(); 42 Orientation expected = expectations_queue_.front();
32 expectations_queue_.pop(); 43 expectations_queue_.pop();
33 44
34 EXPECT_EQ(expected.can_provide_alpha(), orientation.can_provide_alpha()); 45 EXPECT_EQ(expected.can_provide_alpha(), orientation->can_provide_alpha());
35 EXPECT_EQ(expected.can_provide_beta(), orientation.can_provide_beta()); 46 EXPECT_EQ(expected.can_provide_beta(), orientation->can_provide_beta());
36 EXPECT_EQ(expected.can_provide_gamma(), orientation.can_provide_gamma()); 47 EXPECT_EQ(expected.can_provide_gamma(), orientation->can_provide_gamma());
37 EXPECT_EQ(expected.can_provide_absolute(), 48 EXPECT_EQ(expected.can_provide_absolute(),
38 orientation.can_provide_absolute()); 49 orientation->can_provide_absolute());
39 if (expected.can_provide_alpha()) 50 if (expected.can_provide_alpha())
40 EXPECT_EQ(expected.alpha(), orientation.alpha()); 51 EXPECT_EQ(expected.alpha(), orientation->alpha());
41 if (expected.can_provide_beta()) 52 if (expected.can_provide_beta())
42 EXPECT_EQ(expected.beta(), orientation.beta()); 53 EXPECT_EQ(expected.beta(), orientation->beta());
43 if (expected.can_provide_gamma()) 54 if (expected.can_provide_gamma())
44 EXPECT_EQ(expected.gamma(), orientation.gamma()); 55 EXPECT_EQ(expected.gamma(), orientation->gamma());
45 if (expected.can_provide_absolute()) 56 if (expected.can_provide_absolute())
46 EXPECT_EQ(expected.absolute(), orientation.absolute()); 57 EXPECT_EQ(expected.absolute(), orientation->absolute());
47 58
48 --(*expectations_count_ptr_); 59 --(*expectations_count_ptr_);
49 60
50 if (*expectations_count_ptr_ == 0) { 61 if (*expectations_count_ptr_ == 0) {
51 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 62 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
52 } 63 }
53 } 64 }
54 65
55 void AddExpectation(const Orientation& orientation) { 66 void AddExpectation(const Orientation& orientation) {
56 expectations_queue_.push(orientation); 67 expectations_queue_.push(orientation);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 instance_ = NULL; 107 instance_ = NULL;
97 } 108 }
98 109
99 // Owned by ProviderImpl. Holds a reference back to MockOrientationFactory. 110 // Owned by ProviderImpl. Holds a reference back to MockOrientationFactory.
100 class MockDataFetcher : public DataFetcher { 111 class MockDataFetcher : public DataFetcher {
101 public: 112 public:
102 explicit MockDataFetcher(MockOrientationFactory* orientation_factory) 113 explicit MockDataFetcher(MockOrientationFactory* orientation_factory)
103 : orientation_factory_(orientation_factory) { } 114 : orientation_factory_(orientation_factory) { }
104 115
105 // From DataFetcher. Called by the Provider. 116 // From DataFetcher. Called by the Provider.
106 virtual bool GetOrientation(Orientation* orientation) { 117 virtual DeviceData* GetDeviceData(DeviceData::Type device_data_type) {
107 base::AutoLock auto_lock(orientation_factory_->lock_); 118 base::AutoLock auto_lock(orientation_factory_->lock_);
108 if (orientation_factory_->is_failing_) 119 if (orientation_factory_->is_failing_)
109 return false; 120 return NULL;
121 scoped_ptr<Orientation> orientation(new Orientation());
110 *orientation = orientation_factory_->orientation_; 122 *orientation = orientation_factory_->orientation_;
111 return true; 123 return orientation.release();
112 } 124 }
113 125
114 private: 126 private:
115 scoped_refptr<MockOrientationFactory> orientation_factory_; 127 scoped_refptr<MockOrientationFactory> orientation_factory_;
116 }; 128 };
117 129
118 static MockOrientationFactory* instance_; 130 static MockOrientationFactory* instance_;
119 Orientation orientation_; 131 Orientation orientation_;
120 bool is_failing_; 132 bool is_failing_;
121 base::Lock lock_; 133 base::Lock lock_;
122 }; 134 };
123 135
124 MockOrientationFactory* MockOrientationFactory::instance_; 136 MockOrientationFactory* MockOrientationFactory::instance_;
125 137
126 // Mock DataFetcher that always fails to provide any orientation data. 138 // Mock DataFetcher that always fails to provide any orientation data.
127 class FailingDataFetcher : public DataFetcher { 139 class FailingDataFetcher : public DataFetcher {
128 public: 140 public:
129 // Factory method; passed to and called by the ProviderImpl. 141 // Factory method; passed to and called by the ProviderImpl.
130 static DataFetcher* Create() { 142 static DataFetcher* Create() {
131 return new FailingDataFetcher(); 143 return new FailingDataFetcher();
132 } 144 }
133 145
134 // From DataFetcher. 146 // From DataFetcher.
135 virtual bool GetOrientation(Orientation* orientation) { 147 virtual DeviceData* GetDeviceData(DeviceData::Type device_data_type) {
136 return false; 148 return NULL;
137 } 149 }
138 150
139 private: 151 private:
140 FailingDataFetcher() {} 152 FailingDataFetcher() {}
141 }; 153 };
142 154
143 class DeviceOrientationProviderTest : public testing::Test { 155 class DeviceOrientationProviderTest : public testing::Test {
144 public: 156 public:
145 DeviceOrientationProviderTest() 157 DeviceOrientationProviderTest()
146 : pending_expectations_(0) { 158 : pending_expectations_(0) {
(...skipping 30 matching lines...) Expand all
177 // Provider instance under test. 189 // Provider instance under test.
178 scoped_refptr<Provider> provider_; 190 scoped_refptr<Provider> provider_;
179 191
180 // Message loop for the test thread. 192 // Message loop for the test thread.
181 MessageLoop message_loop_; 193 MessageLoop message_loop_;
182 }; 194 };
183 195
184 TEST_F(DeviceOrientationProviderTest, FailingTest) { 196 TEST_F(DeviceOrientationProviderTest, FailingTest) {
185 Init(FailingDataFetcher::Create); 197 Init(FailingDataFetcher::Create);
186 198
187 scoped_ptr<UpdateChecker> checker_a( 199 scoped_ptr<OrientationUpdateChecker> checker_a(
188 new UpdateChecker(&pending_expectations_)); 200 new OrientationUpdateChecker(&pending_expectations_));
189 scoped_ptr<UpdateChecker> checker_b( 201 scoped_ptr<OrientationUpdateChecker> checker_b(
190 new UpdateChecker(&pending_expectations_)); 202 new OrientationUpdateChecker(&pending_expectations_));
191 203
192 checker_a->AddExpectation(Orientation::Empty()); 204 checker_a->AddExpectation(Orientation());
193 provider_->AddObserver(checker_a.get()); 205 provider_->AddObserver(checker_a.get());
194 MessageLoop::current()->Run(); 206 MessageLoop::current()->Run();
195 207
196 checker_b->AddExpectation(Orientation::Empty()); 208 checker_b->AddExpectation(Orientation());
197 provider_->AddObserver(checker_b.get()); 209 provider_->AddObserver(checker_b.get());
198 MessageLoop::current()->Run(); 210 MessageLoop::current()->Run();
199 } 211 }
200 212
201 TEST_F(DeviceOrientationProviderTest, ProviderIsSingleton) { 213 TEST_F(DeviceOrientationProviderTest, ProviderIsSingleton) {
202 Init(FailingDataFetcher::Create); 214 Init(FailingDataFetcher::Create);
203 215
204 scoped_refptr<Provider> provider_a(Provider::GetInstance()); 216 scoped_refptr<Provider> provider_a(Provider::GetInstance());
205 scoped_refptr<Provider> provider_b(Provider::GetInstance()); 217 scoped_refptr<Provider> provider_b(Provider::GetInstance());
206 218
207 EXPECT_EQ(provider_a.get(), provider_b.get()); 219 EXPECT_EQ(provider_a.get(), provider_b.get());
208 } 220 }
209 221
210 TEST_F(DeviceOrientationProviderTest, BasicPushTest) { 222 TEST_F(DeviceOrientationProviderTest, BasicPushTest) {
211 scoped_refptr<MockOrientationFactory> orientation_factory( 223 scoped_refptr<MockOrientationFactory> orientation_factory(
212 new MockOrientationFactory()); 224 new MockOrientationFactory());
213 Init(MockOrientationFactory::CreateDataFetcher); 225 Init(MockOrientationFactory::CreateDataFetcher);
214 Orientation test_orientation; 226 Orientation test_orientation;
215 test_orientation.set_alpha(1); 227 test_orientation.set_alpha(1);
216 test_orientation.set_beta(2); 228 test_orientation.set_beta(2);
217 test_orientation.set_gamma(3); 229 test_orientation.set_gamma(3);
218 test_orientation.set_absolute(true); 230 test_orientation.set_absolute(true);
219 231
220 scoped_ptr<UpdateChecker> checker(new UpdateChecker(&pending_expectations_)); 232 scoped_ptr<OrientationUpdateChecker> checker(
233 new OrientationUpdateChecker(&pending_expectations_));
221 checker->AddExpectation(test_orientation); 234 checker->AddExpectation(test_orientation);
222 orientation_factory->SetOrientation(test_orientation); 235 orientation_factory->SetOrientation(test_orientation);
223 provider_->AddObserver(checker.get()); 236 provider_->AddObserver(checker.get());
224 MessageLoop::current()->Run(); 237 MessageLoop::current()->Run();
225 238
226 provider_->RemoveObserver(checker.get()); 239 provider_->RemoveObserver(checker.get());
227 } 240 }
228 241
229 TEST_F(DeviceOrientationProviderTest, MultipleObserversPushTest) { 242 TEST_F(DeviceOrientationProviderTest, MultipleObserversPushTest) {
230 scoped_refptr<MockOrientationFactory> orientation_factory( 243 scoped_refptr<MockOrientationFactory> orientation_factory(
(...skipping 10 matching lines...) Expand all
241 test_orientations[1].set_alpha(4); 254 test_orientations[1].set_alpha(4);
242 test_orientations[1].set_beta(5); 255 test_orientations[1].set_beta(5);
243 test_orientations[1].set_gamma(6); 256 test_orientations[1].set_gamma(6);
244 test_orientations[1].set_absolute(false); 257 test_orientations[1].set_absolute(false);
245 258
246 test_orientations[2].set_alpha(7); 259 test_orientations[2].set_alpha(7);
247 test_orientations[2].set_beta(8); 260 test_orientations[2].set_beta(8);
248 test_orientations[2].set_gamma(9); 261 test_orientations[2].set_gamma(9);
249 // can't provide absolute 262 // can't provide absolute
250 263
251 scoped_ptr<UpdateChecker> checker_a( 264 scoped_ptr<OrientationUpdateChecker> checker_a(
252 new UpdateChecker(&pending_expectations_)); 265 new OrientationUpdateChecker(&pending_expectations_));
253 scoped_ptr<UpdateChecker> checker_b( 266 scoped_ptr<OrientationUpdateChecker> checker_b(
254 new UpdateChecker(&pending_expectations_)); 267 new OrientationUpdateChecker(&pending_expectations_));
255 scoped_ptr<UpdateChecker> checker_c( 268 scoped_ptr<OrientationUpdateChecker> checker_c(
256 new UpdateChecker(&pending_expectations_)); 269 new OrientationUpdateChecker(&pending_expectations_));
257 270
258 checker_a->AddExpectation(test_orientations[0]); 271 checker_a->AddExpectation(test_orientations[0]);
259 orientation_factory->SetOrientation(test_orientations[0]); 272 orientation_factory->SetOrientation(test_orientations[0]);
260 provider_->AddObserver(checker_a.get()); 273 provider_->AddObserver(checker_a.get());
261 MessageLoop::current()->Run(); 274 MessageLoop::current()->Run();
262 275
263 checker_a->AddExpectation(test_orientations[1]); 276 checker_a->AddExpectation(test_orientations[1]);
264 checker_b->AddExpectation(test_orientations[0]); 277 checker_b->AddExpectation(test_orientations[0]);
265 checker_b->AddExpectation(test_orientations[1]); 278 checker_b->AddExpectation(test_orientations[1]);
266 orientation_factory->SetOrientation(test_orientations[1]); 279 orientation_factory->SetOrientation(test_orientations[1]);
(...skipping 28 matching lines...) Expand all
295 test_orientation.set_beta(2); 308 test_orientation.set_beta(2);
296 test_orientation.set_gamma(3); 309 test_orientation.set_gamma(3);
297 test_orientation.set_absolute(true); 310 test_orientation.set_absolute(true);
298 311
299 Orientation test_orientation2; 312 Orientation test_orientation2;
300 test_orientation2.set_alpha(4); 313 test_orientation2.set_alpha(4);
301 test_orientation2.set_beta(5); 314 test_orientation2.set_beta(5);
302 test_orientation2.set_gamma(6); 315 test_orientation2.set_gamma(6);
303 test_orientation2.set_absolute(false); 316 test_orientation2.set_absolute(false);
304 317
305 scoped_ptr<UpdateChecker> checker(new UpdateChecker(&pending_expectations_)); 318 scoped_ptr<OrientationUpdateChecker> checker(
319 new OrientationUpdateChecker(&pending_expectations_));
306 checker->AddExpectation(test_orientation); 320 checker->AddExpectation(test_orientation);
307 orientation_factory->SetOrientation(test_orientation); 321 orientation_factory->SetOrientation(test_orientation);
308 provider_->AddObserver(checker.get()); 322 provider_->AddObserver(checker.get());
309 MessageLoop::current()->Run(); 323 MessageLoop::current()->Run();
310 324
311 checker->AddExpectation(test_orientation2); 325 checker->AddExpectation(test_orientation2);
312 orientation_factory->SetOrientation(test_orientation2); 326 orientation_factory->SetOrientation(test_orientation2);
313 MessageLoop::current()->Run(); 327 MessageLoop::current()->Run();
314 328
315 // Note that checker is not removed. This should not be a problem. 329 // Note that checker is not removed. This should not be a problem.
316 } 330 }
317 331
318 #if defined(OS_WIN) 332 #if defined(OS_WIN)
319 // FLAKY on Win. See crbug.com/104950. 333 // FLAKY on Win. See crbug.com/104950.
320 #define MAYBE_StartFailing DISABLED_StartFailing 334 #define MAYBE_StartFailing DISABLED_StartFailing
321 #else 335 #else
322 #define MAYBE_StartFailing StartFailing 336 #define MAYBE_StartFailing StartFailing
323 #endif 337 #endif
324 TEST_F(DeviceOrientationProviderTest, MAYBE_StartFailing) { 338 TEST_F(DeviceOrientationProviderTest, MAYBE_StartFailing) {
325 scoped_refptr<MockOrientationFactory> orientation_factory( 339 scoped_refptr<MockOrientationFactory> orientation_factory(
326 new MockOrientationFactory()); 340 new MockOrientationFactory());
327 Init(MockOrientationFactory::CreateDataFetcher); 341 Init(MockOrientationFactory::CreateDataFetcher);
328 Orientation test_orientation; 342 Orientation test_orientation;
329 test_orientation.set_alpha(1); 343 test_orientation.set_alpha(1);
330 test_orientation.set_beta(2); 344 test_orientation.set_beta(2);
331 test_orientation.set_gamma(3); 345 test_orientation.set_gamma(3);
332 test_orientation.set_absolute(true); 346 test_orientation.set_absolute(true);
333 347
334 scoped_ptr<UpdateChecker> checker_a(new UpdateChecker( 348 scoped_ptr<OrientationUpdateChecker> checker_a(new OrientationUpdateChecker(
335 &pending_expectations_)); 349 &pending_expectations_));
336 scoped_ptr<UpdateChecker> checker_b(new UpdateChecker( 350 scoped_ptr<OrientationUpdateChecker> checker_b(new OrientationUpdateChecker(
337 &pending_expectations_)); 351 &pending_expectations_));
338 352
339 orientation_factory->SetOrientation(test_orientation); 353 orientation_factory->SetOrientation(test_orientation);
340 checker_a->AddExpectation(test_orientation); 354 checker_a->AddExpectation(test_orientation);
341 provider_->AddObserver(checker_a.get()); 355 provider_->AddObserver(checker_a.get());
342 MessageLoop::current()->Run(); 356 MessageLoop::current()->Run();
343 357
344 checker_a->AddExpectation(Orientation::Empty()); 358 checker_a->AddExpectation(Orientation());
345 orientation_factory->SetFailing(true); 359 orientation_factory->SetFailing(true);
346 MessageLoop::current()->Run(); 360 MessageLoop::current()->Run();
347 361
348 checker_b->AddExpectation(Orientation::Empty()); 362 checker_b->AddExpectation(Orientation());
349 provider_->AddObserver(checker_b.get()); 363 provider_->AddObserver(checker_b.get());
350 MessageLoop::current()->Run(); 364 MessageLoop::current()->Run();
351 365
352 provider_->RemoveObserver(checker_a.get()); 366 provider_->RemoveObserver(checker_a.get());
353 provider_->RemoveObserver(checker_b.get()); 367 provider_->RemoveObserver(checker_b.get());
354 } 368 }
355 369
356 TEST_F(DeviceOrientationProviderTest, StartStopStart) { 370 TEST_F(DeviceOrientationProviderTest, StartStopStart) {
357 scoped_refptr<MockOrientationFactory> orientation_factory( 371 scoped_refptr<MockOrientationFactory> orientation_factory(
358 new MockOrientationFactory()); 372 new MockOrientationFactory());
359 Init(MockOrientationFactory::CreateDataFetcher); 373 Init(MockOrientationFactory::CreateDataFetcher);
360 374
361 Orientation test_orientation; 375 Orientation test_orientation;
362 test_orientation.set_alpha(1); 376 test_orientation.set_alpha(1);
363 test_orientation.set_beta(2); 377 test_orientation.set_beta(2);
364 test_orientation.set_gamma(3); 378 test_orientation.set_gamma(3);
365 test_orientation.set_absolute(true); 379 test_orientation.set_absolute(true);
366 380
367 Orientation test_orientation2; 381 Orientation test_orientation2;
368 test_orientation2.set_alpha(4); 382 test_orientation2.set_alpha(4);
369 test_orientation2.set_beta(5); 383 test_orientation2.set_beta(5);
370 test_orientation2.set_gamma(6); 384 test_orientation2.set_gamma(6);
371 test_orientation2.set_absolute(false); 385 test_orientation2.set_absolute(false);
372 386
373 scoped_ptr<UpdateChecker> checker_a(new UpdateChecker( 387 scoped_ptr<OrientationUpdateChecker> checker_a(new OrientationUpdateChecker(
374 &pending_expectations_)); 388 &pending_expectations_));
375 scoped_ptr<UpdateChecker> checker_b(new UpdateChecker( 389 scoped_ptr<OrientationUpdateChecker> checker_b(new OrientationUpdateChecker(
376 &pending_expectations_)); 390 &pending_expectations_));
377 391
378 checker_a->AddExpectation(test_orientation); 392 checker_a->AddExpectation(test_orientation);
379 orientation_factory->SetOrientation(test_orientation); 393 orientation_factory->SetOrientation(test_orientation);
380 provider_->AddObserver(checker_a.get()); 394 provider_->AddObserver(checker_a.get());
381 MessageLoop::current()->Run(); 395 MessageLoop::current()->Run();
382 396
383 provider_->RemoveObserver(checker_a.get()); // This stops the Provider. 397 provider_->RemoveObserver(checker_a.get()); // This stops the Provider.
384 398
385 checker_b->AddExpectation(test_orientation2); 399 checker_b->AddExpectation(test_orientation2);
(...skipping 26 matching lines...) Expand all
412 second_orientation.set_beta(kBeta + kInsignificantDifference); 426 second_orientation.set_beta(kBeta + kInsignificantDifference);
413 second_orientation.set_gamma(kGamma + kInsignificantDifference); 427 second_orientation.set_gamma(kGamma + kInsignificantDifference);
414 second_orientation.set_absolute(false); 428 second_orientation.set_absolute(false);
415 429
416 Orientation third_orientation; 430 Orientation third_orientation;
417 third_orientation.set_alpha(kAlpha + kSignificantDifference); 431 third_orientation.set_alpha(kAlpha + kSignificantDifference);
418 third_orientation.set_beta(kBeta + kSignificantDifference); 432 third_orientation.set_beta(kBeta + kSignificantDifference);
419 third_orientation.set_gamma(kGamma + kSignificantDifference); 433 third_orientation.set_gamma(kGamma + kSignificantDifference);
420 // can't provide absolute 434 // can't provide absolute
421 435
422 scoped_ptr<UpdateChecker> checker_a(new UpdateChecker( 436 scoped_ptr<OrientationUpdateChecker> checker_a(new OrientationUpdateChecker(
423 &pending_expectations_)); 437 &pending_expectations_));
424 scoped_ptr<UpdateChecker> checker_b(new UpdateChecker( 438 scoped_ptr<OrientationUpdateChecker> checker_b(new OrientationUpdateChecker(
425 &pending_expectations_)); 439 &pending_expectations_));
426 440
427 441
428 orientation_factory->SetOrientation(first_orientation); 442 orientation_factory->SetOrientation(first_orientation);
429 checker_a->AddExpectation(first_orientation); 443 checker_a->AddExpectation(first_orientation);
430 provider_->AddObserver(checker_a.get()); 444 provider_->AddObserver(checker_a.get());
431 MessageLoop::current()->Run(); 445 MessageLoop::current()->Run();
432 446
433 // The observers should not see this insignificantly different orientation. 447 // The observers should not see this insignificantly different orientation.
434 orientation_factory->SetOrientation(second_orientation); 448 orientation_factory->SetOrientation(second_orientation);
435 checker_b->AddExpectation(first_orientation); 449 checker_b->AddExpectation(first_orientation);
436 provider_->AddObserver(checker_b.get()); 450 provider_->AddObserver(checker_b.get());
437 MessageLoop::current()->Run(); 451 MessageLoop::current()->Run();
438 452
439 orientation_factory->SetOrientation(third_orientation); 453 orientation_factory->SetOrientation(third_orientation);
440 checker_a->AddExpectation(third_orientation); 454 checker_a->AddExpectation(third_orientation);
441 checker_b->AddExpectation(third_orientation); 455 checker_b->AddExpectation(third_orientation);
442 MessageLoop::current()->Run(); 456 MessageLoop::current()->Run();
443 457
444 provider_->RemoveObserver(checker_a.get()); 458 provider_->RemoveObserver(checker_a.get());
445 provider_->RemoveObserver(checker_b.get()); 459 provider_->RemoveObserver(checker_b.get());
446 } 460 }
447 461
448 } // namespace 462 } // namespace
449 463
450 } // namespace device_orientation 464 } // namespace device_orientation
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698