OLD | NEW |
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/c/environment/async_waiter.h" | 7 #include "mojo/public/c/environment/async_waiter.h" |
8 #include "mojo/public/c/system/result.h" | 8 #include "mojo/public/c/system/result.h" |
9 #include "mojo/public/c/system/time.h" | 9 #include "mojo/public/c/system/time.h" |
10 #include "mojo/public/cpp/environment/environment.h" | 10 #include "mojo/public/cpp/environment/environment.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 void CallCancelWait(MojoAsyncWaitID wait_id) { | 55 void CallCancelWait(MojoAsyncWaitID wait_id) { |
56 Environment::GetDefaultAsyncWaiter()->CancelWait(wait_id); | 56 Environment::GetDefaultAsyncWaiter()->CancelWait(wait_id); |
57 } | 57 } |
58 | 58 |
59 class AsyncWaitTest : public testing::Test { | 59 class AsyncWaitTest : public testing::Test { |
60 public: | 60 public: |
61 AsyncWaitTest() {} | 61 AsyncWaitTest() {} |
62 | 62 |
63 private: | 63 private: |
64 Environment environment_; | |
65 RunLoop run_loop_; | 64 RunLoop run_loop_; |
66 | 65 |
67 MOJO_DISALLOW_COPY_AND_ASSIGN(AsyncWaitTest); | 66 MOJO_DISALLOW_COPY_AND_ASSIGN(AsyncWaitTest); |
68 }; | 67 }; |
69 | 68 |
70 // Verifies AsyncWaitCallback is notified when pipe is ready. | 69 // Verifies AsyncWaitCallback is notified when pipe is ready. |
71 TEST_F(AsyncWaitTest, CallbackNotified) { | 70 TEST_F(AsyncWaitTest, CallbackNotified) { |
72 TestAsyncWaitCallback callback; | 71 TestAsyncWaitCallback callback; |
73 MessagePipe test_pipe; | 72 MessagePipe test_pipe; |
74 EXPECT_TRUE(test::WriteTextMessage(test_pipe.handle1.get(), std::string())); | 73 EXPECT_TRUE(test::WriteTextMessage(test_pipe.handle1.get(), std::string())); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 EXPECT_TRUE(test::WriteTextMessage(test_pipe.handle1.get(), std::string())); | 107 EXPECT_TRUE(test::WriteTextMessage(test_pipe.handle1.get(), std::string())); |
109 | 108 |
110 CallCancelWait(CallAsyncWait( | 109 CallCancelWait(CallAsyncWait( |
111 test_pipe.handle0.get(), MOJO_HANDLE_SIGNAL_READABLE, &callback)); | 110 test_pipe.handle0.get(), MOJO_HANDLE_SIGNAL_READABLE, &callback)); |
112 RunLoop::current()->Run(); | 111 RunLoop::current()->Run(); |
113 EXPECT_EQ(0, callback.result_count()); | 112 EXPECT_EQ(0, callback.result_count()); |
114 } | 113 } |
115 | 114 |
116 } // namespace | 115 } // namespace |
117 } // namespace mojo | 116 } // namespace mojo |
OLD | NEW |