OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/stringprintf.h" |
5 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
6 #include "chrome/browser/chromeos/cros/mock_network_library.h" | 7 #include "chrome/browser/chromeos/cros/mock_network_library.h" |
7 #include "chrome/browser/geolocation/wifi_data_provider_chromeos.h" | 8 #include "chrome/browser/geolocation/wifi_data_provider_chromeos.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
9 | 10 |
10 using ::testing::DoAll; | 11 using ::testing::DoAll; |
11 using ::testing::NotNull; | 12 using ::testing::NotNull; |
12 using ::testing::Return; | 13 using ::testing::Return; |
13 using ::testing::ReturnRef; | 14 using ::testing::ReturnRef; |
14 using ::testing::SetArgumentPointee; | 15 using ::testing::SetArgumentPointee; |
15 | 16 |
16 namespace chromeos { | 17 namespace chromeos { |
17 | 18 |
18 class GeolocationChromeOsWifiDataProviderTest : public testing::Test { | 19 class GeolocationChromeOsWifiDataProviderTest : public testing::Test { |
19 protected: | 20 protected: |
20 GeolocationChromeOsWifiDataProviderTest() | 21 GeolocationChromeOsWifiDataProviderTest() |
21 : api_(WifiDataProviderChromeOs::NewWlanApi(&net_lib_)) { | 22 : api_(WifiDataProviderChromeOs::NewWlanApi(&net_lib_)) { |
22 } | 23 } |
23 | 24 |
24 static WifiAccessPointVector MakeWifiAps(int ssids, int aps_per_ssid) { | 25 static WifiAccessPointVector MakeWifiAps(int ssids, int aps_per_ssid) { |
25 WifiAccessPointVector ret; | 26 WifiAccessPointVector ret; |
26 for (int i = 0; i < ssids; ++i) { | 27 for (int i = 0; i < ssids; ++i) { |
27 for (int j = 0; j < aps_per_ssid; ++j) { | 28 for (int j = 0; j < aps_per_ssid; ++j) { |
28 WifiAccessPoint ap; | 29 WifiAccessPoint ap; |
29 ap.name = StringPrintf("SSID %d", i); | 30 ap.name = base::StringPrintf("SSID %d", i); |
30 ap.channel = i * 10 + j; | 31 ap.channel = i * 10 + j; |
31 ap.mac_address = StringPrintf("%02X:%02X:%02X:%02X:%02X:%02X", | 32 ap.mac_address = base::StringPrintf("%02X:%02X:%02X:%02X:%02X:%02X", |
32 i, j, 3, 4, 5, 6); | 33 i, j, 3, 4, 5, 6); |
33 ap.signal_strength = j; | 34 ap.signal_strength = j; |
34 ap.signal_to_noise = i; | 35 ap.signal_to_noise = i; |
35 ret.push_back(ap); | 36 ret.push_back(ap); |
36 } | 37 } |
37 } | 38 } |
38 return ret; | 39 return ret; |
39 } | 40 } |
40 | 41 |
41 chromeos::MockNetworkLibrary net_lib_; | 42 chromeos::MockNetworkLibrary net_lib_; |
42 scoped_ptr<WifiDataProviderCommon::WlanApiInterface> api_; | 43 scoped_ptr<WifiDataProviderCommon::WlanApiInterface> api_; |
(...skipping 26 matching lines...) Expand all Loading... |
69 } | 70 } |
70 | 71 |
71 TEST_F(GeolocationChromeOsWifiDataProviderTest, GetManyAccessPoints) { | 72 TEST_F(GeolocationChromeOsWifiDataProviderTest, GetManyAccessPoints) { |
72 EXPECT_CALL(net_lib_, GetWifiAccessPoints(NotNull())) | 73 EXPECT_CALL(net_lib_, GetWifiAccessPoints(NotNull())) |
73 .WillOnce(DoAll(SetArgumentPointee<0>(MakeWifiAps(3, 4)), Return(true))); | 74 .WillOnce(DoAll(SetArgumentPointee<0>(MakeWifiAps(3, 4)), Return(true))); |
74 EXPECT_TRUE(api_->GetAccessPointData(&ap_data_)); | 75 EXPECT_TRUE(api_->GetAccessPointData(&ap_data_)); |
75 ASSERT_EQ(12u, ap_data_.size()); | 76 ASSERT_EQ(12u, ap_data_.size()); |
76 } | 77 } |
77 | 78 |
78 } // namespace chromeos | 79 } // namespace chromeos |
OLD | NEW |