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

Unified Diff: trunk/src/google_apis/drive/base_requests_unittest.cc

Issue 449323002: Revert 288017 "Parse Drive API responses all at once in the bloc..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « trunk/src/google_apis/drive/base_requests.cc ('k') | trunk/src/google_apis/drive/drive_api_requests.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/google_apis/drive/base_requests_unittest.cc
===================================================================
--- trunk/src/google_apis/drive/base_requests_unittest.cc (revision 288215)
+++ trunk/src/google_apis/drive/base_requests_unittest.cc (working copy)
@@ -51,6 +51,24 @@
GURL url_;
};
+class FakeGetDataRequest : public GetDataRequest {
+ public:
+ explicit FakeGetDataRequest(RequestSender* sender,
+ const GetDataCallback& callback,
+ const GURL& url)
+ : GetDataRequest(sender, callback),
+ url_(url) {
+ }
+
+ virtual ~FakeGetDataRequest() {
+ }
+
+ protected:
+ virtual GURL GetURL() const OVERRIDE { return url_; }
+
+ GURL url_;
+};
+
} // namespace
class BaseRequestsTest : public testing::Test {
@@ -91,7 +109,11 @@
};
TEST_F(BaseRequestsTest, ParseValidJson) {
- scoped_ptr<base::Value> json(ParseJson(kValidJsonString));
+ scoped_ptr<base::Value> json;
+ ParseJson(message_loop_.message_loop_proxy(),
+ kValidJsonString,
+ base::Bind(test_util::CreateCopyResultCallback(&json)));
+ base::RunLoop().RunUntilIdle();
base::DictionaryValue* root_dict = NULL;
ASSERT_TRUE(json);
@@ -103,7 +125,14 @@
}
TEST_F(BaseRequestsTest, ParseInvalidJson) {
- EXPECT_FALSE(ParseJson(kInvalidJsonString));
+ // Initialize with a valid pointer to verify that null is indeed assigned.
+ scoped_ptr<base::Value> json(base::Value::CreateNullValue());
+ ParseJson(message_loop_.message_loop_proxy(),
+ kInvalidJsonString,
+ base::Bind(test_util::CreateCopyResultCallback(&json)));
+ base::RunLoop().RunUntilIdle();
+
+ EXPECT_FALSE(json);
}
TEST_F(BaseRequestsTest, UrlFetchRequestBaseResponseCodeOverride) {
@@ -136,4 +165,40 @@
EXPECT_EQ(HTTP_SERVICE_UNAVAILABLE, error);
}
+TEST_F(BaseRequestsTest, GetDataRequestParseValidResponse) {
+ response_body_ = kValidJsonString;
+
+ GDataErrorCode error = GDATA_OTHER_ERROR;
+ scoped_ptr<base::Value> value;
+ base::RunLoop run_loop;
+ sender_->StartRequestWithRetry(
+ new FakeGetDataRequest(
+ sender_.get(),
+ test_util::CreateQuitCallback(
+ &run_loop, test_util::CreateCopyResultCallback(&error, &value)),
+ test_server_.base_url()));
+ run_loop.Run();
+
+ EXPECT_EQ(HTTP_SUCCESS, error);
+ EXPECT_TRUE(value);
+}
+
+TEST_F(BaseRequestsTest, GetDataRequestParseInvalidResponse) {
+ response_body_ = kInvalidJsonString;
+
+ GDataErrorCode error = GDATA_OTHER_ERROR;
+ scoped_ptr<base::Value> value;
+ base::RunLoop run_loop;
+ sender_->StartRequestWithRetry(
+ new FakeGetDataRequest(
+ sender_.get(),
+ test_util::CreateQuitCallback(
+ &run_loop, test_util::CreateCopyResultCallback(&error, &value)),
+ test_server_.base_url()));
+ run_loop.Run();
+
+ EXPECT_EQ(GDATA_PARSE_ERROR, error);
+ EXPECT_FALSE(value);
+}
+
} // namespace google_apis
« no previous file with comments | « trunk/src/google_apis/drive/base_requests.cc ('k') | trunk/src/google_apis/drive/drive_api_requests.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698