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

Side by Side Diff: extensions/browser/api/cast_channel/keep_alive_delegate_unittest.cc

Issue 2609503002: Fix cast_channel::KeepAliveDelegate DCHECK failure. (Closed)
Patch Set: Created 3 years, 11 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 "extensions/browser/api/cast_channel/keep_alive_delegate.h" 5 #include "extensions/browser/api/cast_channel/keep_alive_delegate.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 EXPECT_CALL(*inner_delegate_, OnMessage(EqualsProto(other_message))); 157 EXPECT_CALL(*inner_delegate_, OnMessage(EqualsProto(other_message)));
158 EXPECT_CALL(*inner_delegate_, Start()); 158 EXPECT_CALL(*inner_delegate_, Start());
159 EXPECT_CALL(*ping_timer_, ResetTriggered()).Times(2); 159 EXPECT_CALL(*ping_timer_, ResetTriggered()).Times(2);
160 EXPECT_CALL(*liveness_timer_, ResetTriggered()).Times(2); 160 EXPECT_CALL(*liveness_timer_, ResetTriggered()).Times(2);
161 161
162 keep_alive_->Start(); 162 keep_alive_->Start();
163 keep_alive_->OnMessage(other_message); 163 keep_alive_->OnMessage(other_message);
164 RunPendingTasks(); 164 RunPendingTasks();
165 } 165 }
166 166
167 TEST_F(KeepAliveDelegateTest, TestPassthroughMessagesAfterError) {
168 CastMessage message =
169 KeepAliveDelegate::CreateKeepAliveMessage("NEITHER_PING_NOR_PONG");
170 CastMessage message_after_error =
171 KeepAliveDelegate::CreateKeepAliveMessage("ANOTHER_NOT_PING_NOR_PONG");
172 CastMessage late_ping_message = KeepAliveDelegate::CreateKeepAliveMessage(
173 KeepAliveDelegate::kHeartbeatPingType);
174
175 // Start, process one message, then error-out. KeepAliveDelegate will
176 // automatically stop itself.
177 EXPECT_CALL(*inner_delegate_, Start()).Times(1);
178 EXPECT_CALL(*inner_delegate_, OnMessage(EqualsProto(message)))
179 .Times(1)
180 .RetiresOnSaturation();
181 EXPECT_CALL(*inner_delegate_, OnError(CHANNEL_ERROR_INVALID_MESSAGE));
182 EXPECT_CALL(*ping_timer_, ResetTriggered()).Times(2);
183 EXPECT_CALL(*liveness_timer_, ResetTriggered()).Times(2);
184 EXPECT_CALL(*liveness_timer_, Stop()).Times(1);
185 EXPECT_CALL(*ping_timer_, Stop()).Times(1);
Wez 2017/01/04 00:10:17 Strictly speaking, GMock has undefined behaviour i
miu 2017/01/12 22:31:27 My understanding is it always works so long as the
Wez 2017/01/13 22:37:11 I believe you're right, but strictly it is undefin
186 keep_alive_->Start();
187 keep_alive_->OnMessage(message);
188 RunPendingTasks();
189 keep_alive_->OnError(CHANNEL_ERROR_INVALID_MESSAGE);
190 RunPendingTasks();
191
192 // Process a non-PING/PONG message and expect it to pass through.
193 EXPECT_CALL(*inner_delegate_, OnMessage(EqualsProto(message_after_error)))
194 .Times(1)
195 .RetiresOnSaturation();
196 keep_alive_->OnMessage(message_after_error);
197 RunPendingTasks();
198
199 // Process a late-arriving PING/PONG message, which should have no effect..
200 EXPECT_CALL(*inner_delegate_, OnMessage(EqualsProto(late_ping_message)))
201 .Times(0)
202 .RetiresOnSaturation();
203 keep_alive_->OnMessage(late_ping_message);
204 RunPendingTasks();
205 }
206
167 } // namespace 207 } // namespace
168 } // namespace cast_channel 208 } // namespace cast_channel
169 } // namespace api 209 } // namespace api
170 } // namespace extensions 210 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698