OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/test/multiprocess_test.h" | 9 #include "base/test/multiprocess_test.h" |
10 #include "content/common/sandbox_mac.h" | 10 #include "content/common/sandbox_mac.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // Base test type with helper functions to spawn a subprocess that exercises | 44 // Base test type with helper functions to spawn a subprocess that exercises |
45 // a given test in the sandbox. | 45 // a given test in the sandbox. |
46 class MacSandboxTest : public base::MultiProcessTest { | 46 class MacSandboxTest : public base::MultiProcessTest { |
47 public: | 47 public: |
48 // Runs a test specified by |test_name| in a sandbox of the type specified | 48 // Runs a test specified by |test_name| in a sandbox of the type specified |
49 // by |sandbox_type|. |test_data| is a custom string that a test can pass | 49 // by |sandbox_type|. |test_data| is a custom string that a test can pass |
50 // to the child process runing in the sandbox, or NULL if additional data is | 50 // to the child process runing in the sandbox, or NULL if additional data is |
51 // required. | 51 // required. |
52 // Returns true if the test passes, false if either of the functions in | 52 // Returns true if the test passes, false if either of the functions in |
53 // the corresponding MacSandboxTestCase return false. | 53 // the corresponding MacSandboxTestCase return false. |
54 bool RunTestInSandbox(sandbox::Sandbox::SandboxProcessType sandbox_type, | 54 bool RunTestInSandbox(content::SandboxType sandbox_type, |
55 const char* test_name, | 55 const char* test_name, |
56 const char* test_data); | 56 const char* test_data); |
57 | 57 |
58 // Runs the test specified by |test_name| in all the different sandbox types, | 58 // Runs the test specified by |test_name| in all the different sandbox types |
59 // one by one. | 59 // known to content, one by one. |
60 // Returns true if the test passes, false if either of the functions in | 60 // Returns true if the test passes, false if either of the functions in |
61 // the corresponding MacSandboxTestCase return false in any of the spawned | 61 // the corresponding MacSandboxTestCase return false in any of the spawned |
62 // processes. | 62 // processes. |
| 63 // |
| 64 // DANGER DANGER DANGER: |
| 65 // Additional sandbox types defined by the embedder (e.g. the NaCL sandbox) |
| 66 // won't be covered by these tests. |
63 bool RunTestInAllSandboxTypes(const char* test_name, | 67 bool RunTestInAllSandboxTypes(const char* test_name, |
64 const char* test_data); | 68 const char* test_data); |
65 }; | 69 }; |
66 | 70 |
67 // Class to ease writing test cases that run inside the OS X sandbox. | 71 // Class to ease writing test cases that run inside the OS X sandbox. |
68 // This class is instantiated in a subprocess, and allows you to run test code | 72 // This class is instantiated in a subprocess, and allows you to run test code |
69 // at various stages of execution. | 73 // at various stages of execution. |
70 // Note that you must register the subclass you create with the | 74 // Note that you must register the subclass you create with the |
71 // REGISTER_SANDBOX_TEST_CASE so it's visible to the test driver. | 75 // REGISTER_SANDBOX_TEST_CASE so it's visible to the test driver. |
72 class MacSandboxTestCase { | 76 class MacSandboxTestCase { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 namespace { \ | 113 namespace { \ |
110 sandboxtest::internal::RegisterSandboxTest<class_name> \ | 114 sandboxtest::internal::RegisterSandboxTest<class_name> \ |
111 register_test##class_name(#class_name); \ | 115 register_test##class_name(#class_name); \ |
112 } // namespace | 116 } // namespace |
113 | 117 |
114 } // namespace internal | 118 } // namespace internal |
115 | 119 |
116 } // namespace sandboxtest | 120 } // namespace sandboxtest |
117 | 121 |
118 #endif // CONTENT_COMMON_SANDBOX_MAC_UNITTEST_HELPER_H_ | 122 #endif // CONTENT_COMMON_SANDBOX_MAC_UNITTEST_HELPER_H_ |
OLD | NEW |