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 22 matching lines...) Expand all Loading... |
33 explicit ShellGrabber(InterfaceRequest<Application> application_request) | 33 explicit ShellGrabber(InterfaceRequest<Application> application_request) |
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, const mojo::String& url) override { |
44 Array<String> args, | |
45 const mojo::String& url) override { | |
46 g_url = url; | 44 g_url = url; |
47 g_application_request = binding_.Unbind(); | 45 g_application_request = binding_.Unbind(); |
48 g_shell = shell.Pass(); | 46 g_shell = shell.Pass(); |
49 } | 47 } |
50 | 48 |
51 void AcceptConnection(const String& requestor_url, | 49 void AcceptConnection(const String& requestor_url, |
52 InterfaceRequest<ServiceProvider> services, | 50 InterfaceRequest<ServiceProvider> services, |
53 ServiceProviderPtr exposed_services, | 51 ServiceProviderPtr exposed_services, |
54 const String& url) override { | 52 const String& url) override { |
55 MOJO_CHECK(false); | 53 MOJO_CHECK(false); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 if (ShouldCreateDefaultRunLoop()) | 118 if (ShouldCreateDefaultRunLoop()) |
121 Environment::InstantiateDefaultRunLoop(); | 119 Environment::InstantiateDefaultRunLoop(); |
122 | 120 |
123 MOJO_CHECK(g_application_request.is_pending()); | 121 MOJO_CHECK(g_application_request.is_pending()); |
124 MOJO_CHECK(g_shell); | 122 MOJO_CHECK(g_shell); |
125 | 123 |
126 // New applications are constructed for each test to avoid persisting state. | 124 // New applications are constructed for each test to avoid persisting state. |
127 application_impl_ = new ApplicationImpl(GetApplicationDelegate(), | 125 application_impl_ = new ApplicationImpl(GetApplicationDelegate(), |
128 g_application_request.Pass()); | 126 g_application_request.Pass()); |
129 | 127 |
130 // Fake application initialization with the given command line arguments. | 128 // Fake application initialization. |
131 Array<String> empty_args; | 129 application_impl_->Initialize(g_shell.Pass(), g_url); |
132 application_impl_->Initialize(g_shell.Pass(), empty_args.Clone(), g_url); | |
133 } | 130 } |
134 | 131 |
135 void ApplicationTestBase::TearDown() { | 132 void ApplicationTestBase::TearDown() { |
136 MOJO_CHECK(!g_application_request.is_pending()); | 133 MOJO_CHECK(!g_application_request.is_pending()); |
137 MOJO_CHECK(!g_shell); | 134 MOJO_CHECK(!g_shell); |
138 | 135 |
139 application_impl_->UnbindConnections(&g_application_request, &g_shell); | 136 application_impl_->UnbindConnections(&g_application_request, &g_shell); |
140 delete application_impl_; | 137 delete application_impl_; |
141 if (ShouldCreateDefaultRunLoop()) | 138 if (ShouldCreateDefaultRunLoop()) |
142 Environment::DestroyDefaultRunLoop(); | 139 Environment::DestroyDefaultRunLoop(); |
143 } | 140 } |
144 | 141 |
145 bool ApplicationTestBase::ShouldCreateDefaultRunLoop() { | 142 bool ApplicationTestBase::ShouldCreateDefaultRunLoop() { |
146 return true; | 143 return true; |
147 } | 144 } |
148 | 145 |
149 } // namespace test | 146 } // namespace test |
150 } // namespace mojo | 147 } // namespace mojo |
OLD | NEW |