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

Side by Side Diff: mojo/examples/apptest/example_apptest.cc

Issue 626033003: Plumb commandline arguments for mojo_example_apptests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@example_apptests_init
Patch Set: Include <limits.h> Created 6 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <limits.h>
6
5 #include "mojo/examples/apptest/example_client_application.h" 7 #include "mojo/examples/apptest/example_client_application.h"
6 #include "mojo/examples/apptest/example_client_impl.h" 8 #include "mojo/examples/apptest/example_client_impl.h"
7 #include "mojo/examples/apptest/example_service.mojom.h" 9 #include "mojo/examples/apptest/example_service.mojom.h"
8 #include "mojo/public/c/system/main.h" 10 #include "mojo/public/c/system/main.h"
9 #include "mojo/public/cpp/application/application_impl.h" 11 #include "mojo/public/cpp/application/application_impl.h"
12 #include "mojo/public/cpp/bindings/array.h"
10 #include "mojo/public/cpp/bindings/callback.h" 13 #include "mojo/public/cpp/bindings/callback.h"
14 #include "mojo/public/cpp/bindings/string.h"
11 #include "mojo/public/cpp/environment/environment.h" 15 #include "mojo/public/cpp/environment/environment.h"
16 #include "mojo/public/cpp/environment/logging.h"
12 #include "mojo/public/cpp/system/macros.h" 17 #include "mojo/public/cpp/system/macros.h"
13 #include "mojo/public/cpp/utility/run_loop.h" 18 #include "mojo/public/cpp/utility/run_loop.h"
14 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
15 20
16 namespace { 21 namespace {
17 22
18 // TODO(msw): Remove this once we can get ApplicationImpl from TLS. 23 // TODO(msw): Remove this once we can get ApplicationImpl from TLS.
19 mojo::ApplicationImpl* g_application_impl_hack = NULL; 24 mojo::ApplicationImpl* g_application_impl_hack = NULL;
20 25
21 } // namespace 26 } // namespace
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 MojoResult MojoMain(MojoHandle shell_handle) { 87 MojoResult MojoMain(MojoHandle shell_handle) {
83 mojo::Environment env; 88 mojo::Environment env;
84 // TODO(msw): Destroy this ambient RunLoop before running tests. 89 // TODO(msw): Destroy this ambient RunLoop before running tests.
85 // Need to CancelWait() / PassMessagePipe() from the ShellPtr? 90 // Need to CancelWait() / PassMessagePipe() from the ShellPtr?
86 mojo::RunLoop loop; 91 mojo::RunLoop loop;
87 mojo::ApplicationDelegate* delegate = new mojo::ExampleClientApplication(); 92 mojo::ApplicationDelegate* delegate = new mojo::ExampleClientApplication();
88 mojo::ApplicationImpl app(delegate, shell_handle); 93 mojo::ApplicationImpl app(delegate, shell_handle);
89 g_application_impl_hack = &app; 94 g_application_impl_hack = &app;
90 MOJO_CHECK(app.WaitForInitialize()); 95 MOJO_CHECK(app.WaitForInitialize());
91 96
92 // TODO(msw): Plumb commandline arguments through app->args(). 97 {
93 int argc = 0; 98 // InitGoogleTest expects (argc + 1) elements, including a terminating NULL.
94 char** argv = NULL; 99 // It also removes GTEST arguments from |argv| and updates the |argc| count.
95 testing::InitGoogleTest(&argc, argv); 100 const mojo::Array<mojo::String>& args = app.args();
101 MOJO_CHECK(args.size() < INT_MAX);
102 int argc = static_cast<int>(args.size());
103 std::vector<char*> argv(argc + 1);
104 for (int i = 0; i < argc; ++i)
105 argv[i] = const_cast<char*>(args[i].data());
106 argv[argc] = NULL;
107 testing::InitGoogleTest(&argc, &argv[0]);
108 }
109
96 mojo_ignore_result(RUN_ALL_TESTS()); 110 mojo_ignore_result(RUN_ALL_TESTS());
97 111
98 delete delegate; 112 delete delegate;
99 return MOJO_RESULT_OK; 113 return MOJO_RESULT_OK;
100 } 114 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698