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

Side by Side Diff: net/socket/sequenced_socket_data_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 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 <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "net/base/io_buffer.h" 11 #include "net/base/io_buffer.h"
12 #include "net/base/test_completion_callback.h" 12 #include "net/base/test_completion_callback.h"
13 #include "net/socket/client_socket_handle.h" 13 #include "net/socket/client_socket_handle.h"
14 #include "net/socket/socket_test_util.h" 14 #include "net/socket/socket_test_util.h"
15 #include "net/socket/transport_client_socket_pool.h" 15 #include "net/socket/transport_client_socket_pool.h"
16 #include "net/test/gtest_util.h"
17 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest-spi.h" 18 #include "testing/gtest/include/gtest/gtest-spi.h"
17 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
18 #include "testing/platform_test.h" 20 #include "testing/platform_test.h"
19 21
22 using net::test::IsError;
23 using net::test::IsOk;
24
20 //----------------------------------------------------------------------------- 25 //-----------------------------------------------------------------------------
21 26
22 namespace net { 27 namespace net {
23 28
24 namespace { 29 namespace {
25 30
26 const char kMsg1[] = "\0hello!\xff"; 31 const char kMsg1[] = "\0hello!\xff";
27 const int kLen1 = arraysize(kMsg1); 32 const int kLen1 = arraysize(kMsg1);
28 const char kMsg2[] = "\0a2345678\0"; 33 const char kMsg2[] = "\0a2345678\0";
29 const int kLen2 = arraysize(kMsg2); 34 const int kLen2 = arraysize(kMsg2);
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 379
375 void SequencedSocketDataTest::ReentrantAsyncWriteCallback( 380 void SequencedSocketDataTest::ReentrantAsyncWriteCallback(
376 const char* data, 381 const char* data,
377 int len, 382 int len,
378 CompletionCallback callback, 383 CompletionCallback callback,
379 int expected_rv, 384 int expected_rv,
380 int rv) { 385 int rv) {
381 EXPECT_EQ(expected_rv, rv); 386 EXPECT_EQ(expected_rv, rv);
382 scoped_refptr<IOBuffer> write_buf(new IOBuffer(len)); 387 scoped_refptr<IOBuffer> write_buf(new IOBuffer(len));
383 memcpy(write_buf->data(), data, len); 388 memcpy(write_buf->data(), data, len);
384 EXPECT_EQ(ERR_IO_PENDING, sock_->Write(write_buf.get(), len, callback)); 389 EXPECT_THAT(sock_->Write(write_buf.get(), len, callback),
390 IsError(ERR_IO_PENDING));
385 } 391 }
386 392
387 void SequencedSocketDataTest::FailingCompletionCallback(int rv) { 393 void SequencedSocketDataTest::FailingCompletionCallback(int rv) {
388 ADD_FAILURE() << "Callback should not have been invoked"; 394 ADD_FAILURE() << "Callback should not have been invoked";
389 } 395 }
390 396
391 // ----------- Read 397 // ----------- Read
392 398
393 TEST_F(SequencedSocketDataTest, SingleSyncRead) { 399 TEST_F(SequencedSocketDataTest, SingleSyncRead) {
394 MockRead reads[] = { 400 MockRead reads[] = {
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 1247
1242 Resume(); 1248 Resume();
1243 ASSERT_FALSE(IsPaused()); 1249 ASSERT_FALSE(IsPaused());
1244 ASSERT_TRUE(write_callback_.have_result()); 1250 ASSERT_TRUE(write_callback_.have_result());
1245 ASSERT_EQ(kLen2, write_callback_.WaitForResult()); 1251 ASSERT_EQ(kLen2, write_callback_.WaitForResult());
1246 } 1252 }
1247 1253
1248 } // namespace 1254 } // namespace
1249 1255
1250 } // namespace net 1256 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/client_socket_pool_base_unittest.cc ('k') | net/socket/socks5_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698