Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Side by Side Diff: dbus/end_to_end_sync_unittest.cc

Issue 7745044: Minor cleanups and improvements for the D-Bus library. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dbus/end_to_end_async_unittest.cc ('k') | dbus/mock_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 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_proxy.h" 9 #include "dbus/object_proxy.h"
10 #include "dbus/test_service.h" 10 #include "dbus/test_service.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 // The end-to-end test exercises the synchronos APIs in ObjectProxy and 13 // The end-to-end test exercises the synchronos APIs in ObjectProxy and
14 // ExportedObject. The test will launch a thread for the service side 14 // ExportedObject. The test will launch a thread for the service side
15 // operations (i.e. ExportedObject side). 15 // operations (i.e. ExportedObject side).
16 class EndToEndSyncTest : public testing::Test { 16 class EndToEndSyncTest : public testing::Test {
17 public: 17 public:
18 EndToEndSyncTest() { 18 EndToEndSyncTest() {
19 } 19 }
20 20
21 void SetUp() { 21 virtual void SetUp() {
22 // Start the test service; 22 // Start the test service;
23 dbus::TestService::Options options; 23 dbus::TestService::Options options;
24 test_service_.reset(new dbus::TestService(options)); 24 test_service_.reset(new dbus::TestService(options));
25 ASSERT_TRUE(test_service_->StartService()); 25 ASSERT_TRUE(test_service_->StartService());
26 ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted()); 26 ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted());
27 ASSERT_FALSE(test_service_->HasDBusThread()); 27 ASSERT_FALSE(test_service_->HasDBusThread());
28 28
29 // Create the client. 29 // Create the client.
30 dbus::Bus::Options client_bus_options; 30 dbus::Bus::Options client_bus_options;
31 client_bus_options.bus_type = dbus::Bus::SESSION; 31 client_bus_options.bus_type = dbus::Bus::SESSION;
32 client_bus_options.connection_type = dbus::Bus::PRIVATE; 32 client_bus_options.connection_type = dbus::Bus::PRIVATE;
33 client_bus_ = new dbus::Bus(client_bus_options); 33 client_bus_ = new dbus::Bus(client_bus_options);
34 object_proxy_ = client_bus_->GetObjectProxy("org.chromium.TestService", 34 object_proxy_ = client_bus_->GetObjectProxy("org.chromium.TestService",
35 "/org/chromium/TestObject"); 35 "/org/chromium/TestObject");
36 ASSERT_FALSE(client_bus_->HasDBusThread()); 36 ASSERT_FALSE(client_bus_->HasDBusThread());
37 } 37 }
38 38
39 void TearDown() { 39 virtual void TearDown() {
40 test_service_->Shutdown(); 40 test_service_->Shutdown();
41 ASSERT_TRUE(test_service_->WaitUntilServiceIsShutdown()); 41 ASSERT_TRUE(test_service_->WaitUntilServiceIsShutdown());
42 test_service_->Stop(); 42 test_service_->Stop();
43 client_bus_->ShutdownAndBlock(); 43 client_bus_->ShutdownAndBlock();
44 } 44 }
45 45
46 protected: 46 protected:
47 scoped_ptr<dbus::TestService> test_service_; 47 scoped_ptr<dbus::TestService> test_service_;
48 scoped_refptr<dbus::Bus> client_bus_; 48 scoped_refptr<dbus::Bus> client_bus_;
49 dbus::ObjectProxy* object_proxy_; 49 dbus::ObjectProxy* object_proxy_;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } 96 }
97 97
98 TEST_F(EndToEndSyncTest, BrokenMethod) { 98 TEST_F(EndToEndSyncTest, BrokenMethod) {
99 dbus::MethodCall method_call("org.chromium.TestInterface", "BrokenMethod"); 99 dbus::MethodCall method_call("org.chromium.TestInterface", "BrokenMethod");
100 100
101 const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT; 101 const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT;
102 scoped_ptr<dbus::Response> response( 102 scoped_ptr<dbus::Response> response(
103 object_proxy_->CallMethodAndBlock(&method_call, timeout_ms)); 103 object_proxy_->CallMethodAndBlock(&method_call, timeout_ms));
104 ASSERT_FALSE(response.get()); 104 ASSERT_FALSE(response.get());
105 } 105 }
OLDNEW
« no previous file with comments | « dbus/end_to_end_async_unittest.cc ('k') | dbus/mock_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698