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

Unified Diff: sync/test/fake_server/fake_server_verifier.cc

Issue 1008983002: Sync: Print FakeServer contents on test failure (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_2
Patch Set: pass DictionaryValue by reference Created 5 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 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: sync/test/fake_server/fake_server_verifier.cc
diff --git a/sync/test/fake_server/fake_server_verifier.cc b/sync/test/fake_server/fake_server_verifier.cc
index 9c020756272e7b67d6052e709348818a3763753c..36e172b162e15ffdc196104336fd4eed0e77cc45 100644
--- a/sync/test/fake_server/fake_server_verifier.cc
+++ b/sync/test/fake_server/fake_server_verifier.cc
@@ -4,12 +4,14 @@
#include "sync/test/fake_server/fake_server_verifier.h"
+#include "base/json/json_writer.h"
#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "sync/internal_api/public/base/model_type.h"
#include "sync/test/fake_server/fake_server.h"
#include "testing/gtest/include/gtest/gtest.h"
+using base::JSONWriter;
using std::string;
using testing::AssertionFailure;
using testing::AssertionResult;
@@ -33,6 +35,18 @@ AssertionResult UnknownTypeAssertionFailure(const string& model_type) {
<< model_type;
}
+// Caller maintains ownership of |entities|.
+string ConvertFakeServerContentsToString(
+ const base::DictionaryValue& entities) {
+ string entities_str;
+ if (!JSONWriter::WriteWithOptions(&entities,
+ JSONWriter::OPTIONS_PRETTY_PRINT,
+ &entities_str)) {
+ entities_str = "Could not convert FakeServer contents to string.";
+ }
+ return "FakeServer contents:\n" + entities_str;
+}
+
} // namespace
namespace fake_server {
@@ -57,7 +71,9 @@ AssertionResult FakeServerVerifier::VerifyEntityCountByType(
return UnknownTypeAssertionFailure(model_type_string);
} else if (expected_count != entity_list->GetSize()) {
return VerificationCountAssertionFailure(entity_list->GetSize(),
- expected_count);
+ expected_count)
+ << "\n\n"
+ << ConvertFakeServerContentsToString(*entities);
}
return AssertionSuccess();
@@ -90,7 +106,10 @@ AssertionResult FakeServerVerifier::VerifyEntityCountByTypeAndName(
return UnknownTypeAssertionFailure(model_type_string);
} else if (actual_count != expected_count) {
return VerificationCountAssertionFailure(actual_count, expected_count)
- << "; Name: " << name;
+ << "; Name: "
+ << name
+ << "\n\n"
+ << ConvertFakeServerContentsToString(*entities);
}
return AssertionSuccess();
« 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