OLD | NEW |
1 // Copyright (c) 2011 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/json/json_reader.h" | 5 #include "base/json/json_reader.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/stringprintf.h" |
7 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
8 #include "base/values.h" | 9 #include "base/values.h" |
9 #include "chrome/common/net/test_url_fetcher_factory.h" | 10 #include "chrome/common/net/test_url_fetcher_factory.h" |
10 #include "content/browser/geolocation/fake_access_token_store.h" | 11 #include "content/browser/geolocation/fake_access_token_store.h" |
11 #include "content/browser/geolocation/network_location_provider.h" | 12 #include "content/browser/geolocation/network_location_provider.h" |
12 #include "net/url_request/url_request_status.h" | 13 #include "net/url_request/url_request_status.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 } | 166 } |
166 | 167 |
167 static int IndexToChannal(int index) { return index + 4; } | 168 static int IndexToChannal(int index) { return index + 4; } |
168 | 169 |
169 // Creates wifi data containing the specified number of access points, with | 170 // Creates wifi data containing the specified number of access points, with |
170 // some differentiating charactistics in each. | 171 // some differentiating charactistics in each. |
171 static WifiData CreateReferenceWifiScanData(int ap_count) { | 172 static WifiData CreateReferenceWifiScanData(int ap_count) { |
172 WifiData data; | 173 WifiData data; |
173 for (int i = 0; i < ap_count; ++i) { | 174 for (int i = 0; i < ap_count; ++i) { |
174 AccessPointData ap; | 175 AccessPointData ap; |
175 ap.mac_address = ASCIIToUTF16(StringPrintf("%02d-34-56-78-54-32", i)); | 176 ap.mac_address = |
| 177 ASCIIToUTF16(base::StringPrintf("%02d-34-56-78-54-32", i)); |
176 ap.radio_signal_strength = i; | 178 ap.radio_signal_strength = i; |
177 ap.channel = IndexToChannal(i); | 179 ap.channel = IndexToChannal(i); |
178 ap.signal_to_noise = i + 42; | 180 ap.signal_to_noise = i + 42; |
179 ap.ssid = ASCIIToUTF16("Some nice network"); | 181 ap.ssid = ASCIIToUTF16("Some nice network"); |
180 data.access_point_data.insert(ap); | 182 data.access_point_data.insert(ap); |
181 } | 183 } |
182 return data; | 184 return data; |
183 } | 185 } |
184 | 186 |
185 // Creates gateway data containing the specified number of routers, with | 187 // Creates gateway data containing the specified number of routers, with |
186 // some differentiating charactistics in each. | 188 // some differentiating charactistics in each. |
187 static GatewayData CreateReferenceRouterData(int router_count) { | 189 static GatewayData CreateReferenceRouterData(int router_count) { |
188 GatewayData data; | 190 GatewayData data; |
189 for (int i = 0; i < router_count; ++i) { | 191 for (int i = 0; i < router_count; ++i) { |
190 RouterData router; | 192 RouterData router; |
191 router.mac_address = | 193 router.mac_address = |
192 ASCIIToUTF16(StringPrintf("%02d-34-56-78-54-32", i)); | 194 ASCIIToUTF16(base::StringPrintf("%02d-34-56-78-54-32", i)); |
193 data.router_data.insert(router); | 195 data.router_data.insert(router); |
194 } | 196 } |
195 return data; | 197 return data; |
196 } | 198 } |
197 | 199 |
198 static Geoposition CreateReferencePosition(int id) { | 200 static Geoposition CreateReferencePosition(int id) { |
199 Geoposition pos; | 201 Geoposition pos; |
200 pos.latitude = id; | 202 pos.latitude = id; |
201 pos.longitude = -(id + 1); | 203 pos.longitude = -(id + 1); |
202 pos.altitude = 2 * id; | 204 pos.altitude = 2 * id; |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 const int evicted = i - kCacheSize; | 773 const int evicted = i - kCacheSize; |
772 EXPECT_FALSE(cache.FindPosition(CreateReferenceRouterData(2), | 774 EXPECT_FALSE(cache.FindPosition(CreateReferenceRouterData(2), |
773 CreateReferenceWifiScanData(evicted))); | 775 CreateReferenceWifiScanData(evicted))); |
774 EXPECT_TRUE(cache.FindPosition(CreateReferenceRouterData(2), | 776 EXPECT_TRUE(cache.FindPosition(CreateReferenceRouterData(2), |
775 CreateReferenceWifiScanData(evicted + 1))); | 777 CreateReferenceWifiScanData(evicted + 1))); |
776 } | 778 } |
777 } | 779 } |
778 } | 780 } |
779 | 781 |
780 } // namespace | 782 } // namespace |
OLD | NEW |