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

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

Issue 2453623003: Decouple MediaSession messages from WebContents (full patch) (Closed)
Patch Set: nit Created 4 years, 1 month 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 <tuple> 5 #include <tuple>
6 6
7 #include "content/browser/media/media_web_contents_observer.h" 7 #include "content/browser/media/media_web_contents_observer.h"
8 #include "content/browser/media/session/media_session.h"
9 #include "content/browser/media/session/media_session_controller.h" 8 #include "content/browser/media/session/media_session_controller.h"
9 #include "content/browser/media/session/media_session_impl.h"
10 #include "content/common/media/media_player_delegate_messages.h" 10 #include "content/common/media/media_player_delegate_messages.h"
11 #include "content/test/test_render_view_host.h" 11 #include "content/test/test_render_view_host.h"
12 #include "content/test/test_web_contents.h" 12 #include "content/test/test_web_contents.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 class MediaSessionControllerTest : public RenderViewHostImplTestHarness { 17 class MediaSessionControllerTest : public RenderViewHostImplTestHarness {
18 public: 18 public:
19 void SetUp() override { 19 void SetUp() override {
20 RenderViewHostImplTestHarness::SetUp(); 20 RenderViewHostImplTestHarness::SetUp();
21 id_ = WebContentsObserver::MediaPlayerId(contents()->GetMainFrame(), 0); 21 id_ = WebContentsObserver::MediaPlayerId(contents()->GetMainFrame(), 0);
22 controller_ = CreateController(); 22 controller_ = CreateController();
23 } 23 }
24 24
25 void TearDown() override { 25 void TearDown() override {
26 // Destruct the controller prior to any other teardown to avoid out of order 26 // Destruct the controller prior to any other teardown to avoid out of order
27 // destruction relative to the MediaSession instance. 27 // destruction relative to the MediaSession instance.
28 controller_.reset(); 28 controller_.reset();
29 RenderViewHostImplTestHarness::TearDown(); 29 RenderViewHostImplTestHarness::TearDown();
30 } 30 }
31 31
32 protected: 32 protected:
33 std::unique_ptr<MediaSessionController> CreateController() { 33 std::unique_ptr<MediaSessionController> CreateController() {
34 return std::unique_ptr<MediaSessionController>(new MediaSessionController( 34 return std::unique_ptr<MediaSessionController>(new MediaSessionController(
35 id_, contents()->media_web_contents_observer())); 35 id_, contents()->media_web_contents_observer()));
36 } 36 }
37 37
38 MediaSession* media_session() { return MediaSession::Get(contents()); } 38 MediaSessionImpl* media_session() {
39 return MediaSessionImpl::Get(contents());
40 }
39 41
40 IPC::TestSink& test_sink() { return main_test_rfh()->GetProcess()->sink(); } 42 IPC::TestSink& test_sink() { return main_test_rfh()->GetProcess()->sink(); }
41 43
42 void Suspend() { 44 void Suspend() {
43 controller_->OnSuspend(controller_->get_player_id_for_testing()); 45 controller_->OnSuspend(controller_->get_player_id_for_testing());
44 } 46 }
45 47
46 void Resume() { 48 void Resume() {
47 controller_->OnResume(controller_->get_player_id_for_testing()); 49 controller_->OnResume(controller_->get_player_id_for_testing());
48 } 50 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 208
207 // Switch to a remote player, which should release the session. 209 // Switch to a remote player, which should release the session.
208 ASSERT_TRUE( 210 ASSERT_TRUE(
209 controller_->Initialize(true, true, media::MediaContentType::Persistent)); 211 controller_->Initialize(true, true, media::MediaContentType::Persistent));
210 EXPECT_TRUE(media_session()->IsSuspended()); 212 EXPECT_TRUE(media_session()->IsSuspended());
211 EXPECT_FALSE(media_session()->IsControllable()); 213 EXPECT_FALSE(media_session()->IsControllable());
212 EXPECT_EQ(current_player_id, controller_->get_player_id_for_testing()); 214 EXPECT_EQ(current_player_id, controller_->get_player_id_for_testing());
213 } 215 }
214 216
215 } // namespace content 217 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698