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

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

Issue 814543006: Move //mojo/{public, edk} underneath //third_party (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 11 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
« no previous file with comments | « mojo/edk/test/BUILD.gn ('k') | mojo/edk/test/multiprocess_test_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MOJO_EDK_TEST_MULTIPROCESS_TEST_HELPER_H_
6 #define MOJO_EDK_TEST_MULTIPROCESS_TEST_HELPER_H_
7
8 #include <string>
9
10 #include "base/macros.h"
11 #include "base/process/process.h"
12 #include "base/test/multiprocess_test.h"
13 #include "base/test/test_timeouts.h"
14 #include "mojo/edk/embedder/scoped_platform_handle.h"
15 #include "testing/multiprocess_func_list.h"
16
17 namespace mojo {
18
19 namespace embedder {
20 class PlatformChannelPair;
21 }
22
23 namespace test {
24
25 class MultiprocessTestHelper {
26 public:
27 MultiprocessTestHelper();
28 ~MultiprocessTestHelper();
29
30 // Start a child process and run the "main" function "named" |test_child_name|
31 // declared using |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| or
32 // |MOJO_MULTIPROCESS_TEST_CHILD_TEST()| (below).
33 void StartChild(const std::string& test_child_name);
34 // Wait for the child process to terminate.
35 // Returns the exit code of the child process. Note that, though it's declared
36 // to be an |int|, the exit code is subject to mangling by the OS. E.g., we
37 // usually return -1 on error in the child (e.g., if |test_child_name| was not
38 // found), but this is mangled to 255 on Linux. You should only rely on codes
39 // 0-127 being preserved, and -1 being outside the range 0-127.
40 int WaitForChildShutdown();
41
42 // Like |WaitForChildShutdown()|, but returns true on success (exit code of 0)
43 // and false otherwise. You probably want to do something like
44 // |EXPECT_TRUE(WaitForChildTestShutdown());|. Mainly for use with
45 // |MOJO_MULTIPROCESS_TEST_CHILD_TEST()|.
46 bool WaitForChildTestShutdown();
47
48 // For use by |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| only:
49 static void ChildSetup();
50
51 // For use in the main process:
52 embedder::ScopedPlatformHandle server_platform_handle;
53
54 // For use (and only valid) in the child process:
55 static embedder::ScopedPlatformHandle client_platform_handle;
56
57 private:
58 scoped_ptr<embedder::PlatformChannelPair> platform_channel_pair_;
59
60 // Valid after |StartChild()| and before |WaitForChildShutdown()|.
61 base::Process test_child_;
62
63 DISALLOW_COPY_AND_ASSIGN(MultiprocessTestHelper);
64 };
65
66 // 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 // exit code (but see the comment about |WaitForChildShutdown()|).
69 #define MOJO_MULTIPROCESS_TEST_CHILD_MAIN(test_child_name) \
70 MULTIPROCESS_TEST_MAIN_WITH_SETUP( \
71 test_child_name##TestChildMain, \
72 ::mojo::test::MultiprocessTestHelper::ChildSetup)
73
74 // Use this (and |WaitForChildTestShutdown()|) for the child process's "main()",
75 // 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
77 // child, it will not abort the test in the parent.)
78 #define MOJO_MULTIPROCESS_TEST_CHILD_TEST(test_child_name) \
79 void test_child_name##TestChildTest(); \
80 MOJO_MULTIPROCESS_TEST_CHILD_MAIN(test_child_name) { \
81 test_child_name##TestChildTest(); \
82 return (::testing::Test::HasFatalFailure() || \
83 ::testing::Test::HasNonfatalFailure()) \
84 ? 1 \
85 : 0; \
86 } \
87 void test_child_name##TestChildTest()
88
89 } // namespace test
90 } // namespace mojo
91
92 #endif // MOJO_EDK_TEST_MULTIPROCESS_TEST_HELPER_H_
OLDNEW
« no previous file with comments | « mojo/edk/test/BUILD.gn ('k') | mojo/edk/test/multiprocess_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698