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

Side by Side Diff: net/quic/p2p/quic_p2p_session_test.cc

Issue 2109503009: Refactor net tests to use GMock matchers for checking net::Error results (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert changes to contents.txt files Created 4 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 "net/quic/p2p/quic_p2p_session.h" 5 #include "net/quic/p2p/quic_p2p_session.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <deque> 8 #include <deque>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback_helpers.h" 12 #include "base/callback_helpers.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/run_loop.h" 16 #include "base/run_loop.h"
17 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
18 #include "base/threading/thread_task_runner_handle.h" 18 #include "base/threading/thread_task_runner_handle.h"
19 #include "net/base/io_buffer.h" 19 #include "net/base/io_buffer.h"
20 #include "net/base/net_errors.h" 20 #include "net/base/net_errors.h"
21 #include "net/quic/crypto/quic_random.h" 21 #include "net/quic/crypto/quic_random.h"
22 #include "net/quic/p2p/quic_p2p_crypto_config.h" 22 #include "net/quic/p2p/quic_p2p_crypto_config.h"
23 #include "net/quic/p2p/quic_p2p_stream.h" 23 #include "net/quic/p2p/quic_p2p_stream.h"
24 #include "net/quic/quic_chromium_alarm_factory.h" 24 #include "net/quic/quic_chromium_alarm_factory.h"
25 #include "net/quic/quic_chromium_connection_helper.h" 25 #include "net/quic/quic_chromium_connection_helper.h"
26 #include "net/quic/quic_chromium_packet_writer.h" 26 #include "net/quic/quic_chromium_packet_writer.h"
27 #include "net/quic/test_tools/quic_session_peer.h" 27 #include "net/quic/test_tools/quic_session_peer.h"
28 #include "net/socket/socket.h" 28 #include "net/socket/socket.h"
29 #include "net/test/gtest_util.h"
30 #include "testing/gmock/include/gmock/gmock.h"
29 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
30 32
33 using net::test::IsOk;
34
31 namespace net { 35 namespace net {
32 36
33 namespace { 37 namespace {
34 38
35 const char kTestSharedKey[] = "Shared key exchanged out of bound."; 39 const char kTestSharedKey[] = "Shared key exchanged out of bound.";
36 40
37 class FakeP2PDatagramSocket : public Socket { 41 class FakeP2PDatagramSocket : public Socket {
38 public: 42 public:
39 FakeP2PDatagramSocket() : weak_factory_(this) {} 43 FakeP2PDatagramSocket() : weak_factory_(this) {}
40 ~FakeP2PDatagramSocket() override {} 44 ~FakeP2PDatagramSocket() override {}
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 QuicConfig config_; 260 QuicConfig config_;
257 261
258 base::WeakPtr<FakeP2PDatagramSocket> socket1_; 262 base::WeakPtr<FakeP2PDatagramSocket> socket1_;
259 std::unique_ptr<QuicP2PSession> session1_; 263 std::unique_ptr<QuicP2PSession> session1_;
260 264
261 base::WeakPtr<FakeP2PDatagramSocket> socket2_; 265 base::WeakPtr<FakeP2PDatagramSocket> socket2_;
262 std::unique_ptr<QuicP2PSession> session2_; 266 std::unique_ptr<QuicP2PSession> session2_;
263 }; 267 };
264 268
265 void QuicP2PSessionTest::OnWriteResult(int result) { 269 void QuicP2PSessionTest::OnWriteResult(int result) {
266 EXPECT_EQ(OK, result); 270 EXPECT_THAT(result, IsOk());
267 } 271 }
268 272
269 void QuicP2PSessionTest::TestStreamConnection(QuicP2PSession* from_session, 273 void QuicP2PSessionTest::TestStreamConnection(QuicP2PSession* from_session,
270 QuicP2PSession* to_session, 274 QuicP2PSession* to_session,
271 QuicStreamId expected_stream_id) { 275 QuicStreamId expected_stream_id) {
272 QuicP2PStream* outgoing_stream = 276 QuicP2PStream* outgoing_stream =
273 from_session->CreateOutgoingDynamicStream(kDefaultPriority); 277 from_session->CreateOutgoingDynamicStream(kDefaultPriority);
274 EXPECT_TRUE(outgoing_stream); 278 EXPECT_TRUE(outgoing_stream);
275 TestP2PStreamDelegate outgoing_stream_delegate; 279 TestP2PStreamDelegate outgoing_stream_delegate;
276 outgoing_stream->SetDelegate(&outgoing_stream_delegate); 280 outgoing_stream->SetDelegate(&outgoing_stream_delegate);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 EXPECT_TRUE(stream_delegate.is_closed()); 400 EXPECT_TRUE(stream_delegate.is_closed());
397 EXPECT_EQ(QUIC_PACKET_READ_ERROR, stream_delegate.error()); 401 EXPECT_EQ(QUIC_PACKET_READ_ERROR, stream_delegate.error());
398 EXPECT_TRUE(session_delegate.is_closed()); 402 EXPECT_TRUE(session_delegate.is_closed());
399 EXPECT_EQ(QUIC_PACKET_READ_ERROR, session_delegate.error()); 403 EXPECT_EQ(QUIC_PACKET_READ_ERROR, session_delegate.error());
400 404
401 // Verify that the socket was destroyed. 405 // Verify that the socket was destroyed.
402 EXPECT_FALSE(socket1_); 406 EXPECT_FALSE(socket1_);
403 } 407 }
404 408
405 } // namespace net 409 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/properties_based_quic_server_info_test.cc ('k') | net/quic/quic_chromium_client_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698