pw_analog: Add gmocks for interfaces

Change-Id: I43c5a555ff6ee8983ab4f78bf9b3dfb00f06df37
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/48321
Commit-Queue: Kevin Zeng <zengk@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
diff --git a/pw_analog/BUILD b/pw_analog/BUILD
index d602521..37fc741 100644
--- a/pw_analog/BUILD
+++ b/pw_analog/BUILD
@@ -48,6 +48,30 @@
     ],
 )
 
+pw_cc_library(
+    name = "microvolt_input_gmock",
+    hdrs = [
+        "public/pw_analog/microvolt_input_gmock.h",
+    ],
+    includes = ["public"],
+    deps = [
+        ":microvolt_input",
+        "$dir_pw_third_party/googletest",
+    ],
+)
+
+pw_cc_library(
+    name = "analog_input_gmock",
+    hdrs = [
+        "public/pw_analog/analog_input_gmock.h",
+    ],
+    includes = ["public"],
+    deps = [
+        ":analog_input",
+        "$dir_pw_third_party/googletest",
+    ],
+)
+
 pw_cc_test(
     name = "analog_input_test",
     srcs = [
diff --git a/pw_analog/BUILD.gn b/pw_analog/BUILD.gn
index 360fc93..dd2761a 100644
--- a/pw_analog/BUILD.gn
+++ b/pw_analog/BUILD.gn
@@ -23,7 +23,14 @@
   include_dirs = [ "public" ]
 }
 
-pw_source_set("pw_analog") {
+group("pw_analog") {
+  public_deps = [
+    ":analog_input",
+    ":microvolt_input",
+  ]
+}
+
+pw_source_set("analog_input") {
   public_configs = [ ":public_include_path" ]
   public_deps = [
     "$dir_pw_chrono:system_clock",
@@ -35,7 +42,7 @@
 pw_source_set("microvolt_input") {
   public_configs = [ ":public_include_path" ]
   public_deps = [
-    ":pw_analog",
+    ":analog_input",
     "$dir_pw_chrono:system_clock",
     "$dir_pw_result",
     "$dir_pw_status",
@@ -43,6 +50,24 @@
   public = [ "public/pw_analog/microvolt_input.h" ]
 }
 
+pw_source_set("analog_input_gmock") {
+  public_configs = [ ":public_include_path" ]
+  public_deps = [
+    ":analog_input",
+    "$dir_pw_third_party/googletest",
+  ]
+  public = [ "public/pw_analog/analog_input_gmock.h" ]
+}
+
+pw_source_set("microvolt_input_gmock") {
+  public_configs = [ ":public_include_path" ]
+  public_deps = [
+    ":microvolt_input",
+    "$dir_pw_third_party/googletest",
+  ]
+  public = [ "public/pw_analog/microvolt_input_gmock.h" ]
+}
+
 pw_test_group("tests") {
   tests = [
     ":analog_input_test",
diff --git a/pw_analog/docs.rst b/pw_analog/docs.rst
index 5176465..19285e0 100644
--- a/pw_analog/docs.rst
+++ b/pw_analog/docs.rst
@@ -28,3 +28,11 @@
 peripheral in order to provide the reference voltages and to configure and
 enable the ADC peripheral where needed. Users are responsible for managing
 multithreaded access to the ADC driver if the ADC services multiple channels.
+
+pw::analog::GmockAnalogInput
+-------------------------------
+gMock of AnalogInput used for testing and mocking out the AnalogInput.
+
+pw::analog::GmockMicrovoltInput
+-------------------------------
+gMock of MicrovoltInput used for testing and mocking out the MicrovoltInput.
diff --git a/pw_analog/public/pw_analog/analog_input_gmock.h b/pw_analog/public/pw_analog/analog_input_gmock.h
new file mode 100644
index 0000000..f328c93
--- /dev/null
+++ b/pw_analog/public/pw_analog/analog_input_gmock.h
@@ -0,0 +1,31 @@
+// Copyright 2021 The Pigweed Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//     https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+#pragma once
+
+#include "gmock/gmock.h"
+#include "pw_analog/analog_input.h"
+
+namespace pw::analog {
+
+class GmockAnalogInput : public AnalogInput {
+ public:
+  MOCK_METHOD(pw::Result<int32_t>,
+              TryReadUntil,
+              (pw::chrono::SystemClock::time_point deadline),
+              (override));
+
+  MOCK_METHOD(Limits, GetLimits, (), (const, override));
+};
+
+}  // namespace pw::analog
diff --git a/pw_analog/public/pw_analog/microvolt_input_gmock.h b/pw_analog/public/pw_analog/microvolt_input_gmock.h
new file mode 100644
index 0000000..a6ce922
--- /dev/null
+++ b/pw_analog/public/pw_analog/microvolt_input_gmock.h
@@ -0,0 +1,33 @@
+// Copyright 2021 The Pigweed Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//     https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+#pragma once
+
+#include "gmock/gmock.h"
+#include "pw_analog/microvolt_input.h"
+
+namespace pw::analog {
+
+class GmockMicrovoltInput : public MicrovoltInput {
+ public:
+  MOCK_METHOD(pw::Result<int32_t>,
+              TryReadUntil,
+              (pw::chrono::SystemClock::time_point deadline),
+              (override));
+
+  MOCK_METHOD(Limits, GetLimits, (), (const, override));
+
+  MOCK_METHOD(References, GetReferences, (), (const, override));
+};
+
+}  // namespace pw::analog