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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/metrics/histogram_samples.h" | 10 #include "base/metrics/histogram_samples.h" |
11 #include "base/metrics/statistics_recorder.h" | 11 #include "base/metrics/statistics_recorder.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/single_thread_task_runner.h" |
13 #include "base/test/test_timeouts.h" | 14 #include "base/test/test_timeouts.h" |
14 #include "base/threading/platform_thread.h" | 15 #include "base/threading/platform_thread.h" |
15 #include "base/threading/thread_restrictions.h" | 16 #include "base/threading/thread_restrictions.h" |
16 #include "dbus/bus.h" | 17 #include "dbus/bus.h" |
17 #include "dbus/message.h" | 18 #include "dbus/message.h" |
18 #include "dbus/object_proxy.h" | 19 #include "dbus/object_proxy.h" |
19 #include "dbus/test_service.h" | 20 #include "dbus/test_service.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 | 22 |
22 namespace dbus { | 23 namespace dbus { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 111 |
111 // Stopping a thread is considered an IO operation, so do this after | 112 // Stopping a thread is considered an IO operation, so do this after |
112 // allowing IO. | 113 // allowing IO. |
113 test_service_->Stop(); | 114 test_service_->Stop(); |
114 test_service2_->Stop(); | 115 test_service2_->Stop(); |
115 } | 116 } |
116 | 117 |
117 void OnOwnership(bool expected, bool success) { | 118 void OnOwnership(bool expected, bool success) { |
118 ASSERT_EQ(expected, success); | 119 ASSERT_EQ(expected, success); |
119 // PostTask to quit the MessageLoop as this is called from D-Bus thread. | 120 // PostTask to quit the MessageLoop as this is called from D-Bus thread. |
120 message_loop_.PostTask( | 121 message_loop_.task_runner()->PostTask( |
121 FROM_HERE, | 122 FROM_HERE, |
122 base::Bind(&SignalSenderVerificationTest::OnOwnershipInternal, | 123 base::Bind(&SignalSenderVerificationTest::OnOwnershipInternal, |
123 base::Unretained(this))); | 124 base::Unretained(this))); |
124 } | 125 } |
125 | 126 |
126 void OnOwnershipInternal() { | 127 void OnOwnershipInternal() { |
127 on_ownership_called_ = true; | 128 on_ownership_called_ = true; |
128 run_loop_->Quit(); | 129 run_loop_->Quit(); |
129 } | 130 } |
130 | 131 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 | 398 |
398 // Now the second service owns the name. | 399 // Now the second service owns the name. |
399 const char kNewMessage[] = "hello, new world"; | 400 const char kNewMessage[] = "hello, new world"; |
400 | 401 |
401 test_service2_->SendTestSignal(kNewMessage); | 402 test_service2_->SendTestSignal(kNewMessage); |
402 WaitForTestSignal(); | 403 WaitForTestSignal(); |
403 ASSERT_EQ(kNewMessage, test_signal_string_); | 404 ASSERT_EQ(kNewMessage, test_signal_string_); |
404 } | 405 } |
405 | 406 |
406 } // namespace dbus | 407 } // namespace dbus |
OLD | NEW |