OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/message_loop_proxy.h" | 6 #include "base/message_loop_proxy.h" |
7 #include "base/ref_counted.h" | 7 #include "base/ref_counted.h" |
8 #include "base/thread.h" | 8 #include "base/thread.h" |
9 #include "base/waitable_event.h" | 9 #include "base/waitable_event.h" |
10 #include "chrome/common/net/url_request_context_getter.h" | 10 #include "chrome/common/net/url_request_context_getter.h" |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 return CloudPrintURLFetcher::RETRY_REQUEST; | 284 return CloudPrintURLFetcher::RETRY_REQUEST; |
285 } | 285 } |
286 | 286 |
287 void CloudPrintURLFetcherRetryBackoffTest::OnRequestGiveUp() { | 287 void CloudPrintURLFetcherRetryBackoffTest::OnRequestGiveUp() { |
288 const TimeDelta one_second = TimeDelta::FromMilliseconds(1000); | 288 const TimeDelta one_second = TimeDelta::FromMilliseconds(1000); |
289 // It takes more than 1 second to finish all 11 requests. | 289 // It takes more than 1 second to finish all 11 requests. |
290 EXPECT_TRUE(Time::Now() - start_time_ >= one_second); | 290 EXPECT_TRUE(Time::Now() - start_time_ >= one_second); |
291 io_message_loop_proxy()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 291 io_message_loop_proxy()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
292 } | 292 } |
293 | 293 |
294 TEST_F(CloudPrintURLFetcherBasicTest, HandleRawResponse) { | 294 // http://code.google.com/p/chromium/issues/detail?id=60426 |
| 295 TEST_F(CloudPrintURLFetcherBasicTest, FLAKY_HandleRawResponse) { |
295 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); | 296 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); |
296 ASSERT_TRUE(test_server.Start()); | 297 ASSERT_TRUE(test_server.Start()); |
297 SetHandleRawResponse(true); | 298 SetHandleRawResponse(true); |
298 | 299 |
299 CreateFetcher(test_server.GetURL("echo"), 0); | 300 CreateFetcher(test_server.GetURL("echo"), 0); |
300 MessageLoop::current()->Run(); | 301 MessageLoop::current()->Run(); |
301 } | 302 } |
302 | 303 |
303 // http://code.google.com/p/chromium/issues/detail?id=62758 | 304 // http://code.google.com/p/chromium/issues/detail?id=60426 |
304 TEST_F(CloudPrintURLFetcherBasicTest, FLAKY_HandleRawData) { | 305 TEST_F(CloudPrintURLFetcherBasicTest, FLAKY_HandleRawData) { |
305 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); | 306 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); |
306 ASSERT_TRUE(test_server.Start()); | 307 ASSERT_TRUE(test_server.Start()); |
307 | 308 |
308 SetHandleRawData(true); | 309 SetHandleRawData(true); |
309 CreateFetcher(test_server.GetURL("echo"), 0); | 310 CreateFetcher(test_server.GetURL("echo"), 0); |
310 MessageLoop::current()->Run(); | 311 MessageLoop::current()->Run(); |
311 } | 312 } |
312 | 313 |
313 TEST_F(CloudPrintURLFetcherOverloadTest, Protect) { | 314 TEST_F(CloudPrintURLFetcherOverloadTest, Protect) { |
314 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); | 315 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); |
315 ASSERT_TRUE(test_server.Start()); | 316 ASSERT_TRUE(test_server.Start()); |
316 | 317 |
317 GURL url(test_server.GetURL("defaultresponse")); | 318 GURL url(test_server.GetURL("defaultresponse")); |
318 | 319 |
319 // Registers an entry for test url. It only allows 3 requests to be sent | 320 // Registers an entry for test url. It only allows 3 requests to be sent |
320 // in 200 milliseconds. | 321 // in 200 milliseconds. |
321 scoped_refptr<net::URLRequestThrottlerEntry> entry( | 322 scoped_refptr<net::URLRequestThrottlerEntry> entry( |
322 new net::URLRequestThrottlerEntry(200, 3, 1, 0, 2.0, 0.0, 256)); | 323 new net::URLRequestThrottlerEntry(200, 3, 1, 0, 2.0, 0.0, 256)); |
323 net::URLRequestThrottlerManager::GetInstance()->OverrideEntryForTests( | 324 net::URLRequestThrottlerManager::GetInstance()->OverrideEntryForTests( |
324 url, entry); | 325 url, entry); |
325 | 326 |
326 CreateFetcher(url, 11); | 327 CreateFetcher(url, 11); |
327 | 328 |
328 MessageLoop::current()->Run(); | 329 MessageLoop::current()->Run(); |
329 | 330 |
330 net::URLRequestThrottlerManager::GetInstance()->EraseEntryForTests(url); | 331 net::URLRequestThrottlerManager::GetInstance()->EraseEntryForTests(url); |
331 } | 332 } |
332 | 333 |
333 // http://code.google.com/p/chromium/issues/detail?id=62758 | 334 // http://code.google.com/p/chromium/issues/detail?id=60426 |
334 TEST_F(CloudPrintURLFetcherRetryBackoffTest, FLAKY_GiveUp) { | 335 TEST_F(CloudPrintURLFetcherRetryBackoffTest, FLAKY_GiveUp) { |
335 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); | 336 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); |
336 ASSERT_TRUE(test_server.Start()); | 337 ASSERT_TRUE(test_server.Start()); |
337 | 338 |
338 GURL url(test_server.GetURL("defaultresponse")); | 339 GURL url(test_server.GetURL("defaultresponse")); |
339 | 340 |
340 // Registers an entry for test url. The backoff time is calculated by: | 341 // Registers an entry for test url. The backoff time is calculated by: |
341 // new_backoff = 2.0 * old_backoff + 0 | 342 // new_backoff = 2.0 * old_backoff + 0 |
342 // and maximum backoff time is 256 milliseconds. | 343 // and maximum backoff time is 256 milliseconds. |
343 // Maximum retries allowed is set to 11. | 344 // Maximum retries allowed is set to 11. |
344 scoped_refptr<net::URLRequestThrottlerEntry> entry( | 345 scoped_refptr<net::URLRequestThrottlerEntry> entry( |
345 new net::URLRequestThrottlerEntry(200, 3, 1, 0, 2.0, 0.0, 256)); | 346 new net::URLRequestThrottlerEntry(200, 3, 1, 0, 2.0, 0.0, 256)); |
346 net::URLRequestThrottlerManager::GetInstance()->OverrideEntryForTests( | 347 net::URLRequestThrottlerManager::GetInstance()->OverrideEntryForTests( |
347 url, entry); | 348 url, entry); |
348 | 349 |
349 CreateFetcher(url, 11); | 350 CreateFetcher(url, 11); |
350 | 351 |
351 MessageLoop::current()->Run(); | 352 MessageLoop::current()->Run(); |
352 | 353 |
353 net::URLRequestThrottlerManager::GetInstance()->EraseEntryForTests(url); | 354 net::URLRequestThrottlerManager::GetInstance()->EraseEntryForTests(url); |
354 } | 355 } |
355 | 356 |
356 } // namespace. | 357 } // namespace. |
OLD | NEW |