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

Side by Side Diff: mojo/common/test/multiprocess_test_base.h

Issue 137273003: Mojo: Rename PlatformChannelHandle to PlatformHandle, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | mojo/common/test/multiprocess_test_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_COMMON_TEST_MULTIPROCESS_TEST_BASE_H_ 5 #ifndef MOJO_COMMON_TEST_MULTIPROCESS_TEST_BASE_H_
6 #define MOJO_COMMON_TEST_MULTIPROCESS_TEST_BASE_H_ 6 #define MOJO_COMMON_TEST_MULTIPROCESS_TEST_BASE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/process/process_handle.h" 12 #include "base/process/process_handle.h"
13 #include "base/test/multiprocess_test.h" 13 #include "base/test/multiprocess_test.h"
14 #include "mojo/system/scoped_platform_handle.h"
14 #include "testing/multiprocess_func_list.h" 15 #include "testing/multiprocess_func_list.h"
15 16
16 namespace mojo { 17 namespace mojo {
17 18
18 namespace system { 19 namespace system {
19 class PlatformChannel;
20 class PlatformChannelPair; 20 class PlatformChannelPair;
21 } 21 }
22 22
23 namespace test { 23 namespace test {
24 24
25 class MultiprocessTestBase : public base::MultiProcessTest { 25 class MultiprocessTestBase : public base::MultiProcessTest {
26 public: 26 public:
27 MultiprocessTestBase(); 27 MultiprocessTestBase();
28 virtual ~MultiprocessTestBase(); 28 virtual ~MultiprocessTestBase();
29 29
30 virtual void SetUp() OVERRIDE; 30 virtual void SetUp() OVERRIDE;
31 virtual void TearDown() OVERRIDE; 31 virtual void TearDown() OVERRIDE;
32 32
33 // Start a child process and run the "main" function "named" |test_child_name| 33 // Start a child process and run the "main" function "named" |test_child_name|
34 // declared using |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| (below). 34 // declared using |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| (below).
35 void StartChild(const std::string& test_child_name); 35 void StartChild(const std::string& test_child_name);
36 // Wait for the child process to terminate. 36 // Wait for the child process to terminate.
37 // Returns the exit code of the child process. Note that, though it's declared 37 // Returns the exit code of the child process. Note that, though it's declared
38 // to be an |int|, the exit code is subject to mangling by the OS. E.g., we 38 // to be an |int|, the exit code is subject to mangling by the OS. E.g., we
39 // usually return -1 on error in the child (e.g., if |test_child_name| was not 39 // usually return -1 on error in the child (e.g., if |test_child_name| was not
40 // found), but this is mangled to 255 on Linux. You should only rely on codes 40 // found), but this is mangled to 255 on Linux. You should only rely on codes
41 // 0-127 being preserved, and -1 being outside the range 0-127. 41 // 0-127 being preserved, and -1 being outside the range 0-127.
42 int WaitForChildShutdown(); 42 int WaitForChildShutdown();
43 43
44 // For use by |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| only: 44 // For use by |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| only:
45 static void ChildSetup(); 45 static void ChildSetup();
46 46
47 // For use in the main process: 47 // For use in the main process:
48 scoped_ptr<system::PlatformChannel> server_platform_channel; 48 system::ScopedPlatformHandle server_platform_handle;
49 49
50 // For use (and only valid) in the child process: 50 // For use (and only valid) in the child process:
51 static scoped_ptr<system::PlatformChannel> client_platform_channel; 51 static system::ScopedPlatformHandle client_platform_handle;
52 52
53 private: 53 private:
54 virtual CommandLine MakeCmdLine(const std::string& procname, 54 virtual CommandLine MakeCmdLine(const std::string& procname,
55 bool debug_on_start) OVERRIDE; 55 bool debug_on_start) OVERRIDE;
56 56
57 scoped_ptr<system::PlatformChannelPair> platform_channel_pair_; 57 scoped_ptr<system::PlatformChannelPair> platform_channel_pair_;
58 58
59 // Valid after |StartChild()| and before |WaitForChildShutdown()|. 59 // Valid after |StartChild()| and before |WaitForChildShutdown()|.
60 base::ProcessHandle test_child_handle_; 60 base::ProcessHandle test_child_handle_;
61 61
62 DISALLOW_COPY_AND_ASSIGN(MultiprocessTestBase); 62 DISALLOW_COPY_AND_ASSIGN(MultiprocessTestBase);
63 }; 63 };
64 64
65 // Use this to declare the child process's "main()" function for tests using 65 // Use this to declare the child process's "main()" function for tests using
66 // |MultiprocessTestBase|. It returns an |int|, which will be the process's exit 66 // |MultiprocessTestBase|. It returns an |int|, which will be the process's exit
67 // code (but see the comment about |WaitForChildShutdown()|). 67 // code (but see the comment about |WaitForChildShutdown()|).
68 #define MOJO_MULTIPROCESS_TEST_CHILD_MAIN(test_child_name) \ 68 #define MOJO_MULTIPROCESS_TEST_CHILD_MAIN(test_child_name) \
69 MULTIPROCESS_TEST_MAIN_WITH_SETUP( \ 69 MULTIPROCESS_TEST_MAIN_WITH_SETUP( \
70 test_child_name ## TestChildMain, \ 70 test_child_name ## TestChildMain, \
71 ::mojo::test::MultiprocessTestBase::ChildSetup) 71 ::mojo::test::MultiprocessTestBase::ChildSetup)
72 72
73 } // namespace test 73 } // namespace test
74 } // namespace mojo 74 } // namespace mojo
75 75
76 #endif // MOJO_COMMON_TEST_MULTIPROCESS_TEST_BASE_H_ 76 #endif // MOJO_COMMON_TEST_MULTIPROCESS_TEST_BASE_H_
OLDNEW
« no previous file with comments | « no previous file | mojo/common/test/multiprocess_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698