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

Side by Side Diff: chrome/browser/media/router/presentation_service_delegate_impl_unittest.cc

Issue 2962623002: [Media Router] Clean up OffscreenPresentationManager params. (Closed)
Patch Set: Addressed Bin's comments Created 3 years, 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/media/router/presentation_service_delegate_impl.h" 5 #include "chrome/browser/media/router/presentation_service_delegate_impl.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/test/mock_callback.h" 8 #include "base/test/mock_callback.h"
9 #include "chrome/browser/media/router/mock_media_router.h" 9 #include "chrome/browser/media/router/mock_media_router.h"
10 #include "chrome/browser/media/router/mock_screen_availability_listener.h" 10 #include "chrome/browser/media/router/mock_screen_availability_listener.h"
(...skipping 25 matching lines...) Expand all
36 using ::testing::WithArgs; 36 using ::testing::WithArgs;
37 37
38 namespace { 38 namespace {
39 39
40 const char kPresentationUrl1[] = "http://foo.fakeurl.com/"; 40 const char kPresentationUrl1[] = "http://foo.fakeurl.com/";
41 const char kPresentationUrl2[] = "http://bar.fakeurl.com/"; 41 const char kPresentationUrl2[] = "http://bar.fakeurl.com/";
42 const char kPresentationUrl3[] = 42 const char kPresentationUrl3[] =
43 "https://google.com/cast#__castAppId__=233637DE"; 43 "https://google.com/cast#__castAppId__=233637DE";
44 const char kFrameUrl[] = "http://anotherframeurl.fakeurl.com/"; 44 const char kFrameUrl[] = "http://anotherframeurl.fakeurl.com/";
45 45
46 // Matches content::PresentationInfo.
47 MATCHER_P(InfoEquals, expected, "") {
48 return expected.presentation_url == arg.presentation_url &&
49 expected.presentation_id == arg.presentation_id;
50 }
51
46 } // namespace 52 } // namespace
47 53
48 namespace media_router { 54 namespace media_router {
49 55
50 class MockDelegateObserver 56 class MockDelegateObserver
51 : public content::PresentationServiceDelegate::Observer { 57 : public content::PresentationServiceDelegate::Observer {
52 public: 58 public:
53 MOCK_METHOD0(OnDelegateDestroyed, void()); 59 MOCK_METHOD0(OnDelegateDestroyed, void());
54 MOCK_METHOD1(OnDefaultPresentationStarted, 60 MOCK_METHOD1(OnDefaultPresentationStarted,
55 void(const content::PresentationInfo&)); 61 void(const content::PresentationInfo&));
(...skipping 11 matching lines...) Expand all
67 public: 73 public:
68 MOCK_METHOD1(OnCreateConnectionSuccess, 74 MOCK_METHOD1(OnCreateConnectionSuccess,
69 void(const content::PresentationInfo& connection)); 75 void(const content::PresentationInfo& connection));
70 MOCK_METHOD1(OnCreateConnectionError, 76 MOCK_METHOD1(OnCreateConnectionError,
71 void(const content::PresentationError& error)); 77 void(const content::PresentationError& error));
72 }; 78 };
73 79
74 class MockOffscreenPresentationManager : public OffscreenPresentationManager { 80 class MockOffscreenPresentationManager : public OffscreenPresentationManager {
75 public: 81 public:
76 void RegisterOffscreenPresentationController( 82 void RegisterOffscreenPresentationController(
77 const std::string& presentation_id, 83 const content::PresentationInfo& presentation_info,
78 const GURL& presentation_url,
79 const RenderFrameHostId& render_frame_id, 84 const RenderFrameHostId& render_frame_id,
80 content::PresentationConnectionPtr controller, 85 content::PresentationConnectionPtr controller,
81 content::PresentationConnectionRequest, 86 content::PresentationConnectionRequest,
82 const MediaRoute& route) override { 87 const MediaRoute& route) override {
83 RegisterOffscreenPresentationController(presentation_id, presentation_url, 88 RegisterOffscreenPresentationController(presentation_info, render_frame_id,
84 render_frame_id, route); 89 route);
85 } 90 }
86 91
87 MOCK_METHOD4(RegisterOffscreenPresentationController, 92 MOCK_METHOD3(RegisterOffscreenPresentationController,
88 void(const std::string& presentation_id, 93 void(const content::PresentationInfo& presentation_info,
89 const GURL& presentation_url,
90 const RenderFrameHostId& render_frame_id, 94 const RenderFrameHostId& render_frame_id,
91 const MediaRoute& route)); 95 const MediaRoute& route));
92 MOCK_METHOD2(UnregisterOffscreenPresentationController, 96 MOCK_METHOD2(UnregisterOffscreenPresentationController,
93 void(const std::string& presentation_id, 97 void(const std::string& presentation_id,
94 const RenderFrameHostId& render_frame_id)); 98 const RenderFrameHostId& render_frame_id));
95 MOCK_METHOD3(OnOffscreenPresentationReceiverCreated, 99 MOCK_METHOD2(OnOffscreenPresentationReceiverCreated,
96 void(const std::string& presentation_id, 100 void(const content::PresentationInfo& presentation_info,
97 const GURL& presentation_url,
98 const content::ReceiverConnectionAvailableCallback& 101 const content::ReceiverConnectionAvailableCallback&
99 receiver_callback)); 102 receiver_callback));
100 MOCK_METHOD1(OnOffscreenPresentationReceiverTerminated, 103 MOCK_METHOD1(OnOffscreenPresentationReceiverTerminated,
101 void(const std::string& presentation_id)); 104 void(const std::string& presentation_id));
102 MOCK_METHOD1(IsOffscreenPresentation, 105 MOCK_METHOD1(IsOffscreenPresentation,
103 bool(const std::string& presentation_id)); 106 bool(const std::string& presentation_id));
104 MOCK_METHOD1(GetRoute, MediaRoute*(const std::string& presentation_id)); 107 MOCK_METHOD1(GetRoute, MediaRoute*(const std::string& presentation_id));
105 }; 108 };
106 109
107 std::unique_ptr<KeyedService> BuildMockOffscreenPresentationManager( 110 std::unique_ptr<KeyedService> BuildMockOffscreenPresentationManager(
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 base::MockCallback<content::PresentationConnectionCallback> success_cb; 610 base::MockCallback<content::PresentationConnectionCallback> success_cb;
608 EXPECT_CALL(success_cb, Run(_)); 611 EXPECT_CALL(success_cb, Run(_));
609 612
610 delegate_impl_->OnStartPresentationSucceeded( 613 delegate_impl_->OnStartPresentationSucceeded(
611 render_process_id, render_frame_id, success_cb.Get(), presentation_info, 614 render_process_id, render_frame_id, success_cb.Get(), presentation_info,
612 media_route); 615 media_route);
613 616
614 auto& mock_offscreen_manager = GetMockOffscreenPresentationManager(); 617 auto& mock_offscreen_manager = GetMockOffscreenPresentationManager();
615 EXPECT_CALL(mock_offscreen_manager, 618 EXPECT_CALL(mock_offscreen_manager,
616 RegisterOffscreenPresentationController( 619 RegisterOffscreenPresentationController(
617 presentation_id, presentation_url, 620 InfoEquals(presentation_info),
618 RenderFrameHostId(render_process_id, render_frame_id), 621 RenderFrameHostId(render_process_id, render_frame_id),
619 Equals(media_route))); 622 Equals(media_route)));
620 623
621 content::PresentationConnectionPtr connection_ptr; 624 content::PresentationConnectionPtr connection_ptr;
622 content::PresentationConnectionRequest connection_request; 625 content::PresentationConnectionRequest connection_request;
623 delegate_impl_->ConnectToPresentation( 626 delegate_impl_->ConnectToPresentation(
624 render_process_id, render_frame_id, presentation_info, 627 render_process_id, render_frame_id, presentation_info,
625 std::move(connection_ptr), std::move(connection_request)); 628 std::move(connection_ptr), std::move(connection_request));
626 629
627 EXPECT_CALL(mock_offscreen_manager, 630 EXPECT_CALL(mock_offscreen_manager,
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 base::Bind(&MockCreatePresentationConnnectionCallbacks:: 790 base::Bind(&MockCreatePresentationConnnectionCallbacks::
788 OnCreateConnectionSuccess, 791 OnCreateConnectionSuccess,
789 base::Unretained(&mock_create_connection_callbacks)), 792 base::Unretained(&mock_create_connection_callbacks)),
790 base::Bind( 793 base::Bind(
791 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError, 794 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError,
792 base::Unretained(&mock_create_connection_callbacks))); 795 base::Unretained(&mock_create_connection_callbacks)));
793 } 796 }
794 #endif // !defined(OS_ANDROID) 797 #endif // !defined(OS_ANDROID)
795 798
796 } // namespace media_router 799 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698