OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_COMMON_SANDBOX_MAC_UNITTEST_RUNNER_H_ | 5 #ifndef CHROME_COMMON_SANDBOX_MAC_UNITTEST_HELPER_H_ |
6 #define CHROME_COMMON_SANDBOX_MAC_UNITTEST_RUNNER_H_ | 6 #define CHROME_COMMON_SANDBOX_MAC_UNITTEST_HELPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/multiprocess_test.h" | 9 #include "base/multiprocess_test.h" |
10 #include "chrome/common/sandbox_mac.h" | 10 #include "chrome/common/sandbox_mac.h" |
11 | 11 |
12 namespace sandboxtest { | 12 namespace sandboxtest { |
13 | 13 |
14 // Helpers for writing unit tests that runs in the context of the Mac sandbox. | 14 // Helpers for writing unit tests that runs in the context of the Mac sandbox. |
15 // | 15 // |
16 // How to write a sandboxed test: | 16 // How to write a sandboxed test: |
17 // 1. Create a class that inherits from MacSandboxTestCase and overrides | 17 // 1. Create a class that inherits from MacSandboxTestCase and overrides |
18 // it's functions to run code before or after the sandbox is initialised in a | 18 // its functions to run code before or after the sandbox is initialised in a |
19 // subprocess. | 19 // subprocess. |
20 // 2. Register the class you just created with the REGISTER_SANDBOX_TEST_CASE() | 20 // 2. Register the class you just created with the REGISTER_SANDBOX_TEST_CASE() |
21 // macro. | 21 // macro. |
22 // 3. Write a test [using TEST_F()] that inherits from MacSandboxTest and call | 22 // 3. Write a test [using TEST_F()] that inherits from MacSandboxTest and call |
23 // one of it's helper functions to launch the test. | 23 // one of its helper functions to launch the test. |
24 // | 24 // |
25 // Example: | 25 // Example: |
26 // class TestCaseThatRunsInSandboxedSubprocess : | 26 // class TestCaseThatRunsInSandboxedSubprocess : |
27 // public sandboxtest::MacSandboxTestCase { | 27 // public sandboxtest::MacSandboxTestCase { |
28 // public: | 28 // public: |
29 // virtual bool SandboxedTest() { | 29 // virtual bool SandboxedTest() { |
30 // .. test code that runs in sandbox goes here .. | 30 // .. test code that runs in sandbox goes here .. |
31 // return true; // always succeed. | 31 // return true; // always succeed. |
32 // } | 32 // } |
33 // }; | 33 // }; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 #define REGISTER_SANDBOX_TEST_CASE(class_name) \ | 107 #define REGISTER_SANDBOX_TEST_CASE(class_name) \ |
108 namespace { \ | 108 namespace { \ |
109 sandboxtest::internal::RegisterSandboxTest<class_name> \ | 109 sandboxtest::internal::RegisterSandboxTest<class_name> \ |
110 register_test##class_name(#class_name); \ | 110 register_test##class_name(#class_name); \ |
111 } // namespace | 111 } // namespace |
112 | 112 |
113 } // namespace internal | 113 } // namespace internal |
114 | 114 |
115 } // namespace sandboxtest | 115 } // namespace sandboxtest |
116 | 116 |
117 #endif // CHROME_COMMON_SANDBOX_MAC_UNITTEST_RUNNER_H_ | 117 #endif // CHROME_COMMON_SANDBOX_MAC_UNITTEST_HELPER_H_ |
OLD | NEW |