Chromium Code Reviews| Index: mojo/application_manager/application_manager_unittest.cc |
| diff --git a/mojo/application_manager/application_manager_unittest.cc b/mojo/application_manager/application_manager_unittest.cc |
| index c276f2e4d0b8911b73138bae6ddab919182ba6e9..18b8ae072b8fca034d3043f0b7175f92745f20f9 100644 |
| --- a/mojo/application_manager/application_manager_unittest.cc |
| +++ b/mojo/application_manager/application_manager_unittest.cc |
| @@ -5,10 +5,10 @@ |
| #include "base/at_exit.h" |
| #include "base/bind.h" |
| #include "base/macros.h" |
| +#include "base/memory/scoped_vector.h" |
| #include "base/message_loop/message_loop.h" |
| #include "mojo/application_manager/application_loader.h" |
| #include "mojo/application_manager/application_manager.h" |
| -#include "mojo/application_manager/background_shell_application_loader.h" |
| #include "mojo/application_manager/test.mojom.h" |
| #include "mojo/public/cpp/application/application_connection.h" |
| #include "mojo/public/cpp/application/application_delegate.h" |
| @@ -84,7 +84,7 @@ class TestClientImpl : public TestClient { |
| base::MessageLoop::current()->Quit(); |
| } |
| - void Test(std::string test_string) { |
| + void Test(const std::string& test_string) { |
| quit_after_ack_ = true; |
| service_->Test(test_string); |
| } |
| @@ -238,7 +238,7 @@ class TesterContext { |
| }; |
| // Used to test that the requestor url will be correctly passed. |
| -class TestAImpl : public InterfaceImpl<TestA> { |
| +class TestAImpl : public TestA { |
| public: |
| TestAImpl(ApplicationConnection* connection, TesterContext* test_context) |
| : test_context_(test_context) { |
| @@ -324,6 +324,11 @@ class Tester : public ApplicationDelegate, |
| ~Tester() override {} |
| private: |
| + struct TestABinding { |
|
qsr
2014/12/18 08:58:34
I'm perfectly fine with this, but you could have o
sky
2014/12/18 16:46:55
Good point. I went with your second suggestion.
|
| + scoped_ptr<TestAImpl> a; |
| + scoped_ptr<Binding<TestA>> binding; |
| + }; |
| + |
| void Load(ApplicationManager* manager, |
| const GURL& url, |
| ScopedMessagePipeHandle shell_handle, |
| @@ -359,7 +364,11 @@ class Tester : public ApplicationDelegate, |
| void Create(ApplicationConnection* connection, |
| InterfaceRequest<TestA> request) override { |
| - BindToRequest(new TestAImpl(connection, context_), &request); |
| + scoped_ptr<TestABinding> binding(new TestABinding); |
| + binding->a.reset(new TestAImpl(connection, context_)); |
| + binding->binding.reset(new Binding<TestA>(binding->a.get(), |
| + request.Pass())); |
| + a_bindings_.push_back(binding.release()); |
| } |
| void Create(ApplicationConnection* connection, |
| @@ -375,6 +384,7 @@ class Tester : public ApplicationDelegate, |
| TesterContext* context_; |
| scoped_ptr<ApplicationImpl> app_; |
| std::string requestor_url_; |
| + ScopedVector<TestABinding> a_bindings_; |
| }; |
| class TestServiceInterceptor : public ApplicationManager::Interceptor { |
| @@ -450,19 +460,9 @@ class ApplicationManagerTest : public testing::Test { |
| application_manager_.reset(NULL); |
| } |
| - scoped_ptr<BackgroundShellApplicationLoader> MakeLoader( |
| - const std::string& requestor_url) { |
| - scoped_ptr<ApplicationLoader> real_loader( |
| - new Tester(&tester_context_, requestor_url)); |
| - scoped_ptr<BackgroundShellApplicationLoader> loader( |
| - new BackgroundShellApplicationLoader(real_loader.Pass(), |
| - std::string(), |
| - base::MessageLoop::TYPE_DEFAULT)); |
| - return loader.Pass(); |
| - } |
| - |
| void AddLoaderForURL(const GURL& url, const std::string& requestor_url) { |
| - application_manager_->SetLoaderForURL(MakeLoader(requestor_url), url); |
| + application_manager_->SetLoaderForURL( |
| + make_scoped_ptr(new Tester(&tester_context_, requestor_url)), url); |
| } |
| bool HasFactoryForTestURL() { |