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

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

Issue 2714783002: [Presentation API] (browser side) Implement reconnect() for 1-UA mode (Closed)
Patch Set: resolve code review comments from Mark Created 3 years, 9 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 <vector> 5 #include <vector>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "chrome/browser/media/router/offscreen_presentation_manager.h" 9 #include "chrome/browser/media/router/offscreen_presentation_manager.h"
10 #include "chrome/browser/media/router/test_helper.h" 10 #include "chrome/browser/media/router/test_helper.h"
(...skipping 21 matching lines...) Expand all
32 } 32 }
33 33
34 MOCK_METHOD2(OnReceiverConnectionAvailableRaw, 34 MOCK_METHOD2(OnReceiverConnectionAvailableRaw,
35 void(const content::PresentationSessionInfo&, 35 void(const content::PresentationSessionInfo&,
36 blink::mojom::PresentationConnection*)); 36 blink::mojom::PresentationConnection*));
37 }; 37 };
38 38
39 class OffscreenPresentationManagerTest : public ::testing::Test { 39 class OffscreenPresentationManagerTest : public ::testing::Test {
40 public: 40 public:
41 OffscreenPresentationManagerTest() 41 OffscreenPresentationManagerTest()
42 : render_frame_host_id_(1, 1), presentation_url_(kPresentationUrl) {} 42 : render_frame_host_id_(1, 1),
43 presentation_url_(kPresentationUrl),
44 route_("route_1",
45 MediaSource("source_1"),
46 "sink_1",
47 "",
48 false,
49 "",
50 false) {}
43 51
44 OffscreenPresentationManager* manager() { return &manager_; } 52 OffscreenPresentationManager* manager() { return &manager_; }
45 53
46 void VerifyPresentationsSize(size_t expected) { 54 void VerifyPresentationsSize(size_t expected) {
47 EXPECT_EQ(expected, manager_.offscreen_presentations_.size()); 55 EXPECT_EQ(expected, manager_.offscreen_presentations_.size());
48 } 56 }
49 57
50 void VerifyControllerSize(size_t expected, 58 void VerifyControllerSize(size_t expected,
51 const std::string& presentationId) { 59 const std::string& presentationId) {
52 EXPECT_TRUE( 60 EXPECT_TRUE(
53 base::ContainsKey(manager_.offscreen_presentations_, presentationId)); 61 base::ContainsKey(manager_.offscreen_presentations_, presentationId));
54 EXPECT_EQ(expected, manager_.offscreen_presentations_[presentationId] 62 EXPECT_EQ(expected, manager_.offscreen_presentations_[presentationId]
55 ->pending_controllers_.size()); 63 ->pending_controllers_.size());
56 } 64 }
57 65
58 void RegisterController(const std::string& presentation_id, 66 void RegisterController(const std::string& presentation_id,
59 content::PresentationConnectionPtr controller) { 67 content::PresentationConnectionPtr controller) {
60 content::PresentationConnectionRequest receiver_conn_request; 68 content::PresentationConnectionRequest receiver_conn_request;
61 manager()->RegisterOffscreenPresentationController( 69 manager()->RegisterOffscreenPresentationController(
62 presentation_id, presentation_url_, render_frame_host_id_, 70 presentation_id, presentation_url_, render_frame_host_id_,
63 std::move(controller), std::move(receiver_conn_request)); 71 std::move(controller), std::move(receiver_conn_request), route_);
64 } 72 }
65 73
66 void RegisterController(const RenderFrameHostId& render_frame_id, 74 void RegisterController(const RenderFrameHostId& render_frame_id,
67 content::PresentationConnectionPtr controller) { 75 content::PresentationConnectionPtr controller) {
68 content::PresentationConnectionRequest receiver_conn_request; 76 content::PresentationConnectionRequest receiver_conn_request;
69 manager()->RegisterOffscreenPresentationController( 77 manager()->RegisterOffscreenPresentationController(
70 kPresentationId, presentation_url_, render_frame_id, 78 kPresentationId, presentation_url_, render_frame_id,
71 std::move(controller), std::move(receiver_conn_request)); 79 std::move(controller), std::move(receiver_conn_request), route_);
72 } 80 }
73 81
74 void RegisterController(content::PresentationConnectionPtr controller) { 82 void RegisterController(content::PresentationConnectionPtr controller) {
75 content::PresentationConnectionRequest receiver_conn_request; 83 content::PresentationConnectionRequest receiver_conn_request;
76 manager()->RegisterOffscreenPresentationController( 84 manager()->RegisterOffscreenPresentationController(
77 kPresentationId, presentation_url_, render_frame_host_id_, 85 kPresentationId, presentation_url_, render_frame_host_id_,
78 std::move(controller), std::move(receiver_conn_request)); 86 std::move(controller), std::move(receiver_conn_request), route_);
79 } 87 }
80 88
81 void RegisterReceiver( 89 void RegisterReceiver(
82 MockReceiverConnectionAvailableCallback& receiver_callback) { 90 MockReceiverConnectionAvailableCallback& receiver_callback) {
83 RegisterReceiver(kPresentationId, receiver_callback); 91 RegisterReceiver(kPresentationId, receiver_callback);
84 } 92 }
85 93
86 void RegisterReceiver( 94 void RegisterReceiver(
87 const std::string& presentation_id, 95 const std::string& presentation_id,
88 MockReceiverConnectionAvailableCallback& receiver_callback) { 96 MockReceiverConnectionAvailableCallback& receiver_callback) {
(...skipping 15 matching lines...) Expand all
104 } 112 }
105 113
106 void UnregisterReceiver() { 114 void UnregisterReceiver() {
107 manager()->OnOffscreenPresentationReceiverTerminated(kPresentationId); 115 manager()->OnOffscreenPresentationReceiverTerminated(kPresentationId);
108 } 116 }
109 117
110 private: 118 private:
111 const RenderFrameHostId render_frame_host_id_; 119 const RenderFrameHostId render_frame_host_id_;
112 GURL presentation_url_; 120 GURL presentation_url_;
113 OffscreenPresentationManager manager_; 121 OffscreenPresentationManager manager_;
122 MediaRoute route_;
114 }; 123 };
115 124
116 TEST_F(OffscreenPresentationManagerTest, RegisterUnregisterController) { 125 TEST_F(OffscreenPresentationManagerTest, RegisterUnregisterController) {
117 content::PresentationConnectionPtr controller; 126 content::PresentationConnectionPtr controller;
118 RegisterController(std::move(controller)); 127 RegisterController(std::move(controller));
119 VerifyPresentationsSize(1); 128 VerifyPresentationsSize(1);
120 UnregisterController(); 129 UnregisterController();
121 VerifyPresentationsSize(0); 130 VerifyPresentationsSize(0);
122 } 131 }
123 132
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 EXPECT_CALL(receiver_callback2, OnReceiverConnectionAvailableRaw(_, _)) 300 EXPECT_CALL(receiver_callback2, OnReceiverConnectionAvailableRaw(_, _))
292 .Times(1); 301 .Times(1);
293 RegisterReceiver(kPresentationId2, receiver_callback2); 302 RegisterReceiver(kPresentationId2, receiver_callback2);
294 303
295 VerifyPresentationsSize(2); 304 VerifyPresentationsSize(2);
296 305
297 UnregisterReceiver(); 306 UnregisterReceiver();
298 VerifyPresentationsSize(1); 307 VerifyPresentationsSize(1);
299 } 308 }
300 309
310 TEST_F(OffscreenPresentationManagerTest, TestIsOffscreenPresentation) {
311 EXPECT_FALSE(manager()->IsOffscreenPresentation(kPresentationId));
312 content::PresentationConnectionPtr controller1;
313 RegisterController(kPresentationId, std::move(controller1));
314 EXPECT_TRUE(manager()->IsOffscreenPresentation(kPresentationId));
315 }
316
317 TEST_F(OffscreenPresentationManagerTest, TestRegisterAndGetRoute) {
318 MediaSource source("source_1");
319 MediaRoute route("route_1", source, "sink_1", "", false, "", false);
320
321 EXPECT_FALSE(manager()->GetRoute(kPresentationId));
322 content::PresentationConnectionPtr controller;
323 RegisterController(std::move(controller));
324
325 auto* actual_route = manager()->GetRoute(kPresentationId);
326 EXPECT_TRUE(actual_route);
327 EXPECT_TRUE(route.Equals(*actual_route));
328 }
329
301 } // namespace media_router 330 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698