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

Side by Side Diff: mojo/public/cpp/bindings/tests/sample_service_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 <algorithm> 7 #include <algorithm>
8 #include <ostream> 8 #include <ostream>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 }; 284 };
285 285
286 class ServiceProxyImpl : public ServiceProxy { 286 class ServiceProxyImpl : public ServiceProxy {
287 public: 287 public:
288 explicit ServiceProxyImpl(mojo::MessageReceiverWithResponder* receiver) 288 explicit ServiceProxyImpl(mojo::MessageReceiverWithResponder* receiver)
289 : ServiceProxy(receiver) {} 289 : ServiceProxy(receiver) {}
290 }; 290 };
291 291
292 class SimpleMessageReceiver : public mojo::MessageReceiverWithResponder { 292 class SimpleMessageReceiver : public mojo::MessageReceiverWithResponder {
293 public: 293 public:
294 bool Accept(mojo::Message* message) override { 294 Result Accept(mojo::Message* message) override {
295 // Imagine some IPC happened here. 295 // Imagine some IPC happened here.
296 296
297 if (g_dump_message_as_hex) { 297 if (g_dump_message_as_hex) {
298 DumpHex(reinterpret_cast<const uint8_t*>(message->data()), 298 DumpHex(reinterpret_cast<const uint8_t*>(message->data()),
299 message->data_num_bytes()); 299 message->data_num_bytes());
300 } 300 }
301 301
302 // In the receiving process, an implementation of ServiceStub is known to 302 // In the receiving process, an implementation of ServiceStub is known to
303 // the system. It receives the incoming message. 303 // the system. It receives the incoming message.
304 ServiceImpl impl; 304 ServiceImpl impl;
305 305
306 ServiceStub stub; 306 ServiceStub stub;
307 stub.set_sink(&impl); 307 stub.set_sink(&impl);
308 return stub.Accept(message); 308 return stub.Accept(message);
309 } 309 }
310 310
311 bool AcceptWithResponder(mojo::Message* message, 311 Result AcceptWithResponder(mojo::Message* message,
312 mojo::MessageReceiver* responder) override { 312 mojo::MessageReceiver* responder) override {
313 return false; 313 return Result::ForUnknownError();
314 } 314 }
315 }; 315 };
316 316
317 using BindingsSampleTest = testing::Test; 317 using BindingsSampleTest = testing::Test;
318 318
319 TEST_F(BindingsSampleTest, Basic) { 319 TEST_F(BindingsSampleTest, Basic) {
320 SimpleMessageReceiver receiver; 320 SimpleMessageReceiver receiver;
321 321
322 // User has a proxy to a Service somehow. 322 // User has a proxy to a Service somehow.
323 Service* service = new ServiceProxyImpl(&receiver); 323 Service* service = new ServiceProxyImpl(&receiver);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 ASSERT_FALSE(defaults->a22.is_null()); 365 ASSERT_FALSE(defaults->a22.is_null());
366 EXPECT_EQ(imported::Shape::RECTANGLE, defaults->a22->shape); 366 EXPECT_EQ(imported::Shape::RECTANGLE, defaults->a22->shape);
367 EXPECT_EQ(imported::Color::BLACK, defaults->a22->color); 367 EXPECT_EQ(imported::Color::BLACK, defaults->a22->color);
368 EXPECT_EQ(0xFFFFFFFFFFFFFFFFULL, defaults->a23); 368 EXPECT_EQ(0xFFFFFFFFFFFFFFFFULL, defaults->a23);
369 EXPECT_EQ(0x123456789, defaults->a24); 369 EXPECT_EQ(0x123456789, defaults->a24);
370 EXPECT_EQ(-0x123456789, defaults->a25); 370 EXPECT_EQ(-0x123456789, defaults->a25);
371 } 371 }
372 372
373 } // namespace 373 } // namespace
374 } // namespace sample 374 } // namespace sample
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698