OLD | NEW |
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/message_pump/message_pump_mojo.h" | 5 #include "mojo/message_pump/message_pump_mojo.h" |
6 | 6 |
7 #include "base/message_loop/message_loop_test.h" | 7 #include "base/message_loop/message_loop_test.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "mojo/message_pump/message_pump_mojo_handler.h" | 9 #include "mojo/message_pump/message_pump_mojo_handler.h" |
10 #include "mojo/public/cpp/system/message_pipe.h" | 10 #include "mojo/public/cpp/system/message_pipe.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 namespace mojo { | 13 namespace mojo { |
14 namespace common { | 14 namespace common { |
15 namespace test { | 15 namespace test { |
16 | 16 |
17 scoped_ptr<base::MessagePump> CreateMojoMessagePump() { | 17 RUN_MESSAGE_LOOP_TESTS(Mojo, &MessagePumpMojo::Create); |
18 return scoped_ptr<base::MessagePump>(new MessagePumpMojo()); | |
19 } | |
20 | |
21 RUN_MESSAGE_LOOP_TESTS(Mojo, &CreateMojoMessagePump); | |
22 | 18 |
23 class CountingMojoHandler : public MessagePumpMojoHandler { | 19 class CountingMojoHandler : public MessagePumpMojoHandler { |
24 public: | 20 public: |
25 CountingMojoHandler() : success_count_(0), error_count_(0) {} | 21 CountingMojoHandler() : success_count_(0), error_count_(0) {} |
26 | 22 |
27 void OnHandleReady(const Handle& handle) override { | 23 void OnHandleReady(const Handle& handle) override { |
28 ReadMessageRaw(static_cast<const MessagePipeHandle&>(handle), | 24 ReadMessageRaw(static_cast<const MessagePipeHandle&>(handle), |
29 NULL, | 25 NULL, |
30 NULL, | 26 NULL, |
31 NULL, | 27 NULL, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 for (int i = 0; i < 2; ++i) { | 111 for (int i = 0; i < 2; ++i) { |
116 base::RunLoop run_loop; | 112 base::RunLoop run_loop; |
117 run_loop.RunUntilIdle(); | 113 run_loop.RunUntilIdle(); |
118 } | 114 } |
119 EXPECT_EQ(1, handler.error_count()); | 115 EXPECT_EQ(1, handler.error_count()); |
120 } | 116 } |
121 | 117 |
122 } // namespace test | 118 } // namespace test |
123 } // namespace common | 119 } // namespace common |
124 } // namespace mojo | 120 } // namespace mojo |
OLD | NEW |