| 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 "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "mojo/application/public/cpp/application_connection.h" | 9 #include "mojo/application/public/cpp/application_connection.h" |
| 10 #include "mojo/application/public/cpp/application_impl.h" | 10 #include "mojo/application/public/cpp/application_impl.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 public: | 111 public: |
| 112 ServiceApplication() : app_(nullptr) {} | 112 ServiceApplication() : app_(nullptr) {} |
| 113 ~ServiceApplication() override {} | 113 ~ServiceApplication() override {} |
| 114 | 114 |
| 115 private: | 115 private: |
| 116 // Overridden from ApplicationDelegate: | 116 // Overridden from ApplicationDelegate: |
| 117 void Initialize(ApplicationImpl* app) override { | 117 void Initialize(ApplicationImpl* app) override { |
| 118 app_ = app; | 118 app_ = app; |
| 119 // ServiceApplications have no capability filter and can thus connect | 119 // ServiceApplications have no capability filter and can thus connect |
| 120 // directly to the validator application. | 120 // directly to the validator application. |
| 121 URLRequestPtr request(URLRequest::New()); | 121 app_->ConnectToService("test:validator", &validator_); |
| 122 request->url = String::From("test:validator"); | |
| 123 app_->ConnectToService(request.Pass(), &validator_); | |
| 124 } | 122 } |
| 125 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { | 123 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { |
| 126 AddService<Safe>(connection); | 124 AddService<Safe>(connection); |
| 127 AddService<Unsafe>(connection); | 125 AddService<Unsafe>(connection); |
| 128 return true; | 126 return true; |
| 129 } | 127 } |
| 130 | 128 |
| 131 // Overridden from InterfaceFactory<Safe>: | 129 // Overridden from InterfaceFactory<Safe>: |
| 132 void Create(ApplicationConnection* connection, | 130 void Create(ApplicationConnection* connection, |
| 133 InterfaceRequest<Safe> request) override { | 131 InterfaceRequest<Safe> request) override { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 163 TestApplication::~TestApplication() {} | 161 TestApplication::~TestApplication() {} |
| 164 | 162 |
| 165 void TestApplication::Initialize(ApplicationImpl* app) { | 163 void TestApplication::Initialize(ApplicationImpl* app) { |
| 166 app_ = app; | 164 app_ = app; |
| 167 } | 165 } |
| 168 bool TestApplication::ConfigureIncomingConnection( | 166 bool TestApplication::ConfigureIncomingConnection( |
| 169 ApplicationConnection* connection) { | 167 ApplicationConnection* connection) { |
| 170 // TestApplications receive their Validator via the inbound connection. | 168 // TestApplications receive their Validator via the inbound connection. |
| 171 connection->ConnectToService(&validator_); | 169 connection->ConnectToService(&validator_); |
| 172 | 170 |
| 173 URLRequestPtr request(URLRequest::New()); | 171 connection1_ = app_->ConnectToApplication("test:service"); |
| 174 request->url = String::From("test:service"); | |
| 175 connection1_ = app_->ConnectToApplication(request.Pass()); | |
| 176 connection1_->SetRemoteServiceProviderConnectionErrorHandler( | 172 connection1_->SetRemoteServiceProviderConnectionErrorHandler( |
| 177 base::Bind(&TestApplication::ConnectionClosed, | 173 base::Bind(&TestApplication::ConnectionClosed, |
| 178 base::Unretained(this), "test:service")); | 174 base::Unretained(this), "test:service")); |
| 179 | 175 |
| 180 URLRequestPtr request2(URLRequest::New()); | 176 connection2_ = app_->ConnectToApplication("test:service2"); |
| 181 request2->url = String::From("test:service2"); | |
| 182 connection2_ = app_->ConnectToApplication(request2.Pass()); | |
| 183 connection2_->SetRemoteServiceProviderConnectionErrorHandler( | 177 connection2_->SetRemoteServiceProviderConnectionErrorHandler( |
| 184 base::Bind(&TestApplication::ConnectionClosed, | 178 base::Bind(&TestApplication::ConnectionClosed, |
| 185 base::Unretained(this), "test:service2")); | 179 base::Unretained(this), "test:service2")); |
| 186 return true; | 180 return true; |
| 187 } | 181 } |
| 188 | 182 |
| 189 void TestApplication::ConnectionClosed(const std::string& service_url) { | 183 void TestApplication::ConnectionClosed(const std::string& service_url) { |
| 190 validator_->ConnectionClosed(app_->url(), service_url); | 184 validator_->ConnectionClosed(app_->url(), service_url); |
| 191 } | 185 } |
| 192 | 186 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 void CapabilityFilterTest::RunTest() { | 317 void CapabilityFilterTest::RunTest() { |
| 324 loop()->Run(); | 318 loop()->Run(); |
| 325 EXPECT_TRUE(validator_->expectations_met()); | 319 EXPECT_TRUE(validator_->expectations_met()); |
| 326 if (!validator_->expectations_met()) | 320 if (!validator_->expectations_met()) |
| 327 validator_->PrintUnmetExpectations(); | 321 validator_->PrintUnmetExpectations(); |
| 328 } | 322 } |
| 329 | 323 |
| 330 } // namespace test | 324 } // namespace test |
| 331 } // namespace shell | 325 } // namespace shell |
| 332 } // namespace mojo | 326 } // namespace mojo |
| OLD | NEW |