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/cpp/environment/default_async_waiter.h" | 7 #include "mojo/public/c/environment/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" |
11 #include "mojo/public/cpp/test_support/test_utils.h" | 11 #include "mojo/public/cpp/test_support/test_utils.h" |
12 #include "mojo/public/cpp/utility/run_loop.h" | 12 #include "mojo/public/cpp/utility/run_loop.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace mojo { | 15 namespace mojo { |
16 namespace { | 16 namespace { |
17 | 17 |
(...skipping 17 matching lines...) Expand all Loading... |
35 private: | 35 private: |
36 int result_count_; | 36 int result_count_; |
37 MojoResult last_result_; | 37 MojoResult last_result_; |
38 | 38 |
39 MOJO_DISALLOW_COPY_AND_ASSIGN(TestAsyncWaitCallback); | 39 MOJO_DISALLOW_COPY_AND_ASSIGN(TestAsyncWaitCallback); |
40 }; | 40 }; |
41 | 41 |
42 MojoAsyncWaitID CallAsyncWait(const Handle& handle, | 42 MojoAsyncWaitID CallAsyncWait(const Handle& handle, |
43 MojoHandleSignals signals, | 43 MojoHandleSignals signals, |
44 TestAsyncWaitCallback* callback) { | 44 TestAsyncWaitCallback* callback) { |
45 return GetDefaultAsyncWaiter()->AsyncWait( | 45 return Environment::GetDefaultAsyncWaiter()->AsyncWait( |
46 handle.value(), | 46 handle.value(), |
47 signals, | 47 signals, |
48 MOJO_DEADLINE_INDEFINITE, | 48 MOJO_DEADLINE_INDEFINITE, |
49 &TestAsyncWaitCallback::OnHandleReady, | 49 &TestAsyncWaitCallback::OnHandleReady, |
50 callback); | 50 callback); |
51 } | 51 } |
52 | 52 |
53 void CallCancelWait(MojoAsyncWaitID wait_id) { | 53 void CallCancelWait(MojoAsyncWaitID wait_id) { |
54 GetDefaultAsyncWaiter()->CancelWait(wait_id); | 54 Environment::GetDefaultAsyncWaiter()->CancelWait(wait_id); |
55 } | 55 } |
56 | 56 |
57 class AsyncWaiterTest : public testing::Test { | 57 class AsyncWaiterTest : public testing::Test { |
58 public: | 58 public: |
59 AsyncWaiterTest() {} | 59 AsyncWaiterTest() {} |
60 | 60 |
61 private: | 61 private: |
62 Environment environment_; | 62 Environment environment_; |
63 RunLoop run_loop_; | 63 RunLoop run_loop_; |
64 | 64 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 CallCancelWait( | 111 CallCancelWait( |
112 CallAsyncWait(test_pipe.handle0.get(), | 112 CallAsyncWait(test_pipe.handle0.get(), |
113 MOJO_HANDLE_SIGNAL_READABLE, | 113 MOJO_HANDLE_SIGNAL_READABLE, |
114 &callback)); | 114 &callback)); |
115 RunLoop::current()->Run(); | 115 RunLoop::current()->Run(); |
116 EXPECT_EQ(0, callback.result_count()); | 116 EXPECT_EQ(0, callback.result_count()); |
117 } | 117 } |
118 | 118 |
119 } // namespace | 119 } // namespace |
120 } // namespace mojo | 120 } // namespace mojo |
OLD | NEW |