diff options
author | tiger@opera.com <tiger@opera.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-06 02:37:16 +0000 |
---|---|---|
committer | tiger@opera.com <tiger@opera.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-06 02:37:16 +0000 |
commit | e846329d778902ee1eb9e0e5884320fd0dc42e87 (patch) | |
tree | b475d3dfb6b8ce201386253238ca96531a41da2f | |
parent | 1fce7dd40057710e908c9a65caca0827d67d64f7 (diff) | |
download | chromium_src-e846329d778902ee1eb9e0e5884320fd0dc42e87.zip chromium_src-e846329d778902ee1eb9e0e5884320fd0dc42e87.tar.gz chromium_src-e846329d778902ee1eb9e0e5884320fd0dc42e87.tar.bz2 |
The test framework doesn't really need to load resources and translations. This removes loading and changes the odd test that wasn't working anymore due to this change.
BUG=
Review URL: https://chromiumcodereview.appspot.com/18429012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215763 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/support/platform_support_android.cc | 39 | ||||
-rw-r--r-- | webkit/support/platform_support_linux.cc | 41 | ||||
-rw-r--r-- | webkit/support/platform_support_mac.mm | 160 | ||||
-rw-r--r-- | webkit/support/platform_support_win.cc | 79 | ||||
-rw-r--r-- | webkit/support/test_webkit_platform_support.cc | 12 |
5 files changed, 12 insertions, 319 deletions
diff --git a/webkit/support/platform_support_android.cc b/webkit/support/platform_support_android.cc index bae32f1..582dc3a 100644 --- a/webkit/support/platform_support_android.cc +++ b/webkit/support/platform_support_android.cc @@ -50,13 +50,9 @@ void BeforeInitialize() { } void AfterInitialize() { - base::FilePath data_path(kDumpRenderTreeDir); - data_path = data_path.Append("DumpRenderTree.pak"); - ResourceBundle::InitSharedInstanceWithPakPath(data_path); } void BeforeShutdown() { - ResourceBundle::CleanupSharedInstance(); } void AfterShutdown() { @@ -64,38 +60,3 @@ void AfterShutdown() { } // namespace webkit_support -base::string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { - return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); -} - -base::StringPiece TestWebKitPlatformSupport::GetDataResource( - int resource_id, - ui::ScaleFactor scale_factor) { - base::FilePath resources_path(kDumpRenderTreeDir); - resources_path = resources_path.Append("DumpRenderTree_resources"); - switch (resource_id) { - case IDR_BROKENIMAGE: { - CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ()); - if (broken_image_data.empty()) { - base::FilePath path = resources_path.Append("missingImage.gif"); - bool success = file_util::ReadFileToString(path, &broken_image_data); - if (!success) - LOG(FATAL) << "Failed reading: " << path.value(); - } - return broken_image_data; - } - case IDR_TEXTAREA_RESIZER: { - CR_DEFINE_STATIC_LOCAL(std::string, resize_corner_data, ()); - if (resize_corner_data.empty()) { - base::FilePath path = resources_path.Append("textAreaResizeCorner.png"); - bool success = file_util::ReadFileToString(path, &resize_corner_data); - if (!success) - LOG(FATAL) << "Failed reading: " << path.value(); - } - return resize_corner_data; - } - } - - return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( - resource_id, scale_factor); -} diff --git a/webkit/support/platform_support_linux.cc b/webkit/support/platform_support_linux.cc index bf0b605..85cc841 100644 --- a/webkit/support/platform_support_linux.cc +++ b/webkit/support/platform_support_linux.cc @@ -23,14 +23,9 @@ void BeforeInitialize() { } void AfterInitialize() { - base::FilePath data_path; - PathService::Get(base::DIR_EXE, &data_path); - data_path = data_path.Append("DumpRenderTree.pak"); - ResourceBundle::InitSharedInstanceWithPakPath(data_path); } void BeforeShutdown() { - ResourceBundle::CleanupSharedInstance(); } void AfterShutdown() { @@ -38,39 +33,3 @@ void AfterShutdown() { } // namespace webkit_support -base::string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { - return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); -} - -base::StringPiece TestWebKitPlatformSupport::GetDataResource( - int resource_id, - ui::ScaleFactor scale_factor) { - base::FilePath resources_path; - PathService::Get(base::DIR_EXE, &resources_path); - resources_path = resources_path.Append("DumpRenderTree_resources"); - switch (resource_id) { - case IDR_BROKENIMAGE: { - CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ()); - if (broken_image_data.empty()) { - base::FilePath path = resources_path.Append("missingImage.gif"); - bool success = file_util::ReadFileToString(path, &broken_image_data); - if (!success) - LOG(FATAL) << "Failed reading: " << path.value(); - } - return broken_image_data; - } - case IDR_TEXTAREA_RESIZER: { - CR_DEFINE_STATIC_LOCAL(std::string, resize_corner_data, ()); - if (resize_corner_data.empty()) { - base::FilePath path = resources_path.Append("textAreaResizeCorner.png"); - bool success = file_util::ReadFileToString(path, &resize_corner_data); - if (!success) - LOG(FATAL) << "Failed reading: " << path.value(); - } - return resize_corner_data; - } - } - - return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( - resource_id, scale_factor); -} diff --git a/webkit/support/platform_support_mac.mm b/webkit/support/platform_support_mac.mm index a1235f4..6d96ec1 100644 --- a/webkit/support/platform_support_mac.mm +++ b/webkit/support/platform_support_mac.mm @@ -12,8 +12,6 @@ #include "base/base_paths.h" #include "base/file_util.h" #include "base/logging.h" -#include "base/mac/bundle_locations.h" -#include "base/mac/mac_util.h" #include "base/path_service.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" @@ -23,8 +21,6 @@ #import "webkit/support/mac/DumpRenderTreePasteboard.h" #include "webkit/support/test_webkit_platform_support.h" -static ui::DataPack* g_resource_data_pack = NULL; - namespace webkit_support { static NSAutoreleasePool* autorelease_pool; @@ -35,82 +31,7 @@ void BeforeInitialize() { DCHECK(autorelease_pool); } -#if OBJC_API_VERSION == 2 -static void SwizzleAllMethods(Class imposter, Class original) { - unsigned int imposterMethodCount = 0; - Method* imposterMethods = - class_copyMethodList(imposter, &imposterMethodCount); - - unsigned int originalMethodCount = 0; - Method* originalMethods = - class_copyMethodList(original, &originalMethodCount); - - for (unsigned int i = 0; i < imposterMethodCount; i++) { - SEL imposterMethodName = method_getName(imposterMethods[i]); - - // Attempt to add the method to the original class. If it fails, the method - // already exists and we should instead exchange the implementations. - if (class_addMethod(original, - imposterMethodName, - method_getImplementation(originalMethods[i]), - method_getTypeEncoding(originalMethods[i]))) { - continue; - } - - unsigned int j = 0; - for (; j < originalMethodCount; j++) { - SEL originalMethodName = method_getName(originalMethods[j]); - if (sel_isEqual(imposterMethodName, originalMethodName)) { - break; - } - } - - // If class_addMethod failed above then the method must exist on the - // original class. - DCHECK(j < originalMethodCount) << "method wasn't found?"; - method_exchangeImplementations(imposterMethods[i], originalMethods[j]); - } - - if (imposterMethods) { - free(imposterMethods); - } - if (originalMethods) { - free(originalMethods); - } -} -#endif - -static void SwizzleNSPasteboard() { - // We replace NSPaseboard w/ the shim (from WebKit) that avoids having - // sideeffects w/ whatever the user does at the same time. - - Class imposterClass = objc_getClass("DumpRenderTreePasteboard"); - Class originalClass = objc_getClass("NSPasteboard"); -#if OBJC_API_VERSION == 0 - class_poseAs(imposterClass, originalClass); -#else - // Swizzle instance methods... - SwizzleAllMethods(imposterClass, originalClass); - // and then class methods. - SwizzleAllMethods(object_getClass(imposterClass), - object_getClass(originalClass)); -#endif -} - void AfterInitialize() { - // Load a data pack. - g_resource_data_pack = new ui::DataPack(ui::SCALE_FACTOR_100P); - base::FilePath resources_pak_path; - PathService::Get(base::DIR_EXE, &resources_pak_path); - resources_pak_path = resources_pak_path.Append("Content Shell.app") - .Append("Contents") - .Append("Frameworks") - .Append("Content Shell Framework.framework") - .Append("Resources") - .Append("content_shell.pak"); - if (!g_resource_data_pack->LoadFromPath(resources_pak_path)) { - LOG(FATAL) << "failed to load DumpRenderTree.pak"; - } } void BeforeShutdown() { @@ -119,88 +40,7 @@ void BeforeShutdown() { void AfterShutdown() { [DumpRenderTreePasteboard releaseLocalPasteboards]; [autorelease_pool drain]; - delete g_resource_data_pack; } } // namespace webkit_support -base::string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { - // |g_resource_data_pack| is null on unit tests. - // But som unit tests reach GetLocalizedString(). - if (!g_resource_data_pack) - return base::string16(); - base::StringPiece res; - if (!g_resource_data_pack->GetStringPiece(message_id, &res)) { - LOG(FATAL) << "failed to load webkit string with id " << message_id; - } - - // Data packs hold strings as either UTF8 or UTF16. - base::string16 msg; - switch (g_resource_data_pack->GetTextEncodingType()) { - case ui::DataPack::UTF8: - msg = UTF8ToUTF16(res); - break; - case ui::DataPack::UTF16: - msg = base::string16(reinterpret_cast<const char16*>(res.data()), - res.length() / 2); - break; - case ui::DataPack::BINARY: - NOTREACHED(); - break; - } - - return msg; -} - -// Helper method for getting the path to the test shell resources directory. -static base::FilePath GetResourcesFilePath() { - base::FilePath path; - // We assume the application is bundled. - if (!base::mac::AmIBundled()) { - LOG(FATAL) << "Failed to locate resources. The applicaiton is not bundled."; - } - PathService::Get(base::DIR_EXE, &path); - path = path.Append(base::FilePath::kParentDirectory); - return path.AppendASCII("Resources"); -} - -base::StringPiece TestWebKitPlatformSupport::GetDataResource( - int resource_id, - ui::ScaleFactor scale_factor) { - switch (resource_id) { - case IDR_BROKENIMAGE: { - // Use webkit's broken image icon (16x16) - CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ()); - if (broken_image_data.empty()) { - base::FilePath path = GetResourcesFilePath(); - // In order to match WebKit's colors for the missing image, we have to - // use a PNG. The GIF doesn't have the color range needed to correctly - // match the TIFF they use in Safari. - path = base::MakeAbsoluteFilePath(path.AppendASCII("missingImage.png")); - bool success = file_util::ReadFileToString(path, &broken_image_data); - if (!success) { - LOG(FATAL) << "Failed reading: " << path.value(); - } - } - return broken_image_data; - } - case IDR_TEXTAREA_RESIZER: { - // Use webkit's text area resizer image. - CR_DEFINE_STATIC_LOCAL(std::string, resize_corner_data, ()); - if (resize_corner_data.empty()) { - base::FilePath path = GetResourcesFilePath(); - path = base::MakeAbsoluteFilePath( - path.AppendASCII("textAreaResizeCorner.png")); - bool success = file_util::ReadFileToString(path, &resize_corner_data); - if (!success) { - LOG(FATAL) << "Failed reading: " << path.value(); - } - } - return resize_corner_data; - } - } - base::StringPiece res; - if (g_resource_data_pack) - g_resource_data_pack->GetStringPiece(resource_id, &res); - return res; -} diff --git a/webkit/support/platform_support_win.cc b/webkit/support/platform_support_win.cc index 58d78be..ce601c5 100644 --- a/webkit/support/platform_support_win.cc +++ b/webkit/support/platform_support_win.cc @@ -17,51 +17,16 @@ #include "ui/base/resource/resource_bundle.h" #include "webkit/support/test_webkit_platform_support.h" -#define MAX_LOADSTRING 100 - -namespace { - -base::FilePath GetResourceFilePath(const char* ascii_name) { - base::FilePath path; - PathService::Get(base::DIR_EXE, &path); - path = path.AppendASCII("DumpRenderTree_resources"); - return path.AppendASCII(ascii_name); -} - -base::StringPiece GetRawDataResource(HMODULE module, int resource_id) { - void* data_ptr; - size_t data_size; - return base::win::GetDataResourceFromModule(module, resource_id, &data_ptr, - &data_size) - ? base::StringPiece(static_cast<char*>(data_ptr), data_size) - : base::StringPiece(); -} - -base::StringPiece ResourceProvider(int key) { - return GetRawDataResource(::GetModuleHandle(NULL), key); -} - -} // namespace namespace webkit_support { -// TODO(tkent): Implement some of the followings for platform-dependent tasks -// such as loading resource. - void BeforeInitialize() { } void AfterInitialize() { - // TODO(dpranke): update other resource loading to use the pak - // instead of loading resources directly compiled in. - base::FilePath path; - PathService::Get(base::DIR_EXE, &path); - path = path.AppendASCII("DumpRenderTree.pak"); - ResourceBundle::InitSharedInstanceWithPakPath(path); } void BeforeShutdown() { - ResourceBundle::CleanupSharedInstance(); } void AfterShutdown() { @@ -69,47 +34,3 @@ void AfterShutdown() { } // namespace webkit_support -base::string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { - wchar_t localized[MAX_LOADSTRING]; - int length = ::LoadString(::GetModuleHandle(NULL), message_id, - localized, MAX_LOADSTRING); - if (!length && ::GetLastError() == ERROR_RESOURCE_NAME_NOT_FOUND) { - NOTREACHED(); - return L"No string for this identifier!"; - } - return base::string16(localized, length); -} - -base::StringPiece TestWebKitPlatformSupport::GetDataResource( - int resource_id, - ui::ScaleFactor scale_factor) { - switch (resource_id) { - case IDR_BROKENIMAGE: { - // Use webkit's broken image icon (16x16) - static std::string broken_image_data; - if (broken_image_data.empty()) { - base::FilePath path = GetResourceFilePath("missingImage.gif"); - bool success = file_util::ReadFileToString(path, &broken_image_data); - if (!success) { - LOG(FATAL) << "Failed reading: " << path.value(); - } - } - return broken_image_data; - } - case IDR_TEXTAREA_RESIZER: { - // Use webkit's text area resizer image. - static std::string resize_corner_data; - if (resize_corner_data.empty()) { - base::FilePath path = GetResourceFilePath("textAreaResizeCorner.png"); - bool success = file_util::ReadFileToString(path, &resize_corner_data); - if (!success) { - LOG(FATAL) << "Failed reading: " << path.value(); - } - } - return resize_corner_data; - } - } - - // TODO(flackr): Pass scale_factor to ResourceProvider. - return ResourceProvider(resource_id); -} diff --git a/webkit/support/test_webkit_platform_support.cc b/webkit/support/test_webkit_platform_support.cc index e54718d..63bc508 100644 --- a/webkit/support/test_webkit_platform_support.cc +++ b/webkit/support/test_webkit_platform_support.cc @@ -221,6 +221,8 @@ WebKit::WebString TestWebKitPlatformSupport::queryLocalizedString( return ASCIIToUTF16("<<ThisMonthLabel>>"); case WebKit::WebLocalizedString::ThisWeekButtonLabel: return ASCIIToUTF16("<<ThisWeekLabel>>"); + case WebKit::WebLocalizedString::WeekFormatTemplate: + return ASCIIToUTF16("Week $2, $1"); default: return WebKitPlatformSupportImpl::queryLocalizedString(name); } @@ -335,6 +337,16 @@ void TestWebKitPlatformSupport::setGamepadData( gamepad_data_ = data; } +base::string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { + return base::string16(); +} + +base::StringPiece TestWebKitPlatformSupport::GetDataResource( + int resource_id, + ui::ScaleFactor scale_factor) { + return base::StringPiece(); +} + webkit_glue::ResourceLoaderBridge* TestWebKitPlatformSupport::CreateResourceLoader( const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { |