| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/tools/test_shell/test_shell.h" | 5 #include "webkit/tools/test_shell/test_shell.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <fontconfig/fontconfig.h> | 9 #include <fontconfig/fontconfig.h> |
| 10 #include <gtk/gtk.h> | 10 #include <gtk/gtk.h> |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // | 174 // |
| 175 // To avoid this we initialise fontconfig here and install a configuration | 175 // To avoid this we initialise fontconfig here and install a configuration |
| 176 // which only knows about a few, select, fonts. | 176 // which only knows about a few, select, fonts. |
| 177 | 177 |
| 178 // We have fontconfig parse a config file from our resources file. This | 178 // We have fontconfig parse a config file from our resources file. This |
| 179 // sets a number of aliases ("sans"->"Arial" etc), but doesn't include any | 179 // sets a number of aliases ("sans"->"Arial" etc), but doesn't include any |
| 180 // font directories. | 180 // font directories. |
| 181 | 181 |
| 182 // fontconfig only knows how to load font config configs from a file name, so | 182 // fontconfig only knows how to load font config configs from a file name, so |
| 183 // we write to a temp file. | 183 // we write to a temp file. |
| 184 StringPiece font_config_xml; | 184 base::StringPiece font_config_xml; |
| 185 g_resource_data_pack->Get(IDR_LINUX_FONT_CONFIG, &font_config_xml); | 185 g_resource_data_pack->Get(IDR_LINUX_FONT_CONFIG, &font_config_xml); |
| 186 FilePath fontconfig_path; | 186 FilePath fontconfig_path; |
| 187 if (!file_util::CreateTemporaryFile(&fontconfig_path)) { | 187 if (!file_util::CreateTemporaryFile(&fontconfig_path)) { |
| 188 LOG(FATAL) << "failed to create temp font config file"; | 188 LOG(FATAL) << "failed to create temp font config file"; |
| 189 } | 189 } |
| 190 if (-1 == file_util::WriteFile(fontconfig_path.ToWStringHack(), | 190 if (-1 == file_util::WriteFile(fontconfig_path.ToWStringHack(), |
| 191 font_config_xml.data(), | 191 font_config_xml.data(), |
| 192 font_config_xml.length())) { | 192 font_config_xml.length())) { |
| 193 LOG(FATAL) << "failed to write temp font config file"; | 193 LOG(FATAL) << "failed to write temp font config file"; |
| 194 } | 194 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 << "Without this, some layout tests will fail." | 263 << "Without this, some layout tests will fail." |
| 264 << "It's not a major problem. See the build instructions " | 264 << "It's not a major problem. See the build instructions " |
| 265 << "for more information on where to get all the data."; | 265 << "for more information on where to get all the data."; |
| 266 } else { | 266 } else { |
| 267 if (!FcConfigAppFontAddFile(fontcfg, (FcChar8 *) font)) | 267 if (!FcConfigAppFontAddFile(fontcfg, (FcChar8 *) font)) |
| 268 LOG(FATAL) << "Failed to load font " << font; | 268 LOG(FATAL) << "Failed to load font " << font; |
| 269 } | 269 } |
| 270 } | 270 } |
| 271 | 271 |
| 272 // Also load the layout-test-specific "Ahem" font. | 272 // Also load the layout-test-specific "Ahem" font. |
| 273 StringPiece ahem_font; | 273 base::StringPiece ahem_font; |
| 274 g_resource_data_pack->Get(IDR_AHEM_FONT, &ahem_font); | 274 g_resource_data_pack->Get(IDR_AHEM_FONT, &ahem_font); |
| 275 g_ahem_path = new FilePath; | 275 g_ahem_path = new FilePath; |
| 276 if (!file_util::CreateTemporaryFile(g_ahem_path)) { | 276 if (!file_util::CreateTemporaryFile(g_ahem_path)) { |
| 277 LOG(FATAL) << "failed to create temp ahem font"; | 277 LOG(FATAL) << "failed to create temp ahem font"; |
| 278 } | 278 } |
| 279 if (-1 == file_util::WriteFile(g_ahem_path->ToWStringHack(), ahem_font.data(), | 279 if (-1 == file_util::WriteFile(g_ahem_path->ToWStringHack(), ahem_font.data(), |
| 280 ahem_font.length())) { | 280 ahem_font.length())) { |
| 281 LOG(FATAL) << "failed to write temp ahem font"; | 281 LOG(FATAL) << "failed to write temp ahem font"; |
| 282 } | 282 } |
| 283 if (!FcConfigAppFontAddFile(fontcfg, FilePathAsFcChar(*g_ahem_path))) { | 283 if (!FcConfigAppFontAddFile(fontcfg, FilePathAsFcChar(*g_ahem_path))) { |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 // static | 625 // static |
| 626 void TestShell::ShowStartupDebuggingDialog() { | 626 void TestShell::ShowStartupDebuggingDialog() { |
| 627 GtkWidget* dialog = gtk_message_dialog_new( | 627 GtkWidget* dialog = gtk_message_dialog_new( |
| 628 NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "attach to me?"); | 628 NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "attach to me?"); |
| 629 gtk_window_set_title(GTK_WINDOW(dialog), "test_shell"); | 629 gtk_window_set_title(GTK_WINDOW(dialog), "test_shell"); |
| 630 gtk_dialog_run(GTK_DIALOG(dialog)); // Runs a nested message loop. | 630 gtk_dialog_run(GTK_DIALOG(dialog)); // Runs a nested message loop. |
| 631 gtk_widget_destroy(dialog); | 631 gtk_widget_destroy(dialog); |
| 632 } | 632 } |
| 633 | 633 |
| 634 // static | 634 // static |
| 635 StringPiece TestShell::NetResourceProvider(int key) { | 635 base::StringPiece TestShell::NetResourceProvider(int key) { |
| 636 StringPiece res; | 636 base::StringPiece res; |
| 637 g_resource_data_pack->Get(key, &res); | 637 g_resource_data_pack->Get(key, &res); |
| 638 return res; | 638 return res; |
| 639 } | 639 } |
| 640 | 640 |
| 641 //----------------------------------------------------------------------------- | 641 //----------------------------------------------------------------------------- |
| 642 | 642 |
| 643 namespace webkit_glue { | 643 namespace webkit_glue { |
| 644 | 644 |
| 645 string16 GetLocalizedString(int message_id) { | 645 string16 GetLocalizedString(int message_id) { |
| 646 StringPiece res; | 646 base::StringPiece res; |
| 647 if (!g_resource_data_pack->Get(message_id, &res)) { | 647 if (!g_resource_data_pack->Get(message_id, &res)) { |
| 648 LOG(FATAL) << "failed to load webkit string with id " << message_id; | 648 LOG(FATAL) << "failed to load webkit string with id " << message_id; |
| 649 } | 649 } |
| 650 | 650 |
| 651 return string16(reinterpret_cast<const char16*>(res.data()), | 651 return string16(reinterpret_cast<const char16*>(res.data()), |
| 652 res.length() / 2); | 652 res.length() / 2); |
| 653 } | 653 } |
| 654 | 654 |
| 655 StringPiece GetDataResource(int resource_id) { | 655 base::StringPiece GetDataResource(int resource_id) { |
| 656 switch (resource_id) { | 656 switch (resource_id) { |
| 657 case IDR_FEED_PREVIEW: | 657 case IDR_FEED_PREVIEW: |
| 658 // It is necessary to return a feed preview template that contains | 658 // It is necessary to return a feed preview template that contains |
| 659 // a {{URL}} substring where the feed URL should go; see the code | 659 // a {{URL}} substring where the feed URL should go; see the code |
| 660 // that computes feed previews in feed_preview.cc:MakeFeedPreview. | 660 // that computes feed previews in feed_preview.cc:MakeFeedPreview. |
| 661 // This fixes issue #932714. | 661 // This fixes issue #932714. |
| 662 resource_id = IDR_FEED_PREVIEW_TESTSHELL; | 662 resource_id = IDR_FEED_PREVIEW_TESTSHELL; |
| 663 break; | 663 break; |
| 664 case IDR_BROKENIMAGE: | 664 case IDR_BROKENIMAGE: |
| 665 resource_id = IDR_BROKENIMAGE_TESTSHELL; | 665 resource_id = IDR_BROKENIMAGE_TESTSHELL; |
| 666 break; | 666 break; |
| 667 case IDR_TEXTAREA_RESIZER: | 667 case IDR_TEXTAREA_RESIZER: |
| 668 resource_id = IDR_TEXTAREA_RESIZER_TESTSHELL; | 668 resource_id = IDR_TEXTAREA_RESIZER_TESTSHELL; |
| 669 break; | 669 break; |
| 670 } | 670 } |
| 671 return TestShell::NetResourceProvider(resource_id); | 671 return TestShell::NetResourceProvider(resource_id); |
| 672 } | 672 } |
| 673 | 673 |
| 674 void GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { | 674 void GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { |
| 675 NPAPI::PluginList::Singleton()->GetPlugins(refresh, plugins); | 675 NPAPI::PluginList::Singleton()->GetPlugins(refresh, plugins); |
| 676 } | 676 } |
| 677 | 677 |
| 678 } // namespace webkit_glue | 678 } // namespace webkit_glue |
| OLD | NEW |