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

Side by Side Diff: mojo/edk/test/multiprocess_test_helper.h

Issue 728783003: Add infrastructure to run tests on android. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Follow review Created 6 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef MOJO_EDK_TEST_MULTIPROCESS_TEST_HELPER_H_ 5 #ifndef MOJO_EDK_TEST_MULTIPROCESS_TEST_HELPER_H_
6 #define MOJO_EDK_TEST_MULTIPROCESS_TEST_HELPER_H_ 6 #define MOJO_EDK_TEST_MULTIPROCESS_TEST_HELPER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/process/process_handle.h" 11 #include "base/process/process_handle.h"
12 #include "base/test/multiprocess_test.h" 12 #include "base/test/multiprocess_test.h"
13 #include "base/test/test_timeouts.h" 13 #include "base/test/test_timeouts.h"
14 #include "mojo/edk/embedder/scoped_platform_handle.h" 14 #include "mojo/edk/embedder/scoped_platform_handle.h"
15 #include "mojo/edk/embedder/test_embedder.h"
15 #include "testing/multiprocess_func_list.h" 16 #include "testing/multiprocess_func_list.h"
16 17
17 namespace mojo { 18 namespace mojo {
18 19
19 namespace embedder { 20 namespace embedder {
20 class PlatformChannelPair; 21 class PlatformChannelPair;
21 } 22 }
22 23
23 namespace test { 24 namespace test {
24 25
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 }; 65 };
65 66
66 // Use this to declare the child process's "main()" function for tests using 67 // Use this to declare the child process's "main()" function for tests using
67 // |MultiprocessTestHelper|. It returns an |int|, which will be the process's 68 // |MultiprocessTestHelper|. It returns an |int|, which will be the process's
68 // exit code (but see the comment about |WaitForChildShutdown()|). 69 // exit code (but see the comment about |WaitForChildShutdown()|).
69 #define MOJO_MULTIPROCESS_TEST_CHILD_MAIN(test_child_name) \ 70 #define MOJO_MULTIPROCESS_TEST_CHILD_MAIN(test_child_name) \
70 MULTIPROCESS_TEST_MAIN_WITH_SETUP( \ 71 MULTIPROCESS_TEST_MAIN_WITH_SETUP( \
71 test_child_name##TestChildMain, \ 72 test_child_name##TestChildMain, \
72 ::mojo::test::MultiprocessTestHelper::ChildSetup) 73 ::mojo::test::MultiprocessTestHelper::ChildSetup)
73 74
75 // On android, multi-process tests cannot call exec. It means that the test must
76 // shutdown the embedder on the forked process as it expects to be in a clean
77 // state.
78 #if defined(OS_ANDROID)
79 #define SHUTDOWN_EMBEDDER_ON_ANDROID() embedder::test::Shutdown()
80 #else
81 #define SHUTDOWN_EMBEDDER_ON_ANDROID() \
82 do { \
83 } while (0)
84 #endif
85
74 // Use this (and |WaitForChildTestShutdown()|) for the child process's "main()", 86 // Use this (and |WaitForChildTestShutdown()|) for the child process's "main()",
75 // if you want to use |EXPECT_...()| or |ASSERT_...()|; it has a |void| return 87 // if you want to use |EXPECT_...()| or |ASSERT_...()|; it has a |void| return
76 // type. (Note that while an |ASSERT_...()| failure will abort the test in the 88 // type. (Note that while an |ASSERT_...()| failure will abort the test in the
77 // child, it will not abort the test in the parent.) 89 // child, it will not abort the test in the parent.)
78 #define MOJO_MULTIPROCESS_TEST_CHILD_TEST(test_child_name) \ 90 #define MOJO_MULTIPROCESS_TEST_CHILD_TEST(test_child_name) \
79 void test_child_name##TestChildTest(); \ 91 void test_child_name##TestChildTest(); \
80 MOJO_MULTIPROCESS_TEST_CHILD_MAIN(test_child_name) { \ 92 MOJO_MULTIPROCESS_TEST_CHILD_MAIN(test_child_name) { \
93 SHUTDOWN_EMBEDDER_ON_ANDROID(); \
81 test_child_name##TestChildTest(); \ 94 test_child_name##TestChildTest(); \
82 return (::testing::Test::HasFatalFailure() || \ 95 return (::testing::Test::HasFatalFailure() || \
83 ::testing::Test::HasNonfatalFailure()) \ 96 ::testing::Test::HasNonfatalFailure()) \
84 ? 1 \ 97 ? 1 \
85 : 0; \ 98 : 0; \
86 } \ 99 } \
87 void test_child_name##TestChildTest() 100 void test_child_name##TestChildTest()
88 101
89 } // namespace test 102 } // namespace test
90 } // namespace mojo 103 } // namespace mojo
91 104
92 #endif // MOJO_EDK_TEST_MULTIPROCESS_TEST_HELPER_H_ 105 #endif // MOJO_EDK_TEST_MULTIPROCESS_TEST_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698