Index: mojo/application/application_test_main_chromium.cc |
diff --git a/mojo/application/application_test_main_chromium.cc b/mojo/application/application_test_main_chromium.cc |
index 4ce761a8a36ffa7a741c862cc82623a30a6f2c7e..75685edcc999c8d8a0568e676a536bb7b59b2152 100644 |
--- a/mojo/application/application_test_main_chromium.cc |
+++ b/mojo/application/application_test_main_chromium.cc |
@@ -5,6 +5,7 @@ |
#include "base/at_exit.h" |
#include "base/command_line.h" |
#include "base/test/test_timeouts.h" |
+#include "mojo/application/application_runner_chromium.h" |
#include "mojo/public/c/system/main.h" |
#include "mojo/public/cpp/application/application_test_base.h" |
@@ -12,10 +13,17 @@ MojoResult MojoMain(MojoHandle handle) { |
// An AtExitManager instance is needed to construct message loops. |
base::AtExitManager at_exit; |
- // Initialize test timeouts, which requires CommandLine::ForCurrentProcess(). |
- // TODO(msw): Plumb relevant command line args before initializing timeouts. |
- base::CommandLine::Init(0, nullptr); |
+ // Initialize test timeouts, which requires an initialized CommandLine. |
+ mojo::ApplicationRunnerChromium::InitBaseCommandLine(); |
TestTimeouts::Initialize(); |
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
+ int argc = 0; |
+ const char** argv = new const char* [command_line->argv().size()]; |
+ for (auto& arg : command_line->argv()) |
+ argv[argc++] = arg.c_str(); |
+ // TODO(msw): Avoid calling InitGoogleTest again in mojo::test::RunAllTests. |
+ testing::InitGoogleTest(&argc, const_cast<char**>(&(argv[0]))); |
+ |
return mojo::test::RunAllTests(handle); |
} |