Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/orientation.h" | 10 #include "content/browser/device_orientation/orientation.h" |
| 11 #include "content/browser/device_orientation/provider.h" | 11 #include "content/browser/device_orientation/provider.h" |
| 12 #include "content/browser/device_orientation/provider_impl.h" | 12 #include "content/browser/device_orientation/provider_impl.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 namespace device_orientation { | 15 namespace device_orientation { |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 // Class for checking expectations on orientation updates from the Provider. | 18 // Class for checking expectations on orientation updates from the Provider. |
| 19 class UpdateChecker : public Provider::Observer { | 19 class OrientationUpdateChecker : public Provider::OrientationObserver { |
| 20 public: | 20 public: |
| 21 explicit UpdateChecker(int* expectations_count_ptr) | 21 explicit OrientationUpdateChecker(int* expectations_count_ptr) |
| 22 : expectations_count_ptr_(expectations_count_ptr) { | 22 : expectations_count_ptr_(expectations_count_ptr) { |
| 23 } | 23 } |
| 24 | 24 |
| 25 virtual ~UpdateChecker() {} | 25 virtual ~OrientationUpdateChecker() {} |
| 26 | 26 |
| 27 // From Provider::Observer. | 27 // From Provider::OrientationObserver. |
| 28 virtual void OnOrientationUpdate(const Orientation& orientation) { | 28 virtual void OnOrientationUpdate(const Orientation& orientation) { |
| 29 ASSERT_FALSE(expectations_queue_.empty()); | 29 ASSERT_FALSE(expectations_queue_.empty()); |
| 30 | 30 |
| 31 Orientation expected = expectations_queue_.front(); | 31 Orientation expected = expectations_queue_.front(); |
| 32 expectations_queue_.pop(); | 32 expectations_queue_.pop(); |
| 33 | 33 |
| 34 EXPECT_EQ(expected.can_provide_alpha_, orientation.can_provide_alpha_); | 34 EXPECT_EQ(expected.can_provide_alpha_, orientation.can_provide_alpha_); |
| 35 EXPECT_EQ(expected.can_provide_beta_, orientation.can_provide_beta_); | 35 EXPECT_EQ(expected.can_provide_beta_, orientation.can_provide_beta_); |
| 36 EXPECT_EQ(expected.can_provide_gamma_, orientation.can_provide_gamma_); | 36 EXPECT_EQ(expected.can_provide_gamma_, orientation.can_provide_gamma_); |
| 37 EXPECT_EQ(expected.can_provide_absolute_, | 37 EXPECT_EQ(expected.can_provide_absolute_, |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 // Provider instance under test. | 177 // Provider instance under test. |
| 178 scoped_refptr<Provider> provider_; | 178 scoped_refptr<Provider> provider_; |
| 179 | 179 |
| 180 // Message loop for the test thread. | 180 // Message loop for the test thread. |
| 181 MessageLoop message_loop_; | 181 MessageLoop message_loop_; |
| 182 }; | 182 }; |
| 183 | 183 |
| 184 TEST_F(DeviceOrientationProviderTest, FailingTest) { | 184 TEST_F(DeviceOrientationProviderTest, FailingTest) { |
| 185 Init(FailingDataFetcher::Create); | 185 Init(FailingDataFetcher::Create); |
| 186 | 186 |
| 187 scoped_ptr<UpdateChecker> checker_a( | 187 scoped_ptr<OrientationUpdateChecker> checker_a( |
| 188 new UpdateChecker(&pending_expectations_)); | 188 new OrientationUpdateChecker(&pending_expectations_)); |
| 189 scoped_ptr<UpdateChecker> checker_b( | 189 scoped_ptr<OrientationUpdateChecker> checker_b( |
| 190 new UpdateChecker(&pending_expectations_)); | 190 new OrientationUpdateChecker(&pending_expectations_)); |
| 191 | 191 |
| 192 checker_a->AddExpectation(Orientation::Empty()); | 192 checker_a->AddExpectation(Orientation::Empty()); |
| 193 provider_->AddObserver(checker_a.get()); | 193 provider_->AddOrientationObserver(checker_a.get()); |
| 194 MessageLoop::current()->Run(); | 194 MessageLoop::current()->Run(); |
| 195 | 195 |
| 196 checker_b->AddExpectation(Orientation::Empty()); | 196 checker_b->AddExpectation(Orientation::Empty()); |
| 197 provider_->AddObserver(checker_b.get()); | 197 provider_->AddOrientationObserver(checker_b.get()); |
| 198 MessageLoop::current()->Run(); | 198 MessageLoop::current()->Run(); |
| 199 } | 199 } |
| 200 | 200 |
| 201 TEST_F(DeviceOrientationProviderTest, ProviderIsSingleton) { | 201 TEST_F(DeviceOrientationProviderTest, ProviderIsSingleton) { |
| 202 Init(FailingDataFetcher::Create); | 202 Init(FailingDataFetcher::Create); |
| 203 | 203 |
| 204 scoped_refptr<Provider> provider_a(Provider::GetInstance()); | 204 scoped_refptr<Provider> provider_a(Provider::GetInstance()); |
| 205 scoped_refptr<Provider> provider_b(Provider::GetInstance()); | 205 scoped_refptr<Provider> provider_b(Provider::GetInstance()); |
| 206 | 206 |
| 207 EXPECT_EQ(provider_a.get(), provider_b.get()); | 207 EXPECT_EQ(provider_a.get(), provider_b.get()); |
| 208 } | 208 } |
| 209 | 209 |
| 210 TEST_F(DeviceOrientationProviderTest, BasicPushTest) { | 210 TEST_F(DeviceOrientationProviderTest, BasicPushTest) { |
| 211 scoped_refptr<MockOrientationFactory> orientation_factory( | 211 scoped_refptr<MockOrientationFactory> orientation_factory( |
| 212 new MockOrientationFactory()); | 212 new MockOrientationFactory()); |
| 213 Init(MockOrientationFactory::CreateDataFetcher); | 213 Init(MockOrientationFactory::CreateDataFetcher); |
| 214 const Orientation kTestOrientation(true, 1, true, 2, true, 3, true, true); | 214 const Orientation kTestOrientation(true, 1, true, 2, true, 3, true, true); |
| 215 | 215 |
| 216 scoped_ptr<UpdateChecker> checker(new UpdateChecker(&pending_expectations_)); | 216 scoped_ptr<OrientationUpdateChecker> checker(new OrientationUpdateChecker( |
| 217 &pending_expectations_)); | |
| 217 checker->AddExpectation(kTestOrientation); | 218 checker->AddExpectation(kTestOrientation); |
| 218 orientation_factory->SetOrientation(kTestOrientation); | 219 orientation_factory->SetOrientation(kTestOrientation); |
| 219 provider_->AddObserver(checker.get()); | 220 provider_->AddOrientationObserver(checker.get()); |
| 220 MessageLoop::current()->Run(); | 221 MessageLoop::current()->Run(); |
| 221 | 222 |
| 222 provider_->RemoveObserver(checker.get()); | 223 provider_->RemoveOrientationObserver(checker.get()); |
| 223 } | 224 } |
| 224 | 225 |
| 225 TEST_F(DeviceOrientationProviderTest, MultipleObserversPushTest) { | 226 TEST_F(DeviceOrientationProviderTest, MultipleOrientationObserversPushTest) { |
| 226 scoped_refptr<MockOrientationFactory> orientation_factory( | 227 scoped_refptr<MockOrientationFactory> orientation_factory( |
| 227 new MockOrientationFactory()); | 228 new MockOrientationFactory()); |
| 228 Init(MockOrientationFactory::CreateDataFetcher); | 229 Init(MockOrientationFactory::CreateDataFetcher); |
| 229 const Orientation kTestOrientations[] = { | 230 const Orientation kTestOrientations[] = { |
| 230 Orientation(true, 1, true, 2, true, 3, true, true), | 231 Orientation(true, 1, true, 2, true, 3, true, true), |
| 231 Orientation(true, 4, true, 5, true, 6, true, false), | 232 Orientation(true, 4, true, 5, true, 6, true, false), |
| 232 Orientation(true, 7, true, 8, true, 9, false, true)}; | 233 Orientation(true, 7, true, 8, true, 9, false, true)}; |
| 233 | 234 |
| 234 scoped_ptr<UpdateChecker> checker_a( | 235 scoped_ptr<OrientationUpdateChecker> checker_a( |
| 235 new UpdateChecker(&pending_expectations_)); | 236 new OrientationUpdateChecker(&pending_expectations_)); |
| 236 scoped_ptr<UpdateChecker> checker_b( | 237 scoped_ptr<OrientationUpdateChecker> checker_b( |
| 237 new UpdateChecker(&pending_expectations_)); | 238 new OrientationUpdateChecker(&pending_expectations_)); |
| 238 scoped_ptr<UpdateChecker> checker_c( | 239 scoped_ptr<OrientationUpdateChecker> checker_c( |
| 239 new UpdateChecker(&pending_expectations_)); | 240 new OrientationUpdateChecker(&pending_expectations_)); |
| 240 | 241 |
| 241 checker_a->AddExpectation(kTestOrientations[0]); | 242 checker_a->AddExpectation(kTestOrientations[0]); |
| 242 orientation_factory->SetOrientation(kTestOrientations[0]); | 243 orientation_factory->SetOrientation(kTestOrientations[0]); |
| 243 provider_->AddObserver(checker_a.get()); | 244 provider_->AddOrientationObserver(checker_a.get()); |
| 244 MessageLoop::current()->Run(); | 245 MessageLoop::current()->Run(); |
| 245 | 246 |
| 246 checker_a->AddExpectation(kTestOrientations[1]); | 247 checker_a->AddExpectation(kTestOrientations[1]); |
| 247 checker_b->AddExpectation(kTestOrientations[0]); | 248 checker_b->AddExpectation(kTestOrientations[0]); |
| 248 checker_b->AddExpectation(kTestOrientations[1]); | 249 checker_b->AddExpectation(kTestOrientations[1]); |
| 249 orientation_factory->SetOrientation(kTestOrientations[1]); | 250 orientation_factory->SetOrientation(kTestOrientations[1]); |
| 250 provider_->AddObserver(checker_b.get()); | 251 provider_->AddOrientationObserver(checker_b.get()); |
| 251 MessageLoop::current()->Run(); | 252 MessageLoop::current()->Run(); |
| 252 | 253 |
| 253 provider_->RemoveObserver(checker_a.get()); | 254 provider_->RemoveOrientationObserver(checker_a.get()); |
| 254 checker_b->AddExpectation(kTestOrientations[2]); | 255 checker_b->AddExpectation(kTestOrientations[2]); |
| 255 checker_c->AddExpectation(kTestOrientations[1]); | 256 checker_c->AddExpectation(kTestOrientations[1]); |
| 256 checker_c->AddExpectation(kTestOrientations[2]); | 257 checker_c->AddExpectation(kTestOrientations[2]); |
| 257 orientation_factory->SetOrientation(kTestOrientations[2]); | 258 orientation_factory->SetOrientation(kTestOrientations[2]); |
| 258 provider_->AddObserver(checker_c.get()); | 259 provider_->AddOrientationObserver(checker_c.get()); |
| 259 MessageLoop::current()->Run(); | 260 MessageLoop::current()->Run(); |
| 260 | 261 |
| 261 provider_->RemoveObserver(checker_b.get()); | 262 provider_->RemoveOrientationObserver(checker_b.get()); |
| 262 provider_->RemoveObserver(checker_c.get()); | 263 provider_->RemoveOrientationObserver(checker_c.get()); |
| 263 } | 264 } |
| 264 | 265 |
| 265 #if defined(OS_LINUX) || defined(OS_WIN) | 266 #if defined(OS_LINUX) || defined(OS_WIN) |
| 266 // Flakily DCHECKs on Linux. See crbug.com/104950. | 267 // Flakily DCHECKs on Linux. See crbug.com/104950. |
| 267 // FLAKY on Win. See crbug.com/104950. | 268 // FLAKY on Win. See crbug.com/104950. |
| 268 #define MAYBE_ObserverNotRemoved DISABLED_ObserverNotRemoved | 269 #define MAYBE_OrientationObserverNotRemoved DISABLED_OrientationObserverNotRemov ed |
| 269 #else | 270 #else |
| 270 #define MAYBE_ObserverNotRemoved ObserverNotRemoved | 271 #define MAYBE_OrientationObserverNotRemoved OrientationObserverNotRemoved |
| 271 #endif | 272 #endif |
| 272 TEST_F(DeviceOrientationProviderTest, MAYBE_ObserverNotRemoved) { | 273 TEST_F(DeviceOrientationProviderTest, MAYBE_OrientationObserverNotRemoved) { |
| 273 scoped_refptr<MockOrientationFactory> orientation_factory( | 274 scoped_refptr<MockOrientationFactory> orientation_factory( |
| 274 new MockOrientationFactory()); | 275 new MockOrientationFactory()); |
| 275 Init(MockOrientationFactory::CreateDataFetcher); | 276 Init(MockOrientationFactory::CreateDataFetcher); |
| 276 const Orientation kTestOrientation(true, 1, true, 2, true, 3, true, true); | 277 const Orientation kTestOrientation(true, 1, true, 2, true, 3, true, true); |
| 277 const Orientation kTestOrientation2(true, 4, true, 5, true, 6, true, false); | 278 const Orientation kTestOrientation2(true, 4, true, 5, true, 6, true, false); |
| 278 | 279 |
| 279 scoped_ptr<UpdateChecker> checker(new UpdateChecker(&pending_expectations_)); | 280 scoped_ptr<OrientationUpdateChecker> checker(new OrientationUpdateChecker( |
| 281 &pending_expectations_)); | |
| 280 checker->AddExpectation(kTestOrientation); | 282 checker->AddExpectation(kTestOrientation); |
| 281 orientation_factory->SetOrientation(kTestOrientation); | 283 orientation_factory->SetOrientation(kTestOrientation); |
| 282 provider_->AddObserver(checker.get()); | 284 provider_->AddOrientationObserver(checker.get()); |
| 283 MessageLoop::current()->Run(); | 285 MessageLoop::current()->Run(); |
| 284 | 286 |
| 285 checker->AddExpectation(kTestOrientation2); | 287 checker->AddExpectation(kTestOrientation2); |
| 286 orientation_factory->SetOrientation(kTestOrientation2); | 288 orientation_factory->SetOrientation(kTestOrientation2); |
| 287 MessageLoop::current()->Run(); | 289 MessageLoop::current()->Run(); |
| 288 | 290 |
| 289 // Note that checker is not removed. This should not be a problem. | 291 // Note that checker is not removed. This should not be a problem. |
| 290 } | 292 } |
| 291 | 293 |
| 292 #if defined(OS_WIN) | 294 #if defined(OS_WIN) |
| 293 // FLAKY on Win. See crbug.com/104950. | 295 // FLAKY on Win. See crbug.com/104950. |
| 294 #define MAYBE_StartFailing DISABLED_StartFailing | 296 #define MAYBE_StartFailing DISABLED_StartFailing |
| 295 #else | 297 #else |
| 296 #define MAYBE_StartFailing StartFailing | 298 #define MAYBE_StartFailing StartFailing |
| 297 #endif | 299 #endif |
| 298 TEST_F(DeviceOrientationProviderTest, MAYBE_StartFailing) { | 300 TEST_F(DeviceOrientationProviderTest, MAYBE_StartFailing) { |
| 299 scoped_refptr<MockOrientationFactory> orientation_factory( | 301 scoped_refptr<MockOrientationFactory> orientation_factory( |
| 300 new MockOrientationFactory()); | 302 new MockOrientationFactory()); |
| 301 Init(MockOrientationFactory::CreateDataFetcher); | 303 Init(MockOrientationFactory::CreateDataFetcher); |
| 302 const Orientation kTestOrientation(true, 1, true, 2, true, 3, true, true); | 304 const Orientation kTestOrientation(true, 1, true, 2, true, 3, true, true); |
| 303 | 305 |
| 304 scoped_ptr<UpdateChecker> checker_a(new UpdateChecker( | 306 scoped_ptr<OrientationUpdateChecker> checker_a(new OrientationUpdateChecker( |
| 305 &pending_expectations_)); | 307 &pending_expectations_)); |
| 306 scoped_ptr<UpdateChecker> checker_b(new UpdateChecker( | 308 scoped_ptr<OrientationUpdateChecker> checker_b(new OrientationUpdateChecker( |
| 307 &pending_expectations_)); | 309 &pending_expectations_)); |
| 308 | 310 |
| 309 orientation_factory->SetOrientation(kTestOrientation); | 311 orientation_factory->SetOrientation(kTestOrientation); |
| 310 checker_a->AddExpectation(kTestOrientation); | 312 checker_a->AddExpectation(kTestOrientation); |
| 311 provider_->AddObserver(checker_a.get()); | 313 provider_->AddOrientationObserver(checker_a.get()); |
| 312 MessageLoop::current()->Run(); | 314 MessageLoop::current()->Run(); |
| 313 | 315 |
| 314 checker_a->AddExpectation(Orientation::Empty()); | 316 checker_a->AddExpectation(Orientation::Empty()); |
| 315 orientation_factory->SetFailing(true); | 317 orientation_factory->SetFailing(true); |
| 316 MessageLoop::current()->Run(); | 318 MessageLoop::current()->Run(); |
| 317 | 319 |
| 318 checker_b->AddExpectation(Orientation::Empty()); | 320 checker_b->AddExpectation(Orientation::Empty()); |
| 319 provider_->AddObserver(checker_b.get()); | 321 provider_->AddOrientationObserver(checker_b.get()); |
| 320 MessageLoop::current()->Run(); | 322 MessageLoop::current()->Run(); |
| 321 | 323 |
| 322 provider_->RemoveObserver(checker_a.get()); | 324 provider_->RemoveOrientationObserver(checker_a.get()); |
| 323 provider_->RemoveObserver(checker_b.get()); | 325 provider_->RemoveOrientationObserver(checker_b.get()); |
| 324 } | 326 } |
| 325 | 327 |
| 326 TEST_F(DeviceOrientationProviderTest, StartStopStart) { | 328 TEST_F(DeviceOrientationProviderTest, StartStopStart) { |
| 327 scoped_refptr<MockOrientationFactory> orientation_factory( | 329 scoped_refptr<MockOrientationFactory> orientation_factory( |
| 328 new MockOrientationFactory()); | 330 new MockOrientationFactory()); |
| 329 Init(MockOrientationFactory::CreateDataFetcher); | 331 Init(MockOrientationFactory::CreateDataFetcher); |
| 330 const Orientation kTestOrientation(true, 1, true, 2, true, 3, true, true); | 332 const Orientation kTestOrientation(true, 1, true, 2, true, 3, true, true); |
| 331 const Orientation kTestOrientation2(true, 4, true, 5, true, 6, true, false); | 333 const Orientation kTestOrientation2(true, 4, true, 5, true, 6, true, false); |
| 332 | 334 |
| 333 scoped_ptr<UpdateChecker> checker_a(new UpdateChecker( | 335 scoped_ptr<OrientationUpdateChecker> checker_a(new OrientationUpdateChecker( |
| 334 &pending_expectations_)); | 336 &pending_expectations_)); |
| 335 scoped_ptr<UpdateChecker> checker_b(new UpdateChecker( | 337 scoped_ptr<OrientationUpdateChecker> checker_b(new OrientationUpdateChecker( |
| 336 &pending_expectations_)); | 338 &pending_expectations_)); |
| 337 | 339 |
| 338 checker_a->AddExpectation(kTestOrientation); | 340 checker_a->AddExpectation(kTestOrientation); |
| 339 orientation_factory->SetOrientation(kTestOrientation); | 341 orientation_factory->SetOrientation(kTestOrientation); |
| 340 provider_->AddObserver(checker_a.get()); | 342 provider_->AddOrientationObserver(checker_a.get()); |
| 341 MessageLoop::current()->Run(); | 343 MessageLoop::current()->Run(); |
| 342 | 344 |
| 343 provider_->RemoveObserver(checker_a.get()); // This stops the Provider. | 345 provider_->RemoveOrientationObserver(checker_a.get()); |
| 346 // This stops the Provider. | |
|
Steve Block
2012/07/04 15:34:38
Comment should be above code.
| |
| 344 | 347 |
| 345 checker_b->AddExpectation(kTestOrientation2); | 348 checker_b->AddExpectation(kTestOrientation2); |
| 346 orientation_factory->SetOrientation(kTestOrientation2); | 349 orientation_factory->SetOrientation(kTestOrientation2); |
| 347 provider_->AddObserver(checker_b.get()); | 350 provider_->AddOrientationObserver(checker_b.get()); |
| 348 MessageLoop::current()->Run(); | 351 MessageLoop::current()->Run(); |
| 349 | 352 |
| 350 provider_->RemoveObserver(checker_b.get()); | 353 provider_->RemoveOrientationObserver(checker_b.get()); |
| 351 } | 354 } |
| 352 | 355 |
| 353 TEST_F(DeviceOrientationProviderTest, SignificantlyDifferent) { | 356 TEST_F(DeviceOrientationProviderTest, SignificantlyDifferent) { |
| 354 scoped_refptr<MockOrientationFactory> orientation_factory( | 357 scoped_refptr<MockOrientationFactory> orientation_factory( |
| 355 new MockOrientationFactory()); | 358 new MockOrientationFactory()); |
| 356 Init(MockOrientationFactory::CreateDataFetcher); | 359 Init(MockOrientationFactory::CreateDataFetcher); |
| 357 | 360 |
| 358 // Values that should be well below or above the implementation's | 361 // Values that should be well below or above the implementation's |
| 359 // significane threshold. | 362 // significane threshold. |
| 360 const double kInsignificantDifference = 1e-6; | 363 const double kInsignificantDifference = 1e-6; |
| 361 const double kSignificantDifference = 30; | 364 const double kSignificantDifference = 30; |
| 362 const double kAlpha = 4, kBeta = 5, kGamma = 6; | 365 const double kAlpha = 4, kBeta = 5, kGamma = 6; |
| 363 | 366 |
| 364 const Orientation first_orientation(true, kAlpha, true, kBeta, true, kGamma, | 367 const Orientation first_orientation(true, kAlpha, true, kBeta, true, kGamma, |
| 365 true, true); | 368 true, true); |
| 366 | 369 |
| 367 const Orientation second_orientation(true, kAlpha + kInsignificantDifference, | 370 const Orientation second_orientation(true, kAlpha + kInsignificantDifference, |
| 368 true, kBeta + kInsignificantDifference, | 371 true, kBeta + kInsignificantDifference, |
| 369 true, kGamma + kInsignificantDifference, | 372 true, kGamma + kInsignificantDifference, |
| 370 true, false); | 373 true, false); |
| 371 | 374 |
| 372 const Orientation third_orientation(true, kAlpha + kSignificantDifference, | 375 const Orientation third_orientation(true, kAlpha + kSignificantDifference, |
| 373 true, kBeta + kSignificantDifference, | 376 true, kBeta + kSignificantDifference, |
| 374 true, kGamma + kSignificantDifference, | 377 true, kGamma + kSignificantDifference, |
| 375 false, true); | 378 false, true); |
| 376 | 379 |
| 377 scoped_ptr<UpdateChecker> checker_a(new UpdateChecker( | 380 scoped_ptr<OrientationUpdateChecker> checker_a(new OrientationUpdateChecker( |
| 378 &pending_expectations_)); | 381 &pending_expectations_)); |
| 379 scoped_ptr<UpdateChecker> checker_b(new UpdateChecker( | 382 scoped_ptr<OrientationUpdateChecker> checker_b(new OrientationUpdateChecker( |
| 380 &pending_expectations_)); | 383 &pending_expectations_)); |
| 381 | 384 |
| 382 | 385 |
| 383 orientation_factory->SetOrientation(first_orientation); | 386 orientation_factory->SetOrientation(first_orientation); |
| 384 checker_a->AddExpectation(first_orientation); | 387 checker_a->AddExpectation(first_orientation); |
| 385 provider_->AddObserver(checker_a.get()); | 388 provider_->AddOrientationObserver(checker_a.get()); |
| 386 MessageLoop::current()->Run(); | 389 MessageLoop::current()->Run(); |
| 387 | 390 |
| 388 // The observers should not see this insignificantly different orientation. | 391 // The orientation observers should not see this insignificantly different |
| 392 // orientation. | |
| 389 orientation_factory->SetOrientation(second_orientation); | 393 orientation_factory->SetOrientation(second_orientation); |
| 390 checker_b->AddExpectation(first_orientation); | 394 checker_b->AddExpectation(first_orientation); |
| 391 provider_->AddObserver(checker_b.get()); | 395 provider_->AddOrientationObserver(checker_b.get()); |
| 392 MessageLoop::current()->Run(); | 396 MessageLoop::current()->Run(); |
| 393 | 397 |
| 394 orientation_factory->SetOrientation(third_orientation); | 398 orientation_factory->SetOrientation(third_orientation); |
| 395 checker_a->AddExpectation(third_orientation); | 399 checker_a->AddExpectation(third_orientation); |
| 396 checker_b->AddExpectation(third_orientation); | 400 checker_b->AddExpectation(third_orientation); |
| 397 MessageLoop::current()->Run(); | 401 MessageLoop::current()->Run(); |
| 398 | 402 |
| 399 provider_->RemoveObserver(checker_a.get()); | 403 provider_->RemoveOrientationObserver(checker_a.get()); |
| 400 provider_->RemoveObserver(checker_b.get()); | 404 provider_->RemoveOrientationObserver(checker_b.get()); |
| 401 } | 405 } |
| 402 | 406 |
| 403 } // namespace | 407 } // namespace |
| 404 | 408 |
| 405 } // namespace device_orientation | 409 } // namespace device_orientation |
| OLD | NEW |