Chromium Code Reviews| Index: content/browser/device_orientation/provider_unittest.cc |
| diff --git a/content/browser/device_orientation/provider_unittest.cc b/content/browser/device_orientation/provider_unittest.cc |
| index 17d3d434b2b3bb3276169e2ed9bd59fed8afb579..5db1aca9977999b1eb42a0138fbeae1d655e5a5f 100644 |
| --- a/content/browser/device_orientation/provider_unittest.cc |
| +++ b/content/browser/device_orientation/provider_unittest.cc |
| @@ -16,15 +16,15 @@ namespace device_orientation { |
| namespace { |
| // Class for checking expectations on orientation updates from the Provider. |
| -class UpdateChecker : public Provider::Observer { |
| +class OrientationUpdateChecker : public Provider::OrientationObserver { |
| public: |
| - explicit UpdateChecker(int* expectations_count_ptr) |
| + explicit OrientationUpdateChecker(int* expectations_count_ptr) |
| : expectations_count_ptr_(expectations_count_ptr) { |
| } |
| - virtual ~UpdateChecker() {} |
| + virtual ~OrientationUpdateChecker() {} |
| - // From Provider::Observer. |
| + // From Provider::OrientationObserver. |
| virtual void OnOrientationUpdate(const Orientation& orientation) { |
| ASSERT_FALSE(expectations_queue_.empty()); |
| @@ -184,17 +184,17 @@ class DeviceOrientationProviderTest : public testing::Test { |
| TEST_F(DeviceOrientationProviderTest, FailingTest) { |
| Init(FailingDataFetcher::Create); |
| - scoped_ptr<UpdateChecker> checker_a( |
| - new UpdateChecker(&pending_expectations_)); |
| - scoped_ptr<UpdateChecker> checker_b( |
| - new UpdateChecker(&pending_expectations_)); |
| + scoped_ptr<OrientationUpdateChecker> checker_a( |
| + new OrientationUpdateChecker(&pending_expectations_)); |
| + scoped_ptr<OrientationUpdateChecker> checker_b( |
| + new OrientationUpdateChecker(&pending_expectations_)); |
| checker_a->AddExpectation(Orientation::Empty()); |
| - provider_->AddObserver(checker_a.get()); |
| + provider_->AddOrientationObserver(checker_a.get()); |
| MessageLoop::current()->Run(); |
| checker_b->AddExpectation(Orientation::Empty()); |
| - provider_->AddObserver(checker_b.get()); |
| + provider_->AddOrientationObserver(checker_b.get()); |
| MessageLoop::current()->Run(); |
| } |
| @@ -213,16 +213,17 @@ TEST_F(DeviceOrientationProviderTest, BasicPushTest) { |
| Init(MockOrientationFactory::CreateDataFetcher); |
| const Orientation kTestOrientation(true, 1, true, 2, true, 3, true, true); |
| - scoped_ptr<UpdateChecker> checker(new UpdateChecker(&pending_expectations_)); |
| + scoped_ptr<OrientationUpdateChecker> checker(new OrientationUpdateChecker( |
| + &pending_expectations_)); |
| checker->AddExpectation(kTestOrientation); |
| orientation_factory->SetOrientation(kTestOrientation); |
| - provider_->AddObserver(checker.get()); |
| + provider_->AddOrientationObserver(checker.get()); |
| MessageLoop::current()->Run(); |
| - provider_->RemoveObserver(checker.get()); |
| + provider_->RemoveOrientationObserver(checker.get()); |
| } |
| -TEST_F(DeviceOrientationProviderTest, MultipleObserversPushTest) { |
| +TEST_F(DeviceOrientationProviderTest, MultipleOrientationObserversPushTest) { |
| scoped_refptr<MockOrientationFactory> orientation_factory( |
| new MockOrientationFactory()); |
| Init(MockOrientationFactory::CreateDataFetcher); |
| @@ -231,55 +232,56 @@ TEST_F(DeviceOrientationProviderTest, MultipleObserversPushTest) { |
| Orientation(true, 4, true, 5, true, 6, true, false), |
| Orientation(true, 7, true, 8, true, 9, false, true)}; |
| - scoped_ptr<UpdateChecker> checker_a( |
| - new UpdateChecker(&pending_expectations_)); |
| - scoped_ptr<UpdateChecker> checker_b( |
| - new UpdateChecker(&pending_expectations_)); |
| - scoped_ptr<UpdateChecker> checker_c( |
| - new UpdateChecker(&pending_expectations_)); |
| + scoped_ptr<OrientationUpdateChecker> checker_a( |
| + new OrientationUpdateChecker(&pending_expectations_)); |
| + scoped_ptr<OrientationUpdateChecker> checker_b( |
| + new OrientationUpdateChecker(&pending_expectations_)); |
| + scoped_ptr<OrientationUpdateChecker> checker_c( |
| + new OrientationUpdateChecker(&pending_expectations_)); |
| checker_a->AddExpectation(kTestOrientations[0]); |
| orientation_factory->SetOrientation(kTestOrientations[0]); |
| - provider_->AddObserver(checker_a.get()); |
| + provider_->AddOrientationObserver(checker_a.get()); |
| MessageLoop::current()->Run(); |
| checker_a->AddExpectation(kTestOrientations[1]); |
| checker_b->AddExpectation(kTestOrientations[0]); |
| checker_b->AddExpectation(kTestOrientations[1]); |
| orientation_factory->SetOrientation(kTestOrientations[1]); |
| - provider_->AddObserver(checker_b.get()); |
| + provider_->AddOrientationObserver(checker_b.get()); |
| MessageLoop::current()->Run(); |
| - provider_->RemoveObserver(checker_a.get()); |
| + provider_->RemoveOrientationObserver(checker_a.get()); |
| checker_b->AddExpectation(kTestOrientations[2]); |
| checker_c->AddExpectation(kTestOrientations[1]); |
| checker_c->AddExpectation(kTestOrientations[2]); |
| orientation_factory->SetOrientation(kTestOrientations[2]); |
| - provider_->AddObserver(checker_c.get()); |
| + provider_->AddOrientationObserver(checker_c.get()); |
| MessageLoop::current()->Run(); |
| - provider_->RemoveObserver(checker_b.get()); |
| - provider_->RemoveObserver(checker_c.get()); |
| + provider_->RemoveOrientationObserver(checker_b.get()); |
| + provider_->RemoveOrientationObserver(checker_c.get()); |
| } |
| #if defined(OS_LINUX) || defined(OS_WIN) |
| // Flakily DCHECKs on Linux. See crbug.com/104950. |
| // FLAKY on Win. See crbug.com/104950. |
| -#define MAYBE_ObserverNotRemoved DISABLED_ObserverNotRemoved |
| +#define MAYBE_OrientationObserverNotRemoved DISABLED_OrientationObserverNotRemoved |
| #else |
| -#define MAYBE_ObserverNotRemoved ObserverNotRemoved |
| +#define MAYBE_OrientationObserverNotRemoved OrientationObserverNotRemoved |
| #endif |
| -TEST_F(DeviceOrientationProviderTest, MAYBE_ObserverNotRemoved) { |
| +TEST_F(DeviceOrientationProviderTest, MAYBE_OrientationObserverNotRemoved) { |
| scoped_refptr<MockOrientationFactory> orientation_factory( |
| new MockOrientationFactory()); |
| Init(MockOrientationFactory::CreateDataFetcher); |
| const Orientation kTestOrientation(true, 1, true, 2, true, 3, true, true); |
| const Orientation kTestOrientation2(true, 4, true, 5, true, 6, true, false); |
| - scoped_ptr<UpdateChecker> checker(new UpdateChecker(&pending_expectations_)); |
| + scoped_ptr<OrientationUpdateChecker> checker(new OrientationUpdateChecker( |
| + &pending_expectations_)); |
| checker->AddExpectation(kTestOrientation); |
| orientation_factory->SetOrientation(kTestOrientation); |
| - provider_->AddObserver(checker.get()); |
| + provider_->AddOrientationObserver(checker.get()); |
| MessageLoop::current()->Run(); |
| checker->AddExpectation(kTestOrientation2); |
| @@ -301,14 +303,14 @@ TEST_F(DeviceOrientationProviderTest, MAYBE_StartFailing) { |
| Init(MockOrientationFactory::CreateDataFetcher); |
| const Orientation kTestOrientation(true, 1, true, 2, true, 3, true, true); |
| - scoped_ptr<UpdateChecker> checker_a(new UpdateChecker( |
| + scoped_ptr<OrientationUpdateChecker> checker_a(new OrientationUpdateChecker( |
| &pending_expectations_)); |
| - scoped_ptr<UpdateChecker> checker_b(new UpdateChecker( |
| + scoped_ptr<OrientationUpdateChecker> checker_b(new OrientationUpdateChecker( |
| &pending_expectations_)); |
| orientation_factory->SetOrientation(kTestOrientation); |
| checker_a->AddExpectation(kTestOrientation); |
| - provider_->AddObserver(checker_a.get()); |
| + provider_->AddOrientationObserver(checker_a.get()); |
| MessageLoop::current()->Run(); |
| checker_a->AddExpectation(Orientation::Empty()); |
| @@ -316,11 +318,11 @@ TEST_F(DeviceOrientationProviderTest, MAYBE_StartFailing) { |
| MessageLoop::current()->Run(); |
| checker_b->AddExpectation(Orientation::Empty()); |
| - provider_->AddObserver(checker_b.get()); |
| + provider_->AddOrientationObserver(checker_b.get()); |
| MessageLoop::current()->Run(); |
| - provider_->RemoveObserver(checker_a.get()); |
| - provider_->RemoveObserver(checker_b.get()); |
| + provider_->RemoveOrientationObserver(checker_a.get()); |
| + provider_->RemoveOrientationObserver(checker_b.get()); |
| } |
| TEST_F(DeviceOrientationProviderTest, StartStopStart) { |
| @@ -330,24 +332,25 @@ TEST_F(DeviceOrientationProviderTest, StartStopStart) { |
| const Orientation kTestOrientation(true, 1, true, 2, true, 3, true, true); |
| const Orientation kTestOrientation2(true, 4, true, 5, true, 6, true, false); |
| - scoped_ptr<UpdateChecker> checker_a(new UpdateChecker( |
| + scoped_ptr<OrientationUpdateChecker> checker_a(new OrientationUpdateChecker( |
| &pending_expectations_)); |
| - scoped_ptr<UpdateChecker> checker_b(new UpdateChecker( |
| + scoped_ptr<OrientationUpdateChecker> checker_b(new OrientationUpdateChecker( |
| &pending_expectations_)); |
| checker_a->AddExpectation(kTestOrientation); |
| orientation_factory->SetOrientation(kTestOrientation); |
| - provider_->AddObserver(checker_a.get()); |
| + provider_->AddOrientationObserver(checker_a.get()); |
| MessageLoop::current()->Run(); |
| - provider_->RemoveObserver(checker_a.get()); // This stops the Provider. |
| + provider_->RemoveOrientationObserver(checker_a.get()); |
| + // This stops the Provider. |
|
Steve Block
2012/07/04 15:34:38
Comment should be above code.
|
| checker_b->AddExpectation(kTestOrientation2); |
| orientation_factory->SetOrientation(kTestOrientation2); |
| - provider_->AddObserver(checker_b.get()); |
| + provider_->AddOrientationObserver(checker_b.get()); |
| MessageLoop::current()->Run(); |
| - provider_->RemoveObserver(checker_b.get()); |
| + provider_->RemoveOrientationObserver(checker_b.get()); |
| } |
| TEST_F(DeviceOrientationProviderTest, SignificantlyDifferent) { |
| @@ -374,21 +377,22 @@ TEST_F(DeviceOrientationProviderTest, SignificantlyDifferent) { |
| true, kGamma + kSignificantDifference, |
| false, true); |
| - scoped_ptr<UpdateChecker> checker_a(new UpdateChecker( |
| + scoped_ptr<OrientationUpdateChecker> checker_a(new OrientationUpdateChecker( |
| &pending_expectations_)); |
| - scoped_ptr<UpdateChecker> checker_b(new UpdateChecker( |
| + scoped_ptr<OrientationUpdateChecker> checker_b(new OrientationUpdateChecker( |
| &pending_expectations_)); |
| orientation_factory->SetOrientation(first_orientation); |
| checker_a->AddExpectation(first_orientation); |
| - provider_->AddObserver(checker_a.get()); |
| + provider_->AddOrientationObserver(checker_a.get()); |
| MessageLoop::current()->Run(); |
| - // The observers should not see this insignificantly different orientation. |
| + // The orientation observers should not see this insignificantly different |
| + // orientation. |
| orientation_factory->SetOrientation(second_orientation); |
| checker_b->AddExpectation(first_orientation); |
| - provider_->AddObserver(checker_b.get()); |
| + provider_->AddOrientationObserver(checker_b.get()); |
| MessageLoop::current()->Run(); |
| orientation_factory->SetOrientation(third_orientation); |
| @@ -396,8 +400,8 @@ TEST_F(DeviceOrientationProviderTest, SignificantlyDifferent) { |
| checker_b->AddExpectation(third_orientation); |
| MessageLoop::current()->Run(); |
| - provider_->RemoveObserver(checker_a.get()); |
| - provider_->RemoveObserver(checker_b.get()); |
| + provider_->RemoveOrientationObserver(checker_a.get()); |
| + provider_->RemoveOrientationObserver(checker_b.get()); |
| } |
| } // namespace |