| Index: mojo/public/cpp/application/lib/application_test_base.cc
|
| diff --git a/mojo/public/cpp/application/lib/application_test_base.cc b/mojo/public/cpp/application/lib/application_test_base.cc
|
| index 42dbda550f70dd04e97bf2680a718a05de23995d..35442497cef5c38112c27e345df8618630de297b 100644
|
| --- a/mojo/public/cpp/application/lib/application_test_base.cc
|
| +++ b/mojo/public/cpp/application/lib/application_test_base.cc
|
| @@ -7,7 +7,6 @@
|
| #include "mojo/public/cpp/application/application_delegate.h"
|
| #include "mojo/public/cpp/application/application_impl.h"
|
| #include "mojo/public/cpp/environment/environment.h"
|
| -#include "mojo/public/cpp/environment/logging.h"
|
| #include "mojo/public/cpp/system/message_pipe.h"
|
|
|
| namespace mojo {
|
| @@ -17,6 +16,8 @@ namespace {
|
|
|
| // This shell handle is shared by multiple test application instances.
|
| MessagePipeHandle g_shell_handle;
|
| +// Share the application command-line arguments with multiple application tests.
|
| +Array<String> g_args;
|
|
|
| } // namespace
|
|
|
| @@ -33,14 +34,25 @@ void SetShellHandle(ScopedMessagePipeHandle handle) {
|
| g_shell_handle = handle.release();
|
| }
|
|
|
| -ApplicationTestBase::ApplicationTestBase(Array<String> args)
|
| - : args_(args.Pass()), application_impl_(nullptr) {
|
| +const Array<String>& Args() {
|
| + return g_args;
|
| +}
|
| +
|
| +void InitializeArgs(int argc, std::vector<const char*> argv) {
|
| + MOJO_CHECK(g_args.is_null());
|
| + for (const char* arg : argv) {
|
| + if (arg)
|
| + g_args.push_back(arg);
|
| + }
|
| +}
|
| +
|
| +ApplicationTestBase::ApplicationTestBase() : application_impl_(nullptr) {
|
| }
|
|
|
| ApplicationTestBase::~ApplicationTestBase() {
|
| }
|
|
|
| -void ApplicationTestBase::SetUp() {
|
| +void ApplicationTestBase::SetUpWithArgs(const Array<String>& args) {
|
| // A run loop is needed for ApplicationImpl initialization and communication.
|
| Environment::InstantiateDefaultRunLoop();
|
|
|
| @@ -49,7 +61,11 @@ void ApplicationTestBase::SetUp() {
|
| PassShellHandle());
|
|
|
| // Fake application initialization with the given command line arguments.
|
| - application_impl_->Initialize(args_.Clone());
|
| + application_impl_->Initialize(args.Clone());
|
| +}
|
| +
|
| +void ApplicationTestBase::SetUp() {
|
| + SetUpWithArgs(Args());
|
| }
|
|
|
| void ApplicationTestBase::TearDown() {
|
|
|