Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(408)

Side by Side Diff: content/browser/geolocation/wifi_data_provider_common_unittest.cc

Issue 10535157: [WIP] attempt to allow chrome OS to inject its wifi data provider (Closed) Base URL: http://git.chromium.org/chromium/src.git@remove_radio
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <vector> 5 #include <vector>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // Stops the specified (nested) message loop when the listener is called back. 60 // Stops the specified (nested) message loop when the listener is called back.
61 class MessageLoopQuitListener 61 class MessageLoopQuitListener
62 : public WifiDataProviderCommon::ListenerInterface { 62 : public WifiDataProviderCommon::ListenerInterface {
63 public: 63 public:
64 explicit MessageLoopQuitListener(MessageLoop* message_loop) 64 explicit MessageLoopQuitListener(MessageLoop* message_loop)
65 : message_loop_to_quit_(message_loop) { 65 : message_loop_to_quit_(message_loop) {
66 CHECK(message_loop_to_quit_ != NULL); 66 CHECK(message_loop_to_quit_ != NULL);
67 } 67 }
68 // ListenerInterface 68 // ListenerInterface
69 virtual void DeviceDataUpdateAvailable( 69 virtual void DeviceDataUpdateAvailable(
70 DeviceDataProvider<WifiData>* provider) { 70 WifiDataProvider* provider) {
71 // Provider should call back on client's thread. 71 // Provider should call back on client's thread.
72 EXPECT_EQ(MessageLoop::current(), message_loop_to_quit_); 72 EXPECT_EQ(MessageLoop::current(), message_loop_to_quit_);
73 provider_ = provider; 73 provider_ = provider;
74 message_loop_to_quit_->QuitNow(); 74 message_loop_to_quit_->QuitNow();
75 } 75 }
76 MessageLoop* message_loop_to_quit_; 76 MessageLoop* message_loop_to_quit_;
77 DeviceDataProvider<WifiData>* provider_; 77 WifiDataProvider* provider_;
78 }; 78 };
79 79
80 80
81 class WifiDataProviderCommonWithMock : public WifiDataProviderCommon { 81 class WifiDataProviderCommonWithMock : public WifiDataProviderCommon {
82 public: 82 public:
83 WifiDataProviderCommonWithMock() 83 WifiDataProviderCommonWithMock()
84 : new_wlan_api_(new MockWlanApi), 84 : new_wlan_api_(new MockWlanApi),
85 new_polling_policy_(new MockPollingPolicy) {} 85 new_polling_policy_(new MockPollingPolicy) {}
86 86
87 // WifiDataProviderCommon 87 // WifiDataProviderCommon
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 WifiData data; 217 WifiData data;
218 EXPECT_TRUE(provider_->GetData(&data)); 218 EXPECT_TRUE(provider_->GetData(&data));
219 EXPECT_EQ(1, static_cast<int>(data.access_point_data.size())); 219 EXPECT_EQ(1, static_cast<int>(data.access_point_data.size()));
220 EXPECT_EQ(single_access_point.ssid, data.access_point_data.begin()->ssid); 220 EXPECT_EQ(single_access_point.ssid, data.access_point_data.begin()->ssid);
221 } 221 }
222 222
223 TEST_F(GeolocationWifiDataProviderCommonTest, 223 TEST_F(GeolocationWifiDataProviderCommonTest,
224 StartThreadViaDeviceDataProvider) { 224 StartThreadViaDeviceDataProvider) {
225 MessageLoopQuitListener quit_listener(&main_message_loop_); 225 MessageLoopQuitListener quit_listener(&main_message_loop_);
226 WifiDataProvider::SetFactory(CreateWifiDataProviderCommonWithMock); 226 WifiDataProvider::SetFactory(CreateWifiDataProviderCommonWithMock);
227 DeviceDataProvider<WifiData>::Register(&quit_listener); 227 WifiDataProvider::Register(&quit_listener);
228 main_message_loop_.Run(); 228 main_message_loop_.Run();
229 DeviceDataProvider<WifiData>::Unregister(&quit_listener); 229 WifiDataProvider::Unregister(&quit_listener);
230 DeviceDataProvider<WifiData>::ResetFactory(); 230 WifiDataProvider::ResetFactory();
231 } 231 }
232 232
233 } // namespace 233 } // namespace
234 234
OLDNEW
« no previous file with comments | « content/browser/geolocation/wifi_data_provider_common.h ('k') | content/browser/geolocation/wifi_data_provider_common_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698