Index: chromeos/dbus/fake_media_analytics_client.h |
diff --git a/chromeos/dbus/fake_media_analytics_client.h b/chromeos/dbus/fake_media_analytics_client.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f02ec87ccea8ec0f631ad3d67b6e75edeffdbe55 |
--- /dev/null |
+++ b/chromeos/dbus/fake_media_analytics_client.h |
@@ -0,0 +1,81 @@ |
+// Copyright 2017 The Chromium 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 CHROMEOS_DBUS_FAKE_MEDIA_ANALYTICS_CLIENT_H_ |
+#define CHROMEOS_DBUS_FAKE_MEDIA_ANALYTICS_CLIENT_H_ |
+ |
+#include "base/callback.h" |
+#include "base/macros.h" |
+#include "base/memory/weak_ptr.h" |
+#include "chromeos/chromeos_export.h" |
+#include "chromeos/dbus/media_analytics_client.h" |
+#include "chromeos/media_perception/media_perception.pb.h" |
+ |
+namespace chromeos { |
+ |
+// MediaAnalyticsClient is used to communicate with a media analytics process |
+// running outside of Chrome. |
+class CHROMEOS_EXPORT FakeMediaAnalyticsClient : public MediaAnalyticsClient { |
+ public: |
+ FakeMediaAnalyticsClient(); |
+ ~FakeMediaAnalyticsClient() override; |
+ |
+ // Inherited from MediaAnalyticsClient. |
+ void GetState(const StateCallback& callback) override; |
+ void SetState(const mri::State& state, |
+ const StateCallback& callback) override; |
+ |
+ void SetMediaPerceptionSignalHandler( |
+ const MediaPerceptionSignalHandler& handler) override; |
+ void ClearMediaPerceptionSignalHandler() override; |
+ |
+ void GetDiagnostics(const DiagnosticsCallback& callback) override; |
+ |
+ // Inherited from DBusClient. |
+ void Init(dbus::Bus* bus) override; |
+ |
+ // Fires a fake media perception event so that we can verify the signal is |
+ // recieved by the app. |
+ void FireMediaPerceptionEvent(); |
+ |
+ // Sets the frame id returned within frame perceptions in GetDiagnostics |
+ // and MediaPerception callbacks. Allows the apitest to set the value being |
+ // returned. |
+ void SetFrameId(int frame_id); |
tbarzic
2017/05/10 23:59:29
I'd pass in mri::Diagnostics, rather than just fra
Luke Sorenson
2017/05/11 15:50:29
Done.
|
+ |
+ // Make the media analytics process as launched or not running. |
+ void set_process_running(bool running) { process_running_ = running; } |
+ |
+ bool process_running() const { return process_running_; } |
+ |
+ private: |
+ // Simply echoes back the previously set state. |
+ void OnState(const StateCallback& callback); |
+ |
+ // Returns a fake, nearly empty serialized Diagnostic proto. |
+ void OnGetDiagnostics(const DiagnosticsCallback& callback); |
+ |
+ // Returns a fake, nearly empty serialized MediaPerception proto. |
+ void OnMediaPerception(); |
+ |
+ // Stores a handler for receiving MediaPerception proto messages. |
+ MediaPerceptionSignalHandler media_perception_signal_handler_; |
+ |
+ // Stores a fake current state for the media analytics process. |
+ mri::State current_state_; |
+ |
+ // Stores the launch state of the fake media analytics process. |
+ bool process_running_; |
+ |
+ // Stores a fake frame id that can be set by a test. |
+ int fake_frame_id_; |
+ |
+ base::WeakPtrFactory<FakeMediaAnalyticsClient> weak_ptr_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(FakeMediaAnalyticsClient); |
+}; |
+ |
+} // namespace chromeos |
+ |
+#endif // CHROMEOS_DBUS_FAKE_MEDIA_ANALYTICS_CLIENT_H_ |