summaryrefslogtreecommitdiffstats
path: root/webkit/tools/test_shell/test_shell_mac.mm
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-10 22:05:40 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-10 22:05:40 +0000
commit480e1292b1020e47ab9486d4a0f3b1f0f2ddec81 (patch)
tree9a6e068ce40e673f23ade5f13f1ff0d79ea3800d /webkit/tools/test_shell/test_shell_mac.mm
parentce221d9f025d58085395cb8b66e68ce45d941fac (diff)
downloadchromium_src-480e1292b1020e47ab9486d4a0f3b1f0f2ddec81.zip
chromium_src-480e1292b1020e47ab9486d4a0f3b1f0f2ddec81.tar.gz
chromium_src-480e1292b1020e47ab9486d4a0f3b1f0f2ddec81.tar.bz2
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
Diffstat (limited to 'webkit/tools/test_shell/test_shell_mac.mm')
-rw-r--r--webkit/tools/test_shell/test_shell_mac.mm28
1 files changed, 23 insertions, 5 deletions
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;
}
}
}