OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_COMMON_SANDBOX_MAC_UNITTEST_HELPER_H_ | 5 #ifndef CONTENT_COMMON_SANDBOX_MAC_UNITTEST_HELPER_H_ |
6 #define CONTENT_COMMON_SANDBOX_MAC_UNITTEST_HELPER_H_ | 6 #define CONTENT_COMMON_SANDBOX_MAC_UNITTEST_HELPER_H_ |
7 | 7 |
8 #include "base/test/multiprocess_test.h" | 8 #include "base/test/multiprocess_test.h" |
9 #include "content/common/sandbox_mac.h" | 9 #include "content/common/sandbox_mac.h" |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 // return true; // always succeed. | 29 // return true; // always succeed. |
30 // } | 30 // } |
31 // }; | 31 // }; |
32 // | 32 // |
33 // // Register the test case you just created. | 33 // // Register the test case you just created. |
34 // REGISTER_SANDBOX_TEST_CASE(TestCaseThatRunsInSandboxedSubprocess); | 34 // REGISTER_SANDBOX_TEST_CASE(TestCaseThatRunsInSandboxedSubprocess); |
35 // | 35 // |
36 // TEST_F(MacSandboxTest, ATest) { | 36 // TEST_F(MacSandboxTest, ATest) { |
37 // EXPECT_TRUE(RunTestInAllSandboxTypes( | 37 // EXPECT_TRUE(RunTestInAllSandboxTypes( |
38 // "TestCaseThatRunsInSandboxedSubprocess", | 38 // "TestCaseThatRunsInSandboxedSubprocess", |
39 // NULL)); | 39 // nullptr)); |
40 // } | 40 // } |
41 | 41 |
42 // Base test type with helper functions to spawn a subprocess that exercises | 42 // Base test type with helper functions to spawn a subprocess that exercises |
43 // a given test in the sandbox. | 43 // a given test in the sandbox. |
44 class MacSandboxTest : public base::MultiProcessTest { | 44 class MacSandboxTest : public base::MultiProcessTest { |
45 public: | 45 public: |
46 // Runs a test specified by |test_name| in a sandbox of the type specified | 46 // Runs a test specified by |test_name| in a sandbox of the type specified |
47 // by |sandbox_type|. |test_data| is a custom string that a test can pass | 47 // by |sandbox_type|. |test_data| is a custom string that a test can pass |
48 // to the child process runing in the sandbox, or NULL if additional data is | 48 // to the child process runing in the sandbox, or nullptr if additional data |
49 // required. | 49 // is required. |
50 // Returns true if the test passes, false if either of the functions in | 50 // Returns true if the test passes, false if either of the functions in |
51 // the corresponding MacSandboxTestCase return false. | 51 // the corresponding MacSandboxTestCase return false. |
52 bool RunTestInSandbox(content::SandboxType sandbox_type, | 52 bool RunTestInSandbox(content::SandboxType sandbox_type, |
53 const char* test_name, | 53 const char* test_name, |
54 const char* test_data); | 54 const char* test_data); |
55 | 55 |
56 // Runs the test specified by |test_name| in all the different sandbox types | 56 // Runs the test specified by |test_name| in all the different sandbox types |
57 // known to content, one by one. | 57 // known to content, one by one. |
58 // Returns true if the test passes, false if either of the functions in | 58 // Returns true if the test passes, false if either of the functions in |
59 // the corresponding MacSandboxTestCase return false in any of the spawned | 59 // the corresponding MacSandboxTestCase return false in any of the spawned |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 namespace { \ | 111 namespace { \ |
112 content::internal::RegisterSandboxTest<class_name> \ | 112 content::internal::RegisterSandboxTest<class_name> \ |
113 register_test##class_name(#class_name); \ | 113 register_test##class_name(#class_name); \ |
114 } // namespace | 114 } // namespace |
115 | 115 |
116 } // namespace internal | 116 } // namespace internal |
117 | 117 |
118 } // namespace content | 118 } // namespace content |
119 | 119 |
120 #endif // CONTENT_COMMON_SANDBOX_MAC_UNITTEST_HELPER_H_ | 120 #endif // CONTENT_COMMON_SANDBOX_MAC_UNITTEST_HELPER_H_ |
OLD | NEW |