OLD | NEW |
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> | 7 #include <utility> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 application_manager_.reset( | 284 application_manager_.reset( |
285 new ApplicationManager(make_scoped_ptr(CreatePackageManager()))); | 285 new ApplicationManager(make_scoped_ptr(CreatePackageManager()))); |
286 CreateLoader<ServiceApplication>("test:service"); | 286 CreateLoader<ServiceApplication>("test:service"); |
287 CreateLoader<ServiceApplication>("test:service2"); | 287 CreateLoader<ServiceApplication>("test:service2"); |
288 } | 288 } |
289 | 289 |
290 void CapabilityFilterTest::TearDown() { | 290 void CapabilityFilterTest::TearDown() { |
291 application_manager_.reset(); | 291 application_manager_.reset(); |
292 } | 292 } |
293 | 293 |
294 class InterfaceProviderImpl : public InterfaceProvider { | 294 class InterfaceProviderImpl : public shell::mojom::InterfaceProvider { |
295 public: | 295 public: |
296 explicit InterfaceProviderImpl( | 296 explicit InterfaceProviderImpl( |
297 InterfaceRequest<InterfaceProvider> interfaces, | 297 shell::mojom::InterfaceProviderRequest interfaces, |
298 InterfaceFactory<Validator>* factory) | 298 InterfaceFactory<Validator>* factory) |
299 : binding_(this, std::move(interfaces)), | 299 : binding_(this, std::move(interfaces)), |
300 factory_(factory) {} | 300 factory_(factory) {} |
301 ~InterfaceProviderImpl() override {} | 301 ~InterfaceProviderImpl() override {} |
302 | 302 |
303 private: | 303 private: |
304 // InterfaceProvider method. | 304 // shell::mojom::InterfaceProvider method. |
305 void GetInterface(const mojo::String& interface_name, | 305 void GetInterface(const mojo::String& interface_name, |
306 ScopedMessagePipeHandle client_handle) override { | 306 ScopedMessagePipeHandle client_handle) override { |
307 if (interface_name == Validator::Name_) { | 307 if (interface_name == Validator::Name_) { |
308 factory_->Create(nullptr, | 308 factory_->Create(nullptr, |
309 MakeRequest<Validator>(std::move(client_handle))); | 309 MakeRequest<Validator>(std::move(client_handle))); |
310 } | 310 } |
311 } | 311 } |
312 | 312 |
313 Binding<InterfaceProvider> binding_; | 313 Binding<InterfaceProvider> binding_; |
314 InterfaceFactory<Validator>* factory_; | 314 InterfaceFactory<Validator>* factory_; |
315 | 315 |
316 DISALLOW_COPY_AND_ASSIGN(InterfaceProviderImpl); | 316 DISALLOW_COPY_AND_ASSIGN(InterfaceProviderImpl); |
317 }; | 317 }; |
318 | 318 |
319 void CapabilityFilterTest::RunApplication(const std::string& url, | 319 void CapabilityFilterTest::RunApplication(const std::string& url, |
320 const CapabilityFilter& filter) { | 320 const CapabilityFilter& filter) { |
321 InterfaceProviderPtr remote_interfaces; | 321 shell::mojom::InterfaceProviderPtr remote_interfaces; |
322 | 322 |
323 // We expose Validator to the test application via ConnectToApplication | 323 // We expose Validator to the test application via ConnectToApplication |
324 // because we don't allow the test application to connect to test:validator. | 324 // because we don't allow the test application to connect to test:validator. |
325 // Adding it to the CapabilityFilter would interfere with the test. | 325 // Adding it to the CapabilityFilter would interfere with the test. |
326 InterfaceProviderPtr local_interfaces; | 326 shell::mojom::InterfaceProviderPtr local_interfaces; |
327 new InterfaceProviderImpl(GetProxy(&local_interfaces), validator_); | 327 new InterfaceProviderImpl(GetProxy(&local_interfaces), validator_); |
328 scoped_ptr<ConnectToApplicationParams> params( | 328 scoped_ptr<ConnectToApplicationParams> params( |
329 new ConnectToApplicationParams); | 329 new ConnectToApplicationParams); |
330 params->SetTarget(Identity(GURL(url), std::string(), filter)); | 330 params->SetTarget(Identity(GURL(url), std::string(), filter)); |
331 params->set_remote_interfaces(GetProxy(&remote_interfaces)); | 331 params->set_remote_interfaces(GetProxy(&remote_interfaces)); |
332 params->set_local_interfaces(std::move(local_interfaces)); | 332 params->set_local_interfaces(std::move(local_interfaces)); |
333 params->set_on_application_end(base::MessageLoop::QuitWhenIdleClosure()); | 333 params->set_on_application_end(base::MessageLoop::QuitWhenIdleClosure()); |
334 application_manager_->ConnectToApplication(std::move(params)); | 334 application_manager_->ConnectToApplication(std::move(params)); |
335 } | 335 } |
336 | 336 |
337 void CapabilityFilterTest::InitValidator( | 337 void CapabilityFilterTest::InitValidator( |
338 const std::set<std::string>& expectations) { | 338 const std::set<std::string>& expectations) { |
339 validator_ = new ConnectionValidator(expectations, &loop_); | 339 validator_ = new ConnectionValidator(expectations, &loop_); |
340 application_manager()->SetLoaderForURL(make_scoped_ptr(validator_), | 340 application_manager()->SetLoaderForURL(make_scoped_ptr(validator_), |
341 GURL("test:validator")); | 341 GURL("test:validator")); |
342 } | 342 } |
343 | 343 |
344 void CapabilityFilterTest::RunTest() { | 344 void CapabilityFilterTest::RunTest() { |
345 loop()->Run(); | 345 loop()->Run(); |
346 EXPECT_TRUE(validator_->expectations_met()); | 346 EXPECT_TRUE(validator_->expectations_met()); |
347 if (!validator_->expectations_met()) | 347 if (!validator_->expectations_met()) |
348 validator_->PrintUnmetExpectations(); | 348 validator_->PrintUnmetExpectations(); |
349 } | 349 } |
350 | 350 |
351 } // namespace test | 351 } // namespace test |
352 } // namespace shell | 352 } // namespace shell |
353 } // namespace mojo | 353 } // namespace mojo |
OLD | NEW |