Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(486)

Side by Side Diff: mojo/public/cpp/application/lib/application_test_base.cc

Issue 905583002: Pass the final URL an app was loaded from to the app in Initialize(). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: o Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « mojo/public/cpp/application/lib/application_impl.cc ('k') | mojo/public/dart/src/application.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698