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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/mac/scoped_cftyperef.h" | 9 #include "base/mac/scoped_cftyperef.h" |
10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
11 #include "base/shared_memory.h" | 11 #include "base/shared_memory.h" |
12 #include "chrome/common/font_loader_mac.h" | 12 #include "chrome/common/font_loader_mac.h" |
13 #include "chrome/common/sandbox_mac_unittest_helper.h" | 13 #include "chrome/common/sandbox_mac_unittest_helper.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 using sandboxtest::MacSandboxTest; | 18 using sandboxtest::MacSandboxTest; |
| 19 using sandbox::Sandbox; |
19 | 20 |
20 bool CGFontFromFontContainer(ATSFontContainerRef container, CGFontRef* out) { | 21 bool CGFontFromFontContainer(ATSFontContainerRef container, CGFontRef* out) { |
21 // Count the number of fonts that were loaded. | 22 // Count the number of fonts that were loaded. |
22 ItemCount fontCount = 0; | 23 ItemCount fontCount = 0; |
23 OSStatus err = ATSFontFindFromContainer(container, kATSOptionFlagsDefault, 0, | 24 OSStatus err = ATSFontFindFromContainer(container, kATSOptionFlagsDefault, 0, |
24 NULL, &fontCount); | 25 NULL, &fontCount); |
25 | 26 |
26 if (err != noErr || fontCount < 1) { | 27 if (err != noErr || fontCount < 1) { |
27 return false; | 28 return false; |
28 } | 29 } |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 base::SharedMemory font_data; | 163 base::SharedMemory font_data; |
163 uint32 font_data_size; | 164 uint32 font_data_size; |
164 NSFont* srcFont = [NSFont fontWithName:@"Geeza Pro" size:16.0]; | 165 NSFont* srcFont = [NSFont fontWithName:@"Geeza Pro" size:16.0]; |
165 EXPECT_TRUE(FontLoader::LoadFontIntoBuffer(srcFont, | 166 EXPECT_TRUE(FontLoader::LoadFontIntoBuffer(srcFont, |
166 &font_data, &font_data_size)); | 167 &font_data, &font_data_size)); |
167 EXPECT_GT(font_data_size, 0U); | 168 EXPECT_GT(font_data_size, 0U); |
168 | 169 |
169 file_util::WriteFileDescriptor(fileno(temp_file), | 170 file_util::WriteFileDescriptor(fileno(temp_file), |
170 static_cast<const char *>(font_data.memory()), font_data_size); | 171 static_cast<const char *>(font_data.memory()), font_data_size); |
171 | 172 |
172 ASSERT_TRUE(RunTestInSandbox(sandbox::SANDBOX_TYPE_RENDERER, | 173 ASSERT_TRUE(RunTestInSandbox(Sandbox::SANDBOX_TYPE_RENDERER, |
173 "FontLoadingTestCase", temp_file_path.value().c_str())); | 174 "FontLoadingTestCase", temp_file_path.value().c_str())); |
174 temp_file_closer.reset(); | 175 temp_file_closer.reset(); |
175 ASSERT_TRUE(file_util::Delete(temp_file_path, false)); | 176 ASSERT_TRUE(file_util::Delete(temp_file_path, false)); |
176 } | 177 } |
177 | 178 |
178 } // namespace | 179 } // namespace |
OLD | NEW |