OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // See comments in ObjectProxy::RunResponseCallback() for why the number was | 28 // See comments in ObjectProxy::RunResponseCallback() for why the number was |
29 // chosen. | 29 // chosen. |
30 const int kHugePayloadSize = 64 << 20; // 64 MB | 30 const int kHugePayloadSize = 64 << 20; // 64 MB |
31 | 31 |
32 } // namespace | 32 } // namespace |
33 | 33 |
34 // The end-to-end test exercises the asynchronous APIs in ObjectProxy and | 34 // The end-to-end test exercises the asynchronous APIs in ObjectProxy and |
35 // ExportedObject. | 35 // ExportedObject. |
36 class EndToEndAsyncTest : public testing::Test { | 36 class EndToEndAsyncTest : public testing::Test { |
37 public: | 37 public: |
38 virtual void SetUp() { | 38 void SetUp() override { |
39 // Make the main thread not to allow IO. | 39 // Make the main thread not to allow IO. |
40 base::ThreadRestrictions::SetIOAllowed(false); | 40 base::ThreadRestrictions::SetIOAllowed(false); |
41 | 41 |
42 // Start the D-Bus thread. | 42 // Start the D-Bus thread. |
43 dbus_thread_.reset(new base::Thread("D-Bus Thread")); | 43 dbus_thread_.reset(new base::Thread("D-Bus Thread")); |
44 base::Thread::Options thread_options; | 44 base::Thread::Options thread_options; |
45 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; | 45 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; |
46 ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options)); | 46 ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options)); |
47 | 47 |
48 // Start the test service, using the D-Bus thread. | 48 // Start the test service, using the D-Bus thread. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 "Test", | 105 "Test", |
106 base::Bind(&EndToEndAsyncTest::OnRootTestSignal, | 106 base::Bind(&EndToEndAsyncTest::OnRootTestSignal, |
107 base::Unretained(this)), | 107 base::Unretained(this)), |
108 base::Bind(&EndToEndAsyncTest::OnConnected, | 108 base::Bind(&EndToEndAsyncTest::OnConnected, |
109 base::Unretained(this))); | 109 base::Unretained(this))); |
110 // Wait until the root object proxy is connected to the signal. | 110 // Wait until the root object proxy is connected to the signal. |
111 run_loop_.reset(new base::RunLoop()); | 111 run_loop_.reset(new base::RunLoop()); |
112 run_loop_->Run(); | 112 run_loop_->Run(); |
113 } | 113 } |
114 | 114 |
115 virtual void TearDown() { | 115 void TearDown() override { |
116 bus_->ShutdownOnDBusThreadAndBlock(); | 116 bus_->ShutdownOnDBusThreadAndBlock(); |
117 | 117 |
118 // Shut down the service. | 118 // Shut down the service. |
119 test_service_->ShutdownAndBlock(); | 119 test_service_->ShutdownAndBlock(); |
120 | 120 |
121 // Reset to the default. | 121 // Reset to the default. |
122 base::ThreadRestrictions::SetIOAllowed(true); | 122 base::ThreadRestrictions::SetIOAllowed(true); |
123 | 123 |
124 // Stopping a thread is considered an IO operation, so do this after | 124 // Stopping a thread is considered an IO operation, so do this after |
125 // allowing IO. | 125 // allowing IO. |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 // This caused a DCHECK failure before. Ensure that the issue is fixed. | 575 // This caused a DCHECK failure before. Ensure that the issue is fixed. |
576 WaitForTestSignal(); | 576 WaitForTestSignal(); |
577 ASSERT_EQ(kHugeMessage, test_signal_string_); | 577 ASSERT_EQ(kHugeMessage, test_signal_string_); |
578 } | 578 } |
579 | 579 |
580 class SignalMultipleHandlerTest : public EndToEndAsyncTest { | 580 class SignalMultipleHandlerTest : public EndToEndAsyncTest { |
581 public: | 581 public: |
582 SignalMultipleHandlerTest() { | 582 SignalMultipleHandlerTest() { |
583 } | 583 } |
584 | 584 |
585 virtual void SetUp() { | 585 void SetUp() override { |
586 // Set up base class. | 586 // Set up base class. |
587 EndToEndAsyncTest::SetUp(); | 587 EndToEndAsyncTest::SetUp(); |
588 | 588 |
589 // Connect the root object proxy's signal handler to a new handler | 589 // Connect the root object proxy's signal handler to a new handler |
590 // so that we can verify that a second call to ConnectSignal() delivers | 590 // so that we can verify that a second call to ConnectSignal() delivers |
591 // to both our new handler and the old. | 591 // to both our new handler and the old. |
592 object_proxy_->ConnectToSignal( | 592 object_proxy_->ConnectToSignal( |
593 "org.chromium.TestInterface", | 593 "org.chromium.TestInterface", |
594 "Test", | 594 "Test", |
595 base::Bind(&SignalMultipleHandlerTest::OnAdditionalTestSignal, | 595 base::Bind(&SignalMultipleHandlerTest::OnAdditionalTestSignal, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 test_service_->SendTestSignal(kMessage); | 628 test_service_->SendTestSignal(kMessage); |
629 // Receive the signal with the object proxy. | 629 // Receive the signal with the object proxy. |
630 WaitForTestSignal(); | 630 WaitForTestSignal(); |
631 // Verify the string WAS received by the original handler. | 631 // Verify the string WAS received by the original handler. |
632 ASSERT_EQ(kMessage, test_signal_string_); | 632 ASSERT_EQ(kMessage, test_signal_string_); |
633 // Verify the signal WAS ALSO received by the additional handler. | 633 // Verify the signal WAS ALSO received by the additional handler. |
634 ASSERT_EQ(kMessage, additional_test_signal_string_); | 634 ASSERT_EQ(kMessage, additional_test_signal_string_); |
635 } | 635 } |
636 | 636 |
637 } // namespace dbus | 637 } // namespace dbus |
OLD | NEW |