OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" | |
10 #include "dbus/object_proxy.h" | 9 #include "dbus/object_proxy.h" |
11 #include "dbus/test_service.h" | 10 #include "dbus/test_service.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
13 | 12 |
14 // The end-to-end test exercises the synchronous APIs in ObjectProxy and | 13 // The end-to-end test exercises the synchronous APIs in ObjectProxy and |
15 // ExportedObject. The test will launch a thread for the service side | 14 // ExportedObject. The test will launch a thread for the service side |
16 // operations (i.e. ExportedObject side). | 15 // operations (i.e. ExportedObject side). |
17 class EndToEndSyncTest : public testing::Test { | 16 class EndToEndSyncTest : public testing::Test { |
18 public: | 17 public: |
19 EndToEndSyncTest() { | 18 EndToEndSyncTest() { |
20 } | 19 } |
21 | 20 |
22 virtual void SetUp() { | 21 virtual void SetUp() { |
23 // Start the test service; | 22 // Start the test service; |
24 dbus::TestService::Options options; | 23 dbus::TestService::Options options; |
25 test_service_.reset(new dbus::TestService(options)); | 24 test_service_.reset(new dbus::TestService(options)); |
26 ASSERT_TRUE(test_service_->StartService()); | 25 ASSERT_TRUE(test_service_->StartService()); |
27 ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted()); | 26 ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted()); |
28 ASSERT_FALSE(test_service_->HasDBusThread()); | 27 ASSERT_FALSE(test_service_->HasDBusThread()); |
29 | 28 |
30 // Create the client. | 29 // Create the client. |
31 dbus::Bus::Options client_bus_options; | 30 dbus::Bus::Options client_bus_options; |
32 client_bus_options.bus_type = dbus::Bus::SESSION; | 31 client_bus_options.bus_type = dbus::Bus::SESSION; |
33 client_bus_options.connection_type = dbus::Bus::PRIVATE; | 32 client_bus_options.connection_type = dbus::Bus::PRIVATE; |
34 client_bus_ = new dbus::Bus(client_bus_options); | 33 client_bus_ = new dbus::Bus(client_bus_options); |
35 object_proxy_ = client_bus_->GetObjectProxy( | 34 object_proxy_ = client_bus_->GetObjectProxy("org.chromium.TestService", |
36 "org.chromium.TestService", | 35 "/org/chromium/TestObject"); |
37 dbus::ObjectPath("/org/chromium/TestObject")); | |
38 ASSERT_FALSE(client_bus_->HasDBusThread()); | 36 ASSERT_FALSE(client_bus_->HasDBusThread()); |
39 } | 37 } |
40 | 38 |
41 virtual void TearDown() { | 39 virtual void TearDown() { |
42 test_service_->ShutdownAndBlock(); | 40 test_service_->ShutdownAndBlock(); |
43 test_service_->Stop(); | 41 test_service_->Stop(); |
44 client_bus_->ShutdownAndBlock(); | 42 client_bus_->ShutdownAndBlock(); |
45 } | 43 } |
46 | 44 |
47 protected: | 45 protected: |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 95 } |
98 | 96 |
99 TEST_F(EndToEndSyncTest, BrokenMethod) { | 97 TEST_F(EndToEndSyncTest, BrokenMethod) { |
100 dbus::MethodCall method_call("org.chromium.TestInterface", "BrokenMethod"); | 98 dbus::MethodCall method_call("org.chromium.TestInterface", "BrokenMethod"); |
101 | 99 |
102 const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT; | 100 const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT; |
103 scoped_ptr<dbus::Response> response( | 101 scoped_ptr<dbus::Response> response( |
104 object_proxy_->CallMethodAndBlock(&method_call, timeout_ms)); | 102 object_proxy_->CallMethodAndBlock(&method_call, timeout_ms)); |
105 ASSERT_FALSE(response.get()); | 103 ASSERT_FALSE(response.get()); |
106 } | 104 } |
OLD | NEW |