From 480e1292b1020e47ab9486d4a0f3b1f0f2ddec81 Mon Sep 17 00:00:00 2001 From: "mark@chromium.org" Date: Wed, 10 Dec 2008 22:05:40 +0000 Subject: Load the Ahem font from the source tree when not running bundled, for test_shell_tests. Review URL: http://codereview.chromium.org/13719 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6738 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/tools/test_shell/test_shell_mac.mm | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'webkit/tools/test_shell/test_shell_mac.mm') diff --git a/webkit/tools/test_shell/test_shell_mac.mm b/webkit/tools/test_shell/test_shell_mac.mm index eaec764..fd2bd99 100644 --- a/webkit/tools/test_shell/test_shell_mac.mm +++ b/webkit/tools/test_shell/test_shell_mac.mm @@ -138,12 +138,30 @@ void TestShell::InitializeTestShell(bool layout_test_mode) { ResetWebPreferences(); // Load the Ahem font, which is used by layout tests. - NSString* ahem_path = [[[NSBundle mainBundle] resourcePath] - stringByAppendingPathComponent:@"AHEM____.TTF"]; - const char* ahem_path_c = [ahem_path fileSystemRepresentation]; + const char* ahem_path_c; + FilePath ahem_path; // Ensure ahem_path_c storage is not freed too soon. + if (mac_util::AmIBundled()) { + // When bundled (in TestShell.app), expect to find the font in + // Contents/Resources. + NSString* ahem_path = [[[NSBundle mainBundle] resourcePath] + stringByAppendingPathComponent:@"AHEM____.TTF"]; + ahem_path_c = [ahem_path fileSystemRepresentation]; + } else { + // When not bundled (in test_shell_tests), look in the source tree for + // the font. + PathService::Get(base::DIR_SOURCE_ROOT, &ahem_path); + ahem_path = ahem_path.Append("webkit"); + ahem_path = ahem_path.Append("tools"); + ahem_path = ahem_path.Append("test_shell"); + ahem_path = ahem_path.Append("resources"); + ahem_path = ahem_path.Append("AHEM____.TTF"); + + ahem_path_c = ahem_path.value().c_str(); + } + FSRef ahem_fsref; if (!mac_util::FSRefFromPath(ahem_path_c, &ahem_fsref)) { - DCHECK(false) << "FSRefFromPath " << ahem_path_c; + DLOG(FATAL) << "FSRefFromPath " << ahem_path_c; } else { // The last argument is an ATSFontContainerRef that can be passed to // ATSFontDeactivate to unload the font. Since the font is only loaded @@ -154,7 +172,7 @@ void TestShell::InitializeTestShell(bool layout_test_mode) { NULL, kATSOptionFlagsDefault, NULL) != noErr) { - DCHECK(false) << "ATSFontActivateFromFileReference " << ahem_path_c; + DLOG(FATAL) << "ATSFontActivateFromFileReference " << ahem_path_c; } } } -- cgit v1.1