| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/geolocation/wifi_data_provider_common.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 5 #include "base/macros.h" | 9 #include "base/macros.h" |
| 6 #include "base/memory/scoped_ptr.h" | |
| 7 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 8 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 13 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
| 11 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
| 12 #include "content/browser/geolocation/wifi_data_provider_common.h" | |
| 13 #include "content/browser/geolocation/wifi_data_provider_manager.h" | 15 #include "content/browser/geolocation/wifi_data_provider_manager.h" |
| 14 #include "content/public/test/test_browser_thread_bundle.h" | 16 #include "content/public/test/test_browser_thread_bundle.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 19 |
| 18 using testing::_; | 20 using testing::_; |
| 19 using testing::AtLeast; | 21 using testing::AtLeast; |
| 20 using testing::DoDefault; | 22 using testing::DoDefault; |
| 21 using testing::Invoke; | 23 using testing::Invoke; |
| 22 using testing::Return; | 24 using testing::Return; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // WifiDataProviderCommon | 71 // WifiDataProviderCommon |
| 70 WlanApiInterface* NewWlanApi() override { | 72 WlanApiInterface* NewWlanApi() override { |
| 71 CHECK(new_wlan_api_ != NULL); | 73 CHECK(new_wlan_api_ != NULL); |
| 72 return new_wlan_api_.release(); | 74 return new_wlan_api_.release(); |
| 73 } | 75 } |
| 74 WifiPollingPolicy* NewPollingPolicy() override { | 76 WifiPollingPolicy* NewPollingPolicy() override { |
| 75 CHECK(new_polling_policy_ != NULL); | 77 CHECK(new_polling_policy_ != NULL); |
| 76 return new_polling_policy_.release(); | 78 return new_polling_policy_.release(); |
| 77 } | 79 } |
| 78 | 80 |
| 79 scoped_ptr<MockWlanApi> new_wlan_api_; | 81 std::unique_ptr<MockWlanApi> new_wlan_api_; |
| 80 scoped_ptr<MockPollingPolicy> new_polling_policy_; | 82 std::unique_ptr<MockPollingPolicy> new_polling_policy_; |
| 81 | 83 |
| 82 private: | 84 private: |
| 83 ~WifiDataProviderCommonWithMock() override {} | 85 ~WifiDataProviderCommonWithMock() override {} |
| 84 | 86 |
| 85 DISALLOW_COPY_AND_ASSIGN(WifiDataProviderCommonWithMock); | 87 DISALLOW_COPY_AND_ASSIGN(WifiDataProviderCommonWithMock); |
| 86 }; | 88 }; |
| 87 | 89 |
| 88 WifiDataProvider* CreateWifiDataProviderCommonWithMock() { | 90 WifiDataProvider* CreateWifiDataProviderCommonWithMock() { |
| 89 return new WifiDataProviderCommonWithMock; | 91 return new WifiDataProviderCommonWithMock; |
| 90 } | 92 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 118 } | 120 } |
| 119 | 121 |
| 120 void RunLoop() { | 122 void RunLoop() { |
| 121 run_loop_.reset(new base::RunLoop()); | 123 run_loop_.reset(new base::RunLoop()); |
| 122 run_loop_->Run(); | 124 run_loop_->Run(); |
| 123 } | 125 } |
| 124 | 126 |
| 125 protected: | 127 protected: |
| 126 TestBrowserThreadBundle thread_bundle_; | 128 TestBrowserThreadBundle thread_bundle_; |
| 127 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 129 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 128 scoped_ptr<base::RunLoop> run_loop_; | 130 std::unique_ptr<base::RunLoop> run_loop_; |
| 129 WifiDataProviderManager::WifiDataUpdateCallback wifi_data_callback_; | 131 WifiDataProviderManager::WifiDataUpdateCallback wifi_data_callback_; |
| 130 scoped_refptr<WifiDataProviderCommonWithMock> provider_; | 132 scoped_refptr<WifiDataProviderCommonWithMock> provider_; |
| 131 MockWlanApi* wlan_api_; | 133 MockWlanApi* wlan_api_; |
| 132 MockPollingPolicy* polling_policy_; | 134 MockPollingPolicy* polling_policy_; |
| 133 }; | 135 }; |
| 134 | 136 |
| 135 TEST_F(GeolocationWifiDataProviderCommonTest, CreateDestroy) { | 137 TEST_F(GeolocationWifiDataProviderCommonTest, CreateDestroy) { |
| 136 // Test fixture members were SetUp correctly. | 138 // Test fixture members were SetUp correctly. |
| 137 EXPECT_TRUE(main_task_runner_->BelongsToCurrentThread()); | 139 EXPECT_TRUE(main_task_runner_->BelongsToCurrentThread()); |
| 138 EXPECT_TRUE(NULL != provider_.get()); | 140 EXPECT_TRUE(NULL != provider_.get()); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 TEST_F(GeolocationWifiDataProviderCommonTest, RegisterUnregister) { | 231 TEST_F(GeolocationWifiDataProviderCommonTest, RegisterUnregister) { |
| 230 WifiDataProviderManager::SetFactoryForTesting( | 232 WifiDataProviderManager::SetFactoryForTesting( |
| 231 CreateWifiDataProviderCommonWithMock); | 233 CreateWifiDataProviderCommonWithMock); |
| 232 WifiDataProviderManager::Register(&wifi_data_callback_); | 234 WifiDataProviderManager::Register(&wifi_data_callback_); |
| 233 RunLoop(); | 235 RunLoop(); |
| 234 WifiDataProviderManager::Unregister(&wifi_data_callback_); | 236 WifiDataProviderManager::Unregister(&wifi_data_callback_); |
| 235 WifiDataProviderManager::ResetFactoryForTesting(); | 237 WifiDataProviderManager::ResetFactoryForTesting(); |
| 236 } | 238 } |
| 237 | 239 |
| 238 } // namespace content | 240 } // namespace content |
| OLD | NEW |