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

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

Issue 2129313002: Geolocation cleanup: corrects uses of content::AccessTokenStore* and net::URLRequestContextGetter* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wez@ comments. Rebase Created 4 years, 5 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 "content/browser/geolocation/network_location_provider.h" 5 #include "content/browser/geolocation/network_location_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 22 matching lines...) Expand all
33 const char kAccessTokenString[] = "accessToken"; 33 const char kAccessTokenString[] = "accessToken";
34 34
35 // Using #define so we can easily paste this into various other strings. 35 // Using #define so we can easily paste this into various other strings.
36 #define REFERENCE_ACCESS_TOKEN "2:k7j3G6LaL6u_lafw:4iXOeOpTh1glSXe" 36 #define REFERENCE_ACCESS_TOKEN "2:k7j3G6LaL6u_lafw:4iXOeOpTh1glSXe"
37 37
38 // Stops the specified (nested) message loop when the listener is called back. 38 // Stops the specified (nested) message loop when the listener is called back.
39 class MessageLoopQuitListener { 39 class MessageLoopQuitListener {
40 public: 40 public:
41 MessageLoopQuitListener() 41 MessageLoopQuitListener()
42 : client_message_loop_(base::MessageLoop::current()), 42 : client_message_loop_(base::MessageLoop::current()),
43 updated_provider_(NULL) { 43 updated_provider_(nullptr) {
44 CHECK(client_message_loop_); 44 CHECK(client_message_loop_);
45 } 45 }
46 46
47 void OnLocationUpdate(const LocationProvider* provider, 47 void OnLocationUpdate(const LocationProvider* provider,
48 const Geoposition& position) { 48 const Geoposition& position) {
49 EXPECT_EQ(client_message_loop_, base::MessageLoop::current()); 49 EXPECT_EQ(client_message_loop_, base::MessageLoop::current());
50 updated_provider_ = provider; 50 updated_provider_ = provider;
51 client_message_loop_->QuitWhenIdle(); 51 client_message_loop_->QuitWhenIdle();
52 } 52 }
53 53
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 this->RunCallbacks(); 92 this->RunCallbacks();
93 } 93 }
94 94
95 void set_got_data(bool got_data) { got_data_ = got_data; } 95 void set_got_data(bool got_data) { got_data_ = got_data; }
96 int start_calls_; 96 int start_calls_;
97 int stop_calls_; 97 int stop_calls_;
98 98
99 private: 99 private:
100 ~MockWifiDataProvider() override { 100 ~MockWifiDataProvider() override {
101 CHECK(this == instance_); 101 CHECK(this == instance_);
102 instance_ = NULL; 102 instance_ = nullptr;
103 } 103 }
104 104
105 static MockWifiDataProvider* instance_; 105 static MockWifiDataProvider* instance_;
106 106
107 WifiData data_; 107 WifiData data_;
108 bool got_data_; 108 bool got_data_;
109 109
110 DISALLOW_COPY_AND_ASSIGN(MockWifiDataProvider); 110 DISALLOW_COPY_AND_ASSIGN(MockWifiDataProvider);
111 }; 111 };
112 112
113 MockWifiDataProvider* MockWifiDataProvider::instance_ = NULL; 113 MockWifiDataProvider* MockWifiDataProvider::instance_ = nullptr;
114 114
115 // Main test fixture 115 // Main test fixture
116 class GeolocationNetworkProviderTest : public testing::Test { 116 class GeolocationNetworkProviderTest : public testing::Test {
117 public: 117 public:
118 void SetUp() override {
119 test_server_url_ = GURL(kTestServerUrl);
120 access_token_store_ = new FakeAccessTokenStore;
121 wifi_data_provider_ = MockWifiDataProvider::CreateInstance();
122 }
123
124 void TearDown() override { 118 void TearDown() override {
125 WifiDataProviderManager::ResetFactoryForTesting(); 119 WifiDataProviderManager::ResetFactoryForTesting();
126 } 120 }
127 121
128 LocationProvider* CreateProvider(bool set_permission_granted) { 122 LocationProvider* CreateProvider(bool set_permission_granted) {
129 LocationProvider* provider = NewNetworkLocationProvider( 123 LocationProvider* provider = NewNetworkLocationProvider(
130 access_token_store_.get(), 124 access_token_store_,
131 NULL, // No URLContextGetter needed, as using test urlfecther factory. 125 nullptr, // No URLContextGetter needed, using test urlfecther factory.
132 test_server_url_, 126 test_server_url_,
133 access_token_store_->access_token_map_[test_server_url_]); 127 access_token_store_->access_token_map_[test_server_url_]);
134 if (set_permission_granted) 128 if (set_permission_granted)
135 provider->OnPermissionGranted(); 129 provider->OnPermissionGranted();
136 return provider; 130 return provider;
137 } 131 }
138 132
139 protected: 133 protected:
140 GeolocationNetworkProviderTest() { 134 GeolocationNetworkProviderTest()
135 : test_server_url_(kTestServerUrl),
136 access_token_store_(new FakeAccessTokenStore),
137 wifi_data_provider_(MockWifiDataProvider::CreateInstance()) {
141 // TODO(joth): Really these should be in SetUp, not here, but they take no 138 // TODO(joth): Really these should be in SetUp, not here, but they take no
142 // effect on Mac OS Release builds if done there. I kid not. Figure out why. 139 // effect on Mac OS Release builds if done there. I kid not. Figure out why.
143 WifiDataProviderManager::SetFactoryForTesting( 140 WifiDataProviderManager::SetFactoryForTesting(
144 MockWifiDataProvider::GetInstance); 141 MockWifiDataProvider::GetInstance);
145 } 142 }
146 143
147 // Returns the current url fetcher (if any) and advances the id ready for the 144 // Returns the current url fetcher (if any) and advances the id ready for the
148 // next test step. 145 // next test step.
149 net::TestURLFetcher* get_url_fetcher_and_advance_id() { 146 net::TestURLFetcher* get_url_fetcher_and_advance_id() {
150 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID( 147 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // network provider url. 258 // network provider url.
262 bool is_default_url = UrlWithoutQuery(request_url) == 259 bool is_default_url = UrlWithoutQuery(request_url) ==
263 UrlWithoutQuery(LocationArbitratorImpl::DefaultNetworkProviderURL()); 260 UrlWithoutQuery(LocationArbitratorImpl::DefaultNetworkProviderURL());
264 EXPECT_EQ(is_default_url, !request_url.query().empty()); 261 EXPECT_EQ(is_default_url, !request_url.query().empty());
265 262
266 const std::string& upload_data = request.upload_data(); 263 const std::string& upload_data = request.upload_data();
267 ASSERT_FALSE(upload_data.empty()); 264 ASSERT_FALSE(upload_data.empty());
268 std::string json_parse_error_msg; 265 std::string json_parse_error_msg;
269 std::unique_ptr<base::Value> parsed_json = 266 std::unique_ptr<base::Value> parsed_json =
270 base::JSONReader::ReadAndReturnError(upload_data, base::JSON_PARSE_RFC, 267 base::JSONReader::ReadAndReturnError(upload_data, base::JSON_PARSE_RFC,
271 NULL, &json_parse_error_msg); 268 nullptr, &json_parse_error_msg);
272 EXPECT_TRUE(json_parse_error_msg.empty()); 269 EXPECT_TRUE(json_parse_error_msg.empty());
273 ASSERT_TRUE(parsed_json.get() != NULL); 270 ASSERT_TRUE(parsed_json.get() != nullptr);
Wez 2016/07/16 00:35:10 nit: ASSERT_FALSE(parsed_json)
mcasas 2016/07/16 01:17:46 You mean ASSERT_TRUE(parsed_json); Done
274 271
275 const base::DictionaryValue* request_json; 272 const base::DictionaryValue* request_json;
276 ASSERT_TRUE(parsed_json->GetAsDictionary(&request_json)); 273 ASSERT_TRUE(parsed_json->GetAsDictionary(&request_json));
277 274
278 if (!is_default_url) { 275 if (!is_default_url) {
279 if (expected_access_token.empty()) 276 if (expected_access_token.empty())
280 ASSERT_FALSE(request_json->HasKey(kAccessTokenString)); 277 ASSERT_FALSE(request_json->HasKey(kAccessTokenString));
281 else { 278 else {
282 std::string access_token; 279 std::string access_token;
283 EXPECT_TRUE(request_json->GetString(kAccessTokenString, &access_token)); 280 EXPECT_TRUE(request_json->GetString(kAccessTokenString, &access_token));
(...skipping 25 matching lines...) Expand all
309 ASSERT_TRUE(JsonFieldEquals("signalToNoiseRatio", *expected_json, 306 ASSERT_TRUE(JsonFieldEquals("signalToNoiseRatio", *expected_json,
310 *actual_json)); 307 *actual_json));
311 } 308 }
312 } else { 309 } else {
313 ASSERT_FALSE(request_json->HasKey("wifiAccessPoints")); 310 ASSERT_FALSE(request_json->HasKey("wifiAccessPoints"));
314 } 311 }
315 EXPECT_TRUE(request_url.is_valid()); 312 EXPECT_TRUE(request_url.is_valid());
316 } 313 }
317 314
318 GURL test_server_url_; 315 GURL test_server_url_;
319 base::MessageLoop main_message_loop_; 316 const base::MessageLoop main_message_loop_;
320 scoped_refptr<FakeAccessTokenStore> access_token_store_; 317 const scoped_refptr<FakeAccessTokenStore> access_token_store_;
321 net::TestURLFetcherFactory url_fetcher_factory_; 318 const net::TestURLFetcherFactory url_fetcher_factory_;
322 scoped_refptr<MockWifiDataProvider> wifi_data_provider_; 319 const scoped_refptr<MockWifiDataProvider> wifi_data_provider_;
Wez 2016/07/16 00:35:10 Is it useful to const-ify all these test members?
mcasas 2016/07/16 01:17:46 Absolutely, please see my reply before.
323 }; 320 };
324 321
325 TEST_F(GeolocationNetworkProviderTest, CreateDestroy) { 322 TEST_F(GeolocationNetworkProviderTest, CreateDestroy) {
326 // Test fixture members were SetUp correctly. 323 // Test fixture members were SetUp correctly.
327 EXPECT_EQ(&main_message_loop_, base::MessageLoop::current()); 324 EXPECT_EQ(&main_message_loop_, base::MessageLoop::current());
328 std::unique_ptr<LocationProvider> provider(CreateProvider(true)); 325 std::unique_ptr<LocationProvider> provider(CreateProvider(true));
329 EXPECT_TRUE(NULL != provider.get()); 326 EXPECT_TRUE(nullptr != provider.get());
Wez 2016/07/16 00:35:10 EXPECT_TRUE(provider)
mcasas 2016/07/16 01:17:46 Done.
330 provider.reset(); 327 provider.reset();
331 SUCCEED(); 328 SUCCEED();
332 } 329 }
333 330
334 TEST_F(GeolocationNetworkProviderTest, StartProvider) { 331 TEST_F(GeolocationNetworkProviderTest, StartProvider) {
335 std::unique_ptr<LocationProvider> provider(CreateProvider(true)); 332 std::unique_ptr<LocationProvider> provider(CreateProvider(true));
336 EXPECT_TRUE(provider->StartProvider(false)); 333 EXPECT_TRUE(provider->StartProvider(false));
337 net::TestURLFetcher* fetcher = get_url_fetcher_and_advance_id(); 334 net::TestURLFetcher* fetcher = get_url_fetcher_and_advance_id();
338 ASSERT_TRUE(fetcher != NULL); 335 ASSERT_TRUE(fetcher != nullptr);
Wez 2016/07/16 00:35:10 ASSERT_TRUE(fetcher) here and below.
mcasas 2016/07/16 01:17:46 Done here and elsewhere.
339 CheckRequestIsValid(*fetcher, 0, 0, 0, std::string()); 336 CheckRequestIsValid(*fetcher, 0, 0, 0, std::string());
340 } 337 }
341 338
342 TEST_F(GeolocationNetworkProviderTest, StartProviderDefaultUrl) { 339 TEST_F(GeolocationNetworkProviderTest, StartProviderDefaultUrl) {
343 test_server_url_ = LocationArbitratorImpl::DefaultNetworkProviderURL(); 340 test_server_url_ = LocationArbitratorImpl::DefaultNetworkProviderURL();
344 std::unique_ptr<LocationProvider> provider(CreateProvider(true)); 341 std::unique_ptr<LocationProvider> provider(CreateProvider(true));
345 EXPECT_TRUE(provider->StartProvider(false)); 342 EXPECT_TRUE(provider->StartProvider(false));
346 net::TestURLFetcher* fetcher = get_url_fetcher_and_advance_id(); 343 net::TestURLFetcher* fetcher = get_url_fetcher_and_advance_id();
347 ASSERT_TRUE(fetcher != NULL); 344 ASSERT_TRUE(fetcher != nullptr);
348 CheckRequestIsValid(*fetcher, 0, 0, 0, std::string()); 345 CheckRequestIsValid(*fetcher, 0, 0, 0, std::string());
349 } 346 }
350 347
351 TEST_F(GeolocationNetworkProviderTest, StartProviderLongRequest) { 348 TEST_F(GeolocationNetworkProviderTest, StartProviderLongRequest) {
352 std::unique_ptr<LocationProvider> provider(CreateProvider(true)); 349 std::unique_ptr<LocationProvider> provider(CreateProvider(true));
353 EXPECT_TRUE(provider->StartProvider(false)); 350 EXPECT_TRUE(provider->StartProvider(false));
354 const int kFirstScanAps = 20; 351 const int kFirstScanAps = 20;
355 wifi_data_provider_->SetData(CreateReferenceWifiScanData(kFirstScanAps)); 352 wifi_data_provider_->SetData(CreateReferenceWifiScanData(kFirstScanAps));
356 base::RunLoop().RunUntilIdle(); 353 base::RunLoop().RunUntilIdle();
357 net::TestURLFetcher* fetcher = get_url_fetcher_and_advance_id(); 354 net::TestURLFetcher* fetcher = get_url_fetcher_and_advance_id();
358 ASSERT_TRUE(fetcher != NULL); 355 ASSERT_TRUE(fetcher != nullptr);
359 // The request url should have been shortened to less than 2048 characters 356 // The request url should have been shortened to less than 2048 characters
360 // in length by not including access points with the lowest signal strength 357 // in length by not including access points with the lowest signal strength
361 // in the request. 358 // in the request.
362 EXPECT_LT(fetcher->GetOriginalURL().spec().size(), size_t(2048)); 359 EXPECT_LT(fetcher->GetOriginalURL().spec().size(), size_t(2048));
363 CheckRequestIsValid(*fetcher, 0, 16, 4, std::string()); 360 CheckRequestIsValid(*fetcher, 0, 16, 4, std::string());
364 } 361 }
365 362
366 TEST_F(GeolocationNetworkProviderTest, MultipleWifiScansComplete) { 363 TEST_F(GeolocationNetworkProviderTest, MultipleWifiScansComplete) {
367 std::unique_ptr<LocationProvider> provider(CreateProvider(true)); 364 std::unique_ptr<LocationProvider> provider(CreateProvider(true));
368 EXPECT_TRUE(provider->StartProvider(false)); 365 EXPECT_TRUE(provider->StartProvider(false));
369 366
370 net::TestURLFetcher* fetcher = get_url_fetcher_and_advance_id(); 367 net::TestURLFetcher* fetcher = get_url_fetcher_and_advance_id();
371 ASSERT_TRUE(fetcher != NULL); 368 ASSERT_TRUE(fetcher != nullptr);
372 EXPECT_TRUE(IsTestServerUrl(fetcher->GetOriginalURL())); 369 EXPECT_TRUE(IsTestServerUrl(fetcher->GetOriginalURL()));
373 370
374 // Complete the network request with bad position fix. 371 // Complete the network request with bad position fix.
375 const char* kNoFixNetworkResponse = 372 const char* kNoFixNetworkResponse =
376 "{" 373 "{"
377 " \"status\": \"ZERO_RESULTS\"" 374 " \"status\": \"ZERO_RESULTS\""
378 "}"; 375 "}";
379 fetcher->set_url(test_server_url_); 376 fetcher->set_url(test_server_url_);
380 fetcher->set_status(net::URLRequestStatus()); 377 fetcher->set_status(net::URLRequestStatus());
381 fetcher->set_response_code(200); // OK 378 fetcher->set_response_code(200); // OK
382 fetcher->SetResponseString(kNoFixNetworkResponse); 379 fetcher->SetResponseString(kNoFixNetworkResponse);
383 fetcher->delegate()->OnURLFetchComplete(fetcher); 380 fetcher->delegate()->OnURLFetchComplete(fetcher);
384 381
385 Geoposition position; 382 Geoposition position;
386 provider->GetPosition(&position); 383 provider->GetPosition(&position);
387 EXPECT_FALSE(position.Validate()); 384 EXPECT_FALSE(position.Validate());
388 385
389 // Now wifi data arrives -- SetData will notify listeners. 386 // Now wifi data arrives -- SetData will notify listeners.
390 const int kFirstScanAps = 6; 387 const int kFirstScanAps = 6;
391 wifi_data_provider_->SetData(CreateReferenceWifiScanData(kFirstScanAps)); 388 wifi_data_provider_->SetData(CreateReferenceWifiScanData(kFirstScanAps));
392 base::RunLoop().RunUntilIdle(); 389 base::RunLoop().RunUntilIdle();
393 fetcher = get_url_fetcher_and_advance_id(); 390 fetcher = get_url_fetcher_and_advance_id();
394 ASSERT_TRUE(fetcher != NULL); 391 ASSERT_TRUE(fetcher != nullptr);
395 // The request should have the wifi data. 392 // The request should have the wifi data.
396 CheckRequestIsValid(*fetcher, 0, kFirstScanAps, 0, std::string()); 393 CheckRequestIsValid(*fetcher, 0, kFirstScanAps, 0, std::string());
397 394
398 // Send a reply with good position fix. 395 // Send a reply with good position fix.
399 const char* kReferenceNetworkResponse = 396 const char* kReferenceNetworkResponse =
400 "{" 397 "{"
401 " \"accessToken\": \"" REFERENCE_ACCESS_TOKEN "\"," 398 " \"accessToken\": \"" REFERENCE_ACCESS_TOKEN "\","
402 " \"accuracy\": 1200.4," 399 " \"accuracy\": 1200.4,"
403 " \"location\": {" 400 " \"location\": {"
404 " \"lat\": 51.0," 401 " \"lat\": 51.0,"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 } 496 }
500 497
501 TEST_F(GeolocationNetworkProviderTest, NetworkRequestDeferredForPermission) { 498 TEST_F(GeolocationNetworkProviderTest, NetworkRequestDeferredForPermission) {
502 std::unique_ptr<LocationProvider> provider(CreateProvider(false)); 499 std::unique_ptr<LocationProvider> provider(CreateProvider(false));
503 EXPECT_TRUE(provider->StartProvider(false)); 500 EXPECT_TRUE(provider->StartProvider(false));
504 net::TestURLFetcher* fetcher = get_url_fetcher_and_advance_id(); 501 net::TestURLFetcher* fetcher = get_url_fetcher_and_advance_id();
505 EXPECT_FALSE(fetcher); 502 EXPECT_FALSE(fetcher);
506 provider->OnPermissionGranted(); 503 provider->OnPermissionGranted();
507 504
508 fetcher = get_url_fetcher_and_advance_id(); 505 fetcher = get_url_fetcher_and_advance_id();
509 ASSERT_TRUE(fetcher != NULL); 506 ASSERT_TRUE(fetcher != nullptr);
510 507
511 EXPECT_TRUE(IsTestServerUrl(fetcher->GetOriginalURL())); 508 EXPECT_TRUE(IsTestServerUrl(fetcher->GetOriginalURL()));
512 } 509 }
513 510
514 TEST_F(GeolocationNetworkProviderTest, 511 TEST_F(GeolocationNetworkProviderTest,
515 NetworkRequestWithWifiDataDeferredForPermission) { 512 NetworkRequestWithWifiDataDeferredForPermission) {
516 access_token_store_->access_token_map_[test_server_url_] = 513 access_token_store_->access_token_map_[test_server_url_] =
517 base::UTF8ToUTF16(REFERENCE_ACCESS_TOKEN); 514 base::UTF8ToUTF16(REFERENCE_ACCESS_TOKEN);
518 std::unique_ptr<LocationProvider> provider(CreateProvider(false)); 515 std::unique_ptr<LocationProvider> provider(CreateProvider(false));
519 EXPECT_TRUE(provider->StartProvider(false)); 516 EXPECT_TRUE(provider->StartProvider(false));
520 net::TestURLFetcher* fetcher = get_url_fetcher_and_advance_id(); 517 net::TestURLFetcher* fetcher = get_url_fetcher_and_advance_id();
521 EXPECT_FALSE(fetcher); 518 EXPECT_FALSE(fetcher);
522 519
523 static const int kScanCount = 4; 520 static const int kScanCount = 4;
524 wifi_data_provider_->SetData(CreateReferenceWifiScanData(kScanCount)); 521 wifi_data_provider_->SetData(CreateReferenceWifiScanData(kScanCount));
525 base::RunLoop().RunUntilIdle(); 522 base::RunLoop().RunUntilIdle();
526 523
527 fetcher = get_url_fetcher_and_advance_id(); 524 fetcher = get_url_fetcher_and_advance_id();
528 EXPECT_FALSE(fetcher); 525 EXPECT_FALSE(fetcher);
529 526
530 provider->OnPermissionGranted(); 527 provider->OnPermissionGranted();
531 528
532 fetcher = get_url_fetcher_and_advance_id(); 529 fetcher = get_url_fetcher_and_advance_id();
533 ASSERT_TRUE(fetcher != NULL); 530 ASSERT_TRUE(fetcher != nullptr);
534 531
535 CheckRequestIsValid(*fetcher, 0, kScanCount, 0, REFERENCE_ACCESS_TOKEN); 532 CheckRequestIsValid(*fetcher, 0, kScanCount, 0, REFERENCE_ACCESS_TOKEN);
536 } 533 }
537 534
538 TEST_F(GeolocationNetworkProviderTest, NetworkPositionCache) { 535 TEST_F(GeolocationNetworkProviderTest, NetworkPositionCache) {
539 NetworkLocationProvider::PositionCache cache; 536 NetworkLocationProvider::PositionCache cache;
540 537
541 const int kCacheSize = NetworkLocationProvider::PositionCache::kMaximumSize; 538 const int kCacheSize = NetworkLocationProvider::PositionCache::kMaximumSize;
542 for (int i = 1; i < kCacheSize * 2 + 1; ++i) { 539 for (int i = 1; i < kCacheSize * 2 + 1; ++i) {
543 Geoposition pos = CreateReferencePosition(i); 540 Geoposition pos = CreateReferencePosition(i);
544 bool ret = cache.CachePosition(CreateReferenceWifiScanData(i), pos); 541 bool ret = cache.CachePosition(CreateReferenceWifiScanData(i), pos);
545 EXPECT_TRUE(ret) << i; 542 EXPECT_TRUE(ret) << i;
546 const Geoposition* item = 543 const Geoposition* item =
547 cache.FindPosition(CreateReferenceWifiScanData(i)); 544 cache.FindPosition(CreateReferenceWifiScanData(i));
548 ASSERT_TRUE(item) << i; 545 ASSERT_TRUE(item) << i;
549 EXPECT_EQ(pos.latitude, item->latitude) << i; 546 EXPECT_EQ(pos.latitude, item->latitude) << i;
550 EXPECT_EQ(pos.longitude, item->longitude) << i; 547 EXPECT_EQ(pos.longitude, item->longitude) << i;
551 if (i <= kCacheSize) { 548 if (i <= kCacheSize) {
552 // Nothing should have spilled yet; check oldest item is still there. 549 // Nothing should have spilled yet; check oldest item is still there.
553 EXPECT_TRUE(cache.FindPosition(CreateReferenceWifiScanData(1))); 550 EXPECT_TRUE(cache.FindPosition(CreateReferenceWifiScanData(1)));
554 } else { 551 } else {
555 const int evicted = i - kCacheSize; 552 const int evicted = i - kCacheSize;
556 EXPECT_FALSE(cache.FindPosition(CreateReferenceWifiScanData(evicted))); 553 EXPECT_FALSE(cache.FindPosition(CreateReferenceWifiScanData(evicted)));
557 EXPECT_TRUE(cache.FindPosition(CreateReferenceWifiScanData(evicted + 1))); 554 EXPECT_TRUE(cache.FindPosition(CreateReferenceWifiScanData(evicted + 1)));
558 } 555 }
559 } 556 }
560 } 557 }
561 558
562 } // namespace content 559 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698