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

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

Issue 2947403004: [MediaRouter] Replace RouteMessage with PresentationConnectionMessage (Closed)
Patch Set: Addressed Takumi'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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/browser_presentation_connection_proxy.h" 5 #include "chrome/browser/media/router/browser_presentation_connection_proxy.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.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/test_helper.h" 10 #include "chrome/browser/media/router/test_helper.h"
11 #include "chrome/common/media_router/media_source.h" 11 #include "chrome/common/media_router/media_source.h"
12 #include "chrome/common/media_router/media_source_helper.h" 12 #include "chrome/common/media_router/media_source_helper.h"
13 #include "chrome/common/media_router/route_message.h"
14 #include "content/public/common/presentation_connection_message.h" 13 #include "content/public/common/presentation_connection_message.h"
15 #include "content/public/test/test_browser_thread_bundle.h" 14 #include "content/public/test/test_browser_thread_bundle.h"
16 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
17 16
18 using ::testing::_; 17 using ::testing::_;
19 using ::testing::Invoke; 18 using ::testing::Invoke;
20 19
21 namespace media_router { 20 namespace media_router {
22 21
23 using OnMessageCallback = BrowserPresentationConnectionProxy::OnMessageCallback; 22 using OnMessageCallback = BrowserPresentationConnectionProxy::OnMessageCallback;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 [&expected_data]( 113 [&expected_data](
115 const MediaRoute::Id& route_id, std::vector<uint8_t>* data, 114 const MediaRoute::Id& route_id, std::vector<uint8_t>* data,
116 const BrowserPresentationConnectionProxy::OnMessageCallback& 115 const BrowserPresentationConnectionProxy::OnMessageCallback&
117 callback) { EXPECT_EQ(*data, expected_data); })); 116 callback) { EXPECT_EQ(*data, expected_data); }));
118 117
119 browser_connection_proxy()->OnMessage(std::move(connection_message), 118 browser_connection_proxy()->OnMessage(std::move(connection_message),
120 mock_on_message_callback.Get()); 119 mock_on_message_callback.Get());
121 } 120 }
122 121
123 TEST_F(BrowserPresentationConnectionProxyTest, OnMessagesReceived) { 122 TEST_F(BrowserPresentationConnectionProxyTest, OnMessagesReceived) {
124 RouteMessage message_1; 123 content::PresentationConnectionMessage message_1;
mark a. foltz 2017/06/28 07:29:55 message_1("foo") etc.
imcheng 2017/06/29 08:21:09 Done.
125 message_1.type = RouteMessage::Type::TEXT; 124 message_1.message = std::string("foo");
126 message_1.text = std::string("foo"); 125 content::PresentationConnectionMessage message_2;
127 RouteMessage message_2; 126 message_2.data = std::vector<uint8_t>({1, 2, 3});
128 message_2.type = RouteMessage::Type::BINARY; 127 std::vector<content::PresentationConnectionMessage> messages = {message_1,
129 message_2.binary = std::vector<uint8_t>({1, 2, 3}); 128 message_2};
130 std::vector<RouteMessage> messages = {message_1, message_2};
131 129
132 content::PresentationConnectionMessage expected_message1("foo");
133 content::PresentationConnectionMessage expected_message2(
134 std::vector<uint8_t>({1, 2, 3}));
135 EXPECT_CALL(*controller_connection_proxy(), OnMessageInternal(_, _)) 130 EXPECT_CALL(*controller_connection_proxy(), OnMessageInternal(_, _))
136 .WillOnce( 131 .WillOnce(Invoke(
137 Invoke([&expected_message1]( 132 [&message_1](const content::PresentationConnectionMessage& message,
138 const content::PresentationConnectionMessage& message, 133 OnMessageCallback& callback) {
139 OnMessageCallback& callback) { 134 ExpectMessageAndRunCallback(message_1, message, callback);
140 ExpectMessageAndRunCallback(expected_message1, message, callback);
141 })) 135 }))
142 .WillOnce( 136 .WillOnce(Invoke(
143 Invoke([&expected_message2]( 137 [&message_2](const content::PresentationConnectionMessage& message,
144 const content::PresentationConnectionMessage& message, 138 OnMessageCallback& callback) {
145 OnMessageCallback& callback) { 139 ExpectMessageAndRunCallback(message_2, message, callback);
146 ExpectMessageAndRunCallback(expected_message2, message, callback);
147 })); 140 }));
148 browser_connection_proxy()->OnMessagesReceived(messages); 141 browser_connection_proxy()->OnMessagesReceived(messages);
149 base::RunLoop().RunUntilIdle(); 142 base::RunLoop().RunUntilIdle();
150 } 143 }
151 144
152 } // namespace media_router 145 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698