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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_operations_unittest.cc

Issue 10831122: gdata cleanup: stop passing Profile* around GData operations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 4 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/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/chromeos/gdata/gdata_operations.h" 8 #include "chrome/browser/chromeos/gdata/gdata_operations.h"
9 #include "chrome/browser/chromeos/gdata/gdata_operation_runner.h" 9 #include "chrome/browser/chromeos/gdata/gdata_operation_runner.h"
10 #include "chrome/browser/chromeos/gdata/gdata_test_util.h" 10 #include "chrome/browser/chromeos/gdata/gdata_test_util.h"
11 #include "chrome/test/base/testing_profile.h" 11 #include "chrome/test/base/testing_profile.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/test/test_browser_thread.h" 13 #include "content/public/test/test_browser_thread.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace gdata { 16 namespace gdata {
17 17
18 namespace { 18 namespace {
19 19
20 class JsonParseTestGetDataOperation : public GetDataOperation { 20 class JsonParseTestGetDataOperation : public GetDataOperation {
21 public: 21 public:
22 JsonParseTestGetDataOperation(GDataOperationRegistry* registry, 22 JsonParseTestGetDataOperation(GDataOperationRegistry* registry,
23 Profile* profile,
24 const GetDataCallback& callback) 23 const GetDataCallback& callback)
25 : GetDataOperation(registry, profile, callback) { 24 : GetDataOperation(registry, callback) {
26 } 25 }
27 26
28 virtual ~JsonParseTestGetDataOperation() { 27 virtual ~JsonParseTestGetDataOperation() {
29 } 28 }
30 29
31 void NotifyStart() { 30 void NotifyStart() {
32 NotifyStartToOperationRegistry(); 31 NotifyStartToOperationRegistry();
33 } 32 }
34 33
35 void NotifySuccess() { 34 void NotifySuccess() {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 scoped_ptr<GDataOperationRunner> runner_; 78 scoped_ptr<GDataOperationRunner> runner_;
80 }; 79 };
81 80
82 TEST_F(GDataOperationsTest, GetDataOperationParseJson) { 81 TEST_F(GDataOperationsTest, GetDataOperationParseJson) {
83 scoped_ptr<base::Value> value; 82 scoped_ptr<base::Value> value;
84 GDataErrorCode error; 83 GDataErrorCode error;
85 gdata::GetDataCallback cb = base::Bind(&GetDataOperationParseJsonCallback, 84 gdata::GetDataCallback cb = base::Bind(&GetDataOperationParseJsonCallback,
86 &error, 85 &error,
87 &value); 86 &value);
88 JsonParseTestGetDataOperation* getData = 87 JsonParseTestGetDataOperation* getData =
89 new JsonParseTestGetDataOperation(runner_->operation_registry(), 88 new JsonParseTestGetDataOperation(runner_->operation_registry(), cb);
90 profile_.get(),
91 cb);
92 getData->NotifyStart(); 89 getData->NotifyStart();
93 90
94 // Parses a valid json string. 91 // Parses a valid json string.
95 { 92 {
96 std::string valid_json_str = 93 std::string valid_json_str =
97 "{" 94 "{"
98 " \"test\": {" 95 " \"test\": {"
99 " \"foo\": true," 96 " \"foo\": true,"
100 " \"bar\": 3.14," 97 " \"bar\": 3.14,"
101 " \"baz\": \"bat\"," 98 " \"baz\": \"bat\","
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 147 }
151 } 148 }
152 149
153 TEST_F(GDataOperationsTest, GetDataOperationParseInvalidJson) { 150 TEST_F(GDataOperationsTest, GetDataOperationParseInvalidJson) {
154 scoped_ptr<base::Value> value; 151 scoped_ptr<base::Value> value;
155 GDataErrorCode error; 152 GDataErrorCode error;
156 gdata::GetDataCallback cb = base::Bind(&GetDataOperationParseJsonCallback, 153 gdata::GetDataCallback cb = base::Bind(&GetDataOperationParseJsonCallback,
157 &error, 154 &error,
158 &value); 155 &value);
159 JsonParseTestGetDataOperation* getData = 156 JsonParseTestGetDataOperation* getData =
160 new JsonParseTestGetDataOperation(runner_->operation_registry(), 157 new JsonParseTestGetDataOperation(runner_->operation_registry(), cb);
161 profile_.get(),
162 cb);
163 getData->NotifyStart(); 158 getData->NotifyStart();
164 159
165 // Parses an invalid json string. 160 // Parses an invalid json string.
166 { 161 {
167 std::string invalid_json_str = 162 std::string invalid_json_str =
168 "/* hogehoge *" 163 "/* hogehoge *"
169 " \"test\": {" 164 " \"test\": {"
170 " \"moo\": \"cow" 165 " \"moo\": \"cow"
171 " " 166 " "
172 " \"list\": [" 167 " \"list\": ["
173 " \"foo\"," 168 " \"foo\","
174 " \"bar\"" 169 " \"bar\""
175 " ]"; 170 " ]";
176 171
177 getData->ParseResponse(HTTP_SUCCESS, invalid_json_str); 172 getData->ParseResponse(HTTP_SUCCESS, invalid_json_str);
178 test_util::RunBlockingPoolTask(); 173 test_util::RunBlockingPoolTask();
179 174
180 EXPECT_EQ(GDATA_PARSE_ERROR, error); 175 EXPECT_EQ(GDATA_PARSE_ERROR, error);
181 ASSERT_TRUE(value.get() == NULL); 176 ASSERT_TRUE(value.get() == NULL);
182 } 177 }
183 } 178 }
184 179
185 } // namespace gdata 180 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_operations.cc ('k') | chrome/browser/chromeos/gdata/operations_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698