Convert browser_tests to Swarming.
[chromium-blink-merge.git] / content / shell / renderer / layout_test / blink_test_helpers.cc
blob6719010a720e11bc25b9f2cf5e744891b5cb1095
1 // Copyright (c) 2012 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/renderer/layout_test/blink_test_helpers.h"
7 #include "base/command_line.h"
8 #include "base/files/file_util.h"
9 #include "base/path_service.h"
10 #include "base/strings/string_split.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "components/test_runner/test_preferences.h"
13 #include "content/public/common/content_switches.h"
14 #include "content/public/common/web_preferences.h"
15 #include "content/shell/common/shell_switches.h"
17 namespace content {
19 void ExportLayoutTestSpecificPreferences(
20 const test_runner::TestPreferences& from,
21 WebPreferences* to) {
22 to->allow_universal_access_from_file_urls =
23 from.allow_universal_access_from_file_urls;
24 to->dom_paste_enabled = from.dom_paste_allowed;
25 to->javascript_can_access_clipboard = from.java_script_can_access_clipboard;
26 to->xss_auditor_enabled = from.xss_auditor_enabled;
27 to->editing_behavior = static_cast<EditingBehavior>(from.editing_behavior);
28 to->default_font_size = from.default_font_size;
29 to->minimum_font_size = from.minimum_font_size;
30 to->default_encoding = from.default_text_encoding_name.utf8().data();
31 to->javascript_enabled = from.java_script_enabled;
32 to->supports_multiple_windows = from.supports_multiple_windows;
33 to->loads_images_automatically = from.loads_images_automatically;
34 to->plugins_enabled = from.plugins_enabled;
35 to->java_enabled = from.java_enabled;
36 to->application_cache_enabled = from.offline_web_application_cache_enabled;
37 to->tabs_to_links = from.tabs_to_links;
38 to->experimental_webgl_enabled = from.experimental_webgl_enabled;
39 // experimentalCSSRegionsEnabled is deprecated and ignored.
40 to->hyperlink_auditing_enabled = from.hyperlink_auditing_enabled;
41 to->caret_browsing_enabled = from.caret_browsing_enabled;
42 to->allow_displaying_insecure_content =
43 from.allow_display_of_insecure_content;
44 to->allow_running_insecure_content = from.allow_running_of_insecure_content;
45 to->should_respect_image_orientation = from.should_respect_image_orientation;
46 to->asynchronous_spell_checking_enabled =
47 from.asynchronous_spell_checking_enabled;
48 to->allow_file_access_from_file_urls = from.allow_file_access_from_file_urls;
49 to->javascript_can_open_windows_automatically =
50 from.java_script_can_open_windows_automatically;
51 to->web_security_enabled =
52 from.web_security_enabled;
53 to->disable_reading_from_canvas = from.disable_reading_from_canvas;
54 to->strict_mixed_content_checking =
55 from.strict_mixed_content_checking;
56 to->strict_powerful_feature_restrictions =
57 from.strict_powerful_feature_restrictions;
60 // Applies settings that differ between layout tests and regular mode. Some
61 // of the defaults are controlled via command line flags which are
62 // automatically set for layout tests.
63 void ApplyLayoutTestDefaultPreferences(WebPreferences* prefs) {
64 const base::CommandLine& command_line =
65 *base::CommandLine::ForCurrentProcess();
66 prefs->allow_universal_access_from_file_urls = true;
67 prefs->dom_paste_enabled = true;
68 prefs->javascript_can_access_clipboard = true;
69 prefs->xslt_enabled = true;
70 prefs->xss_auditor_enabled = false;
71 #if defined(OS_MACOSX)
72 prefs->editing_behavior = EDITING_BEHAVIOR_MAC;
73 #else
74 prefs->editing_behavior = EDITING_BEHAVIOR_WIN;
75 #endif
76 prefs->java_enabled = false;
77 prefs->application_cache_enabled = true;
78 prefs->tabs_to_links = false;
79 prefs->hyperlink_auditing_enabled = false;
80 prefs->allow_displaying_insecure_content = true;
81 prefs->allow_running_insecure_content = false;
82 prefs->disable_reading_from_canvas = false;
83 prefs->strict_mixed_content_checking = false;
84 prefs->strict_powerful_feature_restrictions = false;
85 prefs->webgl_errors_to_console_enabled = false;
86 base::string16 serif;
87 #if defined(OS_MACOSX)
88 prefs->cursive_font_family_map[kCommonScript] =
89 base::ASCIIToUTF16("Apple Chancery");
90 prefs->fantasy_font_family_map[kCommonScript] = base::ASCIIToUTF16("Papyrus");
91 serif = base::ASCIIToUTF16("Times");
92 #else
93 prefs->cursive_font_family_map[kCommonScript] =
94 base::ASCIIToUTF16("Comic Sans MS");
95 prefs->fantasy_font_family_map[kCommonScript] = base::ASCIIToUTF16("Impact");
96 serif = base::ASCIIToUTF16("times new roman");
97 #endif
98 prefs->serif_font_family_map[kCommonScript] = serif;
99 prefs->standard_font_family_map[kCommonScript] = serif;
100 prefs->fixed_font_family_map[kCommonScript] = base::ASCIIToUTF16("Courier");
101 prefs->sans_serif_font_family_map[kCommonScript] =
102 base::ASCIIToUTF16("Helvetica");
103 prefs->minimum_logical_font_size = 9;
104 prefs->asynchronous_spell_checking_enabled = false;
105 prefs->accelerated_2d_canvas_enabled =
106 command_line.HasSwitch(switches::kEnableAccelerated2DCanvas);
107 prefs->mock_scrollbars_enabled = false;
108 prefs->smart_insert_delete_enabled = true;
109 prefs->minimum_accelerated_2d_canvas_size = 0;
110 #if defined(OS_ANDROID)
111 prefs->text_autosizing_enabled = false;
112 #endif
113 prefs->viewport_enabled = false;
114 prefs->default_minimum_page_scale_factor = 1.f;
115 prefs->default_maximum_page_scale_factor = 4.f;
118 base::FilePath GetWebKitRootDirFilePath() {
119 base::FilePath base_path;
120 PathService::Get(base::DIR_SOURCE_ROOT, &base_path);
121 return base_path.Append(FILE_PATH_LITERAL("third_party/WebKit"));
124 std::vector<std::string> GetSideloadFontFiles() {
125 std::vector<std::string> files;
126 const base::CommandLine& command_line =
127 *base::CommandLine::ForCurrentProcess();
128 if (command_line.HasSwitch(switches::kRegisterFontFiles)) {
129 base::SplitString(
130 command_line.GetSwitchValueASCII(switches::kRegisterFontFiles),
131 ';',
132 &files);
134 return files;
137 } // namespace content