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

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

Issue 2043713004: Mojo: Add NotifyBadMessage API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no bindings Created 4 years, 6 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/mojo_test_base.cc ('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
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/callback.h" 10 #include "base/callback.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/process/process.h" 12 #include "base/process/process.h"
13 #include "base/test/multiprocess_test.h" 13 #include "base/test/multiprocess_test.h"
14 #include "base/test/test_timeouts.h" 14 #include "base/test/test_timeouts.h"
15 #include "mojo/edk/embedder/embedder.h"
15 #include "mojo/public/cpp/system/message_pipe.h" 16 #include "mojo/public/cpp/system/message_pipe.h"
16 #include "testing/multiprocess_func_list.h" 17 #include "testing/multiprocess_func_list.h"
17 18
18 namespace mojo { 19 namespace mojo {
19 20
20 namespace edk { 21 namespace edk {
21 class PlatformChannelPair; 22 class PlatformChannelPair;
22 23
23 namespace test { 24 namespace test {
24 25
(...skipping 10 matching lines...) Expand all
35 ScopedMessagePipeHandle StartChild(const std::string& test_child_name); 36 ScopedMessagePipeHandle StartChild(const std::string& test_child_name);
36 37
37 // Like |StartChild()|, but appends an extra switch (with ASCII value) to the 38 // Like |StartChild()|, but appends an extra switch (with ASCII value) to the
38 // command line. (The switch must not already be present in the default 39 // command line. (The switch must not already be present in the default
39 // command line.) 40 // command line.)
40 ScopedMessagePipeHandle StartChildWithExtraSwitch( 41 ScopedMessagePipeHandle StartChildWithExtraSwitch(
41 const std::string& test_child_name, 42 const std::string& test_child_name,
42 const std::string& switch_string, 43 const std::string& switch_string,
43 const std::string& switch_value); 44 const std::string& switch_value);
44 45
46 void set_process_error_callback(const ProcessErrorCallback& callback) {
47 process_error_callback_ = callback;
48 }
49
45 // Wait for the child process to terminate. 50 // Wait for the child process to terminate.
46 // Returns the exit code of the child process. Note that, though it's declared 51 // Returns the exit code of the child process. Note that, though it's declared
47 // to be an |int|, the exit code is subject to mangling by the OS. E.g., we 52 // to be an |int|, the exit code is subject to mangling by the OS. E.g., we
48 // usually return -1 on error in the child (e.g., if |test_child_name| was not 53 // usually return -1 on error in the child (e.g., if |test_child_name| was not
49 // found), but this is mangled to 255 on Linux. You should only rely on codes 54 // found), but this is mangled to 255 on Linux. You should only rely on codes
50 // 0-127 being preserved, and -1 being outside the range 0-127. 55 // 0-127 being preserved, and -1 being outside the range 0-127.
51 int WaitForChildShutdown(); 56 int WaitForChildShutdown();
52 57
53 // Like |WaitForChildShutdown()|, but returns true on success (exit code of 0) 58 // Like |WaitForChildShutdown()|, but returns true on success (exit code of 0)
54 // and false otherwise. You probably want to do something like 59 // and false otherwise. You probably want to do something like
55 // |EXPECT_TRUE(WaitForChildTestShutdown());|. 60 // |EXPECT_TRUE(WaitForChildTestShutdown());|.
56 bool WaitForChildTestShutdown(); 61 bool WaitForChildTestShutdown();
57 62
58 const base::Process& test_child() const { return test_child_; } 63 const base::Process& test_child() const { return test_child_; }
59 64
60 // Used by macros in mojo/edk/test/mojo_test_base.h to support multiprocess 65 // Used by macros in mojo/edk/test/mojo_test_base.h to support multiprocess
61 // test client initialization. 66 // test client initialization.
62 static void ChildSetup(); 67 static void ChildSetup();
63 static int RunClientMain(const base::Callback<int(MojoHandle)>& main); 68 static int RunClientMain(const base::Callback<int(MojoHandle)>& main);
64 static int RunClientTestMain(const base::Callback<void(MojoHandle)>& main); 69 static int RunClientTestMain(const base::Callback<void(MojoHandle)>& main);
65 70
66 // For use (and only valid) in the child process: 71 // For use (and only valid) in the child process:
67 static std::string primordial_pipe_token; 72 static std::string primordial_pipe_token;
68 73
69 private: 74 private:
70 // Valid after |StartChild()| and before |WaitForChildShutdown()|. 75 // Valid after |StartChild()| and before |WaitForChildShutdown()|.
71 base::Process test_child_; 76 base::Process test_child_;
72 77
78 ProcessErrorCallback process_error_callback_;
79
73 DISALLOW_COPY_AND_ASSIGN(MultiprocessTestHelper); 80 DISALLOW_COPY_AND_ASSIGN(MultiprocessTestHelper);
74 }; 81 };
75 82
76 } // namespace test 83 } // namespace test
77 } // namespace edk 84 } // namespace edk
78 } // namespace mojo 85 } // namespace mojo
79 86
80 #endif // MOJO_EDK_TEST_MULTIPROCESS_TEST_HELPER_H_ 87 #endif // MOJO_EDK_TEST_MULTIPROCESS_TEST_HELPER_H_
OLDNEW
« no previous file with comments | « mojo/edk/test/mojo_test_base.cc ('k') | mojo/edk/test/multiprocess_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698