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

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

Issue 1997473005: Remove requirement that mojo::Environment be instantiated. (Closed) Base URL: https://github.com/domokit/mojo.git@work797_no_utility_tls
Patch Set: SetDefaultAsyncWaiter Created 4 years, 7 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 <algorithm> 5 #include <algorithm>
6 #include <ostream> 6 #include <ostream>
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "mojo/public/cpp/environment/environment.h"
11 #include "mojo/public/cpp/system/macros.h" 10 #include "mojo/public/cpp/system/macros.h"
12 #include "mojo/public/interfaces/bindings/tests/sample_service.mojom.h" 11 #include "mojo/public/interfaces/bindings/tests/sample_service.mojom.h"
13 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
14 13
15 namespace mojo { 14 namespace mojo {
16 15
17 template <> 16 template <>
18 struct TypeConverter<int32_t, sample::BarPtr> { 17 struct TypeConverter<int32_t, sample::BarPtr> {
19 static int32_t Convert(const sample::BarPtr& bar) { 18 static int32_t Convert(const sample::BarPtr& bar) {
20 return static_cast<int32_t>(bar->alpha) << 16 | 19 return static_cast<int32_t>(bar->alpha) << 16 |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 stub.set_sink(&impl); 307 stub.set_sink(&impl);
309 return stub.Accept(message); 308 return stub.Accept(message);
310 } 309 }
311 310
312 bool AcceptWithResponder(mojo::Message* message, 311 bool AcceptWithResponder(mojo::Message* message,
313 mojo::MessageReceiver* responder) override { 312 mojo::MessageReceiver* responder) override {
314 return false; 313 return false;
315 } 314 }
316 }; 315 };
317 316
318 class BindingsSampleTest : public testing::Test { 317 TEST(BindingsSampleTest, Basic) {
319 public:
320 BindingsSampleTest() {}
321 ~BindingsSampleTest() override {}
322
323 private:
324 mojo::Environment env_;
325
326 MOJO_DISALLOW_COPY_AND_ASSIGN(BindingsSampleTest);
327 };
328
329 TEST_F(BindingsSampleTest, Basic) {
330 SimpleMessageReceiver receiver; 318 SimpleMessageReceiver receiver;
331 319
332 // User has a proxy to a Service somehow. 320 // User has a proxy to a Service somehow.
333 Service* service = new ServiceProxyImpl(&receiver); 321 Service* service = new ServiceProxyImpl(&receiver);
334 322
335 // User constructs a message to send. 323 // User constructs a message to send.
336 324
337 // Notice that it doesn't matter in what order the structs / arrays are 325 // Notice that it doesn't matter in what order the structs / arrays are
338 // allocated. Here, the various members of Foo are allocated before Foo is 326 // allocated. Here, the various members of Foo are allocated before Foo is
339 // allocated. 327 // allocated.
340 328
341 FooPtr foo = MakeFoo(); 329 FooPtr foo = MakeFoo();
342 CheckFoo(*foo); 330 CheckFoo(*foo);
343 331
344 PortPtr port; 332 PortPtr port;
345 service->Frobinate(foo.Pass(), Service::BazOptions::EXTRA, std::move(port), 333 service->Frobinate(foo.Pass(), Service::BazOptions::EXTRA, std::move(port),
346 Service::FrobinateCallback()); 334 Service::FrobinateCallback());
347 335
348 delete service; 336 delete service;
349 } 337 }
350 338
351 TEST_F(BindingsSampleTest, DefaultValues) { 339 TEST(BindingsSampleTest, DefaultValues) {
352 DefaultsTestPtr defaults(DefaultsTest::New()); 340 DefaultsTestPtr defaults(DefaultsTest::New());
353 EXPECT_EQ(-12, defaults->a0); 341 EXPECT_EQ(-12, defaults->a0);
354 EXPECT_EQ(kTwelve, defaults->a1); 342 EXPECT_EQ(kTwelve, defaults->a1);
355 EXPECT_EQ(1234, defaults->a2); 343 EXPECT_EQ(1234, defaults->a2);
356 EXPECT_EQ(34567U, defaults->a3); 344 EXPECT_EQ(34567U, defaults->a3);
357 EXPECT_EQ(123456, defaults->a4); 345 EXPECT_EQ(123456, defaults->a4);
358 EXPECT_EQ(3456789012U, defaults->a5); 346 EXPECT_EQ(3456789012U, defaults->a5);
359 EXPECT_EQ(-111111111111LL, defaults->a6); 347 EXPECT_EQ(-111111111111LL, defaults->a6);
360 EXPECT_EQ(9999999999999999999ULL, defaults->a7); 348 EXPECT_EQ(9999999999999999999ULL, defaults->a7);
361 EXPECT_EQ(0x12345, defaults->a8); 349 EXPECT_EQ(0x12345, defaults->a8);
(...skipping 13 matching lines...) Expand all
375 ASSERT_FALSE(defaults->a22.is_null()); 363 ASSERT_FALSE(defaults->a22.is_null());
376 EXPECT_EQ(imported::Shape::RECTANGLE, defaults->a22->shape); 364 EXPECT_EQ(imported::Shape::RECTANGLE, defaults->a22->shape);
377 EXPECT_EQ(imported::Color::BLACK, defaults->a22->color); 365 EXPECT_EQ(imported::Color::BLACK, defaults->a22->color);
378 EXPECT_EQ(0xFFFFFFFFFFFFFFFFULL, defaults->a23); 366 EXPECT_EQ(0xFFFFFFFFFFFFFFFFULL, defaults->a23);
379 EXPECT_EQ(0x123456789, defaults->a24); 367 EXPECT_EQ(0x123456789, defaults->a24);
380 EXPECT_EQ(-0x123456789, defaults->a25); 368 EXPECT_EQ(-0x123456789, defaults->a25);
381 } 369 }
382 370
383 } // namespace 371 } // namespace
384 } // namespace sample 372 } // namespace sample
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/tests/router_unittest.cc ('k') | mojo/public/cpp/bindings/tests/serialization_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698