diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-25 07:50:56 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-25 07:50:56 +0000 |
commit | 9ad250b6e17ee57732b57f0c5285f002aad7cf04 (patch) | |
tree | a1bb45ba33d67b232f0851cc324e0452886db79f /mojo/common | |
parent | 3295612b187d98b8e64d508fc41595dcc614e8e8 (diff) | |
download | chromium_src-9ad250b6e17ee57732b57f0c5285f002aad7cf04.zip chromium_src-9ad250b6e17ee57732b57f0c5285f002aad7cf04.tar.gz chromium_src-9ad250b6e17ee57732b57f0c5285f002aad7cf04.tar.bz2 |
Mojo: Add MessagePipe to core_cpp.h for convenience
Review URL: https://codereview.chromium.org/119563003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242484 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/common')
-rw-r--r-- | mojo/common/handle_watcher_unittest.cc | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/mojo/common/handle_watcher_unittest.cc b/mojo/common/handle_watcher_unittest.cc index 0fbbb6b..b3ab76c 100644 --- a/mojo/common/handle_watcher_unittest.cc +++ b/mojo/common/handle_watcher_unittest.cc @@ -112,15 +112,15 @@ class HandleWatcherTest : public testing::Test { // Trivial test case with a single handle to watch. TEST_F(HandleWatcherTest, SingleHandler) { - mojo::test::MessagePipe test_pipe; - ASSERT_TRUE(test_pipe.handle_0.is_valid()); + MessagePipe test_pipe; + ASSERT_TRUE(test_pipe.handle0.is_valid()); CallbackHelper callback_helper; HandleWatcher watcher; - callback_helper.Start(&watcher, test_pipe.handle_0.get()); + callback_helper.Start(&watcher, test_pipe.handle0.get()); RunUntilIdle(); EXPECT_FALSE(callback_helper.got_callback()); EXPECT_EQ(MOJO_RESULT_OK, - mojo::test::WriteEmptyMessage(test_pipe.handle_1.get())); + mojo::test::WriteEmptyMessage(test_pipe.handle1.get())); callback_helper.RunUntilGotCallback(); EXPECT_TRUE(callback_helper.got_callback()); } @@ -128,32 +128,32 @@ TEST_F(HandleWatcherTest, SingleHandler) { // Creates three handles and notfies them in reverse order ensuring each one is // notified appropriately. TEST_F(HandleWatcherTest, ThreeHandles) { - mojo::test::MessagePipe test_pipe1; - mojo::test::MessagePipe test_pipe2; - mojo::test::MessagePipe test_pipe3; + MessagePipe test_pipe1; + MessagePipe test_pipe2; + MessagePipe test_pipe3; CallbackHelper callback_helper1; CallbackHelper callback_helper2; CallbackHelper callback_helper3; - ASSERT_TRUE(test_pipe1.handle_0.is_valid()); - ASSERT_TRUE(test_pipe2.handle_0.is_valid()); - ASSERT_TRUE(test_pipe3.handle_0.is_valid()); + ASSERT_TRUE(test_pipe1.handle0.is_valid()); + ASSERT_TRUE(test_pipe2.handle0.is_valid()); + ASSERT_TRUE(test_pipe3.handle0.is_valid()); HandleWatcher watcher1; - callback_helper1.Start(&watcher1, test_pipe1.handle_0.get()); + callback_helper1.Start(&watcher1, test_pipe1.handle0.get()); RunUntilIdle(); EXPECT_FALSE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); EXPECT_FALSE(callback_helper3.got_callback()); HandleWatcher watcher2; - callback_helper2.Start(&watcher2, test_pipe2.handle_0.get()); + callback_helper2.Start(&watcher2, test_pipe2.handle0.get()); RunUntilIdle(); EXPECT_FALSE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); EXPECT_FALSE(callback_helper3.got_callback()); HandleWatcher watcher3; - callback_helper3.Start(&watcher3, test_pipe3.handle_0.get()); + callback_helper3.Start(&watcher3, test_pipe3.handle0.get()); RunUntilIdle(); EXPECT_FALSE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); @@ -161,7 +161,7 @@ TEST_F(HandleWatcherTest, ThreeHandles) { // Write to 3 and make sure it's notified. EXPECT_EQ(MOJO_RESULT_OK, - mojo::test::WriteEmptyMessage(test_pipe3.handle_1.get())); + mojo::test::WriteEmptyMessage(test_pipe3.handle1.get())); callback_helper3.RunUntilGotCallback(); EXPECT_FALSE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); @@ -171,9 +171,9 @@ TEST_F(HandleWatcherTest, ThreeHandles) { // Write to 1 and 3. Only 1 should be notified since 3 was is no longer // running. EXPECT_EQ(MOJO_RESULT_OK, - mojo::test::WriteEmptyMessage(test_pipe1.handle_1.get())); + mojo::test::WriteEmptyMessage(test_pipe1.handle1.get())); EXPECT_EQ(MOJO_RESULT_OK, - mojo::test::WriteEmptyMessage(test_pipe3.handle_1.get())); + mojo::test::WriteEmptyMessage(test_pipe3.handle1.get())); callback_helper1.RunUntilGotCallback(); EXPECT_TRUE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); @@ -182,9 +182,9 @@ TEST_F(HandleWatcherTest, ThreeHandles) { // Write to 1 and 2. Only 2 should be notified (since 1 was already notified). EXPECT_EQ(MOJO_RESULT_OK, - mojo::test::WriteEmptyMessage(test_pipe1.handle_1.get())); + mojo::test::WriteEmptyMessage(test_pipe1.handle1.get())); EXPECT_EQ(MOJO_RESULT_OK, - mojo::test::WriteEmptyMessage(test_pipe2.handle_1.get())); + mojo::test::WriteEmptyMessage(test_pipe2.handle1.get())); callback_helper2.RunUntilGotCallback(); EXPECT_FALSE(callback_helper1.got_callback()); EXPECT_TRUE(callback_helper2.got_callback()); @@ -193,52 +193,52 @@ TEST_F(HandleWatcherTest, ThreeHandles) { // Verifies Start() invoked a second time works. TEST_F(HandleWatcherTest, Restart) { - mojo::test::MessagePipe test_pipe1; - mojo::test::MessagePipe test_pipe2; + MessagePipe test_pipe1; + MessagePipe test_pipe2; CallbackHelper callback_helper1; CallbackHelper callback_helper2; - ASSERT_TRUE(test_pipe1.handle_0.is_valid()); - ASSERT_TRUE(test_pipe2.handle_0.is_valid()); + ASSERT_TRUE(test_pipe1.handle0.is_valid()); + ASSERT_TRUE(test_pipe2.handle0.is_valid()); HandleWatcher watcher1; - callback_helper1.Start(&watcher1, test_pipe1.handle_0.get()); + callback_helper1.Start(&watcher1, test_pipe1.handle0.get()); RunUntilIdle(); EXPECT_FALSE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); HandleWatcher watcher2; - callback_helper2.Start(&watcher2, test_pipe2.handle_0.get()); + callback_helper2.Start(&watcher2, test_pipe2.handle0.get()); RunUntilIdle(); EXPECT_FALSE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); // Write to 1 and make sure it's notified. EXPECT_EQ(MOJO_RESULT_OK, - mojo::test::WriteEmptyMessage(test_pipe1.handle_1.get())); + mojo::test::WriteEmptyMessage(test_pipe1.handle1.get())); callback_helper1.RunUntilGotCallback(); EXPECT_TRUE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); callback_helper1.clear_callback(); EXPECT_EQ(MOJO_RESULT_OK, - mojo::test::ReadEmptyMessage(test_pipe1.handle_0.get())); + mojo::test::ReadEmptyMessage(test_pipe1.handle0.get())); // Write to 2 and make sure it's notified. EXPECT_EQ(MOJO_RESULT_OK, - mojo::test::WriteEmptyMessage(test_pipe2.handle_1.get())); + mojo::test::WriteEmptyMessage(test_pipe2.handle1.get())); callback_helper2.RunUntilGotCallback(); EXPECT_FALSE(callback_helper1.got_callback()); EXPECT_TRUE(callback_helper2.got_callback()); callback_helper2.clear_callback(); // Listen on 1 again. - callback_helper1.Start(&watcher1, test_pipe1.handle_0.get()); + callback_helper1.Start(&watcher1, test_pipe1.handle0.get()); RunUntilIdle(); EXPECT_FALSE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); // Write to 1 and make sure it's notified. EXPECT_EQ(MOJO_RESULT_OK, - mojo::test::WriteEmptyMessage(test_pipe1.handle_1.get())); + mojo::test::WriteEmptyMessage(test_pipe1.handle1.get())); callback_helper1.RunUntilGotCallback(); EXPECT_TRUE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); @@ -248,19 +248,19 @@ TEST_F(HandleWatcherTest, Restart) { TEST_F(HandleWatcherTest, Deadline) { InstallTickClock(); - mojo::test::MessagePipe test_pipe1; - mojo::test::MessagePipe test_pipe2; - mojo::test::MessagePipe test_pipe3; + MessagePipe test_pipe1; + MessagePipe test_pipe2; + MessagePipe test_pipe3; CallbackHelper callback_helper1; CallbackHelper callback_helper2; CallbackHelper callback_helper3; - ASSERT_TRUE(test_pipe1.handle_0.is_valid()); - ASSERT_TRUE(test_pipe2.handle_0.is_valid()); - ASSERT_TRUE(test_pipe3.handle_0.is_valid()); + ASSERT_TRUE(test_pipe1.handle0.is_valid()); + ASSERT_TRUE(test_pipe2.handle0.is_valid()); + ASSERT_TRUE(test_pipe3.handle0.is_valid()); // Add a watcher with an infinite timeout. HandleWatcher watcher1; - callback_helper1.Start(&watcher1, test_pipe1.handle_0.get()); + callback_helper1.Start(&watcher1, test_pipe1.handle0.get()); RunUntilIdle(); EXPECT_FALSE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); @@ -268,7 +268,7 @@ TEST_F(HandleWatcherTest, Deadline) { // Add another watcher wth a timeout of 500 microseconds. HandleWatcher watcher2; - watcher2.Start(test_pipe2.handle_0.get(), MOJO_WAIT_FLAG_READABLE, 500, + watcher2.Start(test_pipe2.handle0.get(), MOJO_WAIT_FLAG_READABLE, 500, callback_helper2.GetCallback()); RunUntilIdle(); EXPECT_FALSE(callback_helper1.got_callback()); @@ -280,7 +280,7 @@ TEST_F(HandleWatcherTest, Deadline) { tick_clock_.Advance(base::TimeDelta::FromMicroseconds(501)); HandleWatcher watcher3; - callback_helper3.Start(&watcher3, test_pipe3.handle_0.get()); + callback_helper3.Start(&watcher3, test_pipe3.handle0.get()); callback_helper2.RunUntilGotCallback(); EXPECT_FALSE(callback_helper1.got_callback()); @@ -289,15 +289,15 @@ TEST_F(HandleWatcherTest, Deadline) { } TEST_F(HandleWatcherTest, DeleteInCallback) { - mojo::test::MessagePipe test_pipe; + MessagePipe test_pipe; CallbackHelper callback_helper; HandleWatcher* watcher = new HandleWatcher(); - callback_helper.StartWithCallback(watcher, test_pipe.handle_1.get(), + callback_helper.StartWithCallback(watcher, test_pipe.handle1.get(), base::Bind(&DeleteWatcherAndForwardResult, watcher, callback_helper.GetCallback())); - mojo::test::WriteEmptyMessage(test_pipe.handle_0.get()); + mojo::test::WriteEmptyMessage(test_pipe.handle0.get()); callback_helper.RunUntilGotCallback(); EXPECT_TRUE(callback_helper.got_callback()); } |