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

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

Issue 99473007: Mojo: Add a Mojo-specific multiprocess test base class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment + win fix Created 7 years 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
(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_COMMON_TEST_MULTIPROCESS_TEST_BASE_H_
6 #define MOJO_COMMON_TEST_MULTIPROCESS_TEST_BASE_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/process/process_handle.h"
13 #include "base/test/multiprocess_test.h"
14 #include "mojo/system/platform_channel.h"
15 #include "testing/multiprocess_func_list.h"
16
17 namespace mojo {
18 namespace test {
19
20 class MultiprocessTestBase : public base::MultiProcessTest {
21 public:
22 MultiprocessTestBase();
23 virtual ~MultiprocessTestBase();
24
25 virtual void SetUp() OVERRIDE;
26 virtual void TearDown() OVERRIDE;
27
28 // Start a child process and run the "main" function "named" |test_child_name|
29 // declared using |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| (below).
30 void StartChild(const std::string& test_child_name);
31 // Wait for the child process to terminate.
32 // Returns the exit code of the child process. Note that, though it's declared
33 // to be an |int|, the exit code is subject to mangling by the OS. E.g., we
34 // usually return -1 on error in the child (e.g., if |test_child_name| was not
35 // found), but this is mangled to 255 on Linux. You should only rely on codes
36 // 0-127 being preserved, and -1 being outside the range 0-127.
37 int WaitForChildShutdown();
38
39 // For use by |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| only:
40 static void ChildSetup();
41
42 system::PlatformServerChannel* platform_server_channel() {
43 return platform_server_channel_.get();
44 }
45
46 private:
47 virtual CommandLine MakeCmdLine(const std::string& procname,
48 bool debug_on_start) OVERRIDE;
49
50 // Valid after |StartChild()| and before |WaitForChildShutdown()|.
51 base::ProcessHandle test_child_handle_;
52
53 scoped_ptr<system::PlatformServerChannel> platform_server_channel_;
54
55 DISALLOW_COPY_AND_ASSIGN(MultiprocessTestBase);
56 };
57
58 // Use this to declare the child process's "main()" function for tests using
59 // |MultiprocessTestBase|. It returns an |int|, which will be the process's exit
60 // code (but see the comment about |WaitForChildShutdown()|).
61 #define MOJO_MULTIPROCESS_TEST_CHILD_MAIN(test_child_name) \
62 MULTIPROCESS_TEST_MAIN_WITH_SETUP( \
63 test_child_name ## TestChildMain, \
64 ::mojo::test::MultiprocessTestBase::ChildSetup)
65
66 } // namespace test
67 } // namespace mojo
68
69 #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