| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 169 |
| 170 for (size_t i = 0; i < tests.size(); ++i) { | 170 for (size_t i = 0; i < tests.size(); ++i) { |
| 171 Message message; | 171 Message message; |
| 172 std::string expected; | 172 std::string expected; |
| 173 ASSERT_TRUE(ReadTestCase(tests[i], &message, &expected)); | 173 ASSERT_TRUE(ReadTestCase(tests[i], &message, &expected)); |
| 174 | 174 |
| 175 std::string result; | 175 std::string result; |
| 176 base::RunLoop run_loop; | 176 base::RunLoop run_loop; |
| 177 mojo::internal::ValidationErrorObserverForTesting observer( | 177 mojo::internal::ValidationErrorObserverForTesting observer( |
| 178 run_loop.QuitClosure()); | 178 run_loop.QuitClosure()); |
| 179 ignore_result(test_message_receiver->Accept(&message)); | 179 Error error; |
| 180 ignore_result(test_message_receiver->Accept(&message, &error)); |
| 180 if (expected != "PASS") // Observer only gets called on errors. | 181 if (expected != "PASS") // Observer only gets called on errors. |
| 181 run_loop.Run(); | 182 run_loop.Run(); |
| 182 if (observer.last_error() == mojo::internal::VALIDATION_ERROR_NONE) | 183 if (observer.last_error() == mojo::internal::VALIDATION_ERROR_NONE) |
| 183 result = "PASS"; | 184 result = "PASS"; |
| 184 else | 185 else |
| 185 result = mojo::internal::ValidationErrorToString(observer.last_error()); | 186 result = mojo::internal::ValidationErrorToString(observer.last_error()); |
| 186 | 187 |
| 187 EXPECT_EQ(expected, result) << "failed test: " << tests[i]; | 188 EXPECT_EQ(expected, result) << "failed test: " << tests[i]; |
| 188 } | 189 } |
| 189 } | 190 } |
| 190 | 191 |
| 191 class DummyMessageReceiver : public MessageReceiver { | 192 class DummyMessageReceiver : public MessageReceiver { |
| 192 public: | 193 public: |
| 193 bool Accept(Message* message) override { | 194 bool Accept(Message* message, Error* error) override { |
| 194 return true; // Any message is OK. | 195 return true; // Any message is OK. |
| 195 } | 196 } |
| 196 }; | 197 }; |
| 197 | 198 |
| 198 class ValidationTest : public testing::Test { | 199 class ValidationTest : public testing::Test { |
| 199 public: | 200 public: |
| 200 ValidationTest() {} | 201 ValidationTest() {} |
| 201 | 202 |
| 202 protected: | 203 protected: |
| 203 base::MessageLoop loop_; | 204 base::MessageLoop loop_; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 TestMessageReceiver(ValidationIntegrationTest* owner, | 239 TestMessageReceiver(ValidationIntegrationTest* owner, |
| 239 ScopedMessagePipeHandle handle) | 240 ScopedMessagePipeHandle handle) |
| 240 : owner_(owner), | 241 : owner_(owner), |
| 241 connector_(std::move(handle), | 242 connector_(std::move(handle), |
| 242 mojo::internal::Connector::SINGLE_THREADED_SEND, | 243 mojo::internal::Connector::SINGLE_THREADED_SEND, |
| 243 base::ThreadTaskRunnerHandle::Get()) { | 244 base::ThreadTaskRunnerHandle::Get()) { |
| 244 connector_.set_enforce_errors_from_incoming_receiver(false); | 245 connector_.set_enforce_errors_from_incoming_receiver(false); |
| 245 } | 246 } |
| 246 ~TestMessageReceiver() override {} | 247 ~TestMessageReceiver() override {} |
| 247 | 248 |
| 248 bool Accept(Message* message) override { | 249 bool Accept(Message* message, Error* error) override { |
| 249 return connector_.Accept(message); | 250 return connector_.Accept(message, error); |
| 250 } | 251 } |
| 251 | 252 |
| 252 public: | 253 public: |
| 253 ValidationIntegrationTest* owner_; | 254 ValidationIntegrationTest* owner_; |
| 254 mojo::internal::Connector connector_; | 255 mojo::internal::Connector connector_; |
| 255 }; | 256 }; |
| 256 | 257 |
| 257 void PumpMessages() { loop_.RunUntilIdle(); } | 258 void PumpMessages() { loop_.RunUntilIdle(); } |
| 258 | 259 |
| 259 TestMessageReceiver* test_message_receiver_; | 260 TestMessageReceiver* test_message_receiver_; |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(0))); | 491 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(0))); |
| 491 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(1))); | 492 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(1))); |
| 492 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(2))); | 493 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(2))); |
| 493 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(3))); | 494 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(3))); |
| 494 EXPECT_FALSE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(4))); | 495 EXPECT_FALSE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(4))); |
| 495 } | 496 } |
| 496 | 497 |
| 497 } // namespace | 498 } // namespace |
| 498 } // namespace test | 499 } // namespace test |
| 499 } // namespace mojo | 500 } // namespace mojo |
| OLD | NEW |