OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROMEOS_DBUS_FAKE_MEDIA_ANALYTICS_CLIENT_H_ |
| 6 #define CHROMEOS_DBUS_FAKE_MEDIA_ANALYTICS_CLIENT_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/macros.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "chromeos/chromeos_export.h" |
| 12 #include "chromeos/dbus/media_analytics_client.h" |
| 13 #include "chromeos/media_perception/media_perception.pb.h" |
| 14 |
| 15 namespace chromeos { |
| 16 |
| 17 // MediaAnalyticsClient is used to communicate with a media analytics process |
| 18 // running outside of Chrome. The FakeMediaAnalyticsClient is used for |
| 19 // integration testing the MediaPerceptionPrivate API without any requirement on |
| 20 // D-Bus communications to an external process. |
| 21 class CHROMEOS_EXPORT FakeMediaAnalyticsClient : public MediaAnalyticsClient { |
| 22 public: |
| 23 FakeMediaAnalyticsClient(); |
| 24 ~FakeMediaAnalyticsClient() override; |
| 25 |
| 26 // Inherited from MediaAnalyticsClient. |
| 27 void State(const mri::State& state, const StateCallback& callback) override; |
| 28 |
| 29 void SetMediaPerceptionSignalHandler( |
| 30 const MediaPerceptionSignalHandler& handler) override; |
| 31 void UnsetMediaPerceptionSignalHandler() override; |
| 32 |
| 33 void GetDiagnostics(const DiagnosticsCallback& callback) override; |
| 34 |
| 35 // Inherited from DBusClient. |
| 36 void Init(dbus::Bus* bus) override; |
| 37 |
| 38 private: |
| 39 // Simply echoes back the previously set state. |
| 40 void OnState(const StateCallback& callback); |
| 41 |
| 42 // Returns a fake, nearly empty serialized Diagnostic proto. |
| 43 void OnGetDiagnostics(const DiagnosticsCallback& callback); |
| 44 |
| 45 // Returns a fake, nearly empty serialized MediaPerception proto. |
| 46 void OnMediaPerception(); |
| 47 |
| 48 // Stores a handler for receiving MediaPerception proto messages. |
| 49 MediaPerceptionSignalHandler media_perception_signal_handler_; |
| 50 |
| 51 // Stores a fake current state for the media analytics process. |
| 52 mri::State current_state_; |
| 53 |
| 54 base::WeakPtrFactory<FakeMediaAnalyticsClient> weak_ptr_factory_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(FakeMediaAnalyticsClient); |
| 57 }; |
| 58 |
| 59 } // namespace chromeos |
| 60 |
| 61 #endif // CHROMEOS_DBUS_FAKE_MEDIA_ANALYTICS_CLIENT_H_ |
OLD | NEW |