test: add HandleInterface and mock

Add a handle mock for use by other daemon's unit-tests.  This saves a
separate daemon from using the SysMock.

Change-Id: I11802ca2f1b00e3e0de8966856c75599e560996e
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/src/Makefile.am b/src/Makefile.am
index e366846..7bf0aa2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -20,5 +20,6 @@
 libgpioplus_la_SOURCES += gpioplus/internal/sys.cpp
 
 nobase_include_HEADERS += gpioplus/test/sys.hpp
+nobase_include_HEADERS += gpioplus/test/handle.hpp
 
 nobase_include_HEADERS += gpioplus/utility/aspeed.hpp
diff --git a/src/gpioplus/handle.hpp b/src/gpioplus/handle.hpp
index 1837c76..96f8d28 100644
--- a/src/gpioplus/handle.hpp
+++ b/src/gpioplus/handle.hpp
@@ -35,11 +35,25 @@
     uint32_t toInt() const;
 };
 
+/** @class HandleInterface
+ *  @brief Handle interface to provide a set of methods required to exist in
+ * derived objects.
+ */
+class HandleInterface
+{
+  public:
+    virtual ~HandleInterface() = default;
+
+    virtual std::vector<uint8_t> getValues() const = 0;
+    virtual void getValues(std::vector<uint8_t>& values) const = 0;
+    virtual void setValues(const std::vector<uint8_t>& values) const = 0;
+};
+
 /** @class Handle
  *  @brief Handle to a gpio line handle
  *  @details Provides a c++ interface for gpio handle operations
  */
-class Handle
+class Handle : public HandleInterface
 {
   public:
     /** @brief Per line information used to construct a handle */
@@ -76,21 +90,21 @@
      *  @throws std::system_error for underlying syscall failures
      *  @return The values of the gpio lines
      */
-    std::vector<uint8_t> getValues() const;
+    std::vector<uint8_t> getValues() const override;
 
     /** @brief Gets the current values of all associated lines
      *
      *  @param[out] values - The values of the gpio lines
      *  @throws std::system_error for underlying syscall failures
      */
-    void getValues(std::vector<uint8_t>& values) const;
+    void getValues(std::vector<uint8_t>& values) const override;
 
     /** @brief Sets the current values of all associated lines
      *
      *  @param[in] values - The new values of the gpio lines
      *  @throws std::system_error for underlying syscall failures
      */
-    void setValues(const std::vector<uint8_t>& values) const;
+    void setValues(const std::vector<uint8_t>& values) const override;
 
   private:
     internal::Fd fd;
diff --git a/src/gpioplus/test/handle.hpp b/src/gpioplus/test/handle.hpp
new file mode 100644
index 0000000..9249ccd
--- /dev/null
+++ b/src/gpioplus/test/handle.hpp
@@ -0,0 +1,21 @@
+#pragma once
+#include <gmock/gmock.h>
+#include <gpioplus/handle.hpp>
+
+namespace gpioplus
+{
+namespace test
+{
+
+class HandleMock : public HandleInterface
+{
+  public:
+    virtual ~HandleMock() = default;
+
+    MOCK_CONST_METHOD0(getValues, std::vector<uint8_t>());
+    MOCK_CONST_METHOD1(getValues, void(std::vector<uint8_t>&));
+    MOCK_CONST_METHOD1(setValues, void(const std::vector<uint8_t>&));
+};
+
+} // namespace test
+} // namespace gpioplus