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..e9c714014a89a6078e0c274254f022f22860cade 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; |
maniscalco
2015/03/18 15:33:55
Is the using statement necessary? I ask because i
pval...(no longer on Chromium)
2015/03/23 23:35:39
It's not necessary, but I think the code below rea
|
using std::string; |
using testing::AssertionFailure; |
using testing::AssertionResult; |
@@ -33,6 +35,17 @@ AssertionResult UnknownTypeAssertionFailure(const string& model_type) { |
<< model_type; |
} |
+// Caller maintains ownership of |entities|. |
+string ConvertFakeServerContentsToString(base::DictionaryValue* entities) { |
maniscalco
2015/03/18 15:33:56
Does entities need to be a non-const pointer? Cou
pval...(no longer on Chromium)
2015/03/23 23:35:39
It does not. Thanks for pointing this out; I've ma
maniscalco
2015/03/24 00:11:19
Great.
|
+ 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 +70,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.get()); |
} |
return AssertionSuccess(); |
@@ -90,7 +105,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.get()); |
} |
return AssertionSuccess(); |