libweave: Move some of unittest_utils into public interface

User may want to make tests similar to those in libweave implementation.

BUG=brillo:1245
TEST='FEATURES=test emerge-gizmo buffet'

Change-Id: I18843645a59fa2323474157b95faf242d871fe2c
Reviewed-on: https://chromium-review.googlesource.com/289695
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
Tested-by: Vitaly Buka <vitalybuka@chromium.org>
diff --git a/libweave/include/weave/mock_command.h b/libweave/include/weave/mock_command.h
index 6298f99..def903d 100644
--- a/libweave/include/weave/mock_command.h
+++ b/libweave/include/weave/mock_command.h
@@ -15,6 +15,7 @@
 #include <gmock/gmock.h>
 
 namespace weave {
+namespace unittests {
 
 class MockCommand : public Command {
  public:
@@ -44,6 +45,7 @@
   std::unique_ptr<base::DictionaryValue> ToJson() const override;
 };
 
+}  // namespace unittests
 }  // namespace weave
 
 #endif  // LIBWEAVE_INCLUDE_WEAVE_MOCK_COMMAND_H_
diff --git a/libweave/include/weave/mock_commands.h b/libweave/include/weave/mock_commands.h
index 12514c5..3cca6ab 100644
--- a/libweave/include/weave/mock_commands.h
+++ b/libweave/include/weave/mock_commands.h
@@ -12,6 +12,7 @@
 #include <gmock/gmock.h>
 
 namespace weave {
+namespace unittests {
 
 class MockCommands : public Commands {
  public:
@@ -27,6 +28,7 @@
   MOCK_METHOD1(FindCommand, Command*(const std::string&));
 };
 
+}  // namespace unittests
 }  // namespace weave
 
 #endif  // LIBWEAVE_INCLUDE_WEAVE_MOCK_COMMANDS_H_
diff --git a/libweave/include/weave/unittest_utils.h b/libweave/include/weave/unittest_utils.h
new file mode 100644
index 0000000..3cfaeea
--- /dev/null
+++ b/libweave/include/weave/unittest_utils.h
@@ -0,0 +1,37 @@
+// Copyright 2015 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 LIBWEAVE_INCLUDE_WEAVE_UNITTEST_UTILS_H_
+#define LIBWEAVE_INCLUDE_WEAVE_UNITTEST_UTILS_H_
+
+#include <memory>
+#include <string>
+
+#include <base/values.h>
+#include <gtest/gtest.h>
+
+namespace weave {
+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 std::string& json);
+
+// Helper method to create a JSON dictionary object from a string.
+std::unique_ptr<base::DictionaryValue> CreateDictionaryValue(
+    const std::string& json);
+
+inline bool IsEqualValue(const base::Value& val1, const base::Value& val2) {
+  return val1.Equals(&val2);
+}
+
+}  // namespace unittests
+}  // namespace weave
+
+#define EXPECT_JSON_EQ(expected, actual)       \
+  EXPECT_PRED2(weave::unittests::IsEqualValue, \
+               *weave::unittests::CreateValue(expected), actual)
+
+#endif  // LIBWEAVE_INCLUDE_WEAVE_UNITTEST_UTILS_H_
diff --git a/libweave/src/commands/dbus_command_proxy_unittest.cc b/libweave/src/commands/dbus_command_proxy_unittest.cc
index e8fa9ec..9d26892 100644
--- a/libweave/src/commands/dbus_command_proxy_unittest.cc
+++ b/libweave/src/commands/dbus_command_proxy_unittest.cc
@@ -119,7 +119,7 @@
   scoped_refptr<dbus::MockExportedObject> mock_exported_object_command_;
   scoped_refptr<dbus::MockBus> bus_;
 
-  MockCommand command_;
+  unittests::MockCommand command_;
   std::unique_ptr<DBusCommandProxy> proxy_;
 };
 
diff --git a/libweave/src/commands/mock_command.cc b/libweave/src/commands/mock_command.cc
index 6b52b99..2b35de7 100644
--- a/libweave/src/commands/mock_command.cc
+++ b/libweave/src/commands/mock_command.cc
@@ -12,8 +12,7 @@
 #include "libweave/src/commands/unittest_utils.h"
 
 namespace weave {
-
-using unittests::CreateDictionaryValue;
+namespace unittests {
 
 std::unique_ptr<base::DictionaryValue> MockCommand::GetParameters() const {
   return CreateDictionaryValue(MockGetParameters());
@@ -31,4 +30,5 @@
   return CreateDictionaryValue(MockToJson());
 }
 
+}  // namespace unittests
 }  // namespace weave
diff --git a/libweave/src/commands/unittest_utils.h b/libweave/src/commands/unittest_utils.h
index 043bace..0659069 100644
--- a/libweave/src/commands/unittest_utils.h
+++ b/libweave/src/commands/unittest_utils.h
@@ -13,23 +13,11 @@
 
 #include "libweave/src/commands/prop_types.h"
 #include "libweave/src/commands/prop_values.h"
+#include "weave/unittest_utils.h"
 
 namespace weave {
 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 std::string& json);
-
-// Helper method to create a JSON dictionary object from a string.
-std::unique_ptr<base::DictionaryValue> CreateDictionaryValue(
-    const std::string& json);
-
-inline bool IsEqualValue(const base::Value& val1, const base::Value& val2) {
-  return val1.Equals(&val2);
-}
-
 template <typename T>
 std::unique_ptr<const PropValue> make_prop_value(const base::Value& value) {
   auto prop_type = PropType::Create(GetValueType<T>());
@@ -56,8 +44,4 @@
 }  // namespace unittests
 }  // namespace weave
 
-#define EXPECT_JSON_EQ(expected, actual)                                   \
-  EXPECT_PRED2(unittests::IsEqualValue, *unittests::CreateValue(expected), \
-               actual)
-
 #endif  // LIBWEAVE_SRC_COMMANDS_UNITTEST_UTILS_H_