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

Side by Side Diff: chrome/common/sandbox_mac_unittest_helper.mm

Issue 2131005: Mac: Infrastructure for serialization of OS fonts over IPC. (Closed)
Patch Set: Better error logging Created 10 years, 7 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 | « chrome/common/sandbox_mac_unittest_helper.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/common/sandbox_mac_unittest_helper.h" 5 #include "chrome/common/sandbox_mac_unittest_helper.h"
6 6
7 extern "C" { 7 extern "C" {
8 #include <sandbox.h> 8 #include <sandbox.h>
9 } 9 }
10 10
11 #include "base/scoped_ptr.h" 11 #include "base/scoped_ptr.h"
12 #include "chrome/common/sandbox_mac.h" 12 #include "chrome/common/sandbox_mac.h"
13 13
14 namespace { 14 namespace {
15 15
16 const char* kSandboxTypeKey = "CHROMIUM_SANDBOX_SANDBOX_TYPE"; 16 const char* kSandboxTypeKey = "CHROMIUM_SANDBOX_SANDBOX_TYPE";
17 const char* kSandboxTestNameKey = "CHROMIUM_SANDBOX_TEST_NAME"; 17 const char* kSandboxTestNameKey = "CHROMIUM_SANDBOX_TEST_NAME";
18 const char* kTestDataKey = "CHROMIUM_SANDBOX_USER_DATA"; 18 const char* kTestDataKey = "CHROMIUM_SANDBOX_USER_DATA";
19 19
20 } // namespace 20 } // namespace
21 21
22 namespace sandboxtest { 22 namespace sandboxtest {
23 23
24 // Support infrastructure for REGISTER_SANDBOX_TEST_CASE macro. 24 // Support infrastructure for REGISTER_SANDBOX_TEST_CASE macro.
25 namespace internal { 25 namespace internal {
26 26
27 typedef std::map<std::string,MacSandboxTestCase*> SandboxTestMap;
28
29 // A function that returns a common map from string -> test case class.
27 SandboxTestMap& GetSandboxTestMap() { 30 SandboxTestMap& GetSandboxTestMap() {
28 static SandboxTestMap test_map; 31 static SandboxTestMap test_map;
29 return test_map; 32 return test_map;
30 } 33 }
31 34
35 void AddSandboxTestCase(const char* test_name, MacSandboxTestCase* test_class) {
36 SandboxTestMap& test_map = GetSandboxTestMap();
37 if (test_map.find(test_name) != test_map.end()) {
38 LOG(ERROR) << "Trying to register duplicate test" << test_name;
39 NOTREACHED();
40 }
41 test_map[test_name] = test_class;
42 }
43
32 } // namespace internal 44 } // namespace internal
33 45
34 bool MacSandboxTest:: RunTestInAllSandboxTypes(const char* test_name, 46 bool MacSandboxTest:: RunTestInAllSandboxTypes(const char* test_name,
35 const char* test_data) { 47 const char* test_data) {
36 // Go through all the sandbox types, and run the test case in each of them 48 // Go through all the sandbox types, and run the test case in each of them
37 // if one fails, abort. 49 // if one fails, abort.
38 for(int i = static_cast<int>(sandbox::SANDBOX_TYPE_FIRST_TYPE); 50 for(int i = static_cast<int>(sandbox::SANDBOX_TYPE_FIRST_TYPE);
39 i < sandbox::SANDBOX_AFTER_TYPE_LAST_TYPE; 51 i < sandbox::SANDBOX_AFTER_TYPE_LAST_TYPE;
40 ++i) { 52 ++i) {
41 if (!RunTestInSandbox(static_cast<sandbox::SandboxProcessType>(i), 53 if (!RunTestInSandbox(static_cast<sandbox::SandboxProcessType>(i),
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 144
133 if (!test_case->SandboxedTest()) { 145 if (!test_case->SandboxedTest()) {
134 LOG(ERROR) << sandbox_test_name << "Failed sandboxed test"; 146 LOG(ERROR) << sandbox_test_name << "Failed sandboxed test";
135 return -1; 147 return -1;
136 } 148 }
137 149
138 return 0; 150 return 0;
139 } 151 }
140 152
141 } // namespace 153 } // namespace
OLDNEW
« no previous file with comments | « chrome/common/sandbox_mac_unittest_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698