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

Side by Side Diff: dbus/end_to_end_sync_unittest.cc

Issue 1559873005: dbus: Use randomly generated string as a TestService's service name (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « dbus/end_to_end_async_unittest.cc ('k') | dbus/object_manager_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) 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"
(...skipping 17 matching lines...) Expand all
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 test_service_->service_name(),
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 void TearDown() override { 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
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 scoped_ptr<Response> response( 105 scoped_ptr<Response> response(
106 object_proxy_->CallMethodAndBlock(&method_call, timeout_ms)); 106 object_proxy_->CallMethodAndBlock(&method_call, timeout_ms));
107 ASSERT_FALSE(response.get()); 107 ASSERT_FALSE(response.get());
108 } 108 }
109 109
110 TEST_F(EndToEndSyncTest, InvalidObjectPath) { 110 TEST_F(EndToEndSyncTest, InvalidObjectPath) {
111 // Trailing '/' is only allowed for the root path. 111 // Trailing '/' is only allowed for the root path.
112 const ObjectPath invalid_object_path("/org/chromium/TestObject/"); 112 const ObjectPath invalid_object_path("/org/chromium/TestObject/");
113 113
114 // Replace object proxy with new one. 114 // Replace object proxy with new one.
115 object_proxy_ = client_bus_->GetObjectProxy("org.chromium.TestService", 115 object_proxy_ = client_bus_->GetObjectProxy(test_service_->service_name(),
116 invalid_object_path); 116 invalid_object_path);
117 117
118 MethodCall method_call("org.chromium.TestInterface", "Echo"); 118 MethodCall method_call("org.chromium.TestInterface", "Echo");
119 119
120 const int timeout_ms = ObjectProxy::TIMEOUT_USE_DEFAULT; 120 const int timeout_ms = ObjectProxy::TIMEOUT_USE_DEFAULT;
121 scoped_ptr<Response> response( 121 scoped_ptr<Response> response(
122 object_proxy_->CallMethodAndBlock(&method_call, timeout_ms)); 122 object_proxy_->CallMethodAndBlock(&method_call, timeout_ms));
123 ASSERT_FALSE(response.get()); 123 ASSERT_FALSE(response.get());
124 } 124 }
125 125
126 TEST_F(EndToEndSyncTest, InvalidServiceName) { 126 TEST_F(EndToEndSyncTest, InvalidServiceName) {
127 // Bus name cannot contain '/'. 127 // Bus name cannot contain '/'.
128 const std::string invalid_service_name = ":1/2"; 128 const std::string invalid_service_name = ":1/2";
129 129
130 // Replace object proxy with new one. 130 // Replace object proxy with new one.
131 object_proxy_ = client_bus_->GetObjectProxy( 131 object_proxy_ = client_bus_->GetObjectProxy(
132 invalid_service_name, ObjectPath("org.chromium.TestObject")); 132 invalid_service_name, ObjectPath("org.chromium.TestObject"));
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
OLDNEW
« no previous file with comments | « dbus/end_to_end_async_unittest.cc ('k') | dbus/object_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698