OLD | NEW |
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/process/process.h" | 10 #include "base/process/process.h" |
11 #include "base/test/multiprocess_test.h" | 11 #include "base/test/multiprocess_test.h" |
12 #include "base/test/test_timeouts.h" | 12 #include "base/test/test_timeouts.h" |
13 #include "mojo/edk/embedder/scoped_platform_handle.h" | 13 #include "mojo/edk/embedder/scoped_platform_handle.h" |
14 #include "mojo/public/cpp/system/macros.h" | 14 #include "mojo/public/cpp/system/macros.h" |
15 #include "testing/multiprocess_func_list.h" | 15 #include "testing/multiprocess_func_list.h" |
16 | 16 |
17 namespace mojo { | 17 namespace mojo { |
18 | 18 |
19 namespace edk { | 19 namespace edk { |
20 class PlatformChannelPair; | 20 class PlatformChannelPair; |
21 | 21 |
22 namespace test { | 22 namespace test { |
23 | 23 |
| 24 extern const char kBrokerHandleSwitch[]; |
| 25 |
24 class MultiprocessTestHelper { | 26 class MultiprocessTestHelper { |
25 public: | 27 public: |
26 MultiprocessTestHelper(); | 28 MultiprocessTestHelper(); |
27 ~MultiprocessTestHelper(); | 29 ~MultiprocessTestHelper(); |
28 | 30 |
29 // Start a child process and run the "main" function "named" |test_child_name| | 31 // Start a child process and run the "main" function "named" |test_child_name| |
30 // declared using |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| or | 32 // declared using |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| or |
31 // |MOJO_MULTIPROCESS_TEST_CHILD_TEST()| (below). | 33 // |MOJO_MULTIPROCESS_TEST_CHILD_TEST()| (below). |
32 void StartChild(const std::string& test_child_name); | 34 void StartChild(const std::string& test_child_name); |
33 // Like |StartChild()|, but appends an extra switch (with ASCII value) to the | 35 // Like |StartChild()|, but appends an extra switch (with ASCII value) to the |
(...skipping 19 matching lines...) Expand all Loading... |
53 // For use by |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| only: | 55 // For use by |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| only: |
54 static void ChildSetup(); | 56 static void ChildSetup(); |
55 | 57 |
56 // For use in the main process: | 58 // For use in the main process: |
57 ScopedPlatformHandle server_platform_handle; | 59 ScopedPlatformHandle server_platform_handle; |
58 | 60 |
59 // For use (and only valid) in the child process: | 61 // For use (and only valid) in the child process: |
60 static ScopedPlatformHandle client_platform_handle; | 62 static ScopedPlatformHandle client_platform_handle; |
61 | 63 |
62 private: | 64 private: |
| 65 // Used differently depending on the test. |
63 scoped_ptr<PlatformChannelPair> platform_channel_pair_; | 66 scoped_ptr<PlatformChannelPair> platform_channel_pair_; |
64 | 67 |
| 68 // Used by the broker. |
| 69 scoped_ptr<PlatformChannelPair> broker_platform_channel_pair_; |
| 70 |
65 // Valid after |StartChild()| and before |WaitForChildShutdown()|. | 71 // Valid after |StartChild()| and before |WaitForChildShutdown()|. |
66 base::Process test_child_; | 72 base::Process test_child_; |
67 | 73 |
68 MOJO_DISALLOW_COPY_AND_ASSIGN(MultiprocessTestHelper); | 74 MOJO_DISALLOW_COPY_AND_ASSIGN(MultiprocessTestHelper); |
69 }; | 75 }; |
70 | 76 |
71 // Use this to declare the child process's "main()" function for tests using | 77 // Use this to declare the child process's "main()" function for tests using |
72 // |MultiprocessTestHelper|. It returns an |int|, which will be the process's | 78 // |MultiprocessTestHelper|. It returns an |int|, which will be the process's |
73 // exit code (but see the comment about |WaitForChildShutdown()|). | 79 // exit code (but see the comment about |WaitForChildShutdown()|). |
74 #define MOJO_MULTIPROCESS_TEST_CHILD_MAIN(test_child_name) \ | 80 #define MOJO_MULTIPROCESS_TEST_CHILD_MAIN(test_child_name) \ |
(...skipping 14 matching lines...) Expand all Loading... |
89 ? 1 \ | 95 ? 1 \ |
90 : 0; \ | 96 : 0; \ |
91 } \ | 97 } \ |
92 void test_child_name##TestChildTest() | 98 void test_child_name##TestChildTest() |
93 | 99 |
94 } // namespace test | 100 } // namespace test |
95 } // namespace edk | 101 } // namespace edk |
96 } // namespace mojo | 102 } // namespace mojo |
97 | 103 |
98 #endif // MOJO_EDK_TEST_MULTIPROCESS_TEST_HELPER_H_ | 104 #endif // MOJO_EDK_TEST_MULTIPROCESS_TEST_HELPER_H_ |
OLD | NEW |