Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1106)

Side by Side Diff: mojo/public/cpp/bindings/tests/validation_unittest.cc

Issue 2064903002: Mojo: Report bindings validation errors via MojoNotifyBadMessage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 result = "PASS"; 183 result = "PASS";
184 else 184 else
185 result = mojo::internal::ValidationErrorToString(observer.last_error()); 185 result = mojo::internal::ValidationErrorToString(observer.last_error());
186 186
187 EXPECT_EQ(expected, result) << "failed test: " << tests[i]; 187 EXPECT_EQ(expected, result) << "failed test: " << tests[i];
188 } 188 }
189 } 189 }
190 190
191 class DummyMessageReceiver : public MessageReceiver { 191 class DummyMessageReceiver : public MessageReceiver {
192 public: 192 public:
193 bool Accept(Message* message) override { 193 Result Accept(Message* message) override {
194 return true; // Any message is OK. 194 return Result::ForSuccess(); // Any message is OK.
195 } 195 }
196 }; 196 };
197 197
198 class ValidationTest : public testing::Test { 198 class ValidationTest : public testing::Test {
199 public: 199 public:
200 ValidationTest() {} 200 ValidationTest() {}
201 201
202 protected: 202 protected:
203 base::MessageLoop loop_; 203 base::MessageLoop loop_;
204 }; 204 };
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 TestMessageReceiver(ValidationIntegrationTest* owner, 238 TestMessageReceiver(ValidationIntegrationTest* owner,
239 ScopedMessagePipeHandle handle) 239 ScopedMessagePipeHandle handle)
240 : owner_(owner), 240 : owner_(owner),
241 connector_(std::move(handle), 241 connector_(std::move(handle),
242 mojo::internal::Connector::SINGLE_THREADED_SEND, 242 mojo::internal::Connector::SINGLE_THREADED_SEND,
243 base::ThreadTaskRunnerHandle::Get()) { 243 base::ThreadTaskRunnerHandle::Get()) {
244 connector_.set_enforce_errors_from_incoming_receiver(false); 244 connector_.set_enforce_errors_from_incoming_receiver(false);
245 } 245 }
246 ~TestMessageReceiver() override {} 246 ~TestMessageReceiver() override {}
247 247
248 bool Accept(Message* message) override { 248 Result Accept(Message* message) override {
249 return connector_.Accept(message); 249 return connector_.Accept(message);
250 } 250 }
251 251
252 public: 252 public:
253 ValidationIntegrationTest* owner_; 253 ValidationIntegrationTest* owner_;
254 mojo::internal::Connector connector_; 254 mojo::internal::Connector connector_;
255 }; 255 };
256 256
257 void PumpMessages() { loop_.RunUntilIdle(); } 257 void PumpMessages() { loop_.RunUntilIdle(); }
258 258
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(0))); 490 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(0)));
491 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(1))); 491 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(1)));
492 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(2))); 492 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(2)));
493 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(3))); 493 EXPECT_TRUE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(3)));
494 EXPECT_FALSE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(4))); 494 EXPECT_FALSE(IsKnownEnumValue(static_cast<StructWithEnum::EnumWithin>(4)));
495 } 495 }
496 496
497 } // namespace 497 } // namespace
498 } // namespace test 498 } // namespace test
499 } // namespace mojo 499 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698