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

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

Issue 1239993004: Fix all failed and canceled URLRequestStatuses without errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix more failures Created 5 years, 4 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 "base/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 #include "base/json/json_writer.h" 6 #include "base/json/json_writer.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "content/browser/geolocation/fake_access_token_store.h" 13 #include "content/browser/geolocation/fake_access_token_store.h"
14 #include "content/browser/geolocation/location_arbitrator_impl.h" 14 #include "content/browser/geolocation/location_arbitrator_impl.h"
15 #include "content/browser/geolocation/network_location_provider.h" 15 #include "content/browser/geolocation/network_location_provider.h"
16 #include "content/browser/geolocation/wifi_data_provider.h" 16 #include "content/browser/geolocation/wifi_data_provider.h"
17 #include "net/base/net_errors.h"
17 #include "net/url_request/test_url_fetcher_factory.h" 18 #include "net/url_request/test_url_fetcher_factory.h"
18 #include "net/url_request/url_request_status.h" 19 #include "net/url_request/url_request_status.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 namespace content { 22 namespace content {
22 23
23 // Constants used in multiple tests. 24 // Constants used in multiple tests.
24 const char kTestServerUrl[] = "https://www.geolocation.test/service"; 25 const char kTestServerUrl[] = "https://www.geolocation.test/service";
25 const char kAccessTokenString[] = "accessToken"; 26 const char kAccessTokenString[] = "accessToken";
26 27
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 // Now a third scan with more than twice the original amount -> new request. 431 // Now a third scan with more than twice the original amount -> new request.
431 const int kThirdScanAps = kFirstScanAps * 2 + 1; 432 const int kThirdScanAps = kFirstScanAps * 2 + 1;
432 wifi_data_provider_->SetData(CreateReferenceWifiScanData(kThirdScanAps)); 433 wifi_data_provider_->SetData(CreateReferenceWifiScanData(kThirdScanAps));
433 main_message_loop_.RunUntilIdle(); 434 main_message_loop_.RunUntilIdle();
434 fetcher = get_url_fetcher_and_advance_id(); 435 fetcher = get_url_fetcher_and_advance_id();
435 EXPECT_TRUE(fetcher); 436 EXPECT_TRUE(fetcher);
436 CheckRequestIsValid(*fetcher, 0, kThirdScanAps, 0, REFERENCE_ACCESS_TOKEN); 437 CheckRequestIsValid(*fetcher, 0, kThirdScanAps, 0, REFERENCE_ACCESS_TOKEN);
437 // ...reply with a network error. 438 // ...reply with a network error.
438 439
439 fetcher->set_url(test_server_url_); 440 fetcher->set_url(test_server_url_);
440 fetcher->set_status(net::URLRequestStatus(net::URLRequestStatus::FAILED, -1)); 441 fetcher->set_status(net::URLRequestStatus::FromError(net::ERR_FAILED));
441 fetcher->set_response_code(200); // should be ignored 442 fetcher->set_response_code(200); // should be ignored
442 fetcher->SetResponseString(std::string()); 443 fetcher->SetResponseString(std::string());
443 fetcher->delegate()->OnURLFetchComplete(fetcher); 444 fetcher->delegate()->OnURLFetchComplete(fetcher);
444 445
445 // Error means we now no longer have a fix. 446 // Error means we now no longer have a fix.
446 provider->GetPosition(&position); 447 provider->GetPosition(&position);
447 EXPECT_FALSE(position.Validate()); 448 EXPECT_FALSE(position.Validate());
448 449
449 // Wifi scan returns to original set: should be serviced from cache. 450 // Wifi scan returns to original set: should be serviced from cache.
450 wifi_data_provider_->SetData(CreateReferenceWifiScanData(kFirstScanAps)); 451 wifi_data_provider_->SetData(CreateReferenceWifiScanData(kFirstScanAps));
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 EXPECT_TRUE(cache.FindPosition(CreateReferenceWifiScanData(1))); 546 EXPECT_TRUE(cache.FindPosition(CreateReferenceWifiScanData(1)));
546 } else { 547 } else {
547 const int evicted = i - kCacheSize; 548 const int evicted = i - kCacheSize;
548 EXPECT_FALSE(cache.FindPosition(CreateReferenceWifiScanData(evicted))); 549 EXPECT_FALSE(cache.FindPosition(CreateReferenceWifiScanData(evicted)));
549 EXPECT_TRUE(cache.FindPosition(CreateReferenceWifiScanData(evicted + 1))); 550 EXPECT_TRUE(cache.FindPosition(CreateReferenceWifiScanData(evicted + 1)));
550 } 551 }
551 } 552 }
552 } 553 }
553 554
554 } // namespace content 555 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698