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

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

Issue 11824023: Add unittest for google_apis::GetAboutOperation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Get rid of EXPECT_X creation. Move the verification method to test_util to share it with gdata_wapi… 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') | chrome/chrome_tests_unit.gypi » ('j') | 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 009c0269095df51a72ef5171676d93818a5a94f1..05eb682a47bb5acb2539315076bc52dd74e6ffc5 100644
--- a/chrome/browser/google_apis/test_util.cc
+++ b/chrome/browser/google_apis/test_util.cc
@@ -6,6 +6,7 @@
#include "base/file_util.h"
#include "base/json/json_file_value_serializer.h"
+#include "base/json/json_reader.h"
#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/string_util.h"
@@ -90,6 +91,15 @@ void CopyResultsFromGetDataCallback(GDataErrorCode* error_out,
*error_out = error_in;
}
+void CopyResultsFromGetDataCallbackAndQuit(GDataErrorCode* error_out,
+ scoped_ptr<base::Value>* value_out,
+ GDataErrorCode error_in,
+ scoped_ptr<base::Value> value_in) {
+ *error_out = error_in;
+ *value_out = value_in.Pass();
+ MessageLoop::current()->Quit();
+}
+
void CopyResultsFromGetResourceEntryCallback(
GDataErrorCode* error_out,
scoped_ptr<ResourceEntry>* resource_entry_out,
@@ -139,5 +149,35 @@ scoped_ptr<test_server::HttpResponse> CreateHttpResponseFromFile(
return http_response.Pass();
}
+void DoNothingForReAuthenticateCallback(
+ AuthenticatedOperationInterface* /* operation */) {
+ NOTREACHED();
+}
+
+bool VerifyJsonData(const FilePath& expected_json_file_path,
+ const base::Value* json_data) {
+ if (!json_data) {
+ LOG(ERROR) << "json_data is NULL";
+ return false;
+ }
+
+ std::string expected_content;
+ if (!file_util::ReadFileToString(
+ expected_json_file_path, &expected_content)) {
+ LOG(ERROR) << "Failed to read file: " << expected_json_file_path.value();
+ return false;
+ }
+
+ scoped_ptr<base::Value> expected_json_data(
+ base::JSONReader::Read(expected_content));
+ if (!base::Value::Equals(expected_json_data.get(), json_data)) {
+ LOG(ERROR)
+ << "The value of json_data is different from the file's content.";
+ return false;
+ }
+
+ return true;
+}
+
} // namespace test_util
} // namespace google_apis
« no previous file with comments | « chrome/browser/google_apis/test_util.h ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698