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

Unified Diff: mojo/public/cpp/application/lib/application_test_base.cc

Issue 744973002: Pass command line args to apptests (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: switch to using --args-for to pass arguments to apptests Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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..f1572725b0bd01f861515f86d622c4da76a32b28 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,13 +34,30 @@ 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()
+ : args_(mojo::test::Args().Clone()), application_impl_(nullptr) {
msw 2014/11/22 18:23:38 Namespace not needed.
Chris Masone 2014/11/22 20:14:44 Done.
}
ApplicationTestBase::~ApplicationTestBase() {
}
+void ApplicationTestBase::SetUpWithArgs(Array<String> args) {
+ args_.Swap(&args);
+ SetUp();
msw 2014/11/22 18:23:38 Flip this around, have SetUp call SetUpWithArgs(Ar
Chris Masone 2014/11/22 20:14:44 Done.
+}
+
void ApplicationTestBase::SetUp() {
// A run loop is needed for ApplicationImpl initialization and communication.
Environment::InstantiateDefaultRunLoop();

Powered by Google App Engine
This is Rietveld 408576698