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 <algorithm> | 5 #include <algorithm> |
6 #include <ostream> | 6 #include <ostream> |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "mojo/public/cpp/bindings/allocation_scope.h" | 9 #include "mojo/public/cpp/bindings/allocation_scope.h" |
10 #include "mojo/public/cpp/environment/environment.h" | 10 #include "mojo/public/cpp/environment/environment.h" |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 service->Frobinate(foo, Service::BAZ_EXTRA, port.Pass()); | 354 service->Frobinate(foo, Service::BAZ_EXTRA, port.Pass()); |
355 | 355 |
356 delete service; | 356 delete service; |
357 } | 357 } |
358 | 358 |
359 TEST(BindingsSampleTest, DefaultValues) { | 359 TEST(BindingsSampleTest, DefaultValues) { |
360 mojo::Environment env; | 360 mojo::Environment env; |
361 SimpleMessageReceiver receiver; | 361 SimpleMessageReceiver receiver; |
362 mojo::AllocationScope scope; | 362 mojo::AllocationScope scope; |
363 | 363 |
364 Bar bar = Bar::Builder().Finish(); | |
365 EXPECT_EQ(255, bar.alpha()); | |
366 | |
367 Foo foo = Foo::Builder().Finish(); | |
368 ASSERT_FALSE(foo.name().is_null()); | |
369 EXPECT_EQ("Fooby", foo.name().To<std::string>()); | |
370 EXPECT_TRUE(foo.a()); | |
371 EXPECT_EQ(3u, foo.data().size()); | |
372 EXPECT_EQ(1, foo.data()[0]); | |
373 EXPECT_EQ(2, foo.data()[1]); | |
374 EXPECT_EQ(3, foo.data()[2]); | |
375 | |
376 DefaultsTestInner inner = DefaultsTestInner::Builder().Finish(); | |
377 EXPECT_EQ(1u, inner.names().size()); | |
378 EXPECT_EQ("Jim", inner.names()[0].To<std::string>()); | |
379 EXPECT_EQ(6*12, inner.height()); | |
380 | |
381 DefaultsTest full = DefaultsTest::Builder().Finish(); | 364 DefaultsTest full = DefaultsTest::Builder().Finish(); |
382 EXPECT_EQ(1u, full.people().size()); | 365 EXPECT_EQ(-12, full.a0()); |
383 EXPECT_EQ(32, full.people()[0].age()); | 366 EXPECT_EQ(12U, full.a1()); |
384 EXPECT_EQ(2u, full.people()[0].names().size()); | 367 EXPECT_EQ(1234, full.a2()); |
385 EXPECT_EQ("Bob", full.people()[0].names()[0].To<std::string>()); | 368 EXPECT_EQ(34567U, full.a3()); |
386 EXPECT_EQ("Bobby", full.people()[0].names()[1].To<std::string>()); | 369 EXPECT_EQ(123456, full.a4()); |
387 EXPECT_EQ(6*12, full.people()[0].height()); | 370 // TODO(vtl): crbug.com/375522 |
388 | 371 // EXPECT_EQ(3456789012U, full.a5()); |
389 EXPECT_EQ(7, full.point().x()); | 372 EXPECT_EQ(111111111111LL, full.a6()); |
390 EXPECT_EQ(15, full.point().y()); | 373 // TODO(vtl): crbug.com/375522 |
391 | 374 // EXPECT_EQ(9999999999999999999ULL, full.a7()); |
392 EXPECT_EQ(1u, full.shape_masks().size()); | 375 EXPECT_EQ(0x12345, full.a8()); |
393 EXPECT_EQ(1 << imported::SHAPE_RECTANGLE, full.shape_masks()[0]); | 376 EXPECT_EQ(-0x12345, full.a9()); |
394 | 377 // TODO(vtl): crbug.com/375829 |
395 EXPECT_EQ(imported::SHAPE_CIRCLE, full.thing().shape()); | 378 // EXPECT_EQ(8, full.a10()); |
396 EXPECT_EQ(imported::COLOR_BLACK, full.thing().color()); | 379 // EXPECT_EQ(-8, full.a11()); |
| 380 EXPECT_EQ(1234, full.a12()); |
| 381 EXPECT_TRUE(full.a13()); |
| 382 EXPECT_FALSE(full.a14()); |
| 383 EXPECT_FLOAT_EQ(123.25f, full.a15()); |
| 384 EXPECT_DOUBLE_EQ(1234567890.123, full.a16()); |
| 385 EXPECT_DOUBLE_EQ(1E10, full.a17()); |
| 386 EXPECT_DOUBLE_EQ(-1.2E+20, full.a18()); |
| 387 EXPECT_DOUBLE_EQ(1.23E-20, full.a19()); |
| 388 EXPECT_TRUE(full.a20().is_null()); |
| 389 EXPECT_TRUE(full.a21().is_null()); |
| 390 EXPECT_TRUE(full.a22().is_null()); |
397 } | 391 } |
398 | 392 |
399 } // namespace | 393 } // namespace |
400 } // namespace sample | 394 } // namespace sample |
OLD | NEW |