buffet: extract common unittest helper functions into separate file

CreateValue, CreateDictionaryValue and ValueToString() functions
were duplicated in two unit test files in buffet. These functions
will be needed for even more unit tests in the future, so extract
them into their own unittest_utils.cc/.h so they can be reused
in other unit tests.

BUG=None
TEST=USE=buffet P2_TEST_FILTER="buffet::*" FEATURES=test emerge-link platform2

Change-Id: I76ec6d13ed71e78dc02230167041cddc7de653ca
Reviewed-on: https://chromium-review.googlesource.com/208463
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Christopher Wiley <wiley@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/buffet/commands/unittest_utils.h b/buffet/commands/unittest_utils.h
new file mode 100644
index 0000000..e14e4d1
--- /dev/null
+++ b/buffet/commands/unittest_utils.h
@@ -0,0 +1,31 @@
+// Copyright 2014 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BUFFET_COMMANDS_UNITTEST_UTILS_H_
+#define BUFFET_COMMANDS_UNITTEST_UTILS_H_
+
+#include <memory>
+#include <string>
+
+#include <base/values.h>
+
+namespace buffet {
+namespace unittests {
+
+// Helper method to create base::Value from a string as a smart pointer.
+// For ease of definition in C++ code, double-quotes in the source definition
+// are replaced with apostrophes.
+  std::unique_ptr<base::Value> CreateValue(const char* json);
+
+// 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);
+
+}  // namespace unittests
+}  // namespace buffet
+
+#endif  // BUFFET_COMMANDS_UNITTEST_UTILS_H_