Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: content/browser/media/session/mock_media_session_player_observer.h

Issue 2416853005: Fixing naming issues in MediaSession (Closed)
Patch Set: addressed nits Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <vector> 6 #include <vector>
7 7
8 #include "content/browser/media/session/media_session_observer.h" 8 #include "content/browser/media/session/media_session_player_observer.h"
9 9
10 namespace content { 10 namespace content {
11 11
12 // MockMediaSessionObserver is a mock implementation of MediaSessionObserver to 12 // MockMediaSessionPlayerObserver is a mock implementation of
13 // be used in tests. 13 // MediaSessionPlayerObserver to be used in tests.
14 class MockMediaSessionObserver : public MediaSessionObserver { 14 class MockMediaSessionPlayerObserver : public MediaSessionPlayerObserver {
15 public: 15 public:
16 MockMediaSessionObserver(); 16 MockMediaSessionPlayerObserver();
17 ~MockMediaSessionObserver() override; 17 ~MockMediaSessionPlayerObserver() override;
18 18
19 // Implements MediaSessionObserver. 19 // Implements MediaSessionPlayerObserver.
20 void OnSuspend(int player_id) override; 20 void OnSuspend(int player_id) override;
21 void OnResume(int player_id) override; 21 void OnResume(int player_id) override;
22 void OnSetVolumeMultiplier(int player_id, double volume_multiplier) override; 22 void OnSetVolumeMultiplier(int player_id, double volume_multiplier) override;
23 23
24 // Simulate that a new player started. 24 // Simulate that a new player started.
25 // Returns the player_id. 25 // Returns the player_id.
26 int StartNewPlayer(); 26 int StartNewPlayer();
27 27
28 // Returns whether |player_id| is playing. 28 // Returns whether |player_id| is playing.
29 bool IsPlaying(size_t player_id); 29 bool IsPlaying(size_t player_id);
30 30
31 // Returns the volume multiplier of |player_id|. 31 // Returns the volume multiplier of |player_id|.
32 double GetVolumeMultiplier(size_t player_id); 32 double GetVolumeMultiplier(size_t player_id);
33 33
34 // Simulate a play state change for |player_id|. 34 // Simulate a play state change for |player_id|.
35 void SetPlaying(size_t player_id, bool playing); 35 void SetPlaying(size_t player_id, bool playing);
36 36
37 int received_suspend_calls() const; 37 int received_suspend_calls() const;
38 int received_resume_calls() const; 38 int received_resume_calls() const;
39 39
40 private: 40 private:
41 // Internal representation of the players to keep track of their statuses. 41 // Internal representation of the players to keep track of their statuses.
42 struct MockPlayer { 42 struct MockPlayer {
43 public: 43 public:
44 MockPlayer(bool is_playing = true, double volume_multiplier = 1.0f) 44 MockPlayer(bool is_playing = true, double volume_multiplier = 1.0f)
45 : is_playing_(is_playing), 45 : is_playing_(is_playing), volume_multiplier_(volume_multiplier) {}
46 volume_multiplier_(volume_multiplier) {}
47 bool is_playing_; 46 bool is_playing_;
48 double volume_multiplier_; 47 double volume_multiplier_;
49 }; 48 };
50 49
51 // Basic representation of the players. The position in the vector is the 50 // Basic representation of the players. The position in the vector is the
52 // player_id. The value of the vector is the playing status and volume. 51 // player_id. The value of the vector is the playing status and volume.
53 std::vector<MockPlayer> players_; 52 std::vector<MockPlayer> players_;
54 53
55 int received_resume_calls_ = 0; 54 int received_resume_calls_ = 0;
56 int received_suspend_calls_ = 0; 55 int received_suspend_calls_ = 0;
57 }; 56 };
58 57
59 } // namespace content 58 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698