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

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: Cleanup. 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 "mojo/examples/apptest/example_client_application.h" 5 #include "mojo/examples/apptest/example_client_application.h"
6 #include "mojo/examples/apptest/example_client_impl.h" 6 #include "mojo/examples/apptest/example_client_impl.h"
7 #include "mojo/examples/apptest/example_service.mojom.h" 7 #include "mojo/examples/apptest/example_service.mojom.h"
8 #include "mojo/public/c/system/main.h" 8 #include "mojo/public/c/system/main.h"
9 #include "mojo/public/cpp/application/application_impl.h" 9 #include "mojo/public/cpp/application/application_impl.h"
10 #include "mojo/public/cpp/bindings/callback.h" 10 #include "mojo/public/cpp/bindings/callback.h"
11 #include "mojo/public/cpp/environment/environment.h" 11 #include "mojo/public/cpp/environment/environment.h"
12 #include "mojo/public/cpp/system/macros.h" 12 #include "mojo/public/cpp/system/macros.h"
13 #include "mojo/public/cpp/utility/run_loop.h" 13 #include "mojo/public/cpp/utility/run_loop.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace { 16 namespace {
17 17
18 // TODO(msw): Remove this once we can get ApplicationImpl from TLS. 18 // TODO(msw): Remove this once we can get ApplicationImpl from TLS.
19 mojo::ApplicationImpl* g_application_impl_hack = NULL; 19 mojo::ApplicationImpl* g_application_impl_hack = NULL;
20 20
21 static const char kMojoExampleService[] = "mojo:mojo_example_service";
22
21 } // namespace 23 } // namespace
22 24
23 namespace mojo { 25 namespace mojo {
24 26
25 namespace { 27 namespace {
26 28
27 class ExampleApptest : public testing::Test { 29 class ExampleApptest : public testing::Test {
28 public: 30 public:
29 ExampleApptest() { 31 ExampleApptest() {
30 g_application_impl_hack->ConnectToService("mojo:mojo_example_service", 32 g_application_impl_hack->ConnectToService(kMojoExampleService,
31 &example_service_); 33 &example_service_);
32 example_service_.set_client(&example_client_); 34 example_service_.set_client(&example_client_);
33 } 35 }
34 36
35 virtual ~ExampleApptest() override {} 37 virtual ~ExampleApptest() override {}
36 38
37 protected: 39 protected:
38 ExampleServicePtr example_service_; 40 ExampleServicePtr example_service_;
39 ExampleClientImpl example_client_; 41 ExampleClientImpl example_client_;
40 42
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 MojoResult MojoMain(MojoHandle shell_handle) { 84 MojoResult MojoMain(MojoHandle shell_handle) {
83 mojo::Environment env; 85 mojo::Environment env;
84 // TODO(msw): Destroy this ambient RunLoop before running tests. 86 // TODO(msw): Destroy this ambient RunLoop before running tests.
85 // Need to CancelWait() / PassMessagePipe() from the ShellPtr? 87 // Need to CancelWait() / PassMessagePipe() from the ShellPtr?
86 mojo::RunLoop loop; 88 mojo::RunLoop loop;
87 mojo::ApplicationDelegate* delegate = new mojo::ExampleClientApplication(); 89 mojo::ApplicationDelegate* delegate = new mojo::ExampleClientApplication();
88 mojo::ApplicationImpl app(delegate, shell_handle); 90 mojo::ApplicationImpl app(delegate, shell_handle);
89 g_application_impl_hack = &app; 91 g_application_impl_hack = &app;
90 MOJO_CHECK(app.WaitForInitialize()); 92 MOJO_CHECK(app.WaitForInitialize());
91 93
92 // TODO(msw): Plumb commandline arguments through app->args(). 94 std::vector<std::string> args = app.args().To<std::vector<std::string> >();
93 int argc = 0; 95 int argc = args.size();
94 char** argv = NULL; 96 std::vector<char *> argv(argc);
95 testing::InitGoogleTest(&argc, argv); 97 for (int i = 0; i < argc; ++i)
hansmuller 2014/10/06 21:08:52 You might want to use size_t instead of int for th
msw 2014/10/06 21:32:33 InitGoogleTest eventually requires an int* :-/
98 argv[i] = &args[i][0];
99 testing::InitGoogleTest(&argc, argv.data());
100
96 mojo_ignore_result(RUN_ALL_TESTS()); 101 mojo_ignore_result(RUN_ALL_TESTS());
97 102
98 delete delegate; 103 delete delegate;
99 return MOJO_RESULT_OK; 104 return MOJO_RESULT_OK;
100 } 105 }
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