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

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

Issue 668483002: Change mojo URLs from mojo://mojo_foo to mojo://foo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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
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> 5 #include <limits.h>
6 6
7 #include "mojo/examples/apptest/example_client_application.h" 7 #include "mojo/examples/apptest/example_client_application.h"
8 #include "mojo/examples/apptest/example_client_impl.h" 8 #include "mojo/examples/apptest/example_client_impl.h"
9 #include "mojo/examples/apptest/example_service.mojom.h" 9 #include "mojo/examples/apptest/example_service.mojom.h"
10 #include "mojo/public/c/system/main.h" 10 #include "mojo/public/c/system/main.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 ExampleApptest() : Apptest(Array<String>()) {} 77 ExampleApptest() : Apptest(Array<String>()) {}
78 virtual ~ExampleApptest() override {} 78 virtual ~ExampleApptest() override {}
79 79
80 protected: 80 protected:
81 // Apptest: 81 // Apptest:
82 virtual ApplicationDelegate* GetApplicationDelegate() override { 82 virtual ApplicationDelegate* GetApplicationDelegate() override {
83 return &example_client_application_; 83 return &example_client_application_;
84 } 84 }
85 virtual void SetUp() override { 85 virtual void SetUp() override {
86 Apptest::SetUp(); 86 Apptest::SetUp();
87 application_impl()->ConnectToService("mojo:mojo_example_service", 87 application_impl()->ConnectToService("mojo:example_service",
88 &example_service_); 88 &example_service_);
89 example_service_.set_client(&example_client_); 89 example_service_.set_client(&example_client_);
90 } 90 }
91 91
92 ExampleServicePtr example_service_; 92 ExampleServicePtr example_service_;
93 ExampleClientImpl example_client_; 93 ExampleClientImpl example_client_;
94 94
95 private: 95 private:
96 ExampleClientApplication example_client_application_; 96 ExampleClientApplication example_client_application_;
97 97
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 MojoResult MojoMain(MojoHandle shell_handle) { 138 MojoResult MojoMain(MojoHandle shell_handle) {
139 mojo::Environment environment; 139 mojo::Environment environment;
140 140
141 { 141 {
142 // This RunLoop is used for init, and then destroyed before running tests. 142 // This RunLoop is used for init, and then destroyed before running tests.
143 mojo::RunLoop run_loop; 143 mojo::RunLoop run_loop;
144 144
145 // Construct an ApplicationImpl just for the GTEST commandline arguments. 145 // Construct an ApplicationImpl just for the GTEST commandline arguments.
146 // GTEST command line arguments are supported amid application arguments: 146 // GTEST command line arguments are supported amid application arguments:
147 // mojo_shell 'mojo:mojo_example_apptest arg1 --gtest_filter=foo arg2' 147 // mojo_shell 'mojo:example_apptest arg1 --gtest_filter=foo arg2'
148 mojo::ApplicationDelegate dummy_application_delegate; 148 mojo::ApplicationDelegate dummy_application_delegate;
149 mojo::ApplicationImpl app(&dummy_application_delegate, shell_handle); 149 mojo::ApplicationImpl app(&dummy_application_delegate, shell_handle);
150 MOJO_CHECK(app.WaitForInitialize()); 150 MOJO_CHECK(app.WaitForInitialize());
151 151
152 // InitGoogleTest expects (argc + 1) elements, including a terminating NULL. 152 // InitGoogleTest expects (argc + 1) elements, including a terminating NULL.
153 // It also removes GTEST arguments from |argv| and updates the |argc| count. 153 // It also removes GTEST arguments from |argv| and updates the |argc| count.
154 // TODO(msw): Provide tests access to these actual command line arguments. 154 // TODO(msw): Provide tests access to these actual command line arguments.
155 const std::vector<std::string>& args = app.args(); 155 const std::vector<std::string>& args = app.args();
156 MOJO_CHECK(args.size() < INT_MAX); 156 MOJO_CHECK(args.size() < INT_MAX);
157 int argc = static_cast<int>(args.size()); 157 int argc = static_cast<int>(args.size());
158 std::vector<char*> argv(argc + 1); 158 std::vector<char*> argv(argc + 1);
159 for (int i = 0; i < argc; ++i) 159 for (int i = 0; i < argc; ++i)
160 argv[i] = const_cast<char*>(args[i].data()); 160 argv[i] = const_cast<char*>(args[i].data());
161 argv[argc] = NULL; 161 argv[argc] = NULL;
162 testing::InitGoogleTest(&argc, &argv[0]); 162 testing::InitGoogleTest(&argc, &argv[0]);
163 mojo::g_shell_message_pipe_handle_hack = app.UnbindShell().release(); 163 mojo::g_shell_message_pipe_handle_hack = app.UnbindShell().release();
164 } 164 }
165 165
166 mojo_ignore_result(RUN_ALL_TESTS()); 166 mojo_ignore_result(RUN_ALL_TESTS());
167 167
168 MojoResult result = MojoClose(mojo::g_shell_message_pipe_handle_hack.value()); 168 MojoResult result = MojoClose(mojo::g_shell_message_pipe_handle_hack.value());
169 MOJO_ALLOW_UNUSED_LOCAL(result); 169 MOJO_ALLOW_UNUSED_LOCAL(result);
170 assert(result == MOJO_RESULT_OK); 170 assert(result == MOJO_RESULT_OK);
171 171
172 return MOJO_RESULT_OK; 172 return MOJO_RESULT_OK;
173 } 173 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698