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

Side by Side Diff: chrome/browser/google_apis/drive_api_requests_unittest.cc

Issue 18659002: Remove use of TestBrowserThreadBundle from unit tests in c/b/google_apis. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/bind.h" 5 #include "base/bind.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 10 #include "base/run_loop.h"
10 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 #include "chrome/browser/google_apis/auth_service.h" 13 #include "chrome/browser/google_apis/auth_service.h"
13 #include "chrome/browser/google_apis/drive_api_parser.h" 14 #include "chrome/browser/google_apis/drive_api_parser.h"
14 #include "chrome/browser/google_apis/drive_api_requests.h" 15 #include "chrome/browser/google_apis/drive_api_requests.h"
15 #include "chrome/browser/google_apis/drive_api_url_generator.h" 16 #include "chrome/browser/google_apis/drive_api_url_generator.h"
16 #include "chrome/browser/google_apis/request_sender.h" 17 #include "chrome/browser/google_apis/request_sender.h"
17 #include "chrome/browser/google_apis/test_util.h" 18 #include "chrome/browser/google_apis/test_util.h"
18 #include "chrome/test/base/testing_profile.h" 19 #include "chrome/test/base/testing_profile.h"
19 #include "content/public/browser/browser_thread.h"
20 #include "content/public/test/test_browser_thread_bundle.h"
21 #include "net/test/embedded_test_server/embedded_test_server.h" 20 #include "net/test/embedded_test_server/embedded_test_server.h"
22 #include "net/test/embedded_test_server/http_request.h" 21 #include "net/test/embedded_test_server/http_request.h"
23 #include "net/test/embedded_test_server/http_response.h" 22 #include "net/test/embedded_test_server/http_response.h"
24 #include "net/url_request/url_request_test_util.h" 23 #include "net/url_request/url_request_test_util.h"
25 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
26 25
27 namespace google_apis { 26 namespace google_apis {
28 27
29 namespace { 28 namespace {
30 29
(...skipping 11 matching lines...) Expand all
42 41
43 const char kTestUploadExistingFilePath[] = "/upload/existingfile/path"; 42 const char kTestUploadExistingFilePath[] = "/upload/existingfile/path";
44 const char kTestUploadNewFilePath[] = "/upload/newfile/path"; 43 const char kTestUploadNewFilePath[] = "/upload/newfile/path";
45 const char kTestDownloadPathPrefix[] = "/download/"; 44 const char kTestDownloadPathPrefix[] = "/download/";
46 45
47 } // namespace 46 } // namespace
48 47
49 class DriveApiRequestsTest : public testing::Test { 48 class DriveApiRequestsTest : public testing::Test {
50 public: 49 public:
51 DriveApiRequestsTest() 50 DriveApiRequestsTest()
52 : thread_bundle_(content::TestBrowserThreadBundle::REAL_IO_THREAD), 51 : test_server_(message_loop_.message_loop_proxy()) {
53 test_server_(content::BrowserThread::GetMessageLoopProxyForThread(
54 content::BrowserThread::IO)) {
55 } 52 }
56 53
57 virtual void SetUp() OVERRIDE { 54 virtual void SetUp() OVERRIDE {
58 profile_.reset(new TestingProfile); 55 profile_.reset(new TestingProfile);
59 56
60 request_context_getter_ = new net::TestURLRequestContextGetter( 57 request_context_getter_ = new net::TestURLRequestContextGetter(
61 content::BrowserThread::GetMessageLoopProxyForThread( 58 message_loop_.message_loop_proxy());
62 content::BrowserThread::IO));
63 59
64 request_sender_.reset(new RequestSender(profile_.get(), 60 request_sender_.reset(new RequestSender(profile_.get(),
65 request_context_getter_.get(), 61 request_context_getter_.get(),
66 std::vector<std::string>(), 62 std::vector<std::string>(),
67 kTestUserAgent)); 63 kTestUserAgent));
68 request_sender_->auth_service()->set_access_token_for_testing( 64 request_sender_->auth_service()->set_access_token_for_testing(
69 kTestDriveApiAuthToken); 65 kTestDriveApiAuthToken);
70 66
71 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 67 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
72 68
(...skipping 20 matching lines...) Expand all
93 GURL test_base_url = test_util::GetBaseUrlForTesting(test_server_.port()); 89 GURL test_base_url = test_util::GetBaseUrlForTesting(test_server_.port());
94 url_generator_.reset(new DriveApiUrlGenerator( 90 url_generator_.reset(new DriveApiUrlGenerator(
95 test_base_url, test_base_url.Resolve(kTestDownloadPathPrefix))); 91 test_base_url, test_base_url.Resolve(kTestDownloadPathPrefix)));
96 92
97 // Reset the server's expected behavior just in case. 93 // Reset the server's expected behavior just in case.
98 ResetExpectedResponse(); 94 ResetExpectedResponse();
99 received_bytes_ = 0; 95 received_bytes_ = 0;
100 content_length_ = 0; 96 content_length_ = 0;
101 } 97 }
102 98
103 content::TestBrowserThreadBundle thread_bundle_; 99 base::MessageLoopForIO message_loop_; // Test server needs IO thread.
104 net::test_server::EmbeddedTestServer test_server_; 100 net::test_server::EmbeddedTestServer test_server_;
105 scoped_ptr<TestingProfile> profile_; 101 scoped_ptr<TestingProfile> profile_;
106 scoped_ptr<RequestSender> request_sender_; 102 scoped_ptr<RequestSender> request_sender_;
107 scoped_ptr<DriveApiUrlGenerator> url_generator_; 103 scoped_ptr<DriveApiUrlGenerator> url_generator_;
108 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; 104 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_;
109 base::ScopedTempDir temp_dir_; 105 base::ScopedTempDir temp_dir_;
110 106
111 // This is a path to the file which contains expected response from 107 // This is a path to the file which contains expected response from
112 // the server. See also HandleDataFileRequest below. 108 // the server. See also HandleDataFileRequest below.
113 base::FilePath expected_data_file_path_; 109 base::FilePath expected_data_file_path_;
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 EXPECT_EQ(HTTP_SUCCESS, result_code); 1388 EXPECT_EQ(HTTP_SUCCESS, result_code);
1393 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); 1389 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method);
1394 EXPECT_EQ(kTestDownloadPathPrefix + kTestId, http_request_.relative_url); 1390 EXPECT_EQ(kTestDownloadPathPrefix + kTestId, http_request_.relative_url);
1395 EXPECT_EQ(kDownloadedFilePath, temp_file); 1391 EXPECT_EQ(kDownloadedFilePath, temp_file);
1396 1392
1397 const std::string expected_contents = kTestId + kTestId + kTestId; 1393 const std::string expected_contents = kTestId + kTestId + kTestId;
1398 EXPECT_EQ(expected_contents, contents); 1394 EXPECT_EQ(expected_contents, contents);
1399 } 1395 }
1400 1396
1401 } // namespace google_apis 1397 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/base_requests_unittest.cc ('k') | chrome/browser/google_apis/gdata_wapi_requests_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698