| Index: net/socket/sequenced_socket_data_unittest.cc
|
| diff --git a/net/socket/sequenced_socket_data_unittest.cc b/net/socket/sequenced_socket_data_unittest.cc
|
| index d59420ee27aa5d03c4eb998c28d99e5441084c87..41e7b91932b87240a3004bb792dca728a74d14ba 100644
|
| --- a/net/socket/sequenced_socket_data_unittest.cc
|
| +++ b/net/socket/sequenced_socket_data_unittest.cc
|
| @@ -647,15 +647,46 @@ TEST_F(SequencedSocketDataTest, SingleSyncWriteTooEarly) {
|
| set_expect_eof(false);
|
| }
|
|
|
| -TEST_F(SequencedSocketDataTest, DISABLED_SingleSyncWriteTooSmall) {
|
| +TEST_F(SequencedSocketDataTest, SingleSyncWriteTooSmall) {
|
| MockWrite writes[] = {
|
| MockWrite(SYNCHRONOUS, kMsg1, kLen1, 0),
|
| };
|
|
|
| Initialize(nullptr, 0, writes, arraysize(writes));
|
|
|
| - // Attempt to write all of the message, but only some will be written.
|
| - EXPECT_NONFATAL_FAILURE(AssertSyncWriteEquals(kMsg1, kLen1 - 1), "");
|
| + // Expecting too small of a write triggers multiple expectation failures.
|
| + //
|
| + // The gtest infrastructure does not have a macro similar to
|
| + // EXPECT_NONFATAL_FAILURE which works when there is more than one
|
| + // failure.
|
| + //
|
| + // However, tests can gather the TestPartResultArray and directly
|
| + // validate the test failures. That's what the rest of this test does.
|
| +
|
| + ::testing::TestPartResultArray gtest_failures;
|
| +
|
| + {
|
| + ::testing::ScopedFakeTestPartResultReporter gtest_reporter(
|
| + ::testing::ScopedFakeTestPartResultReporter::
|
| + INTERCEPT_ONLY_CURRENT_THREAD,
|
| + >est_failures);
|
| + AssertSyncWriteEquals(kMsg1, kLen1 - 1);
|
| + }
|
| +
|
| + static const char* kExpectedFailures[] = {
|
| + "Expected: (data.length()) >= (expected_data.length())",
|
| + "Value of: actual_data",
|
| + "Value of: sock_->Write(buf.get(), len, failing_callback_)"};
|
| + ASSERT_EQ(arraysize(kExpectedFailures),
|
| + static_cast<size_t>(gtest_failures.size()));
|
| +
|
| + for (int i = 0; i < gtest_failures.size(); ++i) {
|
| + const ::testing::TestPartResult& result =
|
| + gtest_failures.GetTestPartResult(i);
|
| + EXPECT_TRUE(strstr(result.message(), kExpectedFailures[i]) != NULL);
|
| + }
|
| +
|
| + set_expect_eof(false);
|
| }
|
|
|
| TEST_F(SequencedSocketDataTest, SingleSyncPartialWrite) {
|
|
|