| 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/gateway_data_provider_common.h" | 5 #include "chrome/browser/geolocation/gateway_data_provider_common.h" |
| 6 | 6 |
| 7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // Provider should call back on client's thread. | 50 // Provider should call back on client's thread. |
| 51 EXPECT_EQ(MessageLoop::current(), message_loop_to_quit_); | 51 EXPECT_EQ(MessageLoop::current(), message_loop_to_quit_); |
| 52 provider_ = provider; | 52 provider_ = provider; |
| 53 message_loop_to_quit_->QuitNow(); | 53 message_loop_to_quit_->QuitNow(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 MessageLoop* message_loop_to_quit_; | 56 MessageLoop* message_loop_to_quit_; |
| 57 DeviceDataProvider<GatewayData>* provider_; | 57 DeviceDataProvider<GatewayData>* provider_; |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 class MockGatewayPollingPolicy : public PollingPolicyInterface { | 60 class MockGatewayPollingPolicy : public GatewayPollingPolicyInterface { |
| 61 public: | 61 public: |
| 62 MockGatewayPollingPolicy() { | 62 MockGatewayPollingPolicy() { |
| 63 ON_CALL(*this, PollingInterval()) | 63 ON_CALL(*this, PollingInterval()) |
| 64 .WillByDefault(Return(1)); | 64 .WillByDefault(Return(1)); |
| 65 ON_CALL(*this, NoRouterInterval()) | 65 ON_CALL(*this, NoRouterInterval()) |
| 66 .WillByDefault(Return(1)); | 66 .WillByDefault(Return(1)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 // PollingPolicyInterface | 69 // GatewayPollingPolicyInterface |
| 70 MOCK_METHOD0(PollingInterval, int()); | 70 MOCK_METHOD0(PollingInterval, int()); |
| 71 MOCK_METHOD0(NoRouterInterval, int()); | 71 MOCK_METHOD0(NoRouterInterval, int()); |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 class GatewayDataProviderCommonWithMock : public GatewayDataProviderCommon { | 74 class GatewayDataProviderCommonWithMock : public GatewayDataProviderCommon { |
| 75 public: | 75 public: |
| 76 GatewayDataProviderCommonWithMock() | 76 GatewayDataProviderCommonWithMock() |
| 77 : new_gateway_api_(new MockGatewayApi), | 77 : new_gateway_api_(new MockGatewayApi), |
| 78 new_polling_policy_(new MockGatewayPollingPolicy){ | 78 new_polling_policy_(new MockGatewayPollingPolicy){ |
| 79 } | 79 } |
| 80 | 80 |
| 81 // GatewayDataProviderCommon | 81 // GatewayDataProviderCommon |
| 82 virtual GatewayApiInterface* NewGatewayApi() { | 82 virtual GatewayApiInterface* NewGatewayApi() { |
| 83 CHECK(new_gateway_api_ != NULL); | 83 CHECK(new_gateway_api_ != NULL); |
| 84 return new_gateway_api_.release(); | 84 return new_gateway_api_.release(); |
| 85 } | 85 } |
| 86 virtual PollingPolicyInterface* NewPollingPolicy() { | 86 virtual GatewayPollingPolicyInterface* NewPollingPolicy() { |
| 87 CHECK(new_polling_policy_ != NULL); | 87 CHECK(new_polling_policy_ != NULL); |
| 88 return new_polling_policy_.release(); | 88 return new_polling_policy_.release(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 scoped_ptr<MockGatewayApi> new_gateway_api_; | 91 scoped_ptr<MockGatewayApi> new_gateway_api_; |
| 92 scoped_ptr<MockGatewayPollingPolicy> new_polling_policy_; | 92 scoped_ptr<MockGatewayPollingPolicy> new_polling_policy_; |
| 93 | 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(GatewayDataProviderCommonWithMock); | 94 DISALLOW_COPY_AND_ASSIGN(GatewayDataProviderCommonWithMock); |
| 95 }; | 95 }; |
| 96 | 96 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 RouterData single_router; | 178 RouterData single_router; |
| 179 single_router.mac_address = ASCIIToUTF16("12-34-56-78-54-32"); | 179 single_router.mac_address = ASCIIToUTF16("12-34-56-78-54-32"); |
| 180 gateway_api_->data_out_.insert(single_router); | 180 gateway_api_->data_out_.insert(single_router); |
| 181 EXPECT_TRUE(provider_->StartDataProvider()); | 181 EXPECT_TRUE(provider_->StartDataProvider()); |
| 182 main_message_loop_.Run(); | 182 main_message_loop_.Run(); |
| 183 GatewayData data; | 183 GatewayData data; |
| 184 EXPECT_TRUE(provider_->GetData(&data)); | 184 EXPECT_TRUE(provider_->GetData(&data)); |
| 185 EXPECT_EQ(1, static_cast<int>(data.router_data.size())); | 185 EXPECT_EQ(1, static_cast<int>(data.router_data.size())); |
| 186 EXPECT_EQ(single_router.mac_address, data.router_data.begin()->mac_address); | 186 EXPECT_EQ(single_router.mac_address, data.router_data.begin()->mac_address); |
| 187 } | 187 } |
| OLD | NEW |