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 #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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/shared_memory.h" | 11 #include "base/shared_memory.h" |
| 12 #include "content/common/mac/font_descriptor.h" |
12 #include "content/common/mac/font_loader.h" | 13 #include "content/common/mac/font_loader.h" |
13 #include "content/common/sandbox_mac_unittest_helper.h" | 14 #include "content/common/sandbox_mac_unittest_helper.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 using sandboxtest::MacSandboxTest; | 19 using sandboxtest::MacSandboxTest; |
19 using sandbox::Sandbox; | 20 using sandbox::Sandbox; |
20 | 21 |
21 class FontLoadingTestCase : public sandboxtest::MacSandboxTestCase { | 22 class FontLoadingTestCase : public sandboxtest::MacSandboxTestCase { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 103 |
103 return true; | 104 return true; |
104 } | 105 } |
105 | 106 |
106 TEST_F(MacSandboxTest, FontLoadingTest) { | 107 TEST_F(MacSandboxTest, FontLoadingTest) { |
107 FilePath temp_file_path; | 108 FilePath temp_file_path; |
108 FILE* temp_file = file_util::CreateAndOpenTemporaryFile(&temp_file_path); | 109 FILE* temp_file = file_util::CreateAndOpenTemporaryFile(&temp_file_path); |
109 ASSERT_TRUE(temp_file); | 110 ASSERT_TRUE(temp_file); |
110 file_util::ScopedFILE temp_file_closer(temp_file); | 111 file_util::ScopedFILE temp_file_closer(temp_file); |
111 | 112 |
112 base::SharedMemory font_data; | |
113 uint32 font_data_size; | |
114 uint32 font_id; | |
115 NSFont* srcFont = [NSFont fontWithName:@"Geeza Pro" size:16.0]; | 113 NSFont* srcFont = [NSFont fontWithName:@"Geeza Pro" size:16.0]; |
116 EXPECT_TRUE(FontLoader::LoadFontIntoBuffer(srcFont, | 114 FontDescriptor descriptor(srcFont); |
117 &font_data, &font_data_size, &font_id)); | 115 FontLoader::Result result; |
118 EXPECT_GT(font_data_size, 0U); | 116 FontLoader::LoadFont(descriptor, &result); |
119 EXPECT_GT(font_id, 0U); | 117 EXPECT_GT(result.font_data_size, 0U); |
| 118 EXPECT_GT(result.font_id, 0U); |
120 | 119 |
121 file_util::WriteFileDescriptor(fileno(temp_file), | 120 file_util::WriteFileDescriptor(fileno(temp_file), |
122 static_cast<const char *>(font_data.memory()), font_data_size); | 121 static_cast<const char *>(result.font_data.memory()), |
| 122 result.font_data_size); |
123 | 123 |
124 ASSERT_TRUE(RunTestInSandbox(content::SANDBOX_TYPE_RENDERER, | 124 ASSERT_TRUE(RunTestInSandbox(content::SANDBOX_TYPE_RENDERER, |
125 "FontLoadingTestCase", temp_file_path.value().c_str())); | 125 "FontLoadingTestCase", temp_file_path.value().c_str())); |
126 temp_file_closer.reset(); | 126 temp_file_closer.reset(); |
127 ASSERT_TRUE(file_util::Delete(temp_file_path, false)); | 127 ASSERT_TRUE(file_util::Delete(temp_file_path, false)); |
128 } | 128 } |
129 | 129 |
130 } // namespace | 130 } // namespace |
OLD | NEW |