| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/metrics/histogram_samples.h" | 9 #include "base/metrics/histogram_samples.h" |
| 10 #include "base/metrics/statistics_recorder.h" | 10 #include "base/metrics/statistics_recorder.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 namespace dbus { | 21 namespace dbus { |
| 22 | 22 |
| 23 // The test for sender verification in ObjectProxy. | 23 // The test for sender verification in ObjectProxy. |
| 24 class SignalSenderVerificationTest : public testing::Test { | 24 class SignalSenderVerificationTest : public testing::Test { |
| 25 public: | 25 public: |
| 26 SignalSenderVerificationTest() | 26 SignalSenderVerificationTest() |
| 27 : on_name_owner_changed_called_(false), | 27 : on_name_owner_changed_called_(false), |
| 28 on_ownership_called_(false) { | 28 on_ownership_called_(false) { |
| 29 } | 29 } |
| 30 | 30 |
| 31 virtual void SetUp() { | 31 void SetUp() override { |
| 32 base::StatisticsRecorder::Initialize(); | 32 base::StatisticsRecorder::Initialize(); |
| 33 | 33 |
| 34 // Make the main thread not to allow IO. | 34 // Make the main thread not to allow IO. |
| 35 base::ThreadRestrictions::SetIOAllowed(false); | 35 base::ThreadRestrictions::SetIOAllowed(false); |
| 36 | 36 |
| 37 // Start the D-Bus thread. | 37 // Start the D-Bus thread. |
| 38 dbus_thread_.reset(new base::Thread("D-Bus Thread")); | 38 dbus_thread_.reset(new base::Thread("D-Bus Thread")); |
| 39 base::Thread::Options thread_options; | 39 base::Thread::Options thread_options; |
| 40 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; | 40 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; |
| 41 ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options)); | 41 ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options)); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 ASSERT_FALSE(test_service2_->has_ownership()); | 87 ASSERT_FALSE(test_service2_->has_ownership()); |
| 88 | 88 |
| 89 // The name should be owned and known at this point. | 89 // The name should be owned and known at this point. |
| 90 if (!on_name_owner_changed_called_) { | 90 if (!on_name_owner_changed_called_) { |
| 91 run_loop_.reset(new base::RunLoop); | 91 run_loop_.reset(new base::RunLoop); |
| 92 run_loop_->Run(); | 92 run_loop_->Run(); |
| 93 } | 93 } |
| 94 ASSERT_FALSE(latest_name_owner_.empty()); | 94 ASSERT_FALSE(latest_name_owner_.empty()); |
| 95 } | 95 } |
| 96 | 96 |
| 97 virtual void TearDown() { | 97 void TearDown() override { |
| 98 bus_->ShutdownOnDBusThreadAndBlock(); | 98 bus_->ShutdownOnDBusThreadAndBlock(); |
| 99 | 99 |
| 100 // Shut down the service. | 100 // Shut down the service. |
| 101 test_service_->ShutdownAndBlock(); | 101 test_service_->ShutdownAndBlock(); |
| 102 test_service2_->ShutdownAndBlock(); | 102 test_service2_->ShutdownAndBlock(); |
| 103 | 103 |
| 104 // Reset to the default. | 104 // Reset to the default. |
| 105 base::ThreadRestrictions::SetIOAllowed(true); | 105 base::ThreadRestrictions::SetIOAllowed(true); |
| 106 | 106 |
| 107 // Stopping a thread is considered an IO operation, so do this after | 107 // Stopping a thread is considered an IO operation, so do this after |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 392 |
| 393 // Now the second service owns the name. | 393 // Now the second service owns the name. |
| 394 const char kNewMessage[] = "hello, new world"; | 394 const char kNewMessage[] = "hello, new world"; |
| 395 | 395 |
| 396 test_service2_->SendTestSignal(kNewMessage); | 396 test_service2_->SendTestSignal(kNewMessage); |
| 397 WaitForTestSignal(); | 397 WaitForTestSignal(); |
| 398 ASSERT_EQ(kNewMessage, test_signal_string_); | 398 ASSERT_EQ(kNewMessage, test_signal_string_); |
| 399 } | 399 } |
| 400 | 400 |
| 401 } // namespace dbus | 401 } // namespace dbus |
| OLD | NEW |