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

Unified Diff: remoting/host/security_key/remote_security_key_message_reader_unittest.cc

Issue 1849023004: Revert of Fixing a Dr. memory failure in the remoting unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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: remoting/host/security_key/remote_security_key_message_reader_unittest.cc
diff --git a/remoting/host/security_key/remote_security_key_message_reader_unittest.cc b/remoting/host/security_key/remote_security_key_message_reader_unittest.cc
index 51e0752533b23992aa89b3d417947e5d04558521..0fa82c0e710176f3b82b60c9592306c19bd77032 100644
--- a/remoting/host/security_key/remote_security_key_message_reader_unittest.cc
+++ b/remoting/host/security_key/remote_security_key_message_reader_unittest.cc
@@ -33,9 +33,6 @@
// be verified by tests.
void OnMessage(scoped_ptr<SecurityKeyMessage> message);
- // Used as a callback to signal completion.
- void OperationComplete();
-
protected:
// testing::Test interface.
void SetUp() override;
@@ -58,13 +55,12 @@
private:
base::MessageLoopForIO message_loop_;
- scoped_ptr<base::RunLoop> run_loop_;
+ base::RunLoop run_loop_;
DISALLOW_COPY_AND_ASSIGN(RemoteSecurityKeyMessageReaderTest);
};
-RemoteSecurityKeyMessageReaderTest::RemoteSecurityKeyMessageReaderTest()
- : run_loop_(new base::RunLoop()) {}
+RemoteSecurityKeyMessageReaderTest::RemoteSecurityKeyMessageReaderTest() {}
RemoteSecurityKeyMessageReaderTest::~RemoteSecurityKeyMessageReaderTest() {}
@@ -74,26 +70,20 @@
// base::Unretained is safe since no further tasks can run after
// RunLoop::Run() returns.
- reader_->Start(
- base::Bind(&RemoteSecurityKeyMessageReaderTest::OnMessage,
- base::Unretained(this)),
- base::Bind(&RemoteSecurityKeyMessageReaderTest::OperationComplete,
- base::Unretained(this)));
+ reader_->Start(base::Bind(&RemoteSecurityKeyMessageReaderTest::OnMessage,
+ base::Unretained(this)),
+ run_loop_.QuitClosure());
}
void RemoteSecurityKeyMessageReaderTest::Run() {
- run_loop_->Run();
- run_loop_.reset(new base::RunLoop());
+ // Close the write-end, so the reader doesn't block waiting for more data.
+ write_file_.Close();
+ run_loop_.Run();
}
void RemoteSecurityKeyMessageReaderTest::OnMessage(
scoped_ptr<SecurityKeyMessage> message) {
messages_received_.push_back(std::move(message));
- OperationComplete();
-}
-
-void RemoteSecurityKeyMessageReaderTest::OperationComplete() {
- run_loop_->Quit();
}
void RemoteSecurityKeyMessageReaderTest::WriteMessage(
@@ -153,7 +143,6 @@
}
TEST_F(RemoteSecurityKeyMessageReaderTest, EmptyFile) {
- write_file_.Close();
Run();
ASSERT_EQ(0u, messages_received_.size());
}
@@ -169,7 +158,6 @@
TEST_F(RemoteSecurityKeyMessageReaderTest, ShortHeader) {
// Write only 3 bytes - the message length header is supposed to be 4 bytes.
WriteData("xxx", SecurityKeyMessage::kHeaderSizeBytes - 1);
- write_file_.Close();
Run();
ASSERT_EQ(0u, messages_received_.size());
}
@@ -184,7 +172,6 @@
TEST_F(RemoteSecurityKeyMessageReaderTest, MissingControlCode) {
uint32_t length = 1;
WriteData(reinterpret_cast<char*>(&length), sizeof(length));
- write_file_.Close();
Run();
ASSERT_EQ(0u, messages_received_.size());
}
@@ -195,7 +182,6 @@
char test_control_code = static_cast<char>(kTestMessageType);
WriteData(&test_control_code, sizeof(test_control_code));
- write_file_.Close();
Run();
ASSERT_EQ(0u, messages_received_.size());
}
@@ -208,9 +194,9 @@
for (auto& payload : payloads) {
WriteMessage(kTestMessageType, payload);
- Run();
}
+ Run();
ASSERT_EQ(payloads.size(), messages_received_.size());
for (size_t i = 0; i < payloads.size(); i++) {
« 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