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

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

Issue 7524033: Add a scoper object for URLFetcher::Factory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 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 | Annotate | Revision Log
« no previous file with comments | « content/DEPS ('k') | content/browser/speech/speech_recognition_request_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/stringprintf.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "content/browser/geolocation/fake_access_token_store.h" 10 #include "content/browser/geolocation/fake_access_token_store.h"
11 #include "content/browser/geolocation/network_location_provider.h" 11 #include "content/browser/geolocation/network_location_provider.h"
12 #include "content/common/test_url_fetcher_factory.h" 12 #include "content/test/test_url_fetcher_factory.h"
13 #include "net/url_request/url_request_status.h" 13 #include "net/url_request/url_request_status.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace { 16 namespace {
17 17
18 // Constants used in multiple tests. 18 // Constants used in multiple tests.
19 const char kTestServerUrl[] = "https://www.geolocation.test/service"; 19 const char kTestServerUrl[] = "https://www.geolocation.test/service";
20 const char kTestHost[] = "myclienthost.test"; 20 const char kTestHost[] = "myclienthost.test";
21 const char kTestHostUrl[] = "http://myclienthost.test/some/path"; 21 const char kTestHostUrl[] = "http://myclienthost.test/some/path";
22 // Using #define so we can easily paste this into various other strings. 22 // Using #define so we can easily paste this into various other strings.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 }; 108 };
109 109
110 template<typename DataType> 110 template<typename DataType>
111 MockDeviceDataProviderImpl<DataType>* 111 MockDeviceDataProviderImpl<DataType>*
112 MockDeviceDataProviderImpl<DataType>::instance_ = NULL; 112 MockDeviceDataProviderImpl<DataType>::instance_ = NULL;
113 113
114 // Main test fixture 114 // Main test fixture
115 class GeolocationNetworkProviderTest : public testing::Test { 115 class GeolocationNetworkProviderTest : public testing::Test {
116 public: 116 public:
117 virtual void SetUp() { 117 virtual void SetUp() {
118 URLFetcher::set_factory(&url_fetcher_factory_);
119 access_token_store_ = new FakeAccessTokenStore; 118 access_token_store_ = new FakeAccessTokenStore;
120 gateway_data_provider_ = 119 gateway_data_provider_ =
121 MockDeviceDataProviderImpl<GatewayData>::CreateInstance(); 120 MockDeviceDataProviderImpl<GatewayData>::CreateInstance();
122 radio_data_provider_ = 121 radio_data_provider_ =
123 MockDeviceDataProviderImpl<RadioData>::CreateInstance(); 122 MockDeviceDataProviderImpl<RadioData>::CreateInstance();
124 wifi_data_provider_ = 123 wifi_data_provider_ =
125 MockDeviceDataProviderImpl<WifiData>::CreateInstance(); 124 MockDeviceDataProviderImpl<WifiData>::CreateInstance();
126 } 125 }
127 126
128 virtual void TearDown() { 127 virtual void TearDown() {
129 WifiDataProvider::ResetFactory(); 128 WifiDataProvider::ResetFactory();
130 RadioDataProvider::ResetFactory(); 129 RadioDataProvider::ResetFactory();
131 GatewayDataProvider::ResetFactory(); 130 GatewayDataProvider::ResetFactory();
132 URLFetcher::set_factory(NULL);
133 } 131 }
134 132
135 LocationProviderBase* CreateProvider(bool set_permission_granted) { 133 LocationProviderBase* CreateProvider(bool set_permission_granted) {
136 LocationProviderBase* provider = NewNetworkLocationProvider( 134 LocationProviderBase* provider = NewNetworkLocationProvider(
137 access_token_store_.get(), 135 access_token_store_.get(),
138 NULL, // No URLContextGetter needed, as using test urlfecther factory. 136 NULL, // No URLContextGetter needed, as using test urlfecther factory.
139 test_server_url_, 137 test_server_url_,
140 access_token_store_->access_token_set_[test_server_url_]); 138 access_token_store_->access_token_set_[test_server_url_]);
141 if (set_permission_granted) 139 if (set_permission_granted)
142 provider->OnPermissionGranted(GURL(kTestHostUrl)); 140 provider->OnPermissionGranted(GURL(kTestHostUrl));
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 const int evicted = i - kCacheSize; 771 const int evicted = i - kCacheSize;
774 EXPECT_FALSE(cache.FindPosition(CreateReferenceRouterData(2), 772 EXPECT_FALSE(cache.FindPosition(CreateReferenceRouterData(2),
775 CreateReferenceWifiScanData(evicted))); 773 CreateReferenceWifiScanData(evicted)));
776 EXPECT_TRUE(cache.FindPosition(CreateReferenceRouterData(2), 774 EXPECT_TRUE(cache.FindPosition(CreateReferenceRouterData(2),
777 CreateReferenceWifiScanData(evicted + 1))); 775 CreateReferenceWifiScanData(evicted + 1)));
778 } 776 }
779 } 777 }
780 } 778 }
781 779
782 } // namespace 780 } // namespace
OLDNEW
« no previous file with comments | « content/DEPS ('k') | content/browser/speech/speech_recognition_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698