buffet: Raw string literals for some JSON constants in tests

Added EXPECT_JSON_EQ() macro to help compare JSON values without being
influenced by string formatting and whitespace. This allows us to use
raw literal strings in conditions which improves readability of the
tests.

BUG=None
TEST=FEATURE=test emerge-gizmo buffet

Change-Id: Ibc6642a053dd3e6f3b667de31ceefa21f03e85bf
Reviewed-on: https://chromium-review.googlesource.com/268961
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
Tested-by: Vitaly Buka <vitalybuka@chromium.org>
diff --git a/buffet/commands/unittest_utils.h b/buffet/commands/unittest_utils.h
index 25db6b2..3a9dcc1 100644
--- a/buffet/commands/unittest_utils.h
+++ b/buffet/commands/unittest_utils.h
@@ -9,6 +9,7 @@
 #include <string>
 
 #include <base/values.h>
+#include <gtest/gtest.h>
 
 #include "buffet/commands/prop_types.h"
 #include "buffet/commands/prop_values.h"
@@ -24,9 +25,9 @@
 // Helper method to create a JSON dictionary object from a string.
 std::unique_ptr<base::DictionaryValue> CreateDictionaryValue(const char* json);
 
-// Converts a JSON value to a string. It also converts double-quotes to
-// apostrophes for easy comparisons in C++ source code.
-std::string ValueToString(const base::Value* value);
+inline bool IsEqualValue(const base::Value& val1, const base::Value& val2) {
+  return val1.Equals(&val2);
+}
 
 template <typename PropVal, typename T>
 std::unique_ptr<const PropVal> make_prop_value(const T& value) {
@@ -56,4 +57,8 @@
 }  // namespace unittests
 }  // namespace buffet
 
+#define EXPECT_JSON_EQ(expected, actual) \
+  EXPECT_PRED2(buffet::unittests::IsEqualValue, \
+               *buffet::unittests::CreateValue(expected), actual)
+
 #endif  // BUFFET_COMMANDS_UNITTEST_UTILS_H_