Index: chrome/common/font_loader_mac_unittest.mm |
diff --git a/chrome/common/font_loader_mac_unittest.mm b/chrome/common/font_loader_mac_unittest.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..41112c857d1c7f60ed34224f892b0946743883d2 |
--- /dev/null |
+++ b/chrome/common/font_loader_mac_unittest.mm |
@@ -0,0 +1,50 @@ |
+// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/common/font_loader_mac.h" |
+ |
+#import <Cocoa/Cocoa.h> |
+ |
+#include "base/basictypes.h" |
+#include "base/scoped_cftyperef.h" |
+#include "base/string_util.h" |
+#include "testing/platform_test.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace { |
+ |
+class FontLoaderMacTest : public PlatformTest { |
+}; |
+ |
+TEST_F(FontLoaderMacTest, LoadFont) { |
+ base::SharedMemory font_data; |
+ uint32 font_data_size = 0; |
+ |
+ // Font we use for testing must not be in a .dfont container on 10.5 or 10.6 |
+ // see comment about font formats in font_loader_mac.h . |
+ ASSERT_TRUE(FontLoader::LoadFontIntoBuffer(ASCIIToUTF16("Geeza Pro"), |
+ 16.0, &font_data, &font_data_size)); |
+ EXPECT_GT(font_data_size, 0U); |
+ |
+ font_data.Unmap(); |
+ base::SharedMemoryHandle font_data_handle = font_data.handle(); |
+ scoped_cftyperef<CGFontRef> cgfont; |
+ |
+ CGFontRef tmp; |
+ EXPECT_TRUE(FontLoader::CreateCGFontFromBuffer(font_data_handle, |
+ font_data_size, &tmp)); |
+ ASSERT_TRUE(tmp != NULL); |
+ cgfont.reset(tmp); |
+ |
+ const NSFont* nsfont = reinterpret_cast<const NSFont*>( |
+ CTFontCreateWithGraphicsFont(cgfont.get(), 16.0, |
+ NULL, NULL)); |
+ [nsfont autorelease]; |
+ |
+ // Do something with the font to make sure it's loaded. |
+ CGFloat cap_height = [nsfont capHeight]; |
+ EXPECT_GT(cap_height, 0.0); |
+} |
+ |
+} // namespace |