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

Side by Side Diff: mojo/message_pump/message_pump_mojo_unittest.cc

Issue 1467953002: Implement MessagePumpMojo using WaitSet. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-waitset-implementation
Patch Set: Fix component builds. Created 5 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "mojo/message_pump/message_pump_mojo.h" 5 #include "mojo/message_pump/message_pump_mojo.h"
6 6
7 #include "base/message_loop/message_loop_test.h" 7 #include "base/message_loop/message_loop_test.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "mojo/message_pump/message_pump_mojo_handler.h" 9 #include "mojo/message_pump/message_pump_mojo_handler.h"
10 #include "mojo/public/cpp/system/core.h" 10 #include "mojo/public/cpp/system/core.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 handles.handle0.get(), 112 handles.handle0.get(),
113 MOJO_HANDLE_SIGNAL_READABLE, 113 MOJO_HANDLE_SIGNAL_READABLE,
114 base::TimeTicks::Now() - base::TimeDelta::FromSeconds(1)); 114 base::TimeTicks::Now() - base::TimeDelta::FromSeconds(1));
115 for (int i = 0; i < 2; ++i) { 115 for (int i = 0; i < 2; ++i) {
116 base::RunLoop run_loop; 116 base::RunLoop run_loop;
117 run_loop.RunUntilIdle(); 117 run_loop.RunUntilIdle();
118 } 118 }
119 EXPECT_EQ(1, handler.error_count()); 119 EXPECT_EQ(1, handler.error_count());
120 } 120 }
121 121
122 TEST(MessagePumpMojo, AddClosedHandle) {
123 base::MessageLoop message_loop(MessagePumpMojo::Create());
124 CountingMojoHandler handler;
125 MessagePipe handles;
126 Handle closed_handle = handles.handle0.get();
127 handles.handle0.reset();
128 MessagePumpMojo::current()->AddHandler(
129 &handler,
130 closed_handle,
131 MOJO_HANDLE_SIGNAL_READABLE,
132 base::TimeTicks());
133 base::RunLoop run_loop;
134 run_loop.RunUntilIdle();
135 MessagePumpMojo::current()->RemoveHandler(closed_handle);
136 EXPECT_EQ(0, handler.error_count());
137 EXPECT_EQ(0, handler.success_count());
138 }
139
140 TEST(MessagePumpMojo, CloseAfterAdding) {
141 base::MessageLoop message_loop(MessagePumpMojo::Create());
142 CountingMojoHandler handler;
143 MessagePipe handles;
144 MessagePumpMojo::current()->AddHandler(
145 &handler,
146 handles.handle0.get(),
147 MOJO_HANDLE_SIGNAL_READABLE,
148 base::TimeTicks());
149 handles.handle0.reset();
150 base::RunLoop run_loop;
151 run_loop.RunUntilIdle();
152 EXPECT_EQ(1, handler.error_count());
153 EXPECT_EQ(0, handler.success_count());
154 }
155
122 } // namespace test 156 } // namespace test
123 } // namespace common 157 } // namespace common
124 } // namespace mojo 158 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698