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/public/bindings/lib/remote_ptr.h" | 5 #include "mojo/public/bindings/lib/remote_ptr.h" |
6 #include "mojo/public/tests/bindings/simple_bindings_support.h" | 6 #include "mojo/public/environment/environment.h" |
| 7 #include "mojo/public/utility/run_loop.h" |
7 #include "mojom/math_calculator.h" | 8 #include "mojom/math_calculator.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
9 | 10 |
10 namespace mojo { | 11 namespace mojo { |
11 namespace test { | 12 namespace test { |
12 | 13 |
13 class MathCalculatorImpl : public math::Calculator { | 14 class MathCalculatorImpl : public math::Calculator { |
14 public: | 15 public: |
15 virtual ~MathCalculatorImpl() {} | 16 virtual ~MathCalculatorImpl() {} |
16 | 17 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 class RemotePtrTest : public testing::Test { | 83 class RemotePtrTest : public testing::Test { |
83 public: | 84 public: |
84 RemotePtrTest() { | 85 RemotePtrTest() { |
85 CreateMessagePipe(&pipe0_, &pipe1_); | 86 CreateMessagePipe(&pipe0_, &pipe1_); |
86 } | 87 } |
87 | 88 |
88 virtual ~RemotePtrTest() { | 89 virtual ~RemotePtrTest() { |
89 } | 90 } |
90 | 91 |
91 void PumpMessages() { | 92 void PumpMessages() { |
92 bindings_support_.Process(); | 93 loop_.RunUntilIdle(); |
93 } | 94 } |
94 | 95 |
95 protected: | 96 protected: |
96 ScopedMessagePipeHandle pipe0_; | 97 ScopedMessagePipeHandle pipe0_; |
97 ScopedMessagePipeHandle pipe1_; | 98 ScopedMessagePipeHandle pipe1_; |
98 | 99 |
99 private: | 100 private: |
100 SimpleBindingsSupport bindings_support_; | 101 Environment env_; |
| 102 RunLoop loop_; |
101 }; | 103 }; |
102 | 104 |
103 TEST_F(RemotePtrTest, EndToEnd) { | 105 TEST_F(RemotePtrTest, EndToEnd) { |
104 // Suppose this is instantiated in a process that has pipe0_. | 106 // Suppose this is instantiated in a process that has pipe0_. |
105 MathCalculatorImpl calculator(pipe0_.Pass()); | 107 MathCalculatorImpl calculator(pipe0_.Pass()); |
106 | 108 |
107 // Suppose this is instantiated in a process that has pipe1_. | 109 // Suppose this is instantiated in a process that has pipe1_. |
108 MathCalculatorUIImpl calculator_ui(pipe1_.Pass()); | 110 MathCalculatorUIImpl calculator_ui(pipe1_.Pass()); |
109 | 111 |
110 calculator_ui.Add(2.0); | 112 calculator_ui.Add(2.0); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 EXPECT_FALSE(calculator_ui.encountered_error()); | 169 EXPECT_FALSE(calculator_ui.encountered_error()); |
168 | 170 |
169 PumpMessages(); | 171 PumpMessages(); |
170 | 172 |
171 // OK, now we see the error. | 173 // OK, now we see the error. |
172 EXPECT_TRUE(calculator_ui.encountered_error()); | 174 EXPECT_TRUE(calculator_ui.encountered_error()); |
173 } | 175 } |
174 | 176 |
175 } // namespace test | 177 } // namespace test |
176 } // namespace mojo | 178 } // namespace mojo |
OLD | NEW |