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

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

Issue 12861002: drive: Remove "/-/mine" from WAPI resource list urls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Modified the test feed to include an not-mine entry. Created 7 years, 9 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 <algorithm> 5 #include <algorithm>
6 #include <map> 6 #include <map>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 if (absolute_url.path() == "/feeds/default/private/full" && 95 if (absolute_url.path() == "/feeds/default/private/full" &&
96 request.method == test_server::METHOD_POST) { 96 request.method == test_server::METHOD_POST) {
97 // This is a request for copying a document. 97 // This is a request for copying a document.
98 // TODO(satorux): we should generate valid JSON data for the newly 98 // TODO(satorux): we should generate valid JSON data for the newly
99 // copied document but for now, just return "file_entry.json" 99 // copied document but for now, just return "file_entry.json"
100 return test_util::CreateHttpResponseFromFile( 100 return test_util::CreateHttpResponseFromFile(
101 test_util::GetTestFilePath("chromeos/gdata/file_entry.json")); 101 test_util::GetTestFilePath("chromeos/gdata/file_entry.json"));
102 } 102 }
103 103
104 if (!test_util::RemovePrefix(absolute_url.path(), 104 if (!test_util::RemovePrefix(absolute_url.path(),
105 "/feeds/default/private/full/", 105 "/feeds/default/private/full",
106 &remaining_path)) { 106 &remaining_path)) {
107 return scoped_ptr<test_server::HttpResponse>(); 107 return scoped_ptr<test_server::HttpResponse>();
108 } 108 }
109 109
110 if (remaining_path == "-/mine") { 110 if (remaining_path.empty()) {
111 // Process the default feed. 111 // Process the default feed.
112 return test_util::CreateHttpResponseFromFile( 112 return test_util::CreateHttpResponseFromFile(
113 test_util::GetTestFilePath("chromeos/gdata/root_feed.json")); 113 test_util::GetTestFilePath("chromeos/gdata/root_feed.json"));
114 } else { 114 } else {
115 // Process a feed for a single resource ID. 115 // Process a feed for a single resource ID.
116 const std::string resource_id = net::UnescapeURLComponent( 116 const std::string resource_id = net::UnescapeURLComponent(
117 remaining_path, net::UnescapeRule::URL_SPECIAL_CHARS); 117 remaining_path.substr(1), net::UnescapeRule::URL_SPECIAL_CHARS);
118 if (resource_id == "file:2_file_resource_id") { 118 if (resource_id == "file:2_file_resource_id") {
119 // Check if this is an authorization request for an app. 119 // Check if this is an authorization request for an app.
120 if (request.method == test_server::METHOD_PUT && 120 if (request.method == test_server::METHOD_PUT &&
121 request.content.find("<docs:authorizedApp>") != std::string::npos) { 121 request.content.find("<docs:authorizedApp>") != std::string::npos) {
122 return test_util::CreateHttpResponseFromFile( 122 return test_util::CreateHttpResponseFromFile(
123 test_util::GetTestFilePath("chromeos/gdata/basic_feed.json")); 123 test_util::GetTestFilePath("chromeos/gdata/basic_feed.json"));
124 } 124 }
125 125
126 return test_util::CreateHttpResponseFromFile( 126 return test_util::CreateHttpResponseFromFile(
127 test_util::GetTestFilePath("chromeos/gdata/file_entry.json")); 127 test_util::GetTestFilePath("chromeos/gdata/file_entry.json"));
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 "", // directory resource ID 330 "", // directory resource ID
331 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit, 331 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit,
332 &result_code, 332 &result_code,
333 &result_data)); 333 &result_data));
334 operation->Start(kTestGDataAuthToken, kTestUserAgent, 334 operation->Start(kTestGDataAuthToken, kTestUserAgent,
335 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 335 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
336 MessageLoop::current()->Run(); 336 MessageLoop::current()->Run();
337 337
338 EXPECT_EQ(HTTP_SUCCESS, result_code); 338 EXPECT_EQ(HTTP_SUCCESS, result_code);
339 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); 339 EXPECT_EQ(test_server::METHOD_GET, http_request_.method);
340 EXPECT_EQ("/feeds/default/private/full/-/mine?v=3&alt=json&showroot=true&" 340 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&"
341 "showfolders=true&max-results=500&include-installed-apps=true", 341 "showfolders=true&max-results=500&include-installed-apps=true",
342 http_request_.relative_url); 342 http_request_.relative_url);
343 EXPECT_TRUE(test_util::VerifyJsonData( 343 EXPECT_TRUE(test_util::VerifyJsonData(
344 test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), 344 test_util::GetTestFilePath("chromeos/gdata/root_feed.json"),
345 result_data.get())); 345 result_data.get()));
346 } 346 }
347 347
348 TEST_F(GDataWapiOperationsTest, GetResourceListOperation_ValidFeed) { 348 TEST_F(GDataWapiOperationsTest, GetResourceListOperation_ValidFeed) {
349 GDataErrorCode result_code = GDATA_OTHER_ERROR; 349 GDataErrorCode result_code = GDATA_OTHER_ERROR;
350 scoped_ptr<base::Value> result_data; 350 scoped_ptr<base::Value> result_data;
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), 1433 EXPECT_EQ(base::Int64ToString(kUploadContent.size()),
1434 http_request_.headers["X-Upload-Content-Length"]); 1434 http_request_.headers["X-Upload-Content-Length"]);
1435 // For updating an existing file, an empty body should be attached (PUT 1435 // For updating an existing file, an empty body should be attached (PUT
1436 // requires a body) 1436 // requires a body)
1437 EXPECT_TRUE(http_request_.has_content); 1437 EXPECT_TRUE(http_request_.has_content);
1438 EXPECT_EQ("", http_request_.content); 1438 EXPECT_EQ("", http_request_.content);
1439 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]); 1439 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]);
1440 } 1440 }
1441 1441
1442 } // namespace google_apis 1442 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/fake_drive_service_unittest.cc ('k') | chrome/browser/google_apis/gdata_wapi_url_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698