OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_descriptor.h" |
13 #include "content/common/mac/font_loader.h" | 13 #include "content/common/mac/font_loader.h" |
14 #include "content/common/sandbox_mac_unittest_helper.h" | 14 #include "content/common/sandbox_mac_unittest_helper.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 namespace { | 17 namespace content { |
18 | 18 |
19 using sandboxtest::MacSandboxTest; | 19 class FontLoadingTestCase : public MacSandboxTestCase { |
20 using sandbox::Sandbox; | |
21 | |
22 class FontLoadingTestCase : public sandboxtest::MacSandboxTestCase { | |
23 public: | 20 public: |
24 FontLoadingTestCase() : font_data_length_(-1) {} | 21 FontLoadingTestCase() : font_data_length_(-1) {} |
25 virtual bool BeforeSandboxInit(); | 22 virtual bool BeforeSandboxInit(); |
26 virtual bool SandboxedTest(); | 23 virtual bool SandboxedTest(); |
27 private: | 24 private: |
28 scoped_ptr<base::SharedMemory> font_shmem_; | 25 scoped_ptr<base::SharedMemory> font_shmem_; |
29 size_t font_data_length_; | 26 size_t font_data_length_; |
30 }; | 27 }; |
31 REGISTER_SANDBOX_TEST_CASE(FontLoadingTestCase); | 28 REGISTER_SANDBOX_TEST_CASE(FontLoadingTestCase); |
32 | 29 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 FontDescriptor descriptor(srcFont); | 111 FontDescriptor descriptor(srcFont); |
115 FontLoader::Result result; | 112 FontLoader::Result result; |
116 FontLoader::LoadFont(descriptor, &result); | 113 FontLoader::LoadFont(descriptor, &result); |
117 EXPECT_GT(result.font_data_size, 0U); | 114 EXPECT_GT(result.font_data_size, 0U); |
118 EXPECT_GT(result.font_id, 0U); | 115 EXPECT_GT(result.font_id, 0U); |
119 | 116 |
120 file_util::WriteFileDescriptor(fileno(temp_file), | 117 file_util::WriteFileDescriptor(fileno(temp_file), |
121 static_cast<const char *>(result.font_data.memory()), | 118 static_cast<const char *>(result.font_data.memory()), |
122 result.font_data_size); | 119 result.font_data_size); |
123 | 120 |
124 ASSERT_TRUE(RunTestInSandbox(content::SANDBOX_TYPE_RENDERER, | 121 ASSERT_TRUE(RunTestInSandbox(SANDBOX_TYPE_RENDERER, |
125 "FontLoadingTestCase", temp_file_path.value().c_str())); | 122 "FontLoadingTestCase", temp_file_path.value().c_str())); |
126 temp_file_closer.reset(); | 123 temp_file_closer.reset(); |
127 ASSERT_TRUE(file_util::Delete(temp_file_path, false)); | 124 ASSERT_TRUE(file_util::Delete(temp_file_path, false)); |
128 } | 125 } |
129 | 126 |
130 } // namespace | 127 } // namespace content |
OLD | NEW |