| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/geolocation/location_arbitrator.h" | 5 #include "chrome/browser/geolocation/location_arbitrator.h" |
| 6 | 6 |
| 7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 8 #include "chrome/browser/geolocation/fake_access_token_store.h" | 8 #include "chrome/browser/geolocation/fake_access_token_store.h" |
| 9 #include "chrome/browser/geolocation/location_provider.h" | 9 #include "chrome/browser/geolocation/location_provider.h" |
| 10 #include "chrome/common/geoposition.h" | 10 #include "chrome/common/geoposition.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 ASSERT_TRUE(position->IsInitialized()); | 35 ASSERT_TRUE(position->IsInitialized()); |
| 36 ASSERT_TRUE(position->IsValidFix()); | 36 ASSERT_TRUE(position->IsValidFix()); |
| 37 } | 37 } |
| 38 | 38 |
| 39 } // namespace | 39 } // namespace |
| 40 | 40 |
| 41 class GeolocationLocationArbitratorTest : public testing::Test { | 41 class GeolocationLocationArbitratorTest : public testing::Test { |
| 42 protected: | 42 protected: |
| 43 virtual void SetUp() { | 43 virtual void SetUp() { |
| 44 access_token_store_ = new FakeAccessTokenStore; | 44 access_token_store_ = new FakeAccessTokenStore; |
| 45 arbitrator_.reset(GeolocationArbitrator::Create(access_token_store_.get(), | 45 GeolocationArbitrator::SetUseMockProvider(true); |
| 46 NULL)); | 46 arbitrator_ = GeolocationArbitrator::Create(access_token_store_.get(), |
| 47 arbitrator_->SetUseMockProvider(true); | 47 NULL); |
| 48 } | 48 } |
| 49 | 49 |
| 50 virtual void TearDown() { | 50 virtual void TearDown() { |
| 51 } | 51 } |
| 52 | 52 |
| 53 scoped_refptr<FakeAccessTokenStore> access_token_store_; | 53 scoped_refptr<FakeAccessTokenStore> access_token_store_; |
| 54 scoped_ptr<GeolocationArbitrator> arbitrator_; | 54 scoped_refptr<GeolocationArbitrator> arbitrator_; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 TEST_F(GeolocationLocationArbitratorTest, CreateDestroy) { | 57 TEST_F(GeolocationLocationArbitratorTest, CreateDestroy) { |
| 58 EXPECT_TRUE(access_token_store_); | 58 EXPECT_TRUE(access_token_store_); |
| 59 EXPECT_TRUE(arbitrator_ != NULL); | 59 EXPECT_TRUE(arbitrator_ != NULL); |
| 60 arbitrator_.reset(); | 60 arbitrator_ = NULL; |
| 61 SUCCEED(); | 61 SUCCEED(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 TEST_F(GeolocationLocationArbitratorTest, NormalUsage) { | 64 TEST_F(GeolocationLocationArbitratorTest, NormalUsage) { |
| 65 ASSERT_TRUE(access_token_store_); | 65 ASSERT_TRUE(access_token_store_); |
| 66 ASSERT_TRUE(arbitrator_ != NULL); | 66 ASSERT_TRUE(arbitrator_ != NULL); |
| 67 | 67 |
| 68 EXPECT_TRUE(access_token_store_->access_token_set_.empty()); | 68 EXPECT_TRUE(access_token_store_->access_token_set_.empty()); |
| 69 EXPECT_FALSE(access_token_store_->request_); | 69 EXPECT_FALSE(access_token_store_->request_); |
| 70 MockLocationObserver observer; | 70 MockLocationObserver observer; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 EXPECT_TRUE(observer1.last_position_.IsValidFix()); | 146 EXPECT_TRUE(observer1.last_position_.IsValidFix()); |
| 147 | 147 |
| 148 MockLocationObserver observer2; | 148 MockLocationObserver observer2; |
| 149 EXPECT_FALSE(observer2.last_position_.IsValidFix()); | 149 EXPECT_FALSE(observer2.last_position_.IsValidFix()); |
| 150 arbitrator_->AddObserver(&observer2, GeolocationArbitrator::UpdateOptions()); | 150 arbitrator_->AddObserver(&observer2, GeolocationArbitrator::UpdateOptions()); |
| 151 EXPECT_TRUE(observer2.last_position_.IsValidFix()); | 151 EXPECT_TRUE(observer2.last_position_.IsValidFix()); |
| 152 | 152 |
| 153 EXPECT_TRUE(arbitrator_->RemoveObserver(&observer1)); | 153 EXPECT_TRUE(arbitrator_->RemoveObserver(&observer1)); |
| 154 EXPECT_TRUE(arbitrator_->RemoveObserver(&observer2)); | 154 EXPECT_TRUE(arbitrator_->RemoveObserver(&observer2)); |
| 155 } | 155 } |
| OLD | NEW |