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/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "dbus/bus.h" | 7 #include "dbus/bus.h" |
8 #include "dbus/message.h" | 8 #include "dbus/message.h" |
9 #include "dbus/object_path.h" | 9 #include "dbus/object_path.h" |
10 #include "dbus/object_proxy.h" | 10 #include "dbus/object_proxy.h" |
11 #include "dbus/test_service.h" | 11 #include "dbus/test_service.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace dbus { | 14 namespace dbus { |
15 | 15 |
16 // The end-to-end test exercises the synchronous APIs in ObjectProxy and | 16 // The end-to-end test exercises the synchronous APIs in ObjectProxy and |
17 // ExportedObject. The test will launch a thread for the service side | 17 // ExportedObject. The test will launch a thread for the service side |
18 // operations (i.e. ExportedObject side). | 18 // operations (i.e. ExportedObject side). |
19 class EndToEndSyncTest : public testing::Test { | 19 class EndToEndSyncTest : public testing::Test { |
20 public: | 20 public: |
21 EndToEndSyncTest() { | 21 EndToEndSyncTest() { |
22 } | 22 } |
23 | 23 |
24 virtual void SetUp() { | 24 void SetUp() override { |
25 // Start the test service; | 25 // Start the test service; |
26 TestService::Options options; | 26 TestService::Options options; |
27 test_service_.reset(new TestService(options)); | 27 test_service_.reset(new TestService(options)); |
28 ASSERT_TRUE(test_service_->StartService()); | 28 ASSERT_TRUE(test_service_->StartService()); |
29 ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted()); | 29 ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted()); |
30 ASSERT_FALSE(test_service_->HasDBusThread()); | 30 ASSERT_FALSE(test_service_->HasDBusThread()); |
31 | 31 |
32 // Create the client. | 32 // Create the client. |
33 Bus::Options client_bus_options; | 33 Bus::Options client_bus_options; |
34 client_bus_options.bus_type = Bus::SESSION; | 34 client_bus_options.bus_type = Bus::SESSION; |
35 client_bus_options.connection_type = Bus::PRIVATE; | 35 client_bus_options.connection_type = Bus::PRIVATE; |
36 client_bus_ = new Bus(client_bus_options); | 36 client_bus_ = new Bus(client_bus_options); |
37 object_proxy_ = client_bus_->GetObjectProxy( | 37 object_proxy_ = client_bus_->GetObjectProxy( |
38 "org.chromium.TestService", | 38 "org.chromium.TestService", |
39 ObjectPath("/org/chromium/TestObject")); | 39 ObjectPath("/org/chromium/TestObject")); |
40 ASSERT_FALSE(client_bus_->HasDBusThread()); | 40 ASSERT_FALSE(client_bus_->HasDBusThread()); |
41 } | 41 } |
42 | 42 |
43 virtual void TearDown() { | 43 void TearDown() override { |
44 test_service_->ShutdownAndBlock(); | 44 test_service_->ShutdownAndBlock(); |
45 test_service_->Stop(); | 45 test_service_->Stop(); |
46 client_bus_->ShutdownAndBlock(); | 46 client_bus_->ShutdownAndBlock(); |
47 } | 47 } |
48 | 48 |
49 protected: | 49 protected: |
50 scoped_ptr<TestService> test_service_; | 50 scoped_ptr<TestService> test_service_; |
51 scoped_refptr<Bus> client_bus_; | 51 scoped_refptr<Bus> client_bus_; |
52 ObjectProxy* object_proxy_; | 52 ObjectProxy* object_proxy_; |
53 }; | 53 }; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 MethodCall method_call("org.chromium.TestInterface", "Echo"); | 134 MethodCall method_call("org.chromium.TestInterface", "Echo"); |
135 | 135 |
136 const int timeout_ms = ObjectProxy::TIMEOUT_USE_DEFAULT; | 136 const int timeout_ms = ObjectProxy::TIMEOUT_USE_DEFAULT; |
137 scoped_ptr<Response> response( | 137 scoped_ptr<Response> response( |
138 object_proxy_->CallMethodAndBlock(&method_call, timeout_ms)); | 138 object_proxy_->CallMethodAndBlock(&method_call, timeout_ms)); |
139 ASSERT_FALSE(response.get()); | 139 ASSERT_FALSE(response.get()); |
140 } | 140 } |
141 | 141 |
142 } // namespace dbus | 142 } // namespace dbus |
OLD | NEW |