Index: mojo/message_pump/message_pump_mojo_unittest.cc |
diff --git a/mojo/message_pump/message_pump_mojo_unittest.cc b/mojo/message_pump/message_pump_mojo_unittest.cc |
index 5c8fbb40f9a29f39368284ba369efb37930e669e..805b14120b67835885dcf386b16c4aafe19fc584 100644 |
--- a/mojo/message_pump/message_pump_mojo_unittest.cc |
+++ b/mojo/message_pump/message_pump_mojo_unittest.cc |
@@ -159,6 +159,35 @@ TEST(MessagePumpMojo, UnregisterAfterDeadline) { |
EXPECT_EQ(1, handler.error_count()); |
} |
+TEST(MessagePumpMojo, AddClosedHandle) { |
+ base::MessageLoop message_loop(MessagePumpMojo::Create()); |
+ CountingMojoHandler handler; |
+ MessagePipe handles; |
+ Handle closed_handle = handles.handle0.get(); |
+ handles.handle0.reset(); |
+ MessagePumpMojo::current()->AddHandler( |
+ &handler, closed_handle, MOJO_HANDLE_SIGNAL_READABLE, base::TimeTicks()); |
+ base::RunLoop run_loop; |
+ run_loop.RunUntilIdle(); |
+ MessagePumpMojo::current()->RemoveHandler(closed_handle); |
+ EXPECT_EQ(0, handler.error_count()); |
+ EXPECT_EQ(0, handler.success_count()); |
+} |
+ |
+TEST(MessagePumpMojo, CloseAfterAdding) { |
+ base::MessageLoop message_loop(MessagePumpMojo::Create()); |
+ CountingMojoHandler handler; |
+ MessagePipe handles; |
+ MessagePumpMojo::current()->AddHandler(&handler, handles.handle0.get(), |
+ MOJO_HANDLE_SIGNAL_READABLE, |
+ base::TimeTicks()); |
+ handles.handle0.reset(); |
+ base::RunLoop run_loop; |
+ run_loop.RunUntilIdle(); |
+ EXPECT_EQ(1, handler.error_count()); |
+ EXPECT_EQ(0, handler.success_count()); |
+} |
+ |
} // namespace test |
} // namespace common |
} // namespace mojo |