Chromium Code Reviews| 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. | |
| 19 class CHROMEOS_EXPORT FakeMediaAnalyticsClient : public MediaAnalyticsClient { | |
| 20 public: | |
| 21 FakeMediaAnalyticsClient(); | |
| 22 ~FakeMediaAnalyticsClient() override; | |
| 23 | |
| 24 // Inherited from MediaAnalyticsClient. | |
| 25 void GetState(const StateCallback& callback) override; | |
| 26 void SetState(const mri::State& state, | |
| 27 const StateCallback& callback) override; | |
| 28 | |
| 29 void SetMediaPerceptionSignalHandler( | |
| 30 const MediaPerceptionSignalHandler& handler) override; | |
| 31 void ClearMediaPerceptionSignalHandler() override; | |
| 32 | |
| 33 void GetDiagnostics(const DiagnosticsCallback& callback) override; | |
| 34 | |
| 35 // Inherited from DBusClient. | |
| 36 void Init(dbus::Bus* bus) override; | |
| 37 | |
| 38 // Fires a fake media perception event so that we can verify the signal is | |
| 39 // recieved by the app. | |
| 40 void FireMediaPerceptionEvent(); | |
| 41 | |
| 42 // Sets the frame id returned within frame perceptions in GetDiagnostics | |
| 43 // and MediaPerception callbacks. Allows the apitest to set the value being | |
| 44 // returned. | |
| 45 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.
| |
| 46 | |
| 47 // Make the media analytics process as launched or not running. | |
| 48 void set_process_running(bool running) { process_running_ = running; } | |
| 49 | |
| 50 bool process_running() const { return process_running_; } | |
| 51 | |
| 52 private: | |
| 53 // Simply echoes back the previously set state. | |
| 54 void OnState(const StateCallback& callback); | |
| 55 | |
| 56 // Returns a fake, nearly empty serialized Diagnostic proto. | |
| 57 void OnGetDiagnostics(const DiagnosticsCallback& callback); | |
| 58 | |
| 59 // Returns a fake, nearly empty serialized MediaPerception proto. | |
| 60 void OnMediaPerception(); | |
| 61 | |
| 62 // Stores a handler for receiving MediaPerception proto messages. | |
| 63 MediaPerceptionSignalHandler media_perception_signal_handler_; | |
| 64 | |
| 65 // Stores a fake current state for the media analytics process. | |
| 66 mri::State current_state_; | |
| 67 | |
| 68 // Stores the launch state of the fake media analytics process. | |
| 69 bool process_running_; | |
| 70 | |
| 71 // Stores a fake frame id that can be set by a test. | |
| 72 int fake_frame_id_; | |
| 73 | |
| 74 base::WeakPtrFactory<FakeMediaAnalyticsClient> weak_ptr_factory_; | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(FakeMediaAnalyticsClient); | |
| 77 }; | |
| 78 | |
| 79 } // namespace chromeos | |
| 80 | |
| 81 #endif // CHROMEOS_DBUS_FAKE_MEDIA_ANALYTICS_CLIENT_H_ | |
| OLD | NEW |