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

Side by Side Diff: net/spdy/bidirectional_stream_spdy_impl_unittest.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 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 "net/spdy/bidirectional_stream_spdy_impl.h" 5 #include "net/spdy/bidirectional_stream_spdy_impl.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "base/timer/mock_timer.h" 16 #include "base/timer/mock_timer.h"
17 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
18 #include "net/http/http_request_info.h" 18 #include "net/http/http_request_info.h"
19 #include "net/http/http_response_headers.h" 19 #include "net/http/http_response_headers.h"
20 #include "net/http/http_response_info.h" 20 #include "net/http/http_response_info.h"
21 #include "net/log/net_log.h" 21 #include "net/log/net_log.h"
22 #include "net/log/test_net_log.h" 22 #include "net/log/test_net_log.h"
23 #include "net/socket/socket_test_util.h" 23 #include "net/socket/socket_test_util.h"
24 #include "net/spdy/spdy_session.h" 24 #include "net/spdy/spdy_session.h"
25 #include "net/spdy/spdy_test_util_common.h" 25 #include "net/spdy/spdy_test_util_common.h"
26 #include "net/test/cert_test_util.h" 26 #include "net/test/cert_test_util.h"
27 #include "net/test/gtest_util.h"
27 #include "net/test/test_data_directory.h" 28 #include "net/test/test_data_directory.h"
29 #include "testing/gmock/include/gmock/gmock.h"
28 #include "testing/gtest/include/gtest/gtest.h" 30 #include "testing/gtest/include/gtest/gtest.h"
29 31
32 using net::test::IsError;
33 using net::test::IsOk;
34
30 namespace net { 35 namespace net {
31 36
32 namespace { 37 namespace {
33 38
34 const char kBodyData[] = "Body data"; 39 const char kBodyData[] = "Body data";
35 const size_t kBodyDataSize = arraysize(kBodyData); 40 const size_t kBodyDataSize = arraysize(kBodyData);
36 // Size of the buffer to be allocated for each read. 41 // Size of the buffer to be allocated for each read.
37 const size_t kReadBufferSize = 4096; 42 const size_t kReadBufferSize = 4096;
38 43
39 class TestDelegateBase : public BidirectionalStreamImpl::Delegate { 44 class TestDelegateBase : public BidirectionalStreamImpl::Delegate {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 delegate->Start(&request_info, net_log_.bound()); 288 delegate->Start(&request_info, net_log_.bound());
284 base::RunLoop().RunUntilIdle(); 289 base::RunLoop().RunUntilIdle();
285 290
286 EXPECT_TRUE(delegate->on_failed_called()); 291 EXPECT_TRUE(delegate->on_failed_called());
287 292
288 // Try to send data after OnFailed(), should not get called back. 293 // Try to send data after OnFailed(), should not get called back.
289 scoped_refptr<StringIOBuffer> buf(new StringIOBuffer("dummy")); 294 scoped_refptr<StringIOBuffer> buf(new StringIOBuffer("dummy"));
290 delegate->SendData(buf.get(), buf->size(), false); 295 delegate->SendData(buf.get(), buf->size(), false);
291 base::RunLoop().RunUntilIdle(); 296 base::RunLoop().RunUntilIdle();
292 297
293 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, delegate->error()); 298 EXPECT_THAT(delegate->error(), IsError(ERR_SPDY_PROTOCOL_ERROR));
294 EXPECT_EQ(0, delegate->on_data_read_count()); 299 EXPECT_EQ(0, delegate->on_data_read_count());
295 EXPECT_EQ(0, delegate->on_data_sent_count()); 300 EXPECT_EQ(0, delegate->on_data_sent_count());
296 EXPECT_EQ(kProtoHTTP2, delegate->GetProtocol()); 301 EXPECT_EQ(kProtoHTTP2, delegate->GetProtocol());
297 // BidirectionalStreamSpdyStreamJob does not count the bytes sent for |rst| 302 // BidirectionalStreamSpdyStreamJob does not count the bytes sent for |rst|
298 // because it is sent after SpdyStream::Delegate::OnClose is called. 303 // because it is sent after SpdyStream::Delegate::OnClose is called.
299 EXPECT_EQ(CountWriteBytes(writes, 1), delegate->GetTotalSentBytes()); 304 EXPECT_EQ(CountWriteBytes(writes, 1), delegate->GetTotalSentBytes());
300 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)), 305 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)),
301 delegate->GetTotalReceivedBytes()); 306 delegate->GetTotalReceivedBytes());
302 } 307 }
303 308
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 EXPECT_FALSE(delegate->on_failed_called()); 368 EXPECT_FALSE(delegate->on_failed_called());
364 369
365 EXPECT_EQ("200", delegate->response_headers().find(":status")->second); 370 EXPECT_EQ("200", delegate->response_headers().find(":status")->second);
366 EXPECT_EQ(0, delegate->on_data_read_count()); 371 EXPECT_EQ(0, delegate->on_data_read_count());
367 EXPECT_EQ(kProtoHTTP2, delegate->GetProtocol()); 372 EXPECT_EQ(kProtoHTTP2, delegate->GetProtocol());
368 EXPECT_EQ(0, delegate->GetTotalSentBytes()); 373 EXPECT_EQ(0, delegate->GetTotalSentBytes());
369 EXPECT_EQ(0, delegate->GetTotalReceivedBytes()); 374 EXPECT_EQ(0, delegate->GetTotalReceivedBytes());
370 } 375 }
371 376
372 } // namespace net 377 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/websocket_transport_client_socket_pool_unittest.cc ('k') | net/spdy/spdy_http_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698