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

Side by Side Diff: chrome/browser/google_apis/gdata_wapi_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
« no previous file with comments | « chrome/browser/google_apis/drive_api_requests_unittest.cc ('k') | no next file » | 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) 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 <algorithm> 5 #include <algorithm>
6 #include <map> 6 #include <map>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/json/json_reader.h" 12 #include "base/json/json_reader.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/message_loop/message_loop.h"
14 #include "base/run_loop.h" 15 #include "base/run_loop.h"
15 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
17 #include "base/values.h" 18 #include "base/values.h"
18 #include "chrome/browser/google_apis/auth_service.h" 19 #include "chrome/browser/google_apis/auth_service.h"
19 #include "chrome/browser/google_apis/gdata_wapi_parser.h" 20 #include "chrome/browser/google_apis/gdata_wapi_parser.h"
20 #include "chrome/browser/google_apis/gdata_wapi_requests.h" 21 #include "chrome/browser/google_apis/gdata_wapi_requests.h"
21 #include "chrome/browser/google_apis/gdata_wapi_url_generator.h" 22 #include "chrome/browser/google_apis/gdata_wapi_url_generator.h"
22 #include "chrome/browser/google_apis/request_sender.h" 23 #include "chrome/browser/google_apis/request_sender.h"
23 #include "chrome/browser/google_apis/test_util.h" 24 #include "chrome/browser/google_apis/test_util.h"
24 #include "chrome/test/base/testing_profile.h" 25 #include "chrome/test/base/testing_profile.h"
25 #include "content/public/browser/browser_thread.h"
26 #include "content/public/test/test_browser_thread_bundle.h"
27 #include "net/base/escape.h" 26 #include "net/base/escape.h"
28 #include "net/test/embedded_test_server/embedded_test_server.h" 27 #include "net/test/embedded_test_server/embedded_test_server.h"
29 #include "net/test/embedded_test_server/http_request.h" 28 #include "net/test/embedded_test_server/http_request.h"
30 #include "net/test/embedded_test_server/http_response.h" 29 #include "net/test/embedded_test_server/http_response.h"
31 #include "net/url_request/url_request_test_util.h" 30 #include "net/url_request/url_request_test_util.h"
32 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
33 32
34 namespace google_apis { 33 namespace google_apis {
35 34
36 namespace { 35 namespace {
37 36
38 const char kTestGDataAuthToken[] = "testtoken"; 37 const char kTestGDataAuthToken[] = "testtoken";
39 const char kTestUserAgent[] = "test-user-agent"; 38 const char kTestUserAgent[] = "test-user-agent";
40 const char kTestETag[] = "test_etag"; 39 const char kTestETag[] = "test_etag";
41 const char kTestDownloadPathPrefix[] = "/download/"; 40 const char kTestDownloadPathPrefix[] = "/download/";
42 41
43 class GDataWapiRequestsTest : public testing::Test { 42 class GDataWapiRequestsTest : public testing::Test {
44 public: 43 public:
45 GDataWapiRequestsTest() 44 GDataWapiRequestsTest()
46 : thread_bundle_(content::TestBrowserThreadBundle::REAL_IO_THREAD), 45 : test_server_(message_loop_.message_loop_proxy()) {
47 test_server_(content::BrowserThread::GetMessageLoopProxyForThread(
48 content::BrowserThread::IO)) {
49 } 46 }
50 47
51 virtual void SetUp() OVERRIDE { 48 virtual void SetUp() OVERRIDE {
52 profile_.reset(new TestingProfile); 49 profile_.reset(new TestingProfile);
53 50
54 request_context_getter_ = new net::TestURLRequestContextGetter( 51 request_context_getter_ = new net::TestURLRequestContextGetter(
55 content::BrowserThread::GetMessageLoopProxyForThread( 52 message_loop_.message_loop_proxy());
56 content::BrowserThread::IO));
57 53
58 request_sender_.reset(new RequestSender(profile_.get(), 54 request_sender_.reset(new RequestSender(profile_.get(),
59 request_context_getter_.get(), 55 request_context_getter_.get(),
60 std::vector<std::string>(), 56 std::vector<std::string>(),
61 kTestUserAgent)); 57 kTestUserAgent));
62 request_sender_->auth_service()->set_access_token_for_testing( 58 request_sender_->auth_service()->set_access_token_for_testing(
63 kTestGDataAuthToken); 59 kTestGDataAuthToken);
64 60
65 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 61 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
66 62
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 323
328 // For testing, returns a text with |id| repeated 3 times. 324 // For testing, returns a text with |id| repeated 3 times.
329 scoped_ptr<net::test_server::BasicHttpResponse> response( 325 scoped_ptr<net::test_server::BasicHttpResponse> response(
330 new net::test_server::BasicHttpResponse); 326 new net::test_server::BasicHttpResponse);
331 response->set_code(net::HTTP_OK); 327 response->set_code(net::HTTP_OK);
332 response->set_content(id + id + id); 328 response->set_content(id + id + id);
333 response->set_content_type("text/plain"); 329 response->set_content_type("text/plain");
334 return response.PassAs<net::test_server::HttpResponse>(); 330 return response.PassAs<net::test_server::HttpResponse>();
335 } 331 }
336 332
337 content::TestBrowserThreadBundle thread_bundle_; 333 base::MessageLoopForIO message_loop_; // Test server needs IO thread.
338 net::test_server::EmbeddedTestServer test_server_; 334 net::test_server::EmbeddedTestServer test_server_;
339 scoped_ptr<TestingProfile> profile_; 335 scoped_ptr<TestingProfile> profile_;
340 scoped_ptr<RequestSender> request_sender_; 336 scoped_ptr<RequestSender> request_sender_;
341 scoped_ptr<GDataWapiUrlGenerator> url_generator_; 337 scoped_ptr<GDataWapiUrlGenerator> url_generator_;
342 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; 338 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_;
343 base::ScopedTempDir temp_dir_; 339 base::ScopedTempDir temp_dir_;
344 340
345 // These fields are used to keep the current upload state during a 341 // These fields are used to keep the current upload state during a
346 // test case. These values are updated by the request from 342 // test case. These values are updated by the request from
347 // ResumeUploadRequest, and used to construct the response for 343 // ResumeUploadRequest, and used to construct the response for
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 EXPECT_EQ(HTTP_SUCCESS, result_code); 1591 EXPECT_EQ(HTTP_SUCCESS, result_code);
1596 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); 1592 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method);
1597 EXPECT_EQ(kTestDownloadPathPrefix + kTestId, http_request_.relative_url); 1593 EXPECT_EQ(kTestDownloadPathPrefix + kTestId, http_request_.relative_url);
1598 EXPECT_EQ(kDownloadedFilePath, temp_file); 1594 EXPECT_EQ(kDownloadedFilePath, temp_file);
1599 1595
1600 const std::string expected_contents = kTestId + kTestId + kTestId; 1596 const std::string expected_contents = kTestId + kTestId + kTestId;
1601 EXPECT_EQ(expected_contents, contents); 1597 EXPECT_EQ(expected_contents, contents);
1602 } 1598 }
1603 1599
1604 } // namespace google_apis 1600 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/drive_api_requests_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698