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

Unified Diff: net/socket/sequenced_socket_data_unittest.cc

Issue 1158573004: Enable SequencedSocketDataTest.SingleSyncWriteTooSmall test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
+ &gtest_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) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698