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

Side by Side Diff: content/browser/media/session/media_session_impl_service_routing_unittest.cc

Issue 2798083002: Record user interactions with MediaSession by action type (Closed)
Patch Set: addressed style nits Created 3 years, 8 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 "content/browser/media/session/media_session_impl.h" 5 #include "content/browser/media/session/media_session_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 explicit MockMediaSessionPlayerObserver(RenderFrameHost* rfh) 58 explicit MockMediaSessionPlayerObserver(RenderFrameHost* rfh)
59 : render_frame_host_(rfh) {} 59 : render_frame_host_(rfh) {}
60 60
61 ~MockMediaSessionPlayerObserver() override = default; 61 ~MockMediaSessionPlayerObserver() override = default;
62 62
63 MOCK_METHOD1(OnSuspend, void(int player_id)); 63 MOCK_METHOD1(OnSuspend, void(int player_id));
64 MOCK_METHOD1(OnResume, void(int player_id)); 64 MOCK_METHOD1(OnResume, void(int player_id));
65 MOCK_METHOD2(OnSetVolumeMultiplier, 65 MOCK_METHOD2(OnSetVolumeMultiplier,
66 void(int player_id, double volume_multiplier)); 66 void(int player_id, double volume_multiplier));
67 67
68 RenderFrameHost* GetRenderFrameHost() const override { 68 RenderFrameHost* render_frame_host() const override {
69 return render_frame_host_; 69 return render_frame_host_;
70 } 70 }
71 71
72 private: 72 private:
73 RenderFrameHost* render_frame_host_; 73 RenderFrameHost* render_frame_host_;
74 }; 74 };
75 75
76 } // anonymous namespace 76 } // anonymous namespace
77 77
78 class MediaSessionImplServiceRoutingTest 78 class MediaSessionImplServiceRoutingTest
79 : public RenderViewHostImplTestHarness { 79 : public RenderViewHostImplTestHarness {
80 public: 80 public:
81 MediaSessionImplServiceRoutingTest() = default; 81 MediaSessionImplServiceRoutingTest() = default;
82 ~MediaSessionImplServiceRoutingTest() override = default; 82 ~MediaSessionImplServiceRoutingTest() override = default;
83 83
84 void SetUp() override { 84 void SetUp() override {
85 RenderViewHostImplTestHarness::SetUp(); 85 RenderViewHostImplTestHarness::SetUp();
86 86
87 contents()->GetMainFrame()->InitializeRenderFrameIfNeeded(); 87 contents()->GetMainFrame()->InitializeRenderFrameIfNeeded();
88 mock_media_session_observer_.reset(new NiceMock<MockMediaSessionObserver>( 88 mock_media_session_observer_.reset(new NiceMock<MockMediaSessionObserver>(
89 MediaSessionImpl::Get(contents()))); 89 MediaSessionImpl::Get(contents())));
90 main_frame_ = contents()->GetMainFrame(); 90 main_frame_ = contents()->GetMainFrame();
91 sub_frame_ = main_frame_->AppendChild("sub_frame"); 91 sub_frame_ = main_frame_->AppendChild("sub_frame");
92
93 player_in_main_frame_.reset(
94 new MockMediaSessionPlayerObserver(main_frame_));
95 player_in_sub_frame_.reset(new MockMediaSessionPlayerObserver(sub_frame_));
96 } 92 }
97 93
98 void TearDown() override { 94 void TearDown() override {
99 mock_media_session_observer_.reset(); 95 mock_media_session_observer_.reset();
100 services_.clear(); 96 services_.clear();
101 clients_.clear(); 97 clients_.clear();
102 98
103 RenderViewHostImplTestHarness::TearDown(); 99 RenderViewHostImplTestHarness::TearDown();
104 } 100 }
105 101
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 return (iter != players_.end()) ? iter->second.get() : nullptr; 143 return (iter != players_.end()) ? iter->second.get() : nullptr;
148 } 144 }
149 145
150 MediaSessionServiceImpl* ComputeServiceForRouting() { 146 MediaSessionServiceImpl* ComputeServiceForRouting() {
151 return MediaSessionImpl::Get(contents())->ComputeServiceForRouting(); 147 return MediaSessionImpl::Get(contents())->ComputeServiceForRouting();
152 } 148 }
153 149
154 TestRenderFrameHost* main_frame_; 150 TestRenderFrameHost* main_frame_;
155 TestRenderFrameHost* sub_frame_; 151 TestRenderFrameHost* sub_frame_;
156 152
157 std::unique_ptr<MockMediaSessionPlayerObserver> player_in_main_frame_;
158 std::unique_ptr<MockMediaSessionPlayerObserver> player_in_sub_frame_;
159
160 std::unique_ptr<MockMediaSessionObserver> mock_media_session_observer_; 153 std::unique_ptr<MockMediaSessionObserver> mock_media_session_observer_;
161 154
162 using ServiceMap = std::map<TestRenderFrameHost*, 155 using ServiceMap = std::map<TestRenderFrameHost*,
163 std::unique_ptr<MockMediaSessionServiceImpl>>; 156 std::unique_ptr<MockMediaSessionServiceImpl>>;
164 ServiceMap services_; 157 ServiceMap services_;
165 158
166 using ClientMap = 159 using ClientMap =
167 std::map<TestRenderFrameHost*, std::unique_ptr<MockMediaSessionClient>>; 160 std::map<TestRenderFrameHost*, std::unique_ptr<MockMediaSessionClient>>;
168 ClientMap clients_; 161 ClientMap clients_;
169 162
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 CreateServiceForFrame(sub_frame_); 404 CreateServiceForFrame(sub_frame_);
412 405
413 EXPECT_EQ(nullptr, ComputeServiceForRouting()); 406 EXPECT_EQ(nullptr, ComputeServiceForRouting());
414 407
415 // This should not crash. 408 // This should not crash.
416 MediaSessionImpl::Get(contents()) 409 MediaSessionImpl::Get(contents())
417 ->DidReceiveAction(blink::mojom::MediaSessionAction::PAUSE); 410 ->DidReceiveAction(blink::mojom::MediaSessionAction::PAUSE);
418 } 411 }
419 412
420 } // namespace content 413 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/session/media_session_impl.cc ('k') | content/browser/media/session/media_session_impl_uma_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698