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

Side by Side Diff: chrome/service/cloud_print/cloud_print_url_fetcher_unittest.cc

Issue 12226045: Linux/ChromeOS Chromium style checker cleanup, chrome/ edition part 1. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 10 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
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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/message_loop_proxy.h" 7 #include "base/message_loop_proxy.h"
8 #include "base/synchronization/waitable_event.h" 8 #include "base/synchronization/waitable_event.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 scoped_ptr<net::TestURLRequestContext> context_; 58 scoped_ptr<net::TestURLRequestContext> context_;
59 }; 59 };
60 60
61 class TestCloudPrintURLFetcher : public CloudPrintURLFetcher { 61 class TestCloudPrintURLFetcher : public CloudPrintURLFetcher {
62 public: 62 public:
63 explicit TestCloudPrintURLFetcher( 63 explicit TestCloudPrintURLFetcher(
64 base::MessageLoopProxy* io_message_loop_proxy) 64 base::MessageLoopProxy* io_message_loop_proxy)
65 : io_message_loop_proxy_(io_message_loop_proxy) { 65 : io_message_loop_proxy_(io_message_loop_proxy) {
66 } 66 }
67 67
68 virtual net::URLRequestContextGetter* GetRequestContextGetter() { 68 virtual net::URLRequestContextGetter* GetRequestContextGetter() OVERRIDE {
69 return new TrackingTestURLRequestContextGetter( 69 return new TrackingTestURLRequestContextGetter(
70 io_message_loop_proxy_.get(), throttler_manager()); 70 io_message_loop_proxy_.get(), throttler_manager());
71 } 71 }
72 72
73 net::URLRequestThrottlerManager* throttler_manager() { 73 net::URLRequestThrottlerManager* throttler_manager() {
74 return &throttler_manager_; 74 return &throttler_manager_;
75 } 75 }
76 76
77 private: 77 private:
78 virtual ~TestCloudPrintURLFetcher() {} 78 virtual ~TestCloudPrintURLFetcher() {}
(...skipping 13 matching lines...) Expand all
92 // Creates a URLFetcher, using the program's main thread to do IO. 92 // Creates a URLFetcher, using the program's main thread to do IO.
93 virtual void CreateFetcher(const GURL& url, int max_retries); 93 virtual void CreateFetcher(const GURL& url, int max_retries);
94 94
95 // CloudPrintURLFetcher::Delegate 95 // CloudPrintURLFetcher::Delegate
96 virtual CloudPrintURLFetcher::ResponseAction HandleRawResponse( 96 virtual CloudPrintURLFetcher::ResponseAction HandleRawResponse(
97 const net::URLFetcher* source, 97 const net::URLFetcher* source,
98 const GURL& url, 98 const GURL& url,
99 const net::URLRequestStatus& status, 99 const net::URLRequestStatus& status,
100 int response_code, 100 int response_code,
101 const net::ResponseCookies& cookies, 101 const net::ResponseCookies& cookies,
102 const std::string& data); 102 const std::string& data) OVERRIDE;
103 103
104 virtual CloudPrintURLFetcher::ResponseAction OnRequestAuthError() { 104 virtual CloudPrintURLFetcher::ResponseAction OnRequestAuthError() OVERRIDE {
105 ADD_FAILURE(); 105 ADD_FAILURE();
106 return CloudPrintURLFetcher::STOP_PROCESSING; 106 return CloudPrintURLFetcher::STOP_PROCESSING;
107 } 107 }
108 108
109 virtual std::string GetAuthHeader() { 109 virtual std::string GetAuthHeader() OVERRIDE {
110 return std::string(); 110 return std::string();
111 } 111 }
112 112
113 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy() { 113 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy() {
114 return io_message_loop_proxy_; 114 return io_message_loop_proxy_;
115 } 115 }
116 116
117 protected: 117 protected:
118 virtual void SetUp() { 118 virtual void SetUp() {
119 testing::Test::SetUp(); 119 testing::Test::SetUp();
(...skipping 25 matching lines...) Expand all
145 public: 145 public:
146 CloudPrintURLFetcherBasicTest() 146 CloudPrintURLFetcherBasicTest()
147 : handle_raw_response_(false), handle_raw_data_(false) { } 147 : handle_raw_response_(false), handle_raw_data_(false) { }
148 // CloudPrintURLFetcher::Delegate 148 // CloudPrintURLFetcher::Delegate
149 virtual CloudPrintURLFetcher::ResponseAction HandleRawResponse( 149 virtual CloudPrintURLFetcher::ResponseAction HandleRawResponse(
150 const net::URLFetcher* source, 150 const net::URLFetcher* source,
151 const GURL& url, 151 const GURL& url,
152 const net::URLRequestStatus& status, 152 const net::URLRequestStatus& status,
153 int response_code, 153 int response_code,
154 const net::ResponseCookies& cookies, 154 const net::ResponseCookies& cookies,
155 const std::string& data); 155 const std::string& data) OVERRIDE;
156 156
157 virtual CloudPrintURLFetcher::ResponseAction HandleRawData( 157 virtual CloudPrintURLFetcher::ResponseAction HandleRawData(
158 const net::URLFetcher* source, 158 const net::URLFetcher* source,
159 const GURL& url, 159 const GURL& url,
160 const std::string& data); 160 const std::string& data) OVERRIDE;
161 161
162 virtual CloudPrintURLFetcher::ResponseAction HandleJSONData( 162 virtual CloudPrintURLFetcher::ResponseAction HandleJSONData(
163 const net::URLFetcher* source, 163 const net::URLFetcher* source,
164 const GURL& url, 164 const GURL& url,
165 DictionaryValue* json_data, 165 DictionaryValue* json_data,
166 bool succeeded); 166 bool succeeded) OVERRIDE;
167 167
168 void SetHandleRawResponse(bool handle_raw_response) { 168 void SetHandleRawResponse(bool handle_raw_response) {
169 handle_raw_response_ = handle_raw_response; 169 handle_raw_response_ = handle_raw_response;
170 } 170 }
171 void SetHandleRawData(bool handle_raw_data) { 171 void SetHandleRawData(bool handle_raw_data) {
172 handle_raw_data_ = handle_raw_data; 172 handle_raw_data_ = handle_raw_data;
173 } 173 }
174 private: 174 private:
175 bool handle_raw_response_; 175 bool handle_raw_response_;
176 bool handle_raw_data_; 176 bool handle_raw_data_;
177 }; 177 };
178 178
179 // Version of CloudPrintURLFetcherTest that tests overload protection. 179 // Version of CloudPrintURLFetcherTest that tests overload protection.
180 class CloudPrintURLFetcherOverloadTest : public CloudPrintURLFetcherTest { 180 class CloudPrintURLFetcherOverloadTest : public CloudPrintURLFetcherTest {
181 public: 181 public:
182 CloudPrintURLFetcherOverloadTest() : response_count_(0) { 182 CloudPrintURLFetcherOverloadTest() : response_count_(0) {
183 } 183 }
184 184
185 // CloudPrintURLFetcher::Delegate 185 // CloudPrintURLFetcher::Delegate
186 virtual CloudPrintURLFetcher::ResponseAction HandleRawData( 186 virtual CloudPrintURLFetcher::ResponseAction HandleRawData(
187 const net::URLFetcher* source, 187 const net::URLFetcher* source,
188 const GURL& url, 188 const GURL& url,
189 const std::string& data); 189 const std::string& data) OVERRIDE;
190 190
191 private: 191 private:
192 int response_count_; 192 int response_count_;
193 }; 193 };
194 194
195 // Version of CloudPrintURLFetcherTest that tests backoff protection. 195 // Version of CloudPrintURLFetcherTest that tests backoff protection.
196 class CloudPrintURLFetcherRetryBackoffTest : public CloudPrintURLFetcherTest { 196 class CloudPrintURLFetcherRetryBackoffTest : public CloudPrintURLFetcherTest {
197 public: 197 public:
198 CloudPrintURLFetcherRetryBackoffTest() : response_count_(0) { 198 CloudPrintURLFetcherRetryBackoffTest() : response_count_(0) {
199 } 199 }
200 200
201 // CloudPrintURLFetcher::Delegate 201 // CloudPrintURLFetcher::Delegate
202 virtual CloudPrintURLFetcher::ResponseAction HandleRawData( 202 virtual CloudPrintURLFetcher::ResponseAction HandleRawData(
203 const net::URLFetcher* source, 203 const net::URLFetcher* source,
204 const GURL& url, 204 const GURL& url,
205 const std::string& data); 205 const std::string& data) OVERRIDE;
206 206
207 virtual void OnRequestGiveUp(); 207 virtual void OnRequestGiveUp() OVERRIDE;
208 208
209 private: 209 private:
210 int response_count_; 210 int response_count_;
211 }; 211 };
212 212
213 213
214 void CloudPrintURLFetcherTest::CreateFetcher(const GURL& url, int max_retries) { 214 void CloudPrintURLFetcherTest::CreateFetcher(const GURL& url, int max_retries) {
215 fetcher_ = new TestCloudPrintURLFetcher(io_message_loop_proxy()); 215 fetcher_ = new TestCloudPrintURLFetcher(io_message_loop_proxy());
216 216
217 // Registers an entry for test url. It only allows 3 requests to be sent 217 // Registers an entry for test url. It only allows 3 requests to be sent
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 FilePath(kDocRoot)); 366 FilePath(kDocRoot));
367 ASSERT_TRUE(test_server.Start()); 367 ASSERT_TRUE(test_server.Start());
368 368
369 GURL url(test_server.GetURL("defaultresponse")); 369 GURL url(test_server.GetURL("defaultresponse"));
370 CreateFetcher(url, 11); 370 CreateFetcher(url, 11);
371 371
372 MessageLoop::current()->Run(); 372 MessageLoop::current()->Run();
373 } 373 }
374 374
375 } // namespace cloud_print 375 } // namespace cloud_print
OLDNEW
« no previous file with comments | « chrome/renderer/searchbox/searchbox_extension.cc ('k') | chrome/service/cloud_print/print_system_cups.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698