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

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

Issue 10877006: Rename GDataErrorCode to DriveErrorCode, GDataFileError to DriveFileError (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_test_util.h" 9 #include "chrome/browser/chromeos/gdata/gdata_test_util.h"
10 #include "chrome/browser/chromeos/gdata/operation_runner.h" 10 #include "chrome/browser/chromeos/gdata/operation_runner.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 protected: 42 protected:
43 // GetDataOperation overrides: 43 // GetDataOperation overrides:
44 virtual GURL GetURL() const OVERRIDE { 44 virtual GURL GetURL() const OVERRIDE {
45 // This method is never called because this test does not fetch json from 45 // This method is never called because this test does not fetch json from
46 // network. 46 // network.
47 NOTREACHED(); 47 NOTREACHED();
48 return GURL(); 48 return GURL();
49 } 49 }
50 }; 50 };
51 51
52 void GetDataOperationParseJsonCallback(GDataErrorCode* error_out, 52 void GetDataOperationParseJsonCallback(DriveErrorCode* error_out,
53 scoped_ptr<base::Value>* value_out, 53 scoped_ptr<base::Value>* value_out,
54 GDataErrorCode error_in, 54 DriveErrorCode error_in,
55 scoped_ptr<base::Value> value_in) { 55 scoped_ptr<base::Value> value_in) {
56 value_out->swap(value_in); 56 value_out->swap(value_in);
57 *error_out = error_in; 57 *error_out = error_in;
58 } 58 }
59 59
60 } // namespace 60 } // namespace
61 61
62 class GDataOperationsTest : public testing::Test { 62 class GDataOperationsTest : public testing::Test {
63 protected: 63 protected:
64 GDataOperationsTest() 64 GDataOperationsTest()
65 : ui_thread_(content::BrowserThread::UI, &message_loop_) { 65 : ui_thread_(content::BrowserThread::UI, &message_loop_) {
66 } 66 }
67 67
68 virtual void SetUp() OVERRIDE { 68 virtual void SetUp() OVERRIDE {
69 profile_.reset(new TestingProfile); 69 profile_.reset(new TestingProfile);
70 runner_.reset(new OperationRunner(profile_.get())); 70 runner_.reset(new OperationRunner(profile_.get()));
71 runner_->Initialize(); 71 runner_->Initialize();
72 } 72 }
73 73
74 protected: 74 protected:
75 MessageLoopForUI message_loop_; 75 MessageLoopForUI message_loop_;
76 content::TestBrowserThread ui_thread_; 76 content::TestBrowserThread ui_thread_;
77 scoped_ptr<TestingProfile> profile_; 77 scoped_ptr<TestingProfile> profile_;
78 scoped_ptr<OperationRunner> runner_; 78 scoped_ptr<OperationRunner> runner_;
79 }; 79 };
80 80
81 TEST_F(GDataOperationsTest, GetDataOperationParseJson) { 81 TEST_F(GDataOperationsTest, GetDataOperationParseJson) {
82 scoped_ptr<base::Value> value; 82 scoped_ptr<base::Value> value;
83 GDataErrorCode error; 83 DriveErrorCode error;
84 gdata::GetDataCallback cb = base::Bind(&GetDataOperationParseJsonCallback, 84 gdata::GetDataCallback cb = base::Bind(&GetDataOperationParseJsonCallback,
85 &error, 85 &error,
86 &value); 86 &value);
87 JsonParseTestGetDataOperation* getData = 87 JsonParseTestGetDataOperation* getData =
88 new JsonParseTestGetDataOperation(runner_->operation_registry(), cb); 88 new JsonParseTestGetDataOperation(runner_->operation_registry(), cb);
89 getData->NotifyStart(); 89 getData->NotifyStart();
90 90
91 // Parses a valid json string. 91 // Parses a valid json string.
92 { 92 {
93 std::string valid_json_str = 93 std::string valid_json_str =
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 EXPECT_EQ("cow", s); 142 EXPECT_EQ("cow", s);
143 EXPECT_TRUE(list_values[0]->GetAsString(&s)); 143 EXPECT_TRUE(list_values[0]->GetAsString(&s));
144 EXPECT_EQ("a", s); 144 EXPECT_EQ("a", s);
145 EXPECT_TRUE(list_values[1]->GetAsString(&s)); 145 EXPECT_TRUE(list_values[1]->GetAsString(&s));
146 EXPECT_EQ("b", s); 146 EXPECT_EQ("b", s);
147 } 147 }
148 } 148 }
149 149
150 TEST_F(GDataOperationsTest, GetDataOperationParseInvalidJson) { 150 TEST_F(GDataOperationsTest, GetDataOperationParseInvalidJson) {
151 scoped_ptr<base::Value> value; 151 scoped_ptr<base::Value> value;
152 GDataErrorCode error; 152 DriveErrorCode error;
153 gdata::GetDataCallback cb = base::Bind(&GetDataOperationParseJsonCallback, 153 gdata::GetDataCallback cb = base::Bind(&GetDataOperationParseJsonCallback,
154 &error, 154 &error,
155 &value); 155 &value);
156 JsonParseTestGetDataOperation* getData = 156 JsonParseTestGetDataOperation* getData =
157 new JsonParseTestGetDataOperation(runner_->operation_registry(), cb); 157 new JsonParseTestGetDataOperation(runner_->operation_registry(), cb);
158 getData->NotifyStart(); 158 getData->NotifyStart();
159 159
160 // Parses an invalid json string. 160 // Parses an invalid json string.
161 { 161 {
162 std::string invalid_json_str = 162 std::string invalid_json_str =
163 "/* hogehoge *" 163 "/* hogehoge *"
164 " \"test\": {" 164 " \"test\": {"
165 " \"moo\": \"cow" 165 " \"moo\": \"cow"
166 " " 166 " "
167 " \"list\": [" 167 " \"list\": ["
168 " \"foo\"," 168 " \"foo\","
169 " \"bar\"" 169 " \"bar\""
170 " ]"; 170 " ]";
171 171
172 getData->ParseResponse(HTTP_SUCCESS, invalid_json_str); 172 getData->ParseResponse(HTTP_SUCCESS, invalid_json_str);
173 test_util::RunBlockingPoolTask(); 173 test_util::RunBlockingPoolTask();
174 174
175 EXPECT_EQ(GDATA_PARSE_ERROR, error); 175 EXPECT_EQ(DRIVE_PARSE_ERROR, error);
176 ASSERT_TRUE(value.get() == NULL); 176 ASSERT_TRUE(value.get() == NULL);
177 } 177 }
178 } 178 }
179 179
180 } // namespace gdata 180 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698