test_media_client.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #ifndef ASH_TEST_MEDIA_CLIENT_H_
  5. #define ASH_TEST_MEDIA_CLIENT_H_
  6. #include "ash/public/cpp/media_client.h"
  7. namespace ash {
  8. // Implement MediaClient mojo interface to simulate chrome behavior in tests.
  9. // This breaks the ash/chrome dependency to allow testing ash code in isolation.
  10. class TestMediaClient : public MediaClient {
  11. public:
  12. TestMediaClient();
  13. TestMediaClient(const TestMediaClient&) = delete;
  14. TestMediaClient& operator=(const TestMediaClient&) = delete;
  15. ~TestMediaClient() override;
  16. // MediaClient:
  17. void HandleMediaNextTrack() override;
  18. void HandleMediaPlayPause() override;
  19. void HandleMediaPlay() override;
  20. void HandleMediaPause() override;
  21. void HandleMediaStop() override;
  22. void HandleMediaPrevTrack() override;
  23. void HandleMediaSeekBackward() override;
  24. void HandleMediaSeekForward() override;
  25. void RequestCaptureState() override;
  26. void SuspendMediaSessions() override;
  27. int handle_media_next_track_count() const {
  28. return handle_media_next_track_count_;
  29. }
  30. int handle_media_play_pause_count() const {
  31. return handle_media_play_pause_count_;
  32. }
  33. int handle_media_play_count() const { return handle_media_play_count_; }
  34. int handle_media_pause_count() const { return handle_media_pause_count_; }
  35. int handle_media_stop_count() const { return handle_media_pause_count_; }
  36. int handle_media_prev_track_count() const {
  37. return handle_media_prev_track_count_;
  38. }
  39. int handle_media_seek_backward_count() const {
  40. return handle_media_seek_backward_count_;
  41. }
  42. int handle_media_seek_forward_count() const {
  43. return handle_media_seek_forward_count_;
  44. }
  45. bool media_sessions_suspended() const { return media_sessions_suspended_; }
  46. private:
  47. int handle_media_next_track_count_ = 0;
  48. int handle_media_play_pause_count_ = 0;
  49. int handle_media_play_count_ = 0;
  50. int handle_media_pause_count_ = 0;
  51. int handle_media_stop_count_ = 0;
  52. int handle_media_prev_track_count_ = 0;
  53. int handle_media_seek_backward_count_ = 0;
  54. int handle_media_seek_forward_count_ = 0;
  55. bool media_sessions_suspended_ = false;
  56. };
  57. } // namespace ash
  58. #endif // ASH_TEST_MEDIA_CLIENT_H_