Respond with QuotaExceededError when IndexedDB has no disk space on open.
[chromium-blink-merge.git] / content / shell / app / webkit_test_platform_support_linux.cc
blob3b04631ff62dac43eb14c1cbb66e59f7ec462f91
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/shell/app/webkit_test_platform_support.h"
7 #include <fontconfig/fontconfig.h>
8 #include <unistd.h>
10 #include <iostream>
12 #include "base/files/file_path.h"
13 #include "base/files/file_path.h"
14 #include "base/path_service.h"
16 namespace content {
18 namespace {
20 bool CheckAndLoadFontFile(
21 FcConfig* fontcfg, const char* path1, const char* path2) {
22 const char* font = path1;
23 if (access(font, R_OK) < 0) {
24 font = path2;
25 if (access(font, R_OK) < 0) {
26 std::cerr << "You are missing " << path1 << " or " << path2 << ". "
27 << "Without this, some layout tests may fail. See "
28 << "http://code.google.com/p/chromium/wiki/LayoutTestsLinux "
29 << "for more.\n";
30 return false;
33 if (!FcConfigAppFontAddFile(
34 fontcfg, reinterpret_cast<const FcChar8*>(font))) {
35 std::cerr << "Failed to load font " << font << "\n";
36 return false;
38 return true;
41 const char* const kFonts[] = {
42 "/usr/share/fonts/truetype/kochi/kochi-gothic.ttf",
43 "/usr/share/fonts/truetype/kochi/kochi-mincho.ttf",
44 "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf",
45 "/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf",
46 "/usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttf",
47 "/usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf",
48 "/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttf",
49 "/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS_Bold.ttf",
50 "/usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf",
51 "/usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold.ttf",
52 "/usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold_Italic.ttf",
53 "/usr/share/fonts/truetype/msttcorefonts/Courier_New_Italic.ttf",
54 "/usr/share/fonts/truetype/msttcorefonts/Georgia.ttf",
55 "/usr/share/fonts/truetype/msttcorefonts/Georgia_Bold.ttf",
56 "/usr/share/fonts/truetype/msttcorefonts/Georgia_Bold_Italic.ttf",
57 "/usr/share/fonts/truetype/msttcorefonts/Georgia_Italic.ttf",
58 "/usr/share/fonts/truetype/msttcorefonts/Impact.ttf",
59 "/usr/share/fonts/truetype/msttcorefonts/Trebuchet_MS.ttf",
60 "/usr/share/fonts/truetype/msttcorefonts/Trebuchet_MS_Bold.ttf",
61 "/usr/share/fonts/truetype/msttcorefonts/Trebuchet_MS_Bold_Italic.ttf",
62 "/usr/share/fonts/truetype/msttcorefonts/Trebuchet_MS_Italic.ttf",
63 "/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf",
64 "/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold.ttf",
65 "/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold_Italic.ttf",
66 "/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Italic.ttf",
67 "/usr/share/fonts/truetype/msttcorefonts/Verdana.ttf",
68 "/usr/share/fonts/truetype/msttcorefonts/Verdana_Bold.ttf",
69 "/usr/share/fonts/truetype/msttcorefonts/Verdana_Bold_Italic.ttf",
70 "/usr/share/fonts/truetype/msttcorefonts/Verdana_Italic.ttf",
71 // The DejaVuSans font is used by the css2.1 tests.
72 "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf",
73 "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_hi.ttf",
74 "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_ta.ttf",
75 "/usr/share/fonts/truetype/ttf-indic-fonts-core/MuktiNarrow.ttf",
78 bool SetupFontConfig() {
79 FcInit();
81 base::FilePath base_path;
82 PathService::Get(base::DIR_MODULE, &base_path);
83 base::FilePath fonts_conf = base_path.Append(FILE_PATH_LITERAL("fonts.conf"));
85 FcConfig* font_config = FcConfigCreate();
86 if (!FcConfigParseAndLoad(
87 font_config,
88 reinterpret_cast<const FcChar8*>(fonts_conf.value().c_str()),
89 true)) {
90 std::cerr << "Failed to parse fontconfig config file\n";
91 return false;
94 for (size_t i = 0; i < arraysize(kFonts); ++i) {
95 if (access(kFonts[i], R_OK) < 0) {
96 std::cerr << "You are missing " << kFonts[i] << ". Try re-running "
97 << "build/install-build-deps.sh. Also see "
98 << "http://code.google.com/p/chromium/wiki/LayoutTestsLinux";
99 return false;
101 if (!FcConfigAppFontAddFile(
102 font_config, reinterpret_cast<const FcChar8*>(kFonts[i]))) {
103 std::cerr << "Failed to load font " << kFonts[i] << "\n";
104 return false;
108 if (!CheckAndLoadFontFile(
109 font_config,
110 "/usr/share/fonts/truetype/thai/Garuda.ttf",
111 "/usr/share/fonts/truetype/tlwg/Garuda.ttf")) {
112 return false;
115 // We special case these fonts because they're only needed in a few layout
116 // tests.
117 CheckAndLoadFontFile(
118 font_config,
119 "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_pa.ttf",
120 "/usr/share/fonts/truetype/ttf-punjabi-fonts/lohit_pa.ttf");
122 base::FilePath ahem_font = base_path.Append("AHEM____.TTF");
123 if (!FcConfigAppFontAddFile(
124 font_config,
125 reinterpret_cast<const FcChar8*>(ahem_font.value().c_str()))) {
126 std::cerr << "Failed to load font " << ahem_font.value() << "\n";
127 return false;
130 if (!FcConfigSetCurrent(font_config)) {
131 std::cerr << "Failed to set the default font configuration\n";
132 return false;
135 return true;
138 } // namespace
140 bool CheckLayoutSystemDeps() {
141 return true;
144 bool WebKitTestPlatformInitialize() {
145 return SetupFontConfig();
148 } // namespace content