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

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

Issue 1354003002: Make CapabilityFilter be part of Identity (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 3 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 | « mojo/shell/capability_filter.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 "base/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 protected: 334 protected:
335 void RunApplication(const std::string& url, const CapabilityFilter& filter) { 335 void RunApplication(const std::string& url, const CapabilityFilter& filter) {
336 ServiceProviderPtr services; 336 ServiceProviderPtr services;
337 337
338 // We expose Validator to the test application via ConnectToApplication 338 // We expose Validator to the test application via ConnectToApplication
339 // because we don't allow the test application to connect to test:validator. 339 // because we don't allow the test application to connect to test:validator.
340 // Adding it to the CapabilityFilter would interfere with the test. 340 // Adding it to the CapabilityFilter would interfere with the test.
341 ServiceProviderPtr exposed_services; 341 ServiceProviderPtr exposed_services;
342 (new ServiceProviderImpl(GetProxy(&exposed_services)))-> 342 (new ServiceProviderImpl(GetProxy(&exposed_services)))->
343 AddService<Validator>(validator_); 343 AddService<Validator>(validator_);
344 URLRequestPtr request(URLRequest::New());
345 request->url = String::From(url);
346
347 scoped_ptr<ConnectToApplicationParams> params( 344 scoped_ptr<ConnectToApplicationParams> params(
348 new ConnectToApplicationParams); 345 new ConnectToApplicationParams);
349 params->SetURLInfo(request.Pass()); 346 params->SetTarget(Identity(GURL(url), std::string(), filter));
350 params->set_services(GetProxy(&services)); 347 params->set_services(GetProxy(&services));
351 params->set_exposed_services(exposed_services.Pass()); 348 params->set_exposed_services(exposed_services.Pass());
352 params->set_filter(filter);
353 params->set_on_application_end(base::MessageLoop::QuitWhenIdleClosure()); 349 params->set_on_application_end(base::MessageLoop::QuitWhenIdleClosure());
354 application_manager_->ConnectToApplication(params.Pass()); 350 application_manager_->ConnectToApplication(params.Pass());
355 } 351 }
356 352
357 void InitValidator(const std::set<std::string>& expectations) { 353 void InitValidator(const std::set<std::string>& expectations) {
358 validator_ = new ConnectionValidator(expectations, &loop_); 354 validator_ = new ConnectionValidator(expectations, &loop_);
359 application_manager()->SetLoaderForURL(make_scoped_ptr(validator_), 355 application_manager()->SetLoaderForURL(make_scoped_ptr(validator_),
360 GURL("test:validator")); 356 GURL("test:validator"));
361 } 357 }
362 358
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 391
396 // Overridden from testing::Test: 392 // Overridden from testing::Test:
397 void SetUp() override { 393 void SetUp() override {
398 test_package_manager_ = new CFTestPackageManager; 394 test_package_manager_ = new CFTestPackageManager;
399 application_manager_.reset( 395 application_manager_.reset(
400 new ApplicationManager(make_scoped_ptr(test_package_manager_))); 396 new ApplicationManager(make_scoped_ptr(test_package_manager_)));
401 CreateLoader<ServiceApplication>("test:service"); 397 CreateLoader<ServiceApplication>("test:service");
402 CreateLoader<ServiceApplication>("test:service2"); 398 CreateLoader<ServiceApplication>("test:service2");
403 } 399 }
404 void TearDown() override { 400 void TearDown() override {
401 test_package_manager_->set_use_test_fetcher(false);
405 application_manager_.reset(); 402 application_manager_.reset();
406 test_package_manager_->set_use_test_fetcher(false);
407 } 403 }
408 404
409 private: 405 private:
410 template<class T> 406 template<class T>
411 scoped_ptr<ApplicationDelegate> CreateApplicationDelegate() { 407 scoped_ptr<ApplicationDelegate> CreateApplicationDelegate() {
412 return scoped_ptr<ApplicationDelegate>(new T); 408 return scoped_ptr<ApplicationDelegate>(new T);
413 } 409 }
414 410
415 CFTestPackageManager* test_package_manager_; 411 CFTestPackageManager* test_package_manager_;
416 base::ShadowingAtExitManager at_exit_; 412 base::ShadowingAtExitManager at_exit_;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 RunTest(); 542 RunTest();
547 } 543 }
548 544
549 TEST_F(CapabilityFilter_WildcardsTest, ContentHandler) { 545 TEST_F(CapabilityFilter_WildcardsTest, ContentHandler) {
550 RunContentHandlerTest(); 546 RunContentHandlerTest();
551 } 547 }
552 548
553 } // namespace 549 } // namespace
554 } // namespace shell 550 } // namespace shell
555 } // namespace mojo 551 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/capability_filter.cc ('k') | mojo/shell/connect_to_application_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698