| 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) override { | 183 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 private: | 192 private: |
| 193 Environment env_; | 193 Environment env_; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 219 MessageReceiver* test_message_receiver() { return test_message_receiver_; } | 219 MessageReceiver* test_message_receiver() { return test_message_receiver_; } |
| 220 | 220 |
| 221 ScopedMessagePipeHandle testee_endpoint() { return testee_endpoint_.Pass(); } | 221 ScopedMessagePipeHandle testee_endpoint() { return testee_endpoint_.Pass(); } |
| 222 | 222 |
| 223 private: | 223 private: |
| 224 class TestMessageReceiver : public MessageReceiver { | 224 class TestMessageReceiver : public MessageReceiver { |
| 225 public: | 225 public: |
| 226 TestMessageReceiver(ValidationIntegrationTest* owner, | 226 TestMessageReceiver(ValidationIntegrationTest* owner, |
| 227 ScopedMessagePipeHandle handle) | 227 ScopedMessagePipeHandle handle) |
| 228 : owner_(owner), connector_(handle.Pass()) {} | 228 : owner_(owner), connector_(handle.Pass()) {} |
| 229 virtual ~TestMessageReceiver() {} | 229 ~TestMessageReceiver() override {} |
| 230 | 230 |
| 231 virtual bool Accept(Message* message) override { | 231 bool Accept(Message* message) override { |
| 232 bool rv = connector_.Accept(message); | 232 bool rv = connector_.Accept(message); |
| 233 owner_->PumpMessages(); | 233 owner_->PumpMessages(); |
| 234 return rv; | 234 return rv; |
| 235 } | 235 } |
| 236 | 236 |
| 237 public: | 237 public: |
| 238 ValidationIntegrationTest* owner_; | 238 ValidationIntegrationTest* owner_; |
| 239 mojo::internal::Connector connector_; | 239 mojo::internal::Connector connector_; |
| 240 }; | 240 }; |
| 241 | 241 |
| 242 void PumpMessages() { loop_.RunUntilIdle(); } | 242 void PumpMessages() { loop_.RunUntilIdle(); } |
| 243 | 243 |
| 244 RunLoop loop_; | 244 RunLoop loop_; |
| 245 TestMessageReceiver* test_message_receiver_; | 245 TestMessageReceiver* test_message_receiver_; |
| 246 ScopedMessagePipeHandle testee_endpoint_; | 246 ScopedMessagePipeHandle testee_endpoint_; |
| 247 }; | 247 }; |
| 248 | 248 |
| 249 class IntegrationTestInterface1Client : public IntegrationTestInterface1 { | 249 class IntegrationTestInterface1Client : public IntegrationTestInterface1 { |
| 250 public: | 250 public: |
| 251 virtual ~IntegrationTestInterface1Client() {} | 251 ~IntegrationTestInterface1Client() override {} |
| 252 | 252 |
| 253 virtual void Method0(BasicStructPtr param0) override {} | 253 void Method0(BasicStructPtr param0) override {} |
| 254 }; | 254 }; |
| 255 | 255 |
| 256 class IntegrationTestInterface1Impl | 256 class IntegrationTestInterface1Impl |
| 257 : public InterfaceImpl<IntegrationTestInterface1> { | 257 : public InterfaceImpl<IntegrationTestInterface1> { |
| 258 public: | 258 public: |
| 259 virtual ~IntegrationTestInterface1Impl() {} | 259 ~IntegrationTestInterface1Impl() override {} |
| 260 | 260 |
| 261 virtual void Method0(BasicStructPtr param0) override {} | 261 void Method0(BasicStructPtr param0) override {} |
| 262 }; | 262 }; |
| 263 | 263 |
| 264 TEST_F(ValidationTest, InputParser) { | 264 TEST_F(ValidationTest, InputParser) { |
| 265 { | 265 { |
| 266 // The parser, as well as Append() defined above, assumes that this code is | 266 // The parser, as well as Append() defined above, assumes that this code is |
| 267 // running on a little-endian platform. Test whether that is true. | 267 // running on a little-endian platform. Test whether that is true. |
| 268 uint16_t x = 1; | 268 uint16_t x = 1; |
| 269 ASSERT_EQ(1, *(reinterpret_cast<char*>(&x))); | 269 ASSERT_EQ(1, *(reinterpret_cast<char*>(&x))); |
| 270 } | 270 } |
| 271 { | 271 { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 IntegrationTestInterface1Impl* interface1_impl = | 410 IntegrationTestInterface1Impl* interface1_impl = |
| 411 BindToPipe(new IntegrationTestInterface1Impl(), testee_endpoint().Pass()); | 411 BindToPipe(new IntegrationTestInterface1Impl(), testee_endpoint().Pass()); |
| 412 interface1_impl->internal_state()->router()->EnableTestingMode(); | 412 interface1_impl->internal_state()->router()->EnableTestingMode(); |
| 413 | 413 |
| 414 RunValidationTests("integration_", test_message_receiver()); | 414 RunValidationTests("integration_", test_message_receiver()); |
| 415 } | 415 } |
| 416 | 416 |
| 417 } // namespace | 417 } // namespace |
| 418 } // namespace test | 418 } // namespace test |
| 419 } // namespace mojo | 419 } // namespace mojo |
| OLD | NEW |