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

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

Issue 12210088: Make the TestServer use an absolute document root path. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: testserver uses absolute docroot path 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"
11 #include "chrome/service/cloud_print/cloud_print_url_fetcher.h" 11 #include "chrome/service/cloud_print/cloud_print_url_fetcher.h"
12 #include "chrome/service/service_process.h" 12 #include "chrome/service/service_process.h"
13 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
14 #include "net/test/test_server.h" 14 #include "net/test/test_server.h"
15 #include "net/url_request/url_request_context_getter.h" 15 #include "net/url_request/url_request_context_getter.h"
16 #include "net/url_request/url_request_status.h" 16 #include "net/url_request/url_request_status.h"
17 #include "net/url_request/url_request_test_util.h" 17 #include "net/url_request/url_request_test_util.h"
18 #include "net/url_request/url_request_throttler_manager.h" 18 #include "net/url_request/url_request_throttler_manager.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 using base::Time; 21 using base::Time;
22 using base::TimeDelta; 22 using base::TimeDelta;
23 23
24 namespace cloud_print { 24 namespace cloud_print {
25 25
26 const base::FilePath::CharType kDocRoot[] =
27 FILE_PATH_LITERAL("chrome/test/data");
28
29 int g_request_context_getter_instances = 0; 26 int g_request_context_getter_instances = 0;
30 class TrackingTestURLRequestContextGetter 27 class TrackingTestURLRequestContextGetter
31 : public net::TestURLRequestContextGetter { 28 : public net::TestURLRequestContextGetter {
32 public: 29 public:
33 explicit TrackingTestURLRequestContextGetter( 30 explicit TrackingTestURLRequestContextGetter(
34 base::MessageLoopProxy* io_message_loop_proxy, 31 base::MessageLoopProxy* io_message_loop_proxy,
35 net::URLRequestThrottlerManager* throttler_manager) 32 net::URLRequestThrottlerManager* throttler_manager)
36 : TestURLRequestContextGetter(io_message_loop_proxy), 33 : TestURLRequestContextGetter(io_message_loop_proxy),
37 throttler_manager_(throttler_manager), 34 throttler_manager_(throttler_manager),
38 context_(NULL) { 35 context_(NULL) {
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 320
324 void CloudPrintURLFetcherRetryBackoffTest::OnRequestGiveUp() { 321 void CloudPrintURLFetcherRetryBackoffTest::OnRequestGiveUp() {
325 // It takes more than 200 ms to finish all 11 requests. 322 // It takes more than 200 ms to finish all 11 requests.
326 EXPECT_TRUE(Time::Now() - start_time_ >= TimeDelta::FromMilliseconds(200)); 323 EXPECT_TRUE(Time::Now() - start_time_ >= TimeDelta::FromMilliseconds(200));
327 io_message_loop_proxy()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 324 io_message_loop_proxy()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
328 } 325 }
329 326
330 TEST_F(CloudPrintURLFetcherBasicTest, HandleRawResponse) { 327 TEST_F(CloudPrintURLFetcherBasicTest, HandleRawResponse) {
331 net::TestServer test_server(net::TestServer::TYPE_HTTP, 328 net::TestServer test_server(net::TestServer::TYPE_HTTP,
332 net::TestServer::kLocalhost, 329 net::TestServer::kLocalhost,
333 base::FilePath(kDocRoot)); 330 net::TestServer::GetTestDataPath());
334 ASSERT_TRUE(test_server.Start()); 331 ASSERT_TRUE(test_server.Start());
335 SetHandleRawResponse(true); 332 SetHandleRawResponse(true);
336 333
337 CreateFetcher(test_server.GetURL("echo"), 0); 334 CreateFetcher(test_server.GetURL("echo"), 0);
338 MessageLoop::current()->Run(); 335 MessageLoop::current()->Run();
339 } 336 }
340 337
341 TEST_F(CloudPrintURLFetcherBasicTest, HandleRawData) { 338 TEST_F(CloudPrintURLFetcherBasicTest, HandleRawData) {
342 net::TestServer test_server(net::TestServer::TYPE_HTTP, 339 net::TestServer test_server(net::TestServer::TYPE_HTTP,
343 net::TestServer::kLocalhost, 340 net::TestServer::kLocalhost,
344 base::FilePath(kDocRoot)); 341 net::TestServer::GetTestDataPath());
345 ASSERT_TRUE(test_server.Start()); 342 ASSERT_TRUE(test_server.Start());
346 343
347 SetHandleRawData(true); 344 SetHandleRawData(true);
348 CreateFetcher(test_server.GetURL("echo"), 0); 345 CreateFetcher(test_server.GetURL("echo"), 0);
349 MessageLoop::current()->Run(); 346 MessageLoop::current()->Run();
350 } 347 }
351 348
352 TEST_F(CloudPrintURLFetcherOverloadTest, Protect) { 349 TEST_F(CloudPrintURLFetcherOverloadTest, Protect) {
353 net::TestServer test_server(net::TestServer::TYPE_HTTP, 350 net::TestServer test_server(net::TestServer::TYPE_HTTP,
354 net::TestServer::kLocalhost, 351 net::TestServer::kLocalhost,
355 base::FilePath(kDocRoot)); 352 net::TestServer::GetTestDataPath());
356 ASSERT_TRUE(test_server.Start()); 353 ASSERT_TRUE(test_server.Start());
357 354
358 GURL url(test_server.GetURL("defaultresponse")); 355 GURL url(test_server.GetURL("defaultresponse"));
359 CreateFetcher(url, 11); 356 CreateFetcher(url, 11);
360 357
361 MessageLoop::current()->Run(); 358 MessageLoop::current()->Run();
362 } 359 }
363 360
364 TEST_F(CloudPrintURLFetcherRetryBackoffTest, GiveUp) { 361 TEST_F(CloudPrintURLFetcherRetryBackoffTest, GiveUp) {
365 net::TestServer test_server(net::TestServer::TYPE_HTTP, 362 net::TestServer test_server(net::TestServer::TYPE_HTTP,
366 net::TestServer::kLocalhost, 363 net::TestServer::kLocalhost,
367 base::FilePath(kDocRoot)); 364 net::TestServer::GetTestDataPath());
368 ASSERT_TRUE(test_server.Start()); 365 ASSERT_TRUE(test_server.Start());
369 366
370 GURL url(test_server.GetURL("defaultresponse")); 367 GURL url(test_server.GetURL("defaultresponse"));
371 CreateFetcher(url, 11); 368 CreateFetcher(url, 11);
372 369
373 MessageLoop::current()->Run(); 370 MessageLoop::current()->Run();
374 } 371 }
375 372
376 } // namespace cloud_print 373 } // namespace cloud_print
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698