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

Unified Diff: chrome/browser/google_apis/gdata_wapi_operations_unittest.cc

Issue 11415171: google_apis: Add a test for CreateDirectoryOperation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix windows Created 8 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/google_apis/gdata_wapi_operations_unittest.cc
diff --git a/chrome/browser/google_apis/gdata_wapi_operations_unittest.cc b/chrome/browser/google_apis/gdata_wapi_operations_unittest.cc
index 3d28cb05448f5c4ab054b24a01fd5741c53f8b87..62a46bd0a2a992e9ab6752141aca9f7de3204ef7 100644
--- a/chrome/browser/google_apis/gdata_wapi_operations_unittest.cc
+++ b/chrome/browser/google_apis/gdata_wapi_operations_unittest.cc
@@ -205,17 +205,21 @@ class GDataWapiOperationsTest : public testing::Test {
test_util::GetTestFilePath("gdata/root_feed.json"));
} else {
// Process a feed for a single resource ID.
- // For now, we only support a resource feed for a particular entry.
const std::string resource_id = net::UnescapeURLComponent(
remaining_path, net::UnescapeRule::URL_SPECIAL_CHARS);
- if (resource_id != "file:2_file_resource_id")
- return scoped_ptr<test_server::HttpResponse>();
-
- return CreateHttpResponseFromFile(
- test_util::GetTestFilePath("gdata/file_entry.json"));
+ if (resource_id == "file:2_file_resource_id") {
+ return CreateHttpResponseFromFile(
+ test_util::GetTestFilePath("gdata/file_entry.json"));
+ } else if (resource_id == "folder:root" &&
+ request.method == test_server::METHOD_POST) {
+ // This is a request for creating a directory in the root directory.
+ // TODO(satorux): we should generate valid JSON data for the newly
+ // created directory but for now, just return "directory_entry.json"
+ return CreateHttpResponseFromFile(
+ test_util::GetTestFilePath("gdata/directory_entry.json"));
+ }
}
- NOTREACHED();
return scoped_ptr<test_server::HttpResponse>();
}
@@ -453,8 +457,34 @@ TEST_F(GDataWapiOperationsTest, DeleteDocumentOperation) {
EXPECT_EQ("*", http_request_.headers["If-Match"]);
}
-// TODO(satorux): Write tests for CreateDirectoryOperation.
-// crbug.com/162348
+TEST_F(GDataWapiOperationsTest, CreateDirectoryOperation) {
+ GDataErrorCode result_code = GDATA_OTHER_ERROR;
+ scoped_ptr<base::Value> result_data;
+
+ // Create "new directory" in the root directory.
+ CreateDirectoryOperation* operation = new CreateDirectoryOperation(
+ &operation_registry_,
+ *url_generator_,
+ base::Bind(&CopyResultsFromGetDataCallbackAndQuit,
+ &result_code,
+ &result_data),
+ test_server_.GetURL("/feeds/default/private/full/folder%3Aroot"),
+ FILE_PATH_LITERAL("new directory"));
+
+ operation->Start(kTestGDataAuthToken, kTestUserAgent);
+ MessageLoop::current()->Run();
+
+ EXPECT_EQ(HTTP_SUCCESS, result_code);
+ EXPECT_EQ(test_server::METHOD_POST, http_request_.method);
+ EXPECT_TRUE(http_request_.has_content);
+ EXPECT_EQ("<?xml version=\"1.0\"?>\n"
+ "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n"
+ " <category scheme=\"http://schemas.google.com/g/2005#kind\" "
+ "term=\"http://schemas.google.com/docs/2007#folder\"/>\n"
+ " <title>new directory</title>\n"
+ "</entry>\n",
+ http_request_.content);
+}
// TODO(satorux): Write tests for CopyDocumentOperation.
// crbug.com/162348
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698