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

Side by Side Diff: blimp/engine/browser/engine_render_widget_message_processor_unittest.cc

Issue 1486543003: Move blimp/net/test_common.h/cc to a separate source_set. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blimp_tie
Patch Set: Fixed component build breaks. Created 5 years 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
« no previous file with comments | « blimp/engine/browser/BUILD.gn ('k') | blimp/net/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "blimp/engine/browser/engine_render_widget_message_processor.h" 5 #include "blimp/engine/browser/engine_render_widget_message_processor.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/numerics/safe_conversions.h" 9 #include "base/numerics/safe_conversions.h"
10 #include "blimp/common/proto/blimp_message.pb.h" 10 #include "blimp/common/proto/blimp_message.pb.h"
11 #include "blimp/common/proto/compositor.pb.h" 11 #include "blimp/common/proto/compositor.pb.h"
12 #include "blimp/common/proto/render_widget.pb.h" 12 #include "blimp/common/proto/render_widget.pb.h"
13 #include "blimp/net/input_message_generator.h" 13 #include "blimp/net/input_message_generator.h"
14 #include "blimp/net/test_common.h"
14 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
15 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/WebKit/public/web/WebInputEvent.h" 18 #include "third_party/WebKit/public/web/WebInputEvent.h"
18 19
19 using testing::_; 20 using testing::_;
20 using testing::InvokeArgument; 21 using testing::InvokeArgument;
21 using testing::Ref; 22 using testing::Ref;
22 using testing::Return; 23 using testing::Return;
23 using testing::SaveArg; 24 using testing::SaveArg;
24 25
25 namespace blimp { 26 namespace blimp {
26 27
27 namespace { 28 namespace {
28 class MockBlimpMessageProcessor : public BlimpMessageProcessor {
29 public:
30 MockBlimpMessageProcessor() {}
31
32 ~MockBlimpMessageProcessor() override {}
33
34 // Adapts calls from ProcessMessage to MockableProcessMessage by
35 // unboxing the |message| scoped_ptr for GMock compatibility.
36 void ProcessMessage(scoped_ptr<BlimpMessage> message,
37 const net::CompletionCallback& callback) {
38 MockableProcessMessage(*message);
39 if (!callback.is_null())
40 callback.Run(net::OK);
41 }
42
43 MOCK_METHOD1(MockableProcessMessage,
44 void(const BlimpMessage& message));
45 };
46 29
47 class MockHostRenderWidgetMessageDelegate 30 class MockHostRenderWidgetMessageDelegate
48 : public EngineRenderWidgetMessageProcessor::RenderWidgetMessageDelegate { 31 : public EngineRenderWidgetMessageProcessor::RenderWidgetMessageDelegate {
49 public: 32 public:
50 // EngineRenderWidgetMessageProcessor implementation. 33 // EngineRenderWidgetMessageProcessor implementation.
51 void OnWebInputEvent(scoped_ptr<blink::WebInputEvent> event) override { 34 void OnWebInputEvent(scoped_ptr<blink::WebInputEvent> event) override {
52 MockableOnWebInputEvent(); 35 MockableOnWebInputEvent();
53 } 36 }
54 37
55 void OnCompositorMessageReceived( 38 void OnCompositorMessageReceived(
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 143 }
161 144
162 TEST_F(EngineRenderWidgetMessageProcessorTest, DropsStaleMessages) { 145 TEST_F(EngineRenderWidgetMessageProcessorTest, DropsStaleMessages) {
163 std::vector<uint8_t> payload = { 'f', 'u', 'n' }; 146 std::vector<uint8_t> payload = { 'f', 'u', 'n' };
164 147
165 EXPECT_CALL(delegate1_, MockableOnCompositorMessageReceived( 148 EXPECT_CALL(delegate1_, MockableOnCompositorMessageReceived(
166 CompMsgEquals(payload))).Times(1); 149 CompMsgEquals(payload))).Times(1);
167 SendCompositorMessage(&processor_, 1, 1U, payload); 150 SendCompositorMessage(&processor_, 1, 1U, payload);
168 151
169 EXPECT_CALL(out_processor_, 152 EXPECT_CALL(out_processor_,
170 MockableProcessMessage(BlimpRWMsgEquals(1, 2U))).Times(1); 153 MockableProcessMessage(BlimpRWMsgEquals(1, 2U), _)).Times(1);
171 processor_.OnRenderWidgetInitialized(1); 154 processor_.OnRenderWidgetInitialized(1);
172 155
173 EXPECT_CALL(delegate1_, MockableOnCompositorMessageReceived( 156 EXPECT_CALL(delegate1_, MockableOnCompositorMessageReceived(
174 CompMsgEquals(payload))).Times(0); 157 CompMsgEquals(payload))).Times(0);
175 payload[0] = 'a'; 158 payload[0] = 'a';
176 SendCompositorMessage(&processor_, 1, 1U, payload); 159 SendCompositorMessage(&processor_, 1, 1U, payload);
177 160
178 EXPECT_CALL(delegate1_, MockableOnWebInputEvent()).Times(0); 161 EXPECT_CALL(delegate1_, MockableOnWebInputEvent()).Times(0);
179 SendInputMessage(&processor_, 1, 1U); 162 SendInputMessage(&processor_, 1, 1U);
180 163
181 EXPECT_CALL(delegate1_, MockableOnCompositorMessageReceived( 164 EXPECT_CALL(delegate1_, MockableOnCompositorMessageReceived(
182 CompMsgEquals(payload))).Times(1); 165 CompMsgEquals(payload))).Times(1);
183 SendCompositorMessage(&processor_, 1, 2U, payload); 166 SendCompositorMessage(&processor_, 1, 2U, payload);
184 167
185 EXPECT_CALL(delegate1_, MockableOnWebInputEvent()).Times(1); 168 EXPECT_CALL(delegate1_, MockableOnWebInputEvent()).Times(1);
186 SendInputMessage(&processor_, 1, 2U); 169 SendInputMessage(&processor_, 1, 2U);
187 } 170 }
188 171
189 TEST_F(EngineRenderWidgetMessageProcessorTest, 172 TEST_F(EngineRenderWidgetMessageProcessorTest,
190 RepliesHaveCorrectRenderWidgetId) { 173 RepliesHaveCorrectRenderWidgetId) {
191 std::vector<uint8_t> payload = { 'a', 'b', 'c', 'd' }; 174 std::vector<uint8_t> payload = { 'a', 'b', 'c', 'd' };
192 175
193 EXPECT_CALL(out_processor_, 176 EXPECT_CALL(out_processor_,
194 MockableProcessMessage(BlimpRWMsgEquals(1, 2U))).Times(1); 177 MockableProcessMessage(BlimpRWMsgEquals(1, 2U), _)).Times(1);
195 processor_.OnRenderWidgetInitialized(1); 178 processor_.OnRenderWidgetInitialized(1);
196 179
197 EXPECT_CALL(out_processor_, 180 EXPECT_CALL(out_processor_,
198 MockableProcessMessage(BlimpRWMsgEquals(2, 2U))).Times(1); 181 MockableProcessMessage(BlimpRWMsgEquals(2, 2U), _)).Times(1);
199 processor_.OnRenderWidgetInitialized(2); 182 processor_.OnRenderWidgetInitialized(2);
200 183
201 EXPECT_CALL(out_processor_, MockableProcessMessage( 184 EXPECT_CALL(out_processor_, MockableProcessMessage(
202 BlimpCompMsgEquals(1, 2U, payload))).Times(1); 185 BlimpCompMsgEquals(1, 2U, payload), _)).Times(1);
203 186
204 processor_.SendCompositorMessage(1, payload); 187 processor_.SendCompositorMessage(1, payload);
205 } 188 }
206 189
207 190
208 } // namespace blimp 191 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/engine/browser/BUILD.gn ('k') | blimp/net/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698