OLD | NEW |
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 <stdint.h> | 5 #include <stdint.h> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "mojo/message_pump/message_pump_mojo.h" | 9 #include "mojo/message_pump/message_pump_mojo.h" |
10 #include "mojo/public/cpp/bindings/binding.h" | 10 #include "mojo/public/cpp/bindings/binding.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 class IntegerAccessorImpl : public sample::IntegerAccessor { | 173 class IntegerAccessorImpl : public sample::IntegerAccessor { |
174 public: | 174 public: |
175 IntegerAccessorImpl() : integer_(0) {} | 175 IntegerAccessorImpl() : integer_(0) {} |
176 ~IntegerAccessorImpl() override {} | 176 ~IntegerAccessorImpl() override {} |
177 | 177 |
178 int64_t integer() const { return integer_; } | 178 int64_t integer() const { return integer_; } |
179 | 179 |
180 private: | 180 private: |
181 // sample::IntegerAccessor implementation. | 181 // sample::IntegerAccessor implementation. |
182 void GetInteger(const GetIntegerCallback& callback) override { | 182 void GetInteger(const GetIntegerCallback& callback) override { |
183 callback.Run(integer_, sample::ENUM_VALUE); | 183 callback.Run(integer_, sample::Enum::VALUE); |
184 } | 184 } |
185 void SetInteger(int64_t data, sample::Enum type) override { integer_ = data; } | 185 void SetInteger(int64_t data, sample::Enum type) override { integer_ = data; } |
186 | 186 |
187 int64_t integer_; | 187 int64_t integer_; |
188 }; | 188 }; |
189 | 189 |
190 class InterfacePtrTest : public testing::Test { | 190 class InterfacePtrTest : public testing::Test { |
191 public: | 191 public: |
192 InterfacePtrTest() : loop_(common::MessagePumpMojo::Create()) {} | 192 InterfacePtrTest() : loop_(common::MessagePumpMojo::Create()) {} |
193 ~InterfacePtrTest() override { loop_.RunUntilIdle(); } | 193 ~InterfacePtrTest() override { loop_.RunUntilIdle(); } |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 | 377 |
378 PumpMessages(); | 378 PumpMessages(); |
379 | 379 |
380 EXPECT_EQ(0, SelfDestructingMathCalculatorUI::num_instances()); | 380 EXPECT_EQ(0, SelfDestructingMathCalculatorUI::num_instances()); |
381 } | 381 } |
382 | 382 |
383 TEST_F(InterfacePtrTest, ReentrantWaitForIncomingMethodCall) { | 383 TEST_F(InterfacePtrTest, ReentrantWaitForIncomingMethodCall) { |
384 sample::ServicePtr proxy; | 384 sample::ServicePtr proxy; |
385 ReentrantServiceImpl impl(GetProxy(&proxy)); | 385 ReentrantServiceImpl impl(GetProxy(&proxy)); |
386 | 386 |
387 proxy->Frobinate(nullptr, sample::Service::BAZ_OPTIONS_REGULAR, nullptr, | 387 proxy->Frobinate(nullptr, sample::Service::BazOptions::REGULAR, nullptr, |
388 sample::Service::FrobinateCallback()); | 388 sample::Service::FrobinateCallback()); |
389 proxy->Frobinate(nullptr, sample::Service::BAZ_OPTIONS_REGULAR, nullptr, | 389 proxy->Frobinate(nullptr, sample::Service::BazOptions::REGULAR, nullptr, |
390 sample::Service::FrobinateCallback()); | 390 sample::Service::FrobinateCallback()); |
391 | 391 |
392 PumpMessages(); | 392 PumpMessages(); |
393 | 393 |
394 EXPECT_EQ(2, impl.max_call_depth()); | 394 EXPECT_EQ(2, impl.max_call_depth()); |
395 } | 395 } |
396 | 396 |
397 TEST_F(InterfacePtrTest, QueryVersion) { | 397 TEST_F(InterfacePtrTest, QueryVersion) { |
398 IntegerAccessorImpl impl; | 398 IntegerAccessorImpl impl; |
399 sample::IntegerAccessorPtr ptr; | 399 sample::IntegerAccessorPtr ptr; |
(...skipping 11 matching lines...) Expand all Loading... |
411 | 411 |
412 TEST_F(InterfacePtrTest, RequireVersion) { | 412 TEST_F(InterfacePtrTest, RequireVersion) { |
413 IntegerAccessorImpl impl; | 413 IntegerAccessorImpl impl; |
414 sample::IntegerAccessorPtr ptr; | 414 sample::IntegerAccessorPtr ptr; |
415 Binding<sample::IntegerAccessor> binding(&impl, GetProxy(&ptr)); | 415 Binding<sample::IntegerAccessor> binding(&impl, GetProxy(&ptr)); |
416 | 416 |
417 EXPECT_EQ(0u, ptr.version()); | 417 EXPECT_EQ(0u, ptr.version()); |
418 | 418 |
419 ptr.RequireVersion(1u); | 419 ptr.RequireVersion(1u); |
420 EXPECT_EQ(1u, ptr.version()); | 420 EXPECT_EQ(1u, ptr.version()); |
421 ptr->SetInteger(123, sample::ENUM_VALUE); | 421 ptr->SetInteger(123, sample::Enum::VALUE); |
422 PumpMessages(); | 422 PumpMessages(); |
423 EXPECT_FALSE(ptr.encountered_error()); | 423 EXPECT_FALSE(ptr.encountered_error()); |
424 EXPECT_EQ(123, impl.integer()); | 424 EXPECT_EQ(123, impl.integer()); |
425 | 425 |
426 ptr.RequireVersion(3u); | 426 ptr.RequireVersion(3u); |
427 EXPECT_EQ(3u, ptr.version()); | 427 EXPECT_EQ(3u, ptr.version()); |
428 ptr->SetInteger(456, sample::ENUM_VALUE); | 428 ptr->SetInteger(456, sample::Enum::VALUE); |
429 PumpMessages(); | 429 PumpMessages(); |
430 EXPECT_FALSE(ptr.encountered_error()); | 430 EXPECT_FALSE(ptr.encountered_error()); |
431 EXPECT_EQ(456, impl.integer()); | 431 EXPECT_EQ(456, impl.integer()); |
432 | 432 |
433 // Require a version that is not supported by the impl side. | 433 // Require a version that is not supported by the impl side. |
434 ptr.RequireVersion(4u); | 434 ptr.RequireVersion(4u); |
435 // This value is set to the input of RequireVersion() synchronously. | 435 // This value is set to the input of RequireVersion() synchronously. |
436 EXPECT_EQ(4u, ptr.version()); | 436 EXPECT_EQ(4u, ptr.version()); |
437 ptr->SetInteger(789, sample::ENUM_VALUE); | 437 ptr->SetInteger(789, sample::Enum::VALUE); |
438 PumpMessages(); | 438 PumpMessages(); |
439 EXPECT_TRUE(ptr.encountered_error()); | 439 EXPECT_TRUE(ptr.encountered_error()); |
440 // The call to SetInteger() after RequireVersion(4u) is ignored. | 440 // The call to SetInteger() after RequireVersion(4u) is ignored. |
441 EXPECT_EQ(456, impl.integer()); | 441 EXPECT_EQ(456, impl.integer()); |
442 } | 442 } |
443 | 443 |
444 class StrongMathCalculatorImpl : public math::Calculator { | 444 class StrongMathCalculatorImpl : public math::Calculator { |
445 public: | 445 public: |
446 StrongMathCalculatorImpl(ScopedMessagePipeHandle handle, | 446 StrongMathCalculatorImpl(ScopedMessagePipeHandle handle, |
447 bool* error_received, | 447 bool* error_received, |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 // While B & C have fallen out of scope, the pipes will remain until they are | 642 // While B & C have fallen out of scope, the pipes will remain until they are |
643 // flushed. | 643 // flushed. |
644 EXPECT_FALSE(a_impl.d_called()); | 644 EXPECT_FALSE(a_impl.d_called()); |
645 PumpMessages(); | 645 PumpMessages(); |
646 EXPECT_TRUE(a_impl.d_called()); | 646 EXPECT_TRUE(a_impl.d_called()); |
647 } | 647 } |
648 | 648 |
649 } // namespace | 649 } // namespace |
650 } // namespace test | 650 } // namespace test |
651 } // namespace mojo | 651 } // namespace mojo |
OLD | NEW |