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

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

Issue 657393003: Make ApplicationImpl::args() be a std::vector<std::string> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // Need to CancelWait() / PassMessagePipe() from the ShellPtr? 90 // Need to CancelWait() / PassMessagePipe() from the ShellPtr?
91 mojo::RunLoop loop; 91 mojo::RunLoop loop;
92 mojo::ApplicationDelegate* delegate = new mojo::ExampleClientApplication(); 92 mojo::ApplicationDelegate* delegate = new mojo::ExampleClientApplication();
93 mojo::ApplicationImpl app(delegate, shell_handle); 93 mojo::ApplicationImpl app(delegate, shell_handle);
94 g_application_impl_hack = &app; 94 g_application_impl_hack = &app;
95 MOJO_CHECK(app.WaitForInitialize()); 95 MOJO_CHECK(app.WaitForInitialize());
96 96
97 { 97 {
98 // InitGoogleTest expects (argc + 1) elements, including a terminating NULL. 98 // InitGoogleTest expects (argc + 1) elements, including a terminating NULL.
99 // It also removes GTEST arguments from |argv| and updates the |argc| count. 99 // It also removes GTEST arguments from |argv| and updates the |argc| count.
100 const mojo::Array<mojo::String>& args = app.args(); 100 const std::vector<std::string>& args = app.args();
101 MOJO_CHECK(args.size() < INT_MAX); 101 MOJO_CHECK(args.size() < INT_MAX);
102 int argc = static_cast<int>(args.size()); 102 int argc = static_cast<int>(args.size());
103 std::vector<char*> argv(argc + 1); 103 std::vector<char*> argv(argc + 1);
104 for (int i = 0; i < argc; ++i) 104 for (int i = 0; i < argc; ++i)
105 argv[i] = const_cast<char*>(args[i].data()); 105 argv[i] = const_cast<char*>(args[i].data());
106 argv[argc] = NULL; 106 argv[argc] = NULL;
107 testing::InitGoogleTest(&argc, &argv[0]); 107 testing::InitGoogleTest(&argc, &argv[0]);
108 } 108 }
109 109
110 mojo_ignore_result(RUN_ALL_TESTS()); 110 mojo_ignore_result(RUN_ALL_TESTS());
111 111
112 delete delegate; 112 delete delegate;
113 return MOJO_RESULT_OK; 113 return MOJO_RESULT_OK;
114 } 114 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698