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

Unified Diff: chrome/common/font_loader_mac_unittest.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/font_loader_mac.mm ('k') | chrome/common/sandbox_mac_diraccess_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « chrome/common/font_loader_mac.mm ('k') | chrome/common/sandbox_mac_diraccess_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698