Chromium Code Reviews| 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/application/application_test_base_chromium.h" | 5 #include "mojo/application/application_test_base_chromium.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "mojo/application/public/cpp/application_impl.h" | 9 #include "mojo/application/public/cpp/application_impl.h" |
| 10 #include "mojo/application/public/interfaces/application.mojom.h" | 10 #include "mojo/application/public/interfaces/application.mojom.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 : binding_(this, application_request.Pass()) {} | 34 : binding_(this, application_request.Pass()) {} |
| 35 | 35 |
| 36 void WaitForInitialize() { | 36 void WaitForInitialize() { |
| 37 // Initialize is always the first call made on Application. | 37 // Initialize is always the first call made on Application. |
| 38 MOJO_CHECK(binding_.WaitForIncomingMethodCall()); | 38 MOJO_CHECK(binding_.WaitForIncomingMethodCall()); |
| 39 } | 39 } |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 // Application implementation. | 42 // Application implementation. |
| 43 void Initialize(ShellPtr shell, | 43 void Initialize(ShellPtr shell, |
| 44 Array<String> args, | |
| 45 const mojo::String& url) override { | 44 const mojo::String& url) override { |
|
msw
2015/05/19 17:45:27
nit: fits on line above.
jam
2015/05/19 20:56:36
Done.
| |
| 46 g_url = url; | 45 g_url = url; |
| 47 g_application_request = binding_.Unbind(); | 46 g_application_request = binding_.Unbind(); |
| 48 g_shell = shell.Pass(); | 47 g_shell = shell.Pass(); |
| 49 } | 48 } |
| 50 | 49 |
| 51 void AcceptConnection(const String& requestor_url, | 50 void AcceptConnection(const String& requestor_url, |
| 52 InterfaceRequest<ServiceProvider> services, | 51 InterfaceRequest<ServiceProvider> services, |
| 53 ServiceProviderPtr exposed_services, | 52 ServiceProviderPtr exposed_services, |
| 54 const String& url) override { | 53 const String& url) override { |
| 55 MOJO_CHECK(false); | 54 MOJO_CHECK(false); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 if (ShouldCreateDefaultRunLoop()) | 119 if (ShouldCreateDefaultRunLoop()) |
| 121 Environment::InstantiateDefaultRunLoop(); | 120 Environment::InstantiateDefaultRunLoop(); |
| 122 | 121 |
| 123 MOJO_CHECK(g_application_request.is_pending()); | 122 MOJO_CHECK(g_application_request.is_pending()); |
| 124 MOJO_CHECK(g_shell); | 123 MOJO_CHECK(g_shell); |
| 125 | 124 |
| 126 // New applications are constructed for each test to avoid persisting state. | 125 // New applications are constructed for each test to avoid persisting state. |
| 127 application_impl_ = new ApplicationImpl(GetApplicationDelegate(), | 126 application_impl_ = new ApplicationImpl(GetApplicationDelegate(), |
| 128 g_application_request.Pass()); | 127 g_application_request.Pass()); |
| 129 | 128 |
| 130 // Fake application initialization with the given command line arguments. | 129 // Fake application initialization. |
| 131 Array<String> empty_args; | 130 application_impl_->Initialize(g_shell.Pass(), g_url); |
| 132 application_impl_->Initialize(g_shell.Pass(), empty_args.Clone(), g_url); | |
| 133 } | 131 } |
| 134 | 132 |
| 135 void ApplicationTestBase::TearDown() { | 133 void ApplicationTestBase::TearDown() { |
| 136 MOJO_CHECK(!g_application_request.is_pending()); | 134 MOJO_CHECK(!g_application_request.is_pending()); |
| 137 MOJO_CHECK(!g_shell); | 135 MOJO_CHECK(!g_shell); |
| 138 | 136 |
| 139 application_impl_->UnbindConnections(&g_application_request, &g_shell); | 137 application_impl_->UnbindConnections(&g_application_request, &g_shell); |
| 140 delete application_impl_; | 138 delete application_impl_; |
| 141 if (ShouldCreateDefaultRunLoop()) | 139 if (ShouldCreateDefaultRunLoop()) |
| 142 Environment::DestroyDefaultRunLoop(); | 140 Environment::DestroyDefaultRunLoop(); |
| 143 } | 141 } |
| 144 | 142 |
| 145 bool ApplicationTestBase::ShouldCreateDefaultRunLoop() { | 143 bool ApplicationTestBase::ShouldCreateDefaultRunLoop() { |
| 146 return true; | 144 return true; |
| 147 } | 145 } |
| 148 | 146 |
| 149 } // namespace test | 147 } // namespace test |
| 150 } // namespace mojo | 148 } // namespace mojo |
| OLD | NEW |