summaryrefslogtreecommitdiffstats
path: root/webkit/tools
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-21 23:20:19 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-21 23:20:19 +0000
commit930eefad81129f1c8db7621f8a02e02b855adf90 (patch)
tree61298a1c929c488f27665bc7555d96c9e9661b30 /webkit/tools
parentfe5a18648ccda4949a580ce614bdeb9ee71c9cf2 (diff)
downloadchromium_src-930eefad81129f1c8db7621f8a02e02b855adf90.zip
chromium_src-930eefad81129f1c8db7621f8a02e02b855adf90.tar.gz
chromium_src-930eefad81129f1c8db7621f8a02e02b855adf90.tar.bz2
Add additional linux resources to test_shell_resources.
After this change, test_shell only requires icudt38l.dat and test_shell.pak. Review URL: http://codereview.chromium.org/18463 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8405 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools')
-rw-r--r--webkit/tools/test_shell/SConscript3
-rw-r--r--webkit/tools/test_shell/test_shell.h1
-rw-r--r--webkit/tools/test_shell/test_shell_gtk.cc54
-rw-r--r--webkit/tools/test_shell/test_shell_mac.mm1
-rw-r--r--webkit/tools/test_shell/test_shell_resources.grd3
-rw-r--r--webkit/tools/test_shell/test_shell_win.cc1
6 files changed, 48 insertions, 15 deletions
diff --git a/webkit/tools/test_shell/SConscript b/webkit/tools/test_shell/SConscript
index f42160b..45213a9 100644
--- a/webkit/tools/test_shell/SConscript
+++ b/webkit/tools/test_shell/SConscript
@@ -115,7 +115,7 @@ input_files = [
'text_input_controller.cc',
]
if env.Bit('windows'):
- # TODO(port): Consider porting drag_delegate.cc and drop_delecate.cc.
+ # TODO(port): Consider porting drag_delegate.cc and drop_delegate.cc.
input_files.extend([
'drag_delegate.cc',
'drop_delegate.cc',
@@ -175,7 +175,6 @@ exe_input_files = [
]
if env.Bit('windows'):
- # TODO(port): figure out what to do with resources.
resources = [
env_res.RES('resources/test_shell.rc'),
'$TARGET_ROOT/grit_derived_sources/net_resources.res',
diff --git a/webkit/tools/test_shell/test_shell.h b/webkit/tools/test_shell/test_shell.h
index 3da7b8a..d6afe61 100644
--- a/webkit/tools/test_shell/test_shell.h
+++ b/webkit/tools/test_shell/test_shell.h
@@ -39,7 +39,6 @@
#include "base/ref_counted.h"
#include "webkit/tools/test_shell/event_sending_controller.h"
#include "webkit/tools/test_shell/layout_test_controller.h"
-#include "webkit/tools/test_shell/resource.h"
#include "webkit/tools/test_shell/text_input_controller.h"
#include "webkit/tools/test_shell/test_webview_delegate.h"
#include "webkit/tools/test_shell/webview_host.h"
diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc
index 3cac690..f085393 100644
--- a/webkit/tools/test_shell/test_shell_gtk.cc
+++ b/webkit/tools/test_shell/test_shell_gtk.cc
@@ -45,7 +45,10 @@ const FcChar8* FilePathAsFcChar(const FilePath& path) {
}
// Data resources on linux. This is a pointer to the mmapped resources file.
-static base::DataPack* g_resource_data_pack;
+static base::DataPack* g_resource_data_pack = NULL;
+
+// Used to keep track of the temporary ahem file we extract to disk.
+static FilePath* g_ahem_path = NULL;
}
@@ -60,8 +63,9 @@ void TestShell::InitializeTestShell(bool layout_test_mode) {
FilePath data_path;
PathService::Get(base::DIR_EXE, &data_path);
data_path = data_path.Append("test_shell.pak");
- bool success = g_resource_data_pack->Load(data_path);
- CHECK(success) << "failed to load test_shell.pak";
+ if (!g_resource_data_pack->Load(data_path)) {
+ LOG(FATAL) << "failed to load test_shell.pak";
+ }
ResetWebPreferences();
@@ -73,22 +77,33 @@ void TestShell::InitializeTestShell(bool layout_test_mode) {
// To avoid this we initialise fontconfig here and install a configuration
// which only knows about a few, select, fonts.
- FilePath resources_path;
- PathService::Get(base::DIR_SOURCE_ROOT, &resources_path);
- resources_path = resources_path.Append("webkit/tools/test_shell/resources/");
-
- // We have fontconfig parse a config file from our resources directory. This
+ // We have fontconfig parse a config file from our resources file. This
// sets a number of aliases ("sans"->"Arial" etc), but doesn't include any
// font directories.
+ // fontconfig only knows how to load font config configs from a file name, so
+ // we write to a temp file.
+ StringPiece font_config_xml;
+ g_resource_data_pack->Get(IDR_LINUX_FONT_CONFIG, &font_config_xml);
+ FilePath fontconfig_path;
+ if (!file_util::CreateTemporaryFileName(&fontconfig_path)) {
+ LOG(FATAL) << "failed to create temp font config file";
+ }
+ if (-1 == file_util::WriteFile(fontconfig_path.ToWStringHack(),
+ font_config_xml.data(),
+ font_config_xml.length())) {
+ LOG(FATAL) << "failed to write temp font config file";
+ }
+
FcInit();
FcConfig* fontcfg = FcConfigCreate();
- FilePath fontconfig_path = resources_path.Append("linux-fontconfig-config");
if (!FcConfigParseAndLoad(fontcfg, FilePathAsFcChar(fontconfig_path),
true)) {
LOG(FATAL) << "Failed to parse fontconfig config file";
}
+ // We can delete the temp file after font config has parsed it.
+ file_util::Delete(fontconfig_path, false);
// This is the list of fonts that fontconfig will know about. It will try its
// best to match based only on the fonts here in. The paths are where these
@@ -146,9 +161,18 @@ void TestShell::InitializeTestShell(bool layout_test_mode) {
}
// Also load the layout-test-specific "Ahem" font.
- FilePath ahem_path = resources_path.Append("AHEM____.TTF");
- if (!FcConfigAppFontAddFile(fontcfg, FilePathAsFcChar(ahem_path))) {
- LOG(FATAL) << "Failed to load font " << ahem_path.value().c_str();
+ StringPiece ahem_font;
+ g_resource_data_pack->Get(IDR_AHEM_FONT, &ahem_font);
+ g_ahem_path = new FilePath;
+ if (!file_util::CreateTemporaryFileName(g_ahem_path)) {
+ LOG(FATAL) << "failed to create temp ahem font";
+ }
+ if (-1 == file_util::WriteFile(g_ahem_path->ToWStringHack(), ahem_font.data(),
+ ahem_font.length())) {
+ LOG(FATAL) << "failed to write temp ahem font";
+ }
+ if (!FcConfigAppFontAddFile(fontcfg, FilePathAsFcChar(*g_ahem_path))) {
+ LOG(FATAL) << "Failed to load font " << g_ahem_path->value().c_str();
}
if (!FcConfigSetCurrent(fontcfg))
@@ -158,6 +182,12 @@ void TestShell::InitializeTestShell(bool layout_test_mode) {
void TestShell::PlatformShutdown() {
delete g_resource_data_pack;
g_resource_data_pack = NULL;
+
+ if (g_ahem_path) {
+ file_util::Delete(*g_ahem_path, false);
+ delete g_ahem_path;
+ g_ahem_path = NULL;
+ }
}
void TestShell::PlatformCleanUp() {
diff --git a/webkit/tools/test_shell/test_shell_mac.mm b/webkit/tools/test_shell/test_shell_mac.mm
index 4e8c22e..b1e8ac1 100644
--- a/webkit/tools/test_shell/test_shell_mac.mm
+++ b/webkit/tools/test_shell/test_shell_mac.mm
@@ -35,6 +35,7 @@
#include "webkit/glue/webwidget.h"
#include "webkit/glue/plugins/plugin_list.h"
#include "webkit/tools/test_shell/mac/test_shell_webview.h"
+#include "webkit/tools/test_shell/resource.h"
#include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
#include "webkit/tools/test_shell/test_navigation_controller.h"
diff --git a/webkit/tools/test_shell/test_shell_resources.grd b/webkit/tools/test_shell/test_shell_resources.grd
index 7978b60..7f7e93d 100644
--- a/webkit/tools/test_shell/test_shell_resources.grd
+++ b/webkit/tools/test_shell/test_shell_resources.grd
@@ -11,6 +11,9 @@
<include name="IDR_BROKENIMAGE_TESTSHELL" file="resources\missingImage.gif" type="BINDATA" />
<include name="IDR_FEED_PREVIEW_TESTSHELL" file="resources\feed.html" type="BINDATA" />
<include name="IDR_TEXTAREA_RESIZER_TESTSHELL" file="resources\textAreaResizeCorner.png" type="BINDATA" />
+
+ <include name="IDR_LINUX_FONT_CONFIG" file="resources\linux-fontconfig-config" type="BINDATA" />
+ <include name="IDR_AHEM_FONT" file="resources\AHEM____.TTF" type="BINDATA" />
</includes>
</release>
</grit>
diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc
index e217314..1f880e8 100644
--- a/webkit/tools/test_shell/test_shell_win.cc
+++ b/webkit/tools/test_shell/test_shell_win.cc
@@ -31,6 +31,7 @@
#include "webkit/glue/webpreferences.h"
#include "webkit/glue/webview.h"
#include "webkit/glue/plugins/plugin_list.h"
+#include "webkit/tools/test_shell/resource.h"
#include "webkit/tools/test_shell/test_navigation_controller.h"
#include "webkit/tools/test_shell/test_shell_switches.h"