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

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

Issue 1375313006: For c++, Generate enum classes instead of enum from mojom. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "mojo/public/cpp/bindings/binding.h" 5 #include "mojo/public/cpp/bindings/binding.h"
6 #include "mojo/public/cpp/bindings/strong_binding.h" 6 #include "mojo/public/cpp/bindings/strong_binding.h"
7 #include "mojo/public/cpp/environment/environment.h" 7 #include "mojo/public/cpp/environment/environment.h"
8 #include "mojo/public/cpp/utility/run_loop.h" 8 #include "mojo/public/cpp/utility/run_loop.h"
9 #include "mojo/public/interfaces/bindings/tests/math_calculator.mojom.h" 9 #include "mojo/public/interfaces/bindings/tests/math_calculator.mojom.h"
10 #include "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom.h" 10 #include "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 class IntegerAccessorImpl : public sample::IntegerAccessor { 168 class IntegerAccessorImpl : public sample::IntegerAccessor {
169 public: 169 public:
170 IntegerAccessorImpl() : integer_(0) {} 170 IntegerAccessorImpl() : integer_(0) {}
171 ~IntegerAccessorImpl() override {} 171 ~IntegerAccessorImpl() override {}
172 172
173 int64_t integer() const { return integer_; } 173 int64_t integer() const { return integer_; }
174 174
175 private: 175 private:
176 // sample::IntegerAccessor implementation. 176 // sample::IntegerAccessor implementation.
177 void GetInteger(const GetIntegerCallback& callback) override { 177 void GetInteger(const GetIntegerCallback& callback) override {
178 callback.Run(integer_, sample::ENUM_VALUE); 178 callback.Run(integer_, sample::Enum::VALUE);
179 } 179 }
180 void SetInteger(int64_t data, sample::Enum type) override { integer_ = data; } 180 void SetInteger(int64_t data, sample::Enum type) override { integer_ = data; }
181 181
182 int64_t integer_; 182 int64_t integer_;
183 }; 183 };
184 184
185 class InterfacePtrTest : public testing::Test { 185 class InterfacePtrTest : public testing::Test {
186 public: 186 public:
187 ~InterfacePtrTest() override { loop_.RunUntilIdle(); } 187 ~InterfacePtrTest() override { loop_.RunUntilIdle(); }
188 188
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 371
372 PumpMessages(); 372 PumpMessages();
373 373
374 EXPECT_EQ(0, SelfDestructingMathCalculatorUI::num_instances()); 374 EXPECT_EQ(0, SelfDestructingMathCalculatorUI::num_instances());
375 } 375 }
376 376
377 TEST_F(InterfacePtrTest, ReentrantWaitForIncomingMethodCall) { 377 TEST_F(InterfacePtrTest, ReentrantWaitForIncomingMethodCall) {
378 sample::ServicePtr proxy; 378 sample::ServicePtr proxy;
379 ReentrantServiceImpl impl(GetProxy(&proxy)); 379 ReentrantServiceImpl impl(GetProxy(&proxy));
380 380
381 proxy->Frobinate(nullptr, sample::Service::BAZ_OPTIONS_REGULAR, nullptr, 381 proxy->Frobinate(nullptr, sample::Service::BazOptions::REGULAR, nullptr,
382 sample::Service::FrobinateCallback()); 382 sample::Service::FrobinateCallback());
383 proxy->Frobinate(nullptr, sample::Service::BAZ_OPTIONS_REGULAR, nullptr, 383 proxy->Frobinate(nullptr, sample::Service::BazOptions::REGULAR, nullptr,
384 sample::Service::FrobinateCallback()); 384 sample::Service::FrobinateCallback());
385 385
386 PumpMessages(); 386 PumpMessages();
387 387
388 EXPECT_EQ(2, impl.max_call_depth()); 388 EXPECT_EQ(2, impl.max_call_depth());
389 } 389 }
390 390
391 TEST_F(InterfacePtrTest, QueryVersion) { 391 TEST_F(InterfacePtrTest, QueryVersion) {
392 IntegerAccessorImpl impl; 392 IntegerAccessorImpl impl;
393 sample::IntegerAccessorPtr ptr; 393 sample::IntegerAccessorPtr ptr;
(...skipping 11 matching lines...) Expand all
405 405
406 TEST_F(InterfacePtrTest, RequireVersion) { 406 TEST_F(InterfacePtrTest, RequireVersion) {
407 IntegerAccessorImpl impl; 407 IntegerAccessorImpl impl;
408 sample::IntegerAccessorPtr ptr; 408 sample::IntegerAccessorPtr ptr;
409 Binding<sample::IntegerAccessor> binding(&impl, GetProxy(&ptr)); 409 Binding<sample::IntegerAccessor> binding(&impl, GetProxy(&ptr));
410 410
411 EXPECT_EQ(0u, ptr.version()); 411 EXPECT_EQ(0u, ptr.version());
412 412
413 ptr.RequireVersion(1u); 413 ptr.RequireVersion(1u);
414 EXPECT_EQ(1u, ptr.version()); 414 EXPECT_EQ(1u, ptr.version());
415 ptr->SetInteger(123, sample::ENUM_VALUE); 415 ptr->SetInteger(123, sample::Enum::VALUE);
416 PumpMessages(); 416 PumpMessages();
417 EXPECT_FALSE(ptr.encountered_error()); 417 EXPECT_FALSE(ptr.encountered_error());
418 EXPECT_EQ(123, impl.integer()); 418 EXPECT_EQ(123, impl.integer());
419 419
420 ptr.RequireVersion(3u); 420 ptr.RequireVersion(3u);
421 EXPECT_EQ(3u, ptr.version()); 421 EXPECT_EQ(3u, ptr.version());
422 ptr->SetInteger(456, sample::ENUM_VALUE); 422 ptr->SetInteger(456, sample::Enum::VALUE);
423 PumpMessages(); 423 PumpMessages();
424 EXPECT_FALSE(ptr.encountered_error()); 424 EXPECT_FALSE(ptr.encountered_error());
425 EXPECT_EQ(456, impl.integer()); 425 EXPECT_EQ(456, impl.integer());
426 426
427 // Require a version that is not supported by the impl side. 427 // Require a version that is not supported by the impl side.
428 ptr.RequireVersion(4u); 428 ptr.RequireVersion(4u);
429 // This value is set to the input of RequireVersion() synchronously. 429 // This value is set to the input of RequireVersion() synchronously.
430 EXPECT_EQ(4u, ptr.version()); 430 EXPECT_EQ(4u, ptr.version());
431 ptr->SetInteger(789, sample::ENUM_VALUE); 431 ptr->SetInteger(789, sample::Enum::VALUE);
432 PumpMessages(); 432 PumpMessages();
433 EXPECT_TRUE(ptr.encountered_error()); 433 EXPECT_TRUE(ptr.encountered_error());
434 // The call to SetInteger() after RequireVersion(4u) is ignored. 434 // The call to SetInteger() after RequireVersion(4u) is ignored.
435 EXPECT_EQ(456, impl.integer()); 435 EXPECT_EQ(456, impl.integer());
436 } 436 }
437 437
438 class StrongMathCalculatorImpl : public math::Calculator { 438 class StrongMathCalculatorImpl : public math::Calculator {
439 public: 439 public:
440 StrongMathCalculatorImpl(ScopedMessagePipeHandle handle, 440 StrongMathCalculatorImpl(ScopedMessagePipeHandle handle,
441 bool* error_received, 441 bool* error_received,
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 // While B & C have fallen out of scope, the pipes will remain until they are 640 // While B & C have fallen out of scope, the pipes will remain until they are
641 // flushed. 641 // flushed.
642 EXPECT_FALSE(a_impl.d_called()); 642 EXPECT_FALSE(a_impl.d_called());
643 PumpMessages(); 643 PumpMessages();
644 EXPECT_TRUE(a_impl.d_called()); 644 EXPECT_TRUE(a_impl.d_called());
645 } 645 }
646 646
647 } // namespace 647 } // namespace
648 } // namespace test 648 } // namespace test
649 } // namespace mojo 649 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/tests/binding_unittest.cc ('k') | mojo/public/cpp/bindings/tests/request_response_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698