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

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

Issue 12093107: Extract testing utilities from gdata_wapi_operations_unittest to test_util. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 11 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 | « chrome/browser/google_apis/test_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/google_apis/test_util.cc
diff --git a/chrome/browser/google_apis/test_util.cc b/chrome/browser/google_apis/test_util.cc
index 442e643568d28e1f7cb83ef1ebf822dc32a1fd4a..4a7c86240bb3f708e3ced2779a5388b6dcf23df7 100644
--- a/chrome/browser/google_apis/test_util.cc
+++ b/chrome/browser/google_apis/test_util.cc
@@ -14,8 +14,8 @@
#include "base/threading/sequenced_worker_pool.h"
#include "chrome/browser/google_apis/drive_api_parser.h"
#include "chrome/browser/google_apis/gdata_wapi_parser.h"
+#include "chrome/browser/google_apis/test_server/http_request.h"
#include "chrome/browser/google_apis/test_server/http_response.h"
-#include "chrome/browser/google_apis/test_server/http_server.h"
#include "content/public/browser/browser_thread.h"
#include "googleurl/src/gurl.h"
@@ -42,6 +42,16 @@ class TaskObserver : public MessageLoop::TaskObserver {
DISALLOW_COPY_AND_ASSIGN(TaskObserver);
};
+bool RemovePrefix(const std::string& input,
+ const std::string& prefix,
+ std::string* output) {
+ if (!StartsWithASCII(input, prefix, true /* case sensitive */))
+ return false;
+
+ *output = input.substr(prefix.size());
+ return true;
+}
+
FilePath GetTestFilePath(const std::string& relative_path) {
FilePath path;
if (!PathService::Get(base::DIR_SOURCE_ROOT, &path))
@@ -182,6 +192,19 @@ void DoNothingForReAuthenticateCallback(
NOTREACHED();
}
+scoped_ptr<test_server::HttpResponse> HandleDownloadRequest(
+ const GURL& base_url,
+ test_server::HttpRequest* out_request,
+ const test_server::HttpRequest& request) {
+ *out_request = request;
+
+ GURL absolute_url = base_url.Resolve(request.relative_url);
+ std::string remaining_path;
+ if (!RemovePrefix(absolute_url.path(), "/files/", &remaining_path))
+ return scoped_ptr<test_server::HttpResponse>();
+ return CreateHttpResponseFromFile(GetTestFilePath(remaining_path));
+}
+
bool VerifyJsonData(const FilePath& expected_json_file_path,
const base::Value* json_data) {
if (!json_data) {
« no previous file with comments | « chrome/browser/google_apis/test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698