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

Unified Diff: mojo/common/test/multiprocess_test_helper.h

Issue 194593007: Mojo: MultiprocessTestHelper: Allow {ASSERT,EXPECT}_...() to be used in child. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment fix Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | mojo/common/test/multiprocess_test_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/common/test/multiprocess_test_helper.h
diff --git a/mojo/common/test/multiprocess_test_helper.h b/mojo/common/test/multiprocess_test_helper.h
index 103dcf4b7009441efb84fcc8ef62f937a591819e..db5450c8214c151be38baaa5fe9a94f73f12d68d 100644
--- a/mojo/common/test/multiprocess_test_helper.h
+++ b/mojo/common/test/multiprocess_test_helper.h
@@ -29,7 +29,8 @@ class MultiprocessTestHelper {
~MultiprocessTestHelper();
// Start a child process and run the "main" function "named" |test_child_name|
- // declared using |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| (below).
+ // declared using |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| or
+ // |MOJO_MULTIPROCESS_TEST_CHILD_TEST()| (below).
void StartChild(const std::string& test_child_name);
// Wait for the child process to terminate.
// Returns the exit code of the child process. Note that, though it's declared
@@ -39,6 +40,12 @@ class MultiprocessTestHelper {
// 0-127 being preserved, and -1 being outside the range 0-127.
int WaitForChildShutdown();
+ // Like |WaitForChildShutdown()|, but returns true on success (exit code of 0)
+ // and false otherwise. You probably want to do something like
+ // |EXPECT_TRUE(WaitForChildTestShutdown());|. Mainly for use with
+ // |MOJO_MULTIPROCESS_TEST_CHILD_TEST()|.
+ bool WaitForChildTestShutdown();
+
// For use by |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| only:
static void ChildSetup();
@@ -65,6 +72,19 @@ class MultiprocessTestHelper {
test_child_name ## TestChildMain, \
::mojo::test::MultiprocessTestHelper::ChildSetup)
+// Use this (and |WaitForChildTestShutdown()|) for the child process's "main()",
+// if you want to use |EXPECT_...()| or |ASSERT_...()|; it has a |void| return
+// type. (Note that while an |ASSERT_...()| failure will abort the test in the
+// child, it will not abort the test in the parent.)
+#define MOJO_MULTIPROCESS_TEST_CHILD_TEST(test_child_name) \
+ void test_child_name ## TestChildTest(); \
+ MOJO_MULTIPROCESS_TEST_CHILD_MAIN(test_child_name) { \
+ test_child_name ## TestChildTest(); \
+ return (::testing::Test::HasFatalFailure() || \
+ ::testing::Test::HasNonfatalFailure()) ? 1 : 0; \
+ } \
+ void test_child_name ## TestChildTest()
+
} // namespace test
} // namespace mojo
« no previous file with comments | « no previous file | mojo/common/test/multiprocess_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698