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

Side by Side Diff: mojo/shell/capability_filter_test.cc

Issue 1538823002: Convert Pass()→std::move() in mojo/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 | « mojo/shell/application_manager_unittest.cc ('k') | mojo/shell/connect_to_application_params.h » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "mojo/shell/capability_filter_test.h" 5 #include "mojo/shell/capability_filter_test.h"
6 6
7 #include <utility>
8
7 #include "base/stl_util.h" 9 #include "base/stl_util.h"
8 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
9 #include "mojo/application/public/cpp/application_connection.h" 11 #include "mojo/application/public/cpp/application_connection.h"
10 #include "mojo/application/public/cpp/application_impl.h" 12 #include "mojo/application/public/cpp/application_impl.h"
11 #include "mojo/application/public/cpp/connect.h" 13 #include "mojo/application/public/cpp/connect.h"
12 #include "mojo/application/public/cpp/interface_factory.h" 14 #include "mojo/application/public/cpp/interface_factory.h"
13 #include "mojo/application/public/cpp/service_provider_impl.h" 15 #include "mojo/application/public/cpp/service_provider_impl.h"
14 #include "mojo/common/weak_binding_set.h" 16 #include "mojo/common/weak_binding_set.h"
15 #include "mojo/public/cpp/bindings/strong_binding.h" 17 #include "mojo/public/cpp/bindings/strong_binding.h"
16 #include "mojo/shell/application_loader.h" 18 #include "mojo/shell/application_loader.h"
(...skipping 25 matching lines...) Expand all
42 void PrintUnmetExpectations() { 44 void PrintUnmetExpectations() {
43 for (auto expectation : expectations_) 45 for (auto expectation : expectations_)
44 ADD_FAILURE() << "Unmet: " << expectation; 46 ADD_FAILURE() << "Unmet: " << expectation;
45 for (auto unexpected : unexpected_) 47 for (auto unexpected : unexpected_)
46 ADD_FAILURE() << "Unexpected: " << unexpected; 48 ADD_FAILURE() << "Unexpected: " << unexpected;
47 } 49 }
48 50
49 private: 51 private:
50 // Overridden from ApplicationLoader: 52 // Overridden from ApplicationLoader:
51 void Load(const GURL& url, InterfaceRequest<Application> request) override { 53 void Load(const GURL& url, InterfaceRequest<Application> request) override {
52 app_.reset(new ApplicationImpl(this, request.Pass())); 54 app_.reset(new ApplicationImpl(this, std::move(request)));
53 } 55 }
54 56
55 // Overridden from ApplicationDelegate: 57 // Overridden from ApplicationDelegate:
56 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { 58 bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
57 connection->AddService<Validator>(this); 59 connection->AddService<Validator>(this);
58 return true; 60 return true;
59 } 61 }
60 62
61 // Overridden from InterfaceFactory<Validator>: 63 // Overridden from InterfaceFactory<Validator>:
62 void Create(ApplicationConnection* connection, 64 void Create(ApplicationConnection* connection,
63 InterfaceRequest<Validator> request) override { 65 InterfaceRequest<Validator> request) override {
64 validator_bindings_.AddBinding(this, request.Pass()); 66 validator_bindings_.AddBinding(this, std::move(request));
65 } 67 }
66 68
67 // Overridden from Validator: 69 // Overridden from Validator:
68 void AddServiceCalled(const String& app_url, 70 void AddServiceCalled(const String& app_url,
69 const String& service_url, 71 const String& service_url,
70 const String& name, 72 const String& name,
71 bool blocked) override { 73 bool blocked) override {
72 Validate(base::StringPrintf("%s %s %s %s", 74 Validate(base::StringPrintf("%s %s %s %s",
73 blocked ? "B" : "E", app_url.data(), service_url.data(), name.data())); 75 blocked ? "B" : "E", app_url.data(), service_url.data(), name.data()));
74 } 76 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 124 }
123 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { 125 bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
124 AddService<Safe>(connection); 126 AddService<Safe>(connection);
125 AddService<Unsafe>(connection); 127 AddService<Unsafe>(connection);
126 return true; 128 return true;
127 } 129 }
128 130
129 // Overridden from InterfaceFactory<Safe>: 131 // Overridden from InterfaceFactory<Safe>:
130 void Create(ApplicationConnection* connection, 132 void Create(ApplicationConnection* connection,
131 InterfaceRequest<Safe> request) override { 133 InterfaceRequest<Safe> request) override {
132 safe_bindings_.AddBinding(this, request.Pass()); 134 safe_bindings_.AddBinding(this, std::move(request));
133 } 135 }
134 136
135 // Overridden from InterfaceFactory<Unsafe>: 137 // Overridden from InterfaceFactory<Unsafe>:
136 void Create(ApplicationConnection* connection, 138 void Create(ApplicationConnection* connection,
137 InterfaceRequest<Unsafe> request) override { 139 InterfaceRequest<Unsafe> request) override {
138 unsafe_bindings_.AddBinding(this, request.Pass()); 140 unsafe_bindings_.AddBinding(this, std::move(request));
139 } 141 }
140 142
141 template <typename Interface> 143 template <typename Interface>
142 void AddService(ApplicationConnection* connection) { 144 void AddService(ApplicationConnection* connection) {
143 validator_->AddServiceCalled(connection->GetRemoteApplicationURL(), 145 validator_->AddServiceCalled(connection->GetRemoteApplicationURL(),
144 connection->GetConnectionURL(), 146 connection->GetConnectionURL(),
145 Interface::Name_, 147 Interface::Name_,
146 !connection->AddService<Interface>(this)); 148 !connection->AddService<Interface>(this));
147 } 149 }
148 150
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 187 }
186 188
187 //////////////////////////////////////////////////////////////////////////////// 189 ////////////////////////////////////////////////////////////////////////////////
188 // TestLoader: 190 // TestLoader:
189 191
190 TestLoader::TestLoader(ApplicationDelegate* delegate) : delegate_(delegate) {} 192 TestLoader::TestLoader(ApplicationDelegate* delegate) : delegate_(delegate) {}
191 TestLoader::~TestLoader() {} 193 TestLoader::~TestLoader() {}
192 194
193 void TestLoader::Load(const GURL& url, 195 void TestLoader::Load(const GURL& url,
194 InterfaceRequest<Application> request) { 196 InterfaceRequest<Application> request) {
195 app_.reset(new ApplicationImpl(delegate_.get(), request.Pass())); 197 app_.reset(new ApplicationImpl(delegate_.get(), std::move(request)));
196 } 198 }
197 199
198 //////////////////////////////////////////////////////////////////////////////// 200 ////////////////////////////////////////////////////////////////////////////////
199 // CapabilityFilterTest: 201 // CapabilityFilterTest:
200 202
201 CapabilityFilterTest::CapabilityFilterTest() : validator_(nullptr) {} 203 CapabilityFilterTest::CapabilityFilterTest() : validator_(nullptr) {}
202 CapabilityFilterTest::~CapabilityFilterTest() {} 204 CapabilityFilterTest::~CapabilityFilterTest() {}
203 205
204 void CapabilityFilterTest::RunBlockingTest() { 206 void CapabilityFilterTest::RunBlockingTest() {
205 std::set<std::string> expectations; 207 std::set<std::string> expectations;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // We expose Validator to the test application via ConnectToApplication 297 // We expose Validator to the test application via ConnectToApplication
296 // because we don't allow the test application to connect to test:validator. 298 // because we don't allow the test application to connect to test:validator.
297 // Adding it to the CapabilityFilter would interfere with the test. 299 // Adding it to the CapabilityFilter would interfere with the test.
298 ServiceProviderPtr exposed_services; 300 ServiceProviderPtr exposed_services;
299 (new ServiceProviderImpl(GetProxy(&exposed_services)))-> 301 (new ServiceProviderImpl(GetProxy(&exposed_services)))->
300 AddService<Validator>(validator_); 302 AddService<Validator>(validator_);
301 scoped_ptr<ConnectToApplicationParams> params( 303 scoped_ptr<ConnectToApplicationParams> params(
302 new ConnectToApplicationParams); 304 new ConnectToApplicationParams);
303 params->SetTarget(Identity(GURL(url), std::string(), filter)); 305 params->SetTarget(Identity(GURL(url), std::string(), filter));
304 params->set_services(GetProxy(&services)); 306 params->set_services(GetProxy(&services));
305 params->set_exposed_services(exposed_services.Pass()); 307 params->set_exposed_services(std::move(exposed_services));
306 params->set_on_application_end(base::MessageLoop::QuitWhenIdleClosure()); 308 params->set_on_application_end(base::MessageLoop::QuitWhenIdleClosure());
307 application_manager_->ConnectToApplication(params.Pass()); 309 application_manager_->ConnectToApplication(std::move(params));
308 } 310 }
309 311
310 void CapabilityFilterTest::InitValidator( 312 void CapabilityFilterTest::InitValidator(
311 const std::set<std::string>& expectations) { 313 const std::set<std::string>& expectations) {
312 validator_ = new ConnectionValidator(expectations, &loop_); 314 validator_ = new ConnectionValidator(expectations, &loop_);
313 application_manager()->SetLoaderForURL(make_scoped_ptr(validator_), 315 application_manager()->SetLoaderForURL(make_scoped_ptr(validator_),
314 GURL("test:validator")); 316 GURL("test:validator"));
315 } 317 }
316 318
317 void CapabilityFilterTest::RunTest() { 319 void CapabilityFilterTest::RunTest() {
318 loop()->Run(); 320 loop()->Run();
319 EXPECT_TRUE(validator_->expectations_met()); 321 EXPECT_TRUE(validator_->expectations_met());
320 if (!validator_->expectations_met()) 322 if (!validator_->expectations_met())
321 validator_->PrintUnmetExpectations(); 323 validator_->PrintUnmetExpectations();
322 } 324 }
323 325
324 } // namespace test 326 } // namespace test
325 } // namespace shell 327 } // namespace shell
326 } // namespace mojo 328 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/application_manager_unittest.cc ('k') | mojo/shell/connect_to_application_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698