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

Side by Side Diff: mojo/common/handle_watcher_unittest.cc

Issue 781753004: Fix handle_watcher when start is called twice on the same handle. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 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
« mojo/common/handle_watcher.cc ('K') | « mojo/common/handle_watcher.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/common/handle_watcher.h" 5 #include "mojo/common/handle_watcher.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 EXPECT_FALSE(callback_helper2.got_callback()); 273 EXPECT_FALSE(callback_helper2.got_callback());
274 274
275 // Write to 1 and make sure it's notified. 275 // Write to 1 and make sure it's notified.
276 EXPECT_TRUE(mojo::test::WriteTextMessage(test_pipe1.handle1.get(), 276 EXPECT_TRUE(mojo::test::WriteTextMessage(test_pipe1.handle1.get(),
277 std::string())); 277 std::string()));
278 callback_helper1.RunUntilGotCallback(); 278 callback_helper1.RunUntilGotCallback();
279 EXPECT_TRUE(callback_helper1.got_callback()); 279 EXPECT_TRUE(callback_helper1.got_callback());
280 EXPECT_FALSE(callback_helper2.got_callback()); 280 EXPECT_FALSE(callback_helper2.got_callback());
281 } 281 }
282 282
283 // Verifies Start() invoked a second time on the same handle works.
284 TEST_P(HandleWatcherTest, RestartOnSameHandle) {
285 MessagePipe test_pipe;
286 CallbackHelper callback_helper;
287 ASSERT_TRUE(test_pipe.handle0.is_valid());
288
289 HandleWatcher watcher;
290 callback_helper.Start(&watcher, test_pipe.handle0.get());
291 RunUntilIdle();
292 EXPECT_FALSE(callback_helper.got_callback());
293
294 callback_helper.Start(&watcher, test_pipe.handle0.get());
295 RunUntilIdle();
296 EXPECT_FALSE(callback_helper.got_callback());
297 }
298
283 // Verifies deadline is honored. 299 // Verifies deadline is honored.
284 TEST_P(HandleWatcherTest, Deadline) { 300 TEST_P(HandleWatcherTest, Deadline) {
285 InstallTickClock(); 301 InstallTickClock();
286 302
287 MessagePipe test_pipe1; 303 MessagePipe test_pipe1;
288 MessagePipe test_pipe2; 304 MessagePipe test_pipe2;
289 MessagePipe test_pipe3; 305 MessagePipe test_pipe3;
290 CallbackHelper callback_helper1; 306 CallbackHelper callback_helper1;
291 CallbackHelper callback_helper2; 307 CallbackHelper callback_helper2;
292 CallbackHelper callback_helper3; 308 CallbackHelper callback_helper3;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 message_loop.task_runner(), 474 message_loop.task_runner(),
459 &run_loop, &threads_active_counter)); 475 &run_loop, &threads_active_counter));
460 } 476 }
461 run_loop.Run(); 477 run_loop.Run();
462 ASSERT_EQ(0, threads_active_counter); 478 ASSERT_EQ(0, threads_active_counter);
463 } 479 }
464 480
465 } // namespace test 481 } // namespace test
466 } // namespace common 482 } // namespace common
467 } // namespace mojo 483 } // namespace mojo
OLDNEW
« mojo/common/handle_watcher.cc ('K') | « mojo/common/handle_watcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698