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..cc675ee6188c9dc3942e8a1a84cd330ad5cc3792 100644 |
--- a/content/browser/device_orientation/provider_unittest.cc |
+++ b/content/browser/device_orientation/provider_unittest.cc |
@@ -16,7 +16,7 @@ namespace device_orientation { |
namespace { |
// Class for checking expectations on orientation updates from the Provider. |
-class UpdateChecker : public Provider::Observer { |
+class UpdateChecker : public Provider::OrientationObserver { |
public: |
explicit UpdateChecker(int* expectations_count_ptr) |
: expectations_count_ptr_(expectations_count_ptr) { |
@@ -24,7 +24,7 @@ class UpdateChecker : public Provider::Observer { |
virtual ~UpdateChecker() {} |
- // From Provider::Observer. |
+ // From Provider::OrientationObserver. |
virtual void OnOrientationUpdate(const Orientation& orientation) { |
ASSERT_FALSE(expectations_queue_.empty()); |
@@ -103,6 +103,10 @@ class MockOrientationFactory : public base::RefCounted<MockOrientationFactory> { |
: orientation_factory_(orientation_factory) { } |
// From DataFetcher. Called by the Provider. |
+ virtual bool GetMotion(Motion *motion) { |
+ return false; |
+ } |
+ |
virtual bool GetOrientation(Orientation* orientation) { |
base::AutoLock auto_lock(orientation_factory_->lock_); |
if (orientation_factory_->is_failing_) |
@@ -132,6 +136,9 @@ class FailingDataFetcher : public DataFetcher { |
} |
// From DataFetcher. |
+ virtual bool GetMotion(Motion* motion) { |
+ return false; |
+ } |
virtual bool GetOrientation(Orientation* orientation) { |
return false; |
} |
@@ -190,11 +197,11 @@ TEST_F(DeviceOrientationProviderTest, FailingTest) { |
new UpdateChecker(&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(); |
} |
@@ -216,13 +223,13 @@ TEST_F(DeviceOrientationProviderTest, BasicPushTest) { |
scoped_ptr<UpdateChecker> checker(new UpdateChecker(&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); |
@@ -240,36 +247,36 @@ TEST_F(DeviceOrientationProviderTest, MultipleObserversPushTest) { |
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); |
@@ -279,7 +286,7 @@ TEST_F(DeviceOrientationProviderTest, MAYBE_ObserverNotRemoved) { |
scoped_ptr<UpdateChecker> checker(new UpdateChecker(&pending_expectations_)); |
checker->AddExpectation(kTestOrientation); |
orientation_factory->SetOrientation(kTestOrientation); |
- provider_->AddObserver(checker.get()); |
+ provider_->AddOrientationObserver(checker.get()); |
MessageLoop::current()->Run(); |
checker->AddExpectation(kTestOrientation2); |
@@ -308,7 +315,7 @@ TEST_F(DeviceOrientationProviderTest, MAYBE_StartFailing) { |
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 +323,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) { |
@@ -337,17 +344,18 @@ TEST_F(DeviceOrientationProviderTest, StartStopStart) { |
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. |
+ // This stops the Provider. |
+ provider_->RemoveOrientationObserver(checker_a.get()); |
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) { |
@@ -382,13 +390,13 @@ TEST_F(DeviceOrientationProviderTest, SignificantlyDifferent) { |
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. |
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 +404,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 |