| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/public/cpp/application/application_test_base.h" | 5 #include "mojo/public/cpp/application/application_test_base.h" |
| 6 | 6 |
| 7 #include "mojo/public/cpp/application/application_impl.h" | 7 #include "mojo/public/cpp/application/application_impl.h" |
| 8 #include "mojo/public/cpp/bindings/binding.h" | 8 #include "mojo/public/cpp/bindings/binding.h" |
| 9 #include "mojo/public/cpp/environment/environment.h" | 9 #include "mojo/public/cpp/environment/environment.h" |
| 10 #include "mojo/public/cpp/system/message_pipe.h" | 10 #include "mojo/public/cpp/system/message_pipe.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 InterfaceRequest<Application> application_request) | 40 InterfaceRequest<Application> application_request) |
| 41 : args_(args), binding_(this, application_request.Pass()) {} | 41 : args_(args), binding_(this, application_request.Pass()) {} |
| 42 | 42 |
| 43 void WaitForInitialize() { | 43 void WaitForInitialize() { |
| 44 // Initialize is always the first call made on Application. | 44 // Initialize is always the first call made on Application. |
| 45 MOJO_CHECK(binding_.WaitForIncomingMethodCall()); | 45 MOJO_CHECK(binding_.WaitForIncomingMethodCall()); |
| 46 } | 46 } |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 // Application implementation. | 49 // Application implementation. |
| 50 void Initialize(ShellPtr shell, Array<String> args) override { | 50 void Initialize(ShellPtr shell, |
| 51 Array<String> args, |
| 52 const mojo::String& url) override { |
| 51 *args_ = args.Pass(); | 53 *args_ = args.Pass(); |
| 52 g_application_request = binding_.Unbind(); | 54 g_application_request = binding_.Unbind(); |
| 53 g_shell = shell.Pass(); | 55 g_shell = shell.Pass(); |
| 54 } | 56 } |
| 55 | 57 |
| 56 void AcceptConnection(const String& requestor_url, | 58 void AcceptConnection(const String& requestor_url, |
| 57 InterfaceRequest<ServiceProvider> services, | 59 InterfaceRequest<ServiceProvider> services, |
| 58 ServiceProviderPtr exposed_services) override { | 60 ServiceProviderPtr exposed_services) override { |
| 59 MOJO_CHECK(false); | 61 MOJO_CHECK(false); |
| 60 } | 62 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 Environment::InstantiateDefaultRunLoop(); | 132 Environment::InstantiateDefaultRunLoop(); |
| 131 | 133 |
| 132 MOJO_CHECK(g_application_request.is_pending()); | 134 MOJO_CHECK(g_application_request.is_pending()); |
| 133 MOJO_CHECK(g_shell); | 135 MOJO_CHECK(g_shell); |
| 134 | 136 |
| 135 // New applications are constructed for each test to avoid persisting state. | 137 // New applications are constructed for each test to avoid persisting state. |
| 136 application_impl_ = new ApplicationImpl(GetApplicationDelegate(), | 138 application_impl_ = new ApplicationImpl(GetApplicationDelegate(), |
| 137 g_application_request.Pass()); | 139 g_application_request.Pass()); |
| 138 | 140 |
| 139 // Fake application initialization with the given command line arguments. | 141 // Fake application initialization with the given command line arguments. |
| 140 application_impl_->Initialize(g_shell.Pass(), g_args.Clone()); | 142 application_impl_->Initialize(g_shell.Pass(), g_args.Clone(), ""); |
| 141 } | 143 } |
| 142 | 144 |
| 143 void ApplicationTestBase::TearDown() { | 145 void ApplicationTestBase::TearDown() { |
| 144 MOJO_CHECK(!g_application_request.is_pending()); | 146 MOJO_CHECK(!g_application_request.is_pending()); |
| 145 MOJO_CHECK(!g_shell); | 147 MOJO_CHECK(!g_shell); |
| 146 | 148 |
| 147 application_impl_->UnbindConnections(&g_application_request, &g_shell); | 149 application_impl_->UnbindConnections(&g_application_request, &g_shell); |
| 148 delete application_impl_; | 150 delete application_impl_; |
| 149 if (ShouldCreateDefaultRunLoop()) | 151 if (ShouldCreateDefaultRunLoop()) |
| 150 Environment::DestroyDefaultRunLoop(); | 152 Environment::DestroyDefaultRunLoop(); |
| 151 } | 153 } |
| 152 | 154 |
| 153 bool ApplicationTestBase::ShouldCreateDefaultRunLoop() { | 155 bool ApplicationTestBase::ShouldCreateDefaultRunLoop() { |
| 154 return true; | 156 return true; |
| 155 } | 157 } |
| 156 | 158 |
| 157 } // namespace test | 159 } // namespace test |
| 158 } // namespace mojo | 160 } // namespace mojo |
| OLD | NEW |