OLD | NEW |
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 "base/at_exit.h" |
5 #include "mojo/public/c/system/main.h" | 6 #include "mojo/public/c/system/main.h" |
6 #include "mojo/public/cpp/application/application_delegate.h" | 7 #include "mojo/public/cpp/application/application_delegate.h" |
7 #include "mojo/public/cpp/application/application_impl.h" | 8 #include "mojo/public/cpp/application/application_impl.h" |
8 #include "mojo/public/cpp/application/application_test_base.h" | 9 #include "mojo/public/cpp/application/application_test_base.h" |
9 #include "mojo/public/cpp/environment/logging.h" | 10 #include "mojo/public/cpp/environment/logging.h" |
10 #include "mojo/public/cpp/system/message_pipe.h" | 11 #include "mojo/public/cpp/system/message_pipe.h" |
11 | 12 |
12 MojoResult MojoMain(MojoHandle shell_handle) { | 13 MojoResult MojoMain(MojoHandle shell_handle) { |
13 mojo::Environment environment; | 14 #if !defined(COMPONENT_BUILD) |
| 15 // An AtExitManager instance is needed to construct message loops. |
| 16 base::AtExitManager at_exit; |
| 17 #endif |
14 | 18 |
15 { | 19 { |
16 // This RunLoop is used for init, and then destroyed before running tests. | 20 // This RunLoop is used for init, and then destroyed before running tests. |
17 mojo::Environment::InstantiateDefaultRunLoop(); | 21 mojo::Environment::InstantiateDefaultRunLoop(); |
18 | 22 |
19 // Construct an ApplicationImpl just for the GTEST commandline arguments. | 23 // Construct an ApplicationImpl just for the GTEST commandline arguments. |
20 // GTEST command line arguments are supported amid application arguments: | 24 // GTEST command line arguments are supported amid application arguments: |
21 // $ mojo_shell 'mojo:example_apptest arg1 --gtest_filter=foo arg2' | 25 // $ mojo_shell 'mojo:example_apptest arg1 --gtest_filter=foo arg2' |
22 mojo::ApplicationDelegate dummy_application_delegate; | 26 mojo::ApplicationDelegate dummy_application_delegate; |
23 mojo::ApplicationImpl app(&dummy_application_delegate, shell_handle); | 27 mojo::ApplicationImpl app(&dummy_application_delegate, shell_handle); |
(...skipping 17 matching lines...) Expand all Loading... |
41 } | 45 } |
42 | 46 |
43 int result = RUN_ALL_TESTS(); | 47 int result = RUN_ALL_TESTS(); |
44 | 48 |
45 shell_handle = mojo::test::PassShellHandle().release().value(); | 49 shell_handle = mojo::test::PassShellHandle().release().value(); |
46 MojoResult close_result = MojoClose(shell_handle); | 50 MojoResult close_result = MojoClose(shell_handle); |
47 MOJO_CHECK(close_result == MOJO_RESULT_OK); | 51 MOJO_CHECK(close_result == MOJO_RESULT_OK); |
48 | 52 |
49 return (result == 0) ? MOJO_RESULT_OK : MOJO_RESULT_UNKNOWN; | 53 return (result == 0) ? MOJO_RESULT_OK : MOJO_RESULT_UNKNOWN; |
50 } | 54 } |
OLD | NEW |