| 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 "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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 void PrintUnmetExpectations() { | 51 void PrintUnmetExpectations() { |
| 52 for (auto expectation : expectations_) | 52 for (auto expectation : expectations_) |
| 53 ADD_FAILURE() << "Unmet: " << expectation; | 53 ADD_FAILURE() << "Unmet: " << expectation; |
| 54 for (auto unexpected : unexpected_) | 54 for (auto unexpected : unexpected_) |
| 55 ADD_FAILURE() << "Unexpected: " << unexpected; | 55 ADD_FAILURE() << "Unexpected: " << unexpected; |
| 56 } | 56 } |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 // Overridden from ApplicationLoader: | 59 // Overridden from ApplicationLoader: |
| 60 void Load(const GURL& url, InterfaceRequest<Application> request) override { | 60 void Load(const GURL& url, InterfaceRequest<Application> request) override { |
| 61 app_.reset(new ApplicationImpl(this, request.Pass())); | 61 app_.reset(new ApplicationImpl(this, request.Pass(), |
| 62 base::MessageLoop::QuitWhenIdleClosure())); |
| 62 } | 63 } |
| 63 | 64 |
| 64 // Overridden from ApplicationDelegate: | 65 // Overridden from ApplicationDelegate: |
| 65 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { | 66 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { |
| 66 connection->AddService<Validator>(this); | 67 connection->AddService<Validator>(this); |
| 67 return true; | 68 return true; |
| 68 } | 69 } |
| 69 | 70 |
| 70 // Overridden from InterfaceFactory<Validator>: | 71 // Overridden from InterfaceFactory<Validator>: |
| 71 void Create(ApplicationConnection* connection, | 72 void Create(ApplicationConnection* connection, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 // Overridden from InterfaceFactory<ContentHandler>: | 176 // Overridden from InterfaceFactory<ContentHandler>: |
| 176 void Create(ApplicationConnection* connection, | 177 void Create(ApplicationConnection* connection, |
| 177 InterfaceRequest<ContentHandler> request) override { | 178 InterfaceRequest<ContentHandler> request) override { |
| 178 bindings_.AddBinding(this, request.Pass()); | 179 bindings_.AddBinding(this, request.Pass()); |
| 179 } | 180 } |
| 180 | 181 |
| 181 // Overridden from ContentHandler: | 182 // Overridden from ContentHandler: |
| 182 void StartApplication(InterfaceRequest<Application> application, | 183 void StartApplication(InterfaceRequest<Application> application, |
| 183 URLResponsePtr response) override { | 184 URLResponsePtr response) override { |
| 184 embedded_apps_.push_back( | 185 embedded_apps_.push_back( |
| 185 new ApplicationImpl(new TestApplication, application.Pass())); | 186 new ApplicationImpl(new TestApplication, application.Pass(), |
| 187 base::MessageLoop::QuitWhenIdleClosure())); |
| 186 } | 188 } |
| 187 | 189 |
| 188 ApplicationImpl* app_; | 190 ApplicationImpl* app_; |
| 189 WeakBindingSet<ContentHandler> bindings_; | 191 WeakBindingSet<ContentHandler> bindings_; |
| 190 ScopedVector<ApplicationImpl> embedded_apps_; | 192 ScopedVector<ApplicationImpl> embedded_apps_; |
| 191 | 193 |
| 192 DISALLOW_COPY_AND_ASSIGN(TestContentHandler); | 194 DISALLOW_COPY_AND_ASSIGN(TestContentHandler); |
| 193 }; | 195 }; |
| 194 | 196 |
| 195 // This class models a system service that exposes two interfaces, Safe and | 197 // This class models a system service that exposes two interfaces, Safe and |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 }; | 315 }; |
| 314 | 316 |
| 315 class TestLoader : public ApplicationLoader { | 317 class TestLoader : public ApplicationLoader { |
| 316 public: | 318 public: |
| 317 explicit TestLoader(ApplicationDelegate* delegate) : delegate_(delegate) {} | 319 explicit TestLoader(ApplicationDelegate* delegate) : delegate_(delegate) {} |
| 318 ~TestLoader() override {} | 320 ~TestLoader() override {} |
| 319 | 321 |
| 320 private: | 322 private: |
| 321 // Overridden from ApplicationLoader: | 323 // Overridden from ApplicationLoader: |
| 322 void Load(const GURL& url, InterfaceRequest<Application> request) override { | 324 void Load(const GURL& url, InterfaceRequest<Application> request) override { |
| 323 app_.reset(new ApplicationImpl(delegate_.get(), request.Pass())); | 325 app_.reset(new ApplicationImpl(delegate_.get(), request.Pass(), |
| 326 base::MessageLoop::QuitWhenIdleClosure())); |
| 324 } | 327 } |
| 325 | 328 |
| 326 scoped_ptr<ApplicationDelegate> delegate_; | 329 scoped_ptr<ApplicationDelegate> delegate_; |
| 327 scoped_ptr<ApplicationImpl> app_; | 330 scoped_ptr<ApplicationImpl> app_; |
| 328 | 331 |
| 329 DISALLOW_COPY_AND_ASSIGN(TestLoader); | 332 DISALLOW_COPY_AND_ASSIGN(TestLoader); |
| 330 }; | 333 }; |
| 331 | 334 |
| 332 class CapabilityFilterTest : public testing::Test { | 335 class CapabilityFilterTest : public testing::Test { |
| 333 public: | 336 public: |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 RunTest(); | 545 RunTest(); |
| 543 } | 546 } |
| 544 | 547 |
| 545 TEST_F(CapabilityFilter_WildcardsTest, ContentHandler) { | 548 TEST_F(CapabilityFilter_WildcardsTest, ContentHandler) { |
| 546 RunContentHandlerTest(); | 549 RunContentHandlerTest(); |
| 547 } | 550 } |
| 548 | 551 |
| 549 } // namespace | 552 } // namespace |
| 550 } // namespace shell | 553 } // namespace shell |
| 551 } // namespace mojo | 554 } // namespace mojo |
| OLD | NEW |