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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <string.h> | 6 #include <string.h> |
7 | 7 |
8 #include "mojo/public/cpp/bindings/lib/message_builder.h" | 8 #include "mojo/public/cpp/bindings/lib/message_builder.h" |
9 #include "mojo/public/cpp/bindings/lib/router.h" | 9 #include "mojo/public/cpp/bindings/lib/router.h" |
10 #include "mojo/public/cpp/bindings/tests/message_queue.h" | 10 #include "mojo/public/cpp/bindings/tests/message_queue.h" |
11 #include "mojo/public/cpp/environment/environment.h" | |
12 #include "mojo/public/cpp/system/macros.h" | 11 #include "mojo/public/cpp/system/macros.h" |
13 #include "mojo/public/cpp/utility/run_loop.h" | 12 #include "mojo/public/cpp/utility/run_loop.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
15 | 14 |
16 namespace mojo { | 15 namespace mojo { |
17 namespace test { | 16 namespace test { |
18 namespace { | 17 namespace { |
19 | 18 |
20 void AllocRequestMessage(uint32_t name, const char* text, Message* message) { | 19 void AllocRequestMessage(uint32_t name, const char* text, Message* message) { |
21 size_t payload_size = strlen(text) + 1; // Plus null terminator. | 20 size_t payload_size = strlen(text) + 1; // Plus null terminator. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 132 |
134 void TearDown() override {} | 133 void TearDown() override {} |
135 | 134 |
136 void PumpMessages() { loop_.RunUntilIdle(); } | 135 void PumpMessages() { loop_.RunUntilIdle(); } |
137 | 136 |
138 protected: | 137 protected: |
139 ScopedMessagePipeHandle handle0_; | 138 ScopedMessagePipeHandle handle0_; |
140 ScopedMessagePipeHandle handle1_; | 139 ScopedMessagePipeHandle handle1_; |
141 | 140 |
142 private: | 141 private: |
143 Environment env_; | |
144 RunLoop loop_; | 142 RunLoop loop_; |
145 }; | 143 }; |
146 | 144 |
147 TEST_F(RouterTest, BasicRequestResponse) { | 145 TEST_F(RouterTest, BasicRequestResponse) { |
148 internal::Router router0(handle0_.Pass(), internal::MessageValidatorList()); | 146 internal::Router router0(handle0_.Pass(), internal::MessageValidatorList()); |
149 internal::Router router1(handle1_.Pass(), internal::MessageValidatorList()); | 147 internal::Router router1(handle1_.Pass(), internal::MessageValidatorList()); |
150 | 148 |
151 ResponseGenerator generator; | 149 ResponseGenerator generator; |
152 router1.set_incoming_receiver(&generator); | 150 router1.set_incoming_receiver(&generator); |
153 | 151 |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 EXPECT_TRUE(generator.has_responder()); | 453 EXPECT_TRUE(generator.has_responder()); |
456 } | 454 } |
457 | 455 |
458 EXPECT_FALSE(generator.responder_is_valid()); | 456 EXPECT_FALSE(generator.responder_is_valid()); |
459 generator.CompleteWithResponse(); // This should end up doing nothing. | 457 generator.CompleteWithResponse(); // This should end up doing nothing. |
460 } | 458 } |
461 | 459 |
462 } // namespace | 460 } // namespace |
463 } // namespace test | 461 } // namespace test |
464 } // namespace mojo | 462 } // namespace mojo |
OLD | NEW |