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 <stdio.h> | 5 #include <stdio.h> |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 result = "PASS"; | 173 result = "PASS"; |
174 else | 174 else |
175 result = mojo::internal::ValidationErrorToString(observer.last_error()); | 175 result = mojo::internal::ValidationErrorToString(observer.last_error()); |
176 | 176 |
177 EXPECT_EQ(expected, result) << "failed test: " << tests[i]; | 177 EXPECT_EQ(expected, result) << "failed test: " << tests[i]; |
178 } | 178 } |
179 } | 179 } |
180 | 180 |
181 class DummyMessageReceiver : public MessageReceiver { | 181 class DummyMessageReceiver : public MessageReceiver { |
182 public: | 182 public: |
183 virtual bool Accept(Message* message) MOJO_OVERRIDE { | 183 virtual bool Accept(Message* message) override { |
184 return true; // Any message is OK. | 184 return true; // Any message is OK. |
185 } | 185 } |
186 }; | 186 }; |
187 | 187 |
188 class ValidationTest : public testing::Test { | 188 class ValidationTest : public testing::Test { |
189 public: | 189 public: |
190 virtual ~ValidationTest() { | 190 virtual ~ValidationTest() { |
191 } | 191 } |
192 | 192 |
193 private: | 193 private: |
194 Environment env_; | 194 Environment env_; |
195 }; | 195 }; |
196 | 196 |
197 class ValidationIntegrationTest : public ValidationTest { | 197 class ValidationIntegrationTest : public ValidationTest { |
198 public: | 198 public: |
199 ValidationIntegrationTest() : test_message_receiver_(NULL) { | 199 ValidationIntegrationTest() : test_message_receiver_(NULL) { |
200 } | 200 } |
201 | 201 |
202 virtual ~ValidationIntegrationTest() { | 202 virtual ~ValidationIntegrationTest() { |
203 } | 203 } |
204 | 204 |
205 virtual void SetUp() MOJO_OVERRIDE { | 205 virtual void SetUp() override { |
206 ScopedMessagePipeHandle tester_endpoint; | 206 ScopedMessagePipeHandle tester_endpoint; |
207 ASSERT_EQ(MOJO_RESULT_OK, | 207 ASSERT_EQ(MOJO_RESULT_OK, |
208 CreateMessagePipe(NULL, &tester_endpoint, &testee_endpoint_)); | 208 CreateMessagePipe(NULL, &tester_endpoint, &testee_endpoint_)); |
209 test_message_receiver_ = | 209 test_message_receiver_ = |
210 new TestMessageReceiver(this, tester_endpoint.Pass()); | 210 new TestMessageReceiver(this, tester_endpoint.Pass()); |
211 } | 211 } |
212 | 212 |
213 virtual void TearDown() MOJO_OVERRIDE { | 213 virtual void TearDown() override { |
214 delete test_message_receiver_; | 214 delete test_message_receiver_; |
215 test_message_receiver_ = NULL; | 215 test_message_receiver_ = NULL; |
216 | 216 |
217 // Make sure that the other end receives the OnConnectionError() | 217 // Make sure that the other end receives the OnConnectionError() |
218 // notification. | 218 // notification. |
219 PumpMessages(); | 219 PumpMessages(); |
220 } | 220 } |
221 | 221 |
222 MessageReceiver* test_message_receiver() { | 222 MessageReceiver* test_message_receiver() { |
223 return test_message_receiver_; | 223 return test_message_receiver_; |
224 } | 224 } |
225 | 225 |
226 ScopedMessagePipeHandle testee_endpoint() { | 226 ScopedMessagePipeHandle testee_endpoint() { |
227 return testee_endpoint_.Pass(); | 227 return testee_endpoint_.Pass(); |
228 } | 228 } |
229 | 229 |
230 private: | 230 private: |
231 class TestMessageReceiver : public MessageReceiver { | 231 class TestMessageReceiver : public MessageReceiver { |
232 public: | 232 public: |
233 TestMessageReceiver(ValidationIntegrationTest* owner, | 233 TestMessageReceiver(ValidationIntegrationTest* owner, |
234 ScopedMessagePipeHandle handle) | 234 ScopedMessagePipeHandle handle) |
235 : owner_(owner), | 235 : owner_(owner), |
236 connector_(handle.Pass()) { | 236 connector_(handle.Pass()) { |
237 } | 237 } |
238 virtual ~TestMessageReceiver() { | 238 virtual ~TestMessageReceiver() { |
239 } | 239 } |
240 | 240 |
241 virtual bool Accept(Message* message) MOJO_OVERRIDE { | 241 virtual bool Accept(Message* message) override { |
242 bool rv = connector_.Accept(message); | 242 bool rv = connector_.Accept(message); |
243 owner_->PumpMessages(); | 243 owner_->PumpMessages(); |
244 return rv; | 244 return rv; |
245 } | 245 } |
246 | 246 |
247 public: | 247 public: |
248 ValidationIntegrationTest* owner_; | 248 ValidationIntegrationTest* owner_; |
249 mojo::internal::Connector connector_; | 249 mojo::internal::Connector connector_; |
250 }; | 250 }; |
251 | 251 |
252 void PumpMessages() { | 252 void PumpMessages() { |
253 loop_.RunUntilIdle(); | 253 loop_.RunUntilIdle(); |
254 } | 254 } |
255 | 255 |
256 RunLoop loop_; | 256 RunLoop loop_; |
257 TestMessageReceiver* test_message_receiver_; | 257 TestMessageReceiver* test_message_receiver_; |
258 ScopedMessagePipeHandle testee_endpoint_; | 258 ScopedMessagePipeHandle testee_endpoint_; |
259 }; | 259 }; |
260 | 260 |
261 class IntegrationTestInterface1Client : public IntegrationTestInterface1 { | 261 class IntegrationTestInterface1Client : public IntegrationTestInterface1 { |
262 public: | 262 public: |
263 virtual ~IntegrationTestInterface1Client() { | 263 virtual ~IntegrationTestInterface1Client() { |
264 } | 264 } |
265 | 265 |
266 virtual void Method0(BasicStructPtr param0) MOJO_OVERRIDE { | 266 virtual void Method0(BasicStructPtr param0) override {} |
267 } | |
268 }; | 267 }; |
269 | 268 |
270 class IntegrationTestInterface1Impl | 269 class IntegrationTestInterface1Impl |
271 : public InterfaceImpl<IntegrationTestInterface1> { | 270 : public InterfaceImpl<IntegrationTestInterface1> { |
272 public: | 271 public: |
273 virtual ~IntegrationTestInterface1Impl() { | 272 virtual ~IntegrationTestInterface1Impl() { |
274 } | 273 } |
275 | 274 |
276 virtual void Method0(BasicStructPtr param0) MOJO_OVERRIDE { | 275 virtual void Method0(BasicStructPtr param0) override {} |
277 } | |
278 }; | 276 }; |
279 | 277 |
280 TEST_F(ValidationTest, InputParser) { | 278 TEST_F(ValidationTest, InputParser) { |
281 { | 279 { |
282 // The parser, as well as Append() defined above, assumes that this code is | 280 // The parser, as well as Append() defined above, assumes that this code is |
283 // running on a little-endian platform. Test whether that is true. | 281 // running on a little-endian platform. Test whether that is true. |
284 uint16_t x = 1; | 282 uint16_t x = 1; |
285 ASSERT_EQ(1, *(reinterpret_cast<char*>(&x))); | 283 ASSERT_EQ(1, *(reinterpret_cast<char*>(&x))); |
286 } | 284 } |
287 { | 285 { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 IntegrationTestInterface1Impl* interface1_impl = | 425 IntegrationTestInterface1Impl* interface1_impl = |
428 BindToPipe(new IntegrationTestInterface1Impl(), testee_endpoint().Pass()); | 426 BindToPipe(new IntegrationTestInterface1Impl(), testee_endpoint().Pass()); |
429 interface1_impl->internal_state()->router()->EnableTestingMode(); | 427 interface1_impl->internal_state()->router()->EnableTestingMode(); |
430 | 428 |
431 RunValidationTests("integration_", test_message_receiver()); | 429 RunValidationTests("integration_", test_message_receiver()); |
432 } | 430 } |
433 | 431 |
434 } // namespace | 432 } // namespace |
435 } // namespace test | 433 } // namespace test |
436 } // namespace mojo | 434 } // namespace mojo |
OLD | NEW |