diff options
author | jknotten@chromium.org <jknotten@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 14:54:28 +0000 |
---|---|---|
committer | jknotten@chromium.org <jknotten@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 14:54:28 +0000 |
commit | 37960b931bf59ad260480ad09e56c8ab472ad504 (patch) | |
tree | 17c2dd64c7f13c7fdc9f61e9380d0be1bd3c3ebc /content/browser/device_orientation/provider_unittest.cc | |
parent | cfda7b132c6de23afbadb14fd1ffaf6a695dc61b (diff) | |
download | chromium_src-37960b931bf59ad260480ad09e56c8ab472ad504.zip chromium_src-37960b931bf59ad260480ad09e56c8ab472ad504.tar.gz chromium_src-37960b931bf59ad260480ad09e56c8ab472ad504.tar.bz2 |
Upstream Device Orientation For Android.
Some minor changes to support and make clear that a DataFetcher can
return true without providing an orientation. This is the case for
Android's data fetcher where we need to wait for the sensor manager to
push an event instead of being able to directly poll the orientation
sensor.
TBR=jam@chromium.org
TEST=content_unittests:DeviceOrientationProviderTest
Review URL: https://chromiumcodereview.appspot.com/10268013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136555 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/device_orientation/provider_unittest.cc')
-rw-r--r-- | content/browser/device_orientation/provider_unittest.cc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/content/browser/device_orientation/provider_unittest.cc b/content/browser/device_orientation/provider_unittest.cc index e95e7b8..17d3d43 100644 --- a/content/browser/device_orientation/provider_unittest.cc +++ b/content/browser/device_orientation/provider_unittest.cc @@ -68,7 +68,8 @@ class UpdateChecker : public Provider::Observer { // Class for injecting test orientation data into the Provider. class MockOrientationFactory : public base::RefCounted<MockOrientationFactory> { public: - MockOrientationFactory() { + MockOrientationFactory() + : is_failing_(false) { EXPECT_FALSE(instance_); instance_ = this; } @@ -83,6 +84,11 @@ class MockOrientationFactory : public base::RefCounted<MockOrientationFactory> { orientation_ = orientation; } + void SetFailing(bool is_failing) { + base::AutoLock auto_lock(lock_); + is_failing_ = is_failing; + } + private: friend class base::RefCounted<MockOrientationFactory>; @@ -99,6 +105,8 @@ class MockOrientationFactory : public base::RefCounted<MockOrientationFactory> { // From DataFetcher. Called by the Provider. virtual bool GetOrientation(Orientation* orientation) { base::AutoLock auto_lock(orientation_factory_->lock_); + if (orientation_factory_->is_failing_) + return false; *orientation = orientation_factory_->orientation_; return true; } @@ -109,6 +117,7 @@ class MockOrientationFactory : public base::RefCounted<MockOrientationFactory> { static MockOrientationFactory* instance_; Orientation orientation_; + bool is_failing_; base::Lock lock_; }; @@ -303,7 +312,7 @@ TEST_F(DeviceOrientationProviderTest, MAYBE_StartFailing) { MessageLoop::current()->Run(); checker_a->AddExpectation(Orientation::Empty()); - orientation_factory->SetOrientation(Orientation::Empty()); + orientation_factory->SetFailing(true); MessageLoop::current()->Run(); checker_b->AddExpectation(Orientation::Empty()); |