diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-07 14:42:12 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-07 14:42:12 +0000 |
commit | b7c504cecc8b04c302e281ebc72da98ee4a6dd2d (patch) | |
tree | d7ea23ca69c62eda1f0972c7c64acb13c7311108 /content/shell/common | |
parent | b2dfbc509328f83c1996c16bee638ab14416abeb (diff) | |
download | chromium_src-b7c504cecc8b04c302e281ebc72da98ee4a6dd2d.zip chromium_src-b7c504cecc8b04c302e281ebc72da98ee4a6dd2d.tar.gz chromium_src-b7c504cecc8b04c302e281ebc72da98ee4a6dd2d.tar.bz2 |
[content shell] move code common to several processes to a common dir
BUG=180021
TBR=marja@chromium.org
Review URL: https://codereview.chromium.org/14767019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198723 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell/common')
-rw-r--r-- | content/shell/common/shell_content_client.cc | 109 | ||||
-rw-r--r-- | content/shell/common/shell_content_client.h | 32 | ||||
-rw-r--r-- | content/shell/common/shell_messages.cc | 33 | ||||
-rw-r--r-- | content/shell/common/shell_messages.h | 103 | ||||
-rw-r--r-- | content/shell/common/shell_switches.cc | 40 | ||||
-rw-r--r-- | content/shell/common/shell_switches.h | 25 | ||||
-rw-r--r-- | content/shell/common/shell_test_configuration.cc | 16 | ||||
-rw-r--r-- | content/shell/common/shell_test_configuration.h | 43 | ||||
-rw-r--r-- | content/shell/common/webkit_test_helpers.cc | 146 | ||||
-rw-r--r-- | content/shell/common/webkit_test_helpers.h | 40 |
10 files changed, 587 insertions, 0 deletions
diff --git a/content/shell/common/shell_content_client.cc b/content/shell/common/shell_content_client.cc new file mode 100644 index 0000000..6b9a9bf --- /dev/null +++ b/content/shell/common/shell_content_client.cc @@ -0,0 +1,109 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/shell/common/shell_content_client.h" + +#include "base/command_line.h" +#include "base/strings/string_piece.h" +#include "base/utf_string_conversions.h" +#include "content/public/common/content_switches.h" +#include "content/shell/common/shell_switches.h" +#include "grit/shell_resources.h" +#include "grit/webkit_resources.h" +#include "grit/webkit_strings.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/base/resource/resource_bundle.h" +#include "webkit/user_agent/user_agent_util.h" + +namespace content { + +ShellContentClient::~ShellContentClient() { +} + +std::string ShellContentClient::GetUserAgent() const { + std::string product = "Chrome/" CONTENT_SHELL_VERSION; + CommandLine* command_line = CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kUseMobileUserAgent)) + product += " Mobile"; + return webkit_glue::BuildUserAgentFromProduct(product); +} + +string16 ShellContentClient::GetLocalizedString(int message_id) const { + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { + switch (message_id) { + case IDS_FORM_VALIDATION_VALUE_MISSING: + case IDS_FORM_VALIDATION_VALUE_MISSING_CHECKBOX: + case IDS_FORM_VALIDATION_VALUE_MISSING_FILE: + case IDS_FORM_VALIDATION_VALUE_MISSING_MULTIPLE_FILE: + case IDS_FORM_VALIDATION_VALUE_MISSING_RADIO: + case IDS_FORM_VALIDATION_VALUE_MISSING_SELECT: + return ASCIIToUTF16("value missing"); + case IDS_FORM_VALIDATION_TYPE_MISMATCH: + case IDS_FORM_VALIDATION_TYPE_MISMATCH_EMAIL: + case IDS_FORM_VALIDATION_TYPE_MISMATCH_MULTIPLE_EMAIL: + case IDS_FORM_VALIDATION_TYPE_MISMATCH_URL: + return ASCIIToUTF16("type mismatch"); + case IDS_FORM_VALIDATION_PATTERN_MISMATCH: + return ASCIIToUTF16("pattern mismatch"); + case IDS_FORM_VALIDATION_TOO_LONG: + return ASCIIToUTF16("too long"); + case IDS_FORM_VALIDATION_RANGE_UNDERFLOW: + return ASCIIToUTF16("range underflow"); + case IDS_FORM_VALIDATION_RANGE_OVERFLOW: + return ASCIIToUTF16("range overflow"); + case IDS_FORM_VALIDATION_STEP_MISMATCH: + return ASCIIToUTF16("step mismatch"); + case IDS_FORM_OTHER_DATE_LABEL: + return ASCIIToUTF16("<<OtherDateLabel>>"); + case IDS_FORM_OTHER_MONTH_LABEL: + return ASCIIToUTF16("<<OtherMonthLabel>>"); + case IDS_FORM_OTHER_TIME_LABEL: + return ASCIIToUTF16("<<OtherTimeLabel>>"); + case IDS_FORM_OTHER_WEEK_LABEL: + return ASCIIToUTF16("<<OtherWeekLabel>>"); + case IDS_FORM_CALENDAR_CLEAR: + return ASCIIToUTF16("<<CalendarClear>>"); + case IDS_FORM_CALENDAR_TODAY: + return ASCIIToUTF16("<<CalendarToday>>"); + case IDS_FORM_THIS_MONTH_LABEL: + return ASCIIToUTF16("<<ThisMonthLabel>>"); + case IDS_FORM_THIS_WEEK_LABEL: + return ASCIIToUTF16("<<ThisWeekLabel>>"); + } + } + return l10n_util::GetStringUTF16(message_id); +} + +base::StringPiece ShellContentClient::GetDataResource( + int resource_id, + ui::ScaleFactor scale_factor) const { + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { + switch (resource_id) { + case IDR_BROKENIMAGE: +#if defined(OS_MACOSX) + resource_id = IDR_CONTENT_SHELL_MISSING_IMAGE_PNG; +#else + resource_id = IDR_CONTENT_SHELL_MISSING_IMAGE_GIF; +#endif + break; + + case IDR_TEXTAREA_RESIZER: + resource_id = IDR_CONTENT_SHELL_TEXT_AREA_RESIZE_CORNER_PNG; + break; + } + } + return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( + resource_id, scale_factor); +} + +base::RefCountedStaticMemory* ShellContentClient::GetDataResourceBytes( + int resource_id) const { + return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id); +} + +gfx::Image& ShellContentClient::GetNativeImageNamed(int resource_id) const { + return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); +} + +} // namespace content diff --git a/content/shell/common/shell_content_client.h b/content/shell/common/shell_content_client.h new file mode 100644 index 0000000..84a1483 --- /dev/null +++ b/content/shell/common/shell_content_client.h @@ -0,0 +1,32 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_SHELL_COMMON_SHELL_CONTENT_CLIENT_H_ +#define CONTENT_SHELL_COMMON_SHELL_CONTENT_CLIENT_H_ + +#include <string> +#include <vector> + +#include "base/compiler_specific.h" +#include "content/public/common/content_client.h" + +namespace content { + +class ShellContentClient : public ContentClient { + public: + virtual ~ShellContentClient(); + + virtual std::string GetUserAgent() const OVERRIDE; + virtual string16 GetLocalizedString(int message_id) const OVERRIDE; + virtual base::StringPiece GetDataResource( + int resource_id, + ui::ScaleFactor scale_factor) const OVERRIDE; + virtual base::RefCountedStaticMemory* GetDataResourceBytes( + int resource_id) const OVERRIDE; + virtual gfx::Image& GetNativeImageNamed(int resource_id) const OVERRIDE; +}; + +} // namespace content + +#endif // CONTENT_SHELL_COMMON_SHELL_CONTENT_CLIENT_H_ diff --git a/content/shell/common/shell_messages.cc b/content/shell/common/shell_messages.cc new file mode 100644 index 0000000..3eae912 --- /dev/null +++ b/content/shell/common/shell_messages.cc @@ -0,0 +1,33 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Get basic type definitions. +#define IPC_MESSAGE_IMPL +#include "content/shell/common/shell_messages.h" + +// Generate constructors. +#include "ipc/struct_constructor_macros.h" +#include "content/shell/common/shell_messages.h" + +// Generate destructors. +#include "ipc/struct_destructor_macros.h" +#include "content/shell/common/shell_messages.h" + +// Generate param traits write methods. +#include "ipc/param_traits_write_macros.h" +namespace IPC { +#include "content/shell/common/shell_messages.h" +} // namespace IPC + +// Generate param traits read methods. +#include "ipc/param_traits_read_macros.h" +namespace IPC { +#include "content/shell/common/shell_messages.h" +} // namespace IPC + +// Generate param traits log methods. +#include "ipc/param_traits_log_macros.h" +namespace IPC { +#include "content/shell/common/shell_messages.h" +} // namespace IPC diff --git a/content/shell/common/shell_messages.h b/content/shell/common/shell_messages.h new file mode 100644 index 0000000..fb10973 --- /dev/null +++ b/content/shell/common/shell_messages.h @@ -0,0 +1,103 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Multiply-included file, no traditional include guard. +#include <string> +#include <vector> + +#include "content/public/common/common_param_traits.h" +#include "content/shell/common/shell_test_configuration.h" +#include "ipc/ipc_message_macros.h" +#include "ipc/ipc_platform_file.h" +#include "third_party/skia/include/core/SkBitmap.h" + +#define IPC_MESSAGE_START ShellMsgStart + +IPC_STRUCT_TRAITS_BEGIN(content::ShellTestConfiguration) +IPC_STRUCT_TRAITS_MEMBER(current_working_directory) +IPC_STRUCT_TRAITS_MEMBER(temp_path) +IPC_STRUCT_TRAITS_MEMBER(test_url) +IPC_STRUCT_TRAITS_MEMBER(enable_pixel_dumping) +IPC_STRUCT_TRAITS_MEMBER(layout_test_timeout) +IPC_STRUCT_TRAITS_MEMBER(allow_external_pages) +IPC_STRUCT_TRAITS_MEMBER(expected_pixel_hash) +IPC_STRUCT_TRAITS_END() + +// Tells the renderer to reset all test runners. +IPC_MESSAGE_ROUTED0(ShellViewMsg_Reset) + +// Sets the path to the WebKit checkout. +IPC_MESSAGE_CONTROL1(ShellViewMsg_SetWebKitSourceDir, + base::FilePath /* webkit source dir */) + +// Loads the hyphen dictionary used for layout tests. +IPC_MESSAGE_CONTROL1(ShellViewMsg_LoadHyphenDictionary, + IPC::PlatformFileForTransit /* dict_file */) + +// Sets the initial configuration to use for layout tests. +IPC_MESSAGE_ROUTED1(ShellViewMsg_SetTestConfiguration, + content::ShellTestConfiguration) + +// Tells the main window that a secondary window in a different process invoked +// notifyDone(). +IPC_MESSAGE_ROUTED0(ShellViewMsg_NotifyDone) + +// Pushes a snapshot of the current session history from the browser process. +// This includes only information about those RenderViews that are in the +// same process as the main window of the layout test and that are the current +// active RenderView of their WebContents. +IPC_MESSAGE_ROUTED3( + ShellViewMsg_SessionHistory, + std::vector<int> /* routing_ids */, + std::vector<std::vector<std::string> > /* session_histories */, + std::vector<unsigned> /* current_entry_indexes */) + +// Send a text dump of the WebContents to the render host. +IPC_MESSAGE_ROUTED1(ShellViewHostMsg_TextDump, + std::string /* dump */) + +// Send an image dump of the WebContents to the render host. +IPC_MESSAGE_ROUTED2(ShellViewHostMsg_ImageDump, + std::string /* actual pixel hash */, + SkBitmap /* image */) + +// Send an audio dump to the render host. +IPC_MESSAGE_ROUTED1(ShellViewHostMsg_AudioDump, + std::vector<unsigned char> /* audio data */) + +IPC_MESSAGE_ROUTED1(ShellViewHostMsg_TestFinished, + bool /* did_timeout */) + +IPC_MESSAGE_ROUTED0(ShellViewHostMsg_ResetDone) + +IPC_MESSAGE_ROUTED0(ShellViewHostMsg_TestFinishedInSecondaryWindow) + +// WebTestDelegate related. +IPC_MESSAGE_ROUTED1(ShellViewHostMsg_OverridePreferences, + WebPreferences /* preferences */) +IPC_SYNC_MESSAGE_ROUTED1_1(ShellViewHostMsg_RegisterIsolatedFileSystem, + std::vector<base::FilePath> /* absolute_filenames */, + std::string /* filesystem_id */) +IPC_SYNC_MESSAGE_ROUTED1_1(ShellViewHostMsg_ReadFileToString, + base::FilePath /* local path */, + std::string /* contents */) +IPC_MESSAGE_ROUTED1(ShellViewHostMsg_PrintMessage, + std::string /* message */) +IPC_MESSAGE_ROUTED0(ShellViewHostMsg_ShowDevTools) +IPC_MESSAGE_ROUTED0(ShellViewHostMsg_CloseDevTools) +IPC_MESSAGE_ROUTED1(ShellViewHostMsg_GoToOffset, + int /* offset */) +IPC_MESSAGE_ROUTED0(ShellViewHostMsg_Reload) +IPC_MESSAGE_ROUTED2(ShellViewHostMsg_LoadURLForFrame, + GURL /* url */, + std::string /* frame_name */) +IPC_MESSAGE_ROUTED0(ShellViewHostMsg_ClearAllDatabases) +IPC_MESSAGE_ROUTED1(ShellViewHostMsg_SetDatabaseQuota, + int /* quota */) +IPC_MESSAGE_ROUTED1(ShellViewHostMsg_AcceptAllCookies, + bool /* accept */) +IPC_MESSAGE_ROUTED1(ShellViewHostMsg_SetDeviceScaleFactor, + float /* factor */) +IPC_MESSAGE_ROUTED0(ShellViewHostMsg_CaptureSessionHistory) +IPC_MESSAGE_ROUTED0(ShellViewHostMsg_CloseRemainingWindows) diff --git a/content/shell/common/shell_switches.cc b/content/shell/common/shell_switches.cc new file mode 100644 index 0000000..6cc052a --- /dev/null +++ b/content/shell/common/shell_switches.cc @@ -0,0 +1,40 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/shell/common/shell_switches.h" + +namespace switches { + +// Allow access to external pages during layout tests. +const char kAllowExternalPages[] = "allow-external-pages"; + +// Check whether all system dependencies for running layout tests are met. +const char kCheckLayoutTestSysDeps[] = "check-layout-test-sys-deps"; + +// Tells Content Shell that it's running as a content_browsertest. +const char kContentBrowserTest[] = "browser-test"; + +// Makes Content Shell use the given path for its data directory. +const char kContentShellDataPath[] = "data-path"; + +// Show the content_shell window, even when running in layout test mode. +const char kDisableHeadlessForLayoutTests[] = + "disable-headless-for-layout-tests"; + +// Request pages to be dumped as text once they finished loading. +const char kDumpRenderTree[] = "dump-render-tree"; + +// Enable accelerated 2D canvas. +const char kEnableAccelerated2DCanvas[] = "enable-accelerated-2d-canvas"; + +// Alias for kEnableSoftwareCompositingGLAdapter. +const char kEnableSoftwareCompositing[] = "enable-software-compositing"; + +// Disables the timeout for layout tests. +const char kNoTimeout[] = "no-timeout"; + +// Save results when layout-as-browser tests fail. +const char kOutputLayoutTestDifferences[] = "output-layout-test-differences"; + +} // namespace switches diff --git a/content/shell/common/shell_switches.h b/content/shell/common/shell_switches.h new file mode 100644 index 0000000..5a182c5 --- /dev/null +++ b/content/shell/common/shell_switches.h @@ -0,0 +1,25 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Defines all the "content_shell" command-line switches. + +#ifndef CONTENT_SHELL_COMMON_SHELL_SWITCHES_H_ +#define CONTENT_SHELL_COMMON_SHELL_SWITCHES_H_ + +namespace switches { + +extern const char kAllowExternalPages[]; +extern const char kCheckLayoutTestSysDeps[]; +extern const char kContentBrowserTest[]; +extern const char kContentShellDataPath[]; +extern const char kDisableHeadlessForLayoutTests[]; +extern const char kDumpRenderTree[]; +extern const char kEnableAccelerated2DCanvas[]; +extern const char kEnableSoftwareCompositing[]; +extern const char kNoTimeout[]; +extern const char kOutputLayoutTestDifferences[]; + +} // namespace switches + +#endif // CONTENT_SHELL_COMMON_SHELL_SWITCHES_H_ diff --git a/content/shell/common/shell_test_configuration.cc b/content/shell/common/shell_test_configuration.cc new file mode 100644 index 0000000..43f2651 --- /dev/null +++ b/content/shell/common/shell_test_configuration.cc @@ -0,0 +1,16 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/shell/common/shell_test_configuration.h" + +namespace content { + +ShellTestConfiguration::ShellTestConfiguration() + : enable_pixel_dumping(true), + layout_test_timeout(30 * 1000), + allow_external_pages(false) {} + +ShellTestConfiguration::~ShellTestConfiguration() {} + +} // namespace content diff --git a/content/shell/common/shell_test_configuration.h b/content/shell/common/shell_test_configuration.h new file mode 100644 index 0000000..f24033c --- /dev/null +++ b/content/shell/common/shell_test_configuration.h @@ -0,0 +1,43 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_SHELL_COMMON_SHELL_TEST_CONFIGURATION_H_ +#define CONTENT_SHELL_COMMON_SHELL_TEST_CONFIGURATION_H_ + +#include <string> + +#include "base/files/file_path.h" +#include "googleurl/src/gurl.h" + +namespace content { + +struct ShellTestConfiguration { + ShellTestConfiguration(); + ~ShellTestConfiguration(); + + // The current working directory. + base::FilePath current_working_directory; + + // The temporary directory of the system. + base::FilePath temp_path; + + // The URL of the current layout test. + GURL test_url; + + // True if pixel tests are enabled. + bool enable_pixel_dumping; + + // The layout test timeout in milliseconds. + int layout_test_timeout; + + // True if tests can open external URLs + bool allow_external_pages; + + // The expected MD5 hash of the pixel results. + std::string expected_pixel_hash; +}; + +} // namespace content + +#endif // CONTENT_SHELL_COMMON_SHELL_TEST_CONFIGURATION_H_ diff --git a/content/shell/common/webkit_test_helpers.cc b/content/shell/common/webkit_test_helpers.cc new file mode 100644 index 0000000..1993e5d --- /dev/null +++ b/content/shell/common/webkit_test_helpers.cc @@ -0,0 +1,146 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/shell/common/webkit_test_helpers.h" + +#include "base/command_line.h" +#include "base/file_util.h" +#include "base/path_service.h" +#include "base/utf_string_conversions.h" +#include "content/shell/common/shell_switches.h" +#include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebPreferences.h" +#include "webkit/glue/webpreferences.h" + +namespace content { + +void ExportLayoutTestSpecificPreferences( + const WebTestRunner::WebPreferences& from, + WebPreferences* to) { + to->allow_universal_access_from_file_urls = + from.allowUniversalAccessFromFileURLs; + to->dom_paste_enabled = from.DOMPasteAllowed; + to->javascript_can_access_clipboard = from.javaScriptCanAccessClipboard; + to->xss_auditor_enabled = from.XSSAuditorEnabled; + to->editing_behavior = static_cast<webkit_glue::EditingBehavior>( + from.editingBehavior); + to->default_font_size = from.defaultFontSize; + to->minimum_font_size = from.minimumFontSize; + to->default_encoding = from.defaultTextEncodingName.utf8().data(); + to->javascript_enabled = from.javaScriptEnabled; + to->supports_multiple_windows = from.supportsMultipleWindows; + to->loads_images_automatically = from.loadsImagesAutomatically; + to->plugins_enabled = from.pluginsEnabled; + to->java_enabled = from.javaEnabled; + to->application_cache_enabled = from.offlineWebApplicationCacheEnabled; + to->tabs_to_links = from.tabsToLinks; + to->experimental_webgl_enabled = from.experimentalWebGLEnabled; + to->css_grid_layout_enabled = from.experimentalCSSGridLayoutEnabled; + // experimentalCSSRegionsEnabled is deprecated and ignored. + to->hyperlink_auditing_enabled = from.hyperlinkAuditingEnabled; + to->caret_browsing_enabled = from.caretBrowsingEnabled; + to->allow_displaying_insecure_content = from.allowDisplayOfInsecureContent; + to->allow_running_insecure_content = from.allowRunningOfInsecureContent; + to->css_shaders_enabled = from.cssCustomFilterEnabled; + to->should_respect_image_orientation = from.shouldRespectImageOrientation; + to->asynchronous_spell_checking_enabled = + from.asynchronousSpellCheckingEnabled; + to->allow_file_access_from_file_urls = from.allowFileAccessFromFileURLs; + to->author_and_user_styles_enabled = from.authorAndUserStylesEnabled; + to->javascript_can_open_windows_automatically = + from.javaScriptCanOpenWindowsAutomatically; + to->user_style_sheet_location = from.userStyleSheetLocation; + to->touch_drag_drop_enabled = from.touchDragDropEnabled; +} + +// Applies settings that differ between layout tests and regular mode. Some +// of the defaults are controlled via command line flags which are +// automatically set for layout tests. +void ApplyLayoutTestDefaultPreferences(WebPreferences* prefs) { + CommandLine& command_line = *CommandLine::ForCurrentProcess(); + prefs->allow_universal_access_from_file_urls = true; + prefs->dom_paste_enabled = true; + prefs->javascript_can_access_clipboard = true; + prefs->xss_auditor_enabled = false; +#if defined(OS_MACOSX) + prefs->editing_behavior = webkit_glue::EDITING_BEHAVIOR_MAC; +#else + prefs->editing_behavior = webkit_glue::EDITING_BEHAVIOR_WIN; +#endif + prefs->java_enabled = false; + prefs->application_cache_enabled = true; + prefs->tabs_to_links = false; + prefs->hyperlink_auditing_enabled = false; + prefs->allow_displaying_insecure_content = true; + prefs->allow_running_insecure_content = true; + prefs->webgl_errors_to_console_enabled = false; + string16 serif; +#if defined(OS_MACOSX) + prefs->cursive_font_family_map[webkit_glue::kCommonScript] = + ASCIIToUTF16("Apple Chancery"); + prefs->fantasy_font_family_map[webkit_glue::kCommonScript] = + ASCIIToUTF16("Papyrus"); + serif = ASCIIToUTF16("Times"); +#else + prefs->cursive_font_family_map[webkit_glue::kCommonScript] = + ASCIIToUTF16("Comic Sans MS"); + prefs->fantasy_font_family_map[webkit_glue::kCommonScript] = + ASCIIToUTF16("Impact"); + serif = ASCIIToUTF16("times new roman"); +#endif + prefs->serif_font_family_map[webkit_glue::kCommonScript] = + serif; + prefs->standard_font_family_map[webkit_glue::kCommonScript] = + serif; + prefs->fixed_font_family_map[webkit_glue::kCommonScript] = + ASCIIToUTF16("Courier"); + prefs->sans_serif_font_family_map[ + webkit_glue::kCommonScript] = ASCIIToUTF16("Helvetica"); + prefs->minimum_logical_font_size = 9; + prefs->asynchronous_spell_checking_enabled = false; + prefs->user_style_sheet_enabled = true; + prefs->threaded_html_parser = true; + prefs->accelerated_2d_canvas_enabled = + command_line.HasSwitch(switches::kEnableAccelerated2DCanvas); + prefs->accelerated_compositing_for_video_enabled = false; + prefs->mock_scrollbars_enabled = false; + prefs->fixed_position_creates_stacking_context = false; + prefs->apply_page_scale_factor_in_compositor = false; + prefs->smart_insert_delete_enabled = true; + prefs->minimum_accelerated_2d_canvas_size = 0; +} + +base::FilePath GetWebKitRootDirFilePath() { + base::FilePath base_path; + PathService::Get(base::DIR_SOURCE_ROOT, &base_path); + if (file_util::PathExists( + base_path.Append(FILE_PATH_LITERAL("third_party/WebKit")))) { + // We're in a WebKit-in-chrome checkout. + return base_path.Append(FILE_PATH_LITERAL("third_party/WebKit")); + } else if (file_util::PathExists( + base_path.Append(FILE_PATH_LITERAL("chromium")))) { + // We're in a WebKit-only checkout on Windows. + return base_path.Append(FILE_PATH_LITERAL("../..")); + } else if (file_util::PathExists( + base_path.Append(FILE_PATH_LITERAL("webkit/support")))) { + // We're in a WebKit-only/xcodebuild checkout on Mac + return base_path.Append(FILE_PATH_LITERAL("../../..")); + } + // We're in a WebKit-only, make-build, so the DIR_SOURCE_ROOT is already the + // WebKit root. That, or we have no idea where we are. + return base_path; +} + +base::FilePath GetChromiumRootDirFilePath() { + base::FilePath webkit_path = GetWebKitRootDirFilePath(); + if (file_util::PathExists(webkit_path.Append( + FILE_PATH_LITERAL("Source/WebKit/chromium/webkit/support")))) { + // We're in a WebKit-only checkout. + return webkit_path.Append(FILE_PATH_LITERAL("Source/WebKit/chromium")); + } else { + // We're in a Chromium checkout, and WebKit is in third_party/WebKit. + return webkit_path.Append(FILE_PATH_LITERAL("../..")); + } +} + +} // namespace content diff --git a/content/shell/common/webkit_test_helpers.h b/content/shell/common/webkit_test_helpers.h new file mode 100644 index 0000000..a171f2e --- /dev/null +++ b/content/shell/common/webkit_test_helpers.h @@ -0,0 +1,40 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_SHELL_COMMON_WEBKIT_TEST_HELPERS_H_ +#define CONTENT_SHELL_COMMON_WEBKIT_TEST_HELPERS_H_ + +struct WebPreferences; + +namespace WebTestRunner { +struct WebPreferences; +} + +namespace base { +class FilePath; +} + +struct WebPreferences; + +namespace content { + +// The TestRunner library keeps its settings in a WebTestRunner::WebPreferenes +// object. The content_shell, however, uses WebPreferences. This +// method exports the settings from the WebTestRunner library which are relevant +// for layout tests. +void ExportLayoutTestSpecificPreferences( + const WebTestRunner::WebPreferences& from, WebPreferences* to); + +// Applies settings that differ between layout tests and regular mode. +void ApplyLayoutTestDefaultPreferences(WebPreferences* prefs); + +// Returns the root of the Blink checkout. +base::FilePath GetWebKitRootDirFilePath(); + +// Returns the root of the chromium checkout. +base::FilePath GetChromiumRootDirFilePath(); + +} // namespace content + +#endif // CONTENT_SHELL_COMMON_WEBKIT_TEST_HELPERS_H_ |