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

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

Issue 16175003: google_apis: Rename OperationRunner to RequestSender (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 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 "chrome/browser/google_apis/base_requests.h" 5 #include "chrome/browser/google_apis/base_requests.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/google_apis/operation_runner.h" 11 #include "chrome/browser/google_apis/request_sender.h"
12 #include "chrome/browser/google_apis/test_util.h" 12 #include "chrome/browser/google_apis/test_util.h"
13 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
14 #include "content/public/test/test_browser_thread.h" 14 #include "content/public/test/test_browser_thread.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace google_apis { 17 namespace google_apis {
18 18
19 namespace { 19 namespace {
20 20
21 const char kValidJsonString[] = "{ \"test\": 123 }"; 21 const char kValidJsonString[] = "{ \"test\": 123 }";
22 const char kInvalidJsonString[] = "$$$"; 22 const char kInvalidJsonString[] = "$$$";
23 23
24 class FakeGetDataRequest : public GetDataRequest { 24 class FakeGetDataRequest : public GetDataRequest {
25 public: 25 public:
26 explicit FakeGetDataRequest(OperationRunner* runner, 26 explicit FakeGetDataRequest(RequestSender* runner,
27 const GetDataCallback& callback) 27 const GetDataCallback& callback)
28 : GetDataRequest(runner, NULL, callback) { 28 : GetDataRequest(runner, NULL, callback) {
29 } 29 }
30 30
31 virtual ~FakeGetDataRequest() { 31 virtual ~FakeGetDataRequest() {
32 } 32 }
33 33
34 void NotifyStart() { 34 void NotifyStart() {
35 NotifyStartToOperationRegistry(); 35 NotifyStartToOperationRegistry();
36 } 36 }
(...skipping 21 matching lines...) Expand all
58 } 58 }
59 59
60 void GetDataCallback(GDataErrorCode error, scoped_ptr<base::Value> value) { 60 void GetDataCallback(GDataErrorCode error, scoped_ptr<base::Value> value) {
61 get_data_result_error_ = error; 61 get_data_result_error_ = error;
62 get_data_result_value_ = value.Pass(); 62 get_data_result_value_ = value.Pass();
63 get_data_callback_called_ = true; 63 get_data_callback_called_ = true;
64 } 64 }
65 65
66 virtual void SetUp() OVERRIDE { 66 virtual void SetUp() OVERRIDE {
67 profile_.reset(new TestingProfile); 67 profile_.reset(new TestingProfile);
68 runner_.reset(new OperationRunner(profile_.get(), 68 runner_.reset(new RequestSender(profile_.get(),
69 NULL /* url_request_context_getter */, 69 NULL /* url_request_context_getter */,
70 std::vector<std::string>() /* scopes */, 70 std::vector<std::string>() /* scopes */,
71 std::string() /* custom user agent */)); 71 std::string() /* custom user agent */));
72 runner_->Initialize(); 72 runner_->Initialize();
73 LOG(ERROR) << "Initialized."; 73 LOG(ERROR) << "Initialized.";
74 } 74 }
75 75
76 base::MessageLoopForUI message_loop_; 76 base::MessageLoopForUI message_loop_;
77 content::TestBrowserThread ui_thread_; 77 content::TestBrowserThread ui_thread_;
78 scoped_ptr<TestingProfile> profile_; 78 scoped_ptr<TestingProfile> profile_;
79 scoped_ptr<OperationRunner> runner_; 79 scoped_ptr<RequestSender> runner_;
80 80
81 // Following members stores data returned with callbacks to be verified 81 // Following members stores data returned with callbacks to be verified
82 // by tests. 82 // by tests.
83 scoped_ptr<base::Value> parse_json_result_; 83 scoped_ptr<base::Value> parse_json_result_;
84 bool parse_json_callback_called_; 84 bool parse_json_callback_called_;
85 GDataErrorCode get_data_result_error_; 85 GDataErrorCode get_data_result_error_;
86 scoped_ptr<base::Value> get_data_result_value_; 86 scoped_ptr<base::Value> get_data_result_value_;
87 bool get_data_callback_called_; 87 bool get_data_callback_called_;
88 }; 88 };
89 89
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // Should wait for a blocking pool task, as the JSON parsing is done in the 148 // Should wait for a blocking pool task, as the JSON parsing is done in the
149 // blocking pool. 149 // blocking pool.
150 test_util::RunBlockingPoolTask(); 150 test_util::RunBlockingPoolTask();
151 151
152 ASSERT_TRUE(get_data_callback_called_); 152 ASSERT_TRUE(get_data_callback_called_);
153 ASSERT_EQ(GDATA_PARSE_ERROR, get_data_result_error_); 153 ASSERT_EQ(GDATA_PARSE_ERROR, get_data_result_error_);
154 ASSERT_FALSE(get_data_result_value_.get()); 154 ASSERT_FALSE(get_data_result_value_.get());
155 } 155 }
156 156
157 } // namespace google_apis 157 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/base_requests_server_unittest.cc ('k') | chrome/browser/google_apis/drive_api_operations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698