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

Side by Side Diff: mojo/public/cpp/environment/tests/async_waiter_unittest.cc

Issue 336313007: Mojo: Rename MOJO_WAIT_FLAG_... -> MOJO_HANDLE_SIGNAL_.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <string> 5 #include <string>
6 6
7 #include "mojo/public/cpp/environment/default_async_waiter.h" 7 #include "mojo/public/cpp/environment/default_async_waiter.h"
8 #include "mojo/public/cpp/environment/environment.h" 8 #include "mojo/public/cpp/environment/environment.h"
9 #include "mojo/public/cpp/system/core.h" 9 #include "mojo/public/cpp/system/core.h"
10 #include "mojo/public/cpp/system/macros.h" 10 #include "mojo/public/cpp/system/macros.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 MOJO_DISALLOW_COPY_AND_ASSIGN(AsyncWaiterTest); 65 MOJO_DISALLOW_COPY_AND_ASSIGN(AsyncWaiterTest);
66 }; 66 };
67 67
68 // Verifies AsyncWaitCallback is notified when pipe is ready. 68 // Verifies AsyncWaitCallback is notified when pipe is ready.
69 TEST_F(AsyncWaiterTest, CallbackNotified) { 69 TEST_F(AsyncWaiterTest, CallbackNotified) {
70 TestAsyncWaitCallback callback; 70 TestAsyncWaitCallback callback;
71 MessagePipe test_pipe; 71 MessagePipe test_pipe;
72 EXPECT_TRUE(test::WriteTextMessage(test_pipe.handle1.get(), std::string())); 72 EXPECT_TRUE(test::WriteTextMessage(test_pipe.handle1.get(), std::string()));
73 73
74 CallAsyncWait(test_pipe.handle0.get(), 74 CallAsyncWait(test_pipe.handle0.get(),
75 MOJO_WAIT_FLAG_READABLE, 75 MOJO_HANDLE_SIGNAL_READABLE,
76 &callback); 76 &callback);
77 RunLoop::current()->Run(); 77 RunLoop::current()->Run();
78 EXPECT_EQ(1, callback.result_count()); 78 EXPECT_EQ(1, callback.result_count());
79 EXPECT_EQ(MOJO_RESULT_OK, callback.last_result()); 79 EXPECT_EQ(MOJO_RESULT_OK, callback.last_result());
80 } 80 }
81 81
82 // Verifies 2 AsyncWaitCallbacks are notified when there pipes are ready. 82 // Verifies 2 AsyncWaitCallbacks are notified when there pipes are ready.
83 TEST_F(AsyncWaiterTest, TwoCallbacksNotified) { 83 TEST_F(AsyncWaiterTest, TwoCallbacksNotified) {
84 TestAsyncWaitCallback callback1; 84 TestAsyncWaitCallback callback1;
85 TestAsyncWaitCallback callback2; 85 TestAsyncWaitCallback callback2;
86 MessagePipe test_pipe1; 86 MessagePipe test_pipe1;
87 MessagePipe test_pipe2; 87 MessagePipe test_pipe2;
88 EXPECT_TRUE(test::WriteTextMessage(test_pipe1.handle1.get(), std::string())); 88 EXPECT_TRUE(test::WriteTextMessage(test_pipe1.handle1.get(), std::string()));
89 EXPECT_TRUE(test::WriteTextMessage(test_pipe2.handle1.get(), std::string())); 89 EXPECT_TRUE(test::WriteTextMessage(test_pipe2.handle1.get(), std::string()));
90 90
91 CallAsyncWait(test_pipe1.handle0.get(), MOJO_WAIT_FLAG_READABLE, &callback1); 91 CallAsyncWait(test_pipe1.handle0.get(),
92 CallAsyncWait(test_pipe2.handle0.get(), MOJO_WAIT_FLAG_READABLE, &callback2); 92 MOJO_HANDLE_SIGNAL_READABLE,
93 &callback1);
94 CallAsyncWait(test_pipe2.handle0.get(),
95 MOJO_HANDLE_SIGNAL_READABLE,
96 &callback2);
93 97
94 RunLoop::current()->Run(); 98 RunLoop::current()->Run();
95 EXPECT_EQ(1, callback1.result_count()); 99 EXPECT_EQ(1, callback1.result_count());
96 EXPECT_EQ(MOJO_RESULT_OK, callback1.last_result()); 100 EXPECT_EQ(MOJO_RESULT_OK, callback1.last_result());
97 EXPECT_EQ(1, callback2.result_count()); 101 EXPECT_EQ(1, callback2.result_count());
98 EXPECT_EQ(MOJO_RESULT_OK, callback2.last_result()); 102 EXPECT_EQ(MOJO_RESULT_OK, callback2.last_result());
99 } 103 }
100 104
101 // Verifies cancel works. 105 // Verifies cancel works.
102 TEST_F(AsyncWaiterTest, CancelCallback) { 106 TEST_F(AsyncWaiterTest, CancelCallback) {
103 TestAsyncWaitCallback callback; 107 TestAsyncWaitCallback callback;
104 MessagePipe test_pipe; 108 MessagePipe test_pipe;
105 EXPECT_TRUE(test::WriteTextMessage(test_pipe.handle1.get(), std::string())); 109 EXPECT_TRUE(test::WriteTextMessage(test_pipe.handle1.get(), std::string()));
106 110
107 CallCancelWait( 111 CallCancelWait(
108 CallAsyncWait(test_pipe.handle0.get(), 112 CallAsyncWait(test_pipe.handle0.get(),
109 MOJO_WAIT_FLAG_READABLE, 113 MOJO_HANDLE_SIGNAL_READABLE,
110 &callback)); 114 &callback));
111 RunLoop::current()->Run(); 115 RunLoop::current()->Run();
112 EXPECT_EQ(0, callback.result_count()); 116 EXPECT_EQ(0, callback.result_count());
113 } 117 }
114 118
115 } // namespace 119 } // namespace
116 } // namespace mojo 120 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/sync_dispatcher.cc ('k') | mojo/public/cpp/system/tests/core_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698