diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-21 19:48:46 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-21 19:48:46 +0000 |
commit | 8bcb0ab7d54f5786320e782e10b6616023a92931 (patch) | |
tree | c9a6b4468b1d937066455f5571d3d515f1e62f83 | |
parent | 0798330b106865a81bfcf31bcde6d699f1ea191e (diff) | |
download | chromium_src-8bcb0ab7d54f5786320e782e10b6616023a92931.zip chromium_src-8bcb0ab7d54f5786320e782e10b6616023a92931.tar.gz chromium_src-8bcb0ab7d54f5786320e782e10b6616023a92931.tar.bz2 |
webkit tests: Fix computeLastHyphenLocation() when building with make or ninja.
DIR_SOURCE_ROOT returns unreliable results in standalone WebKit checkouts,
to not introduce a layering violation in base (see
https://codereview.chromium.org/8585029/). Make the code that relies on it
more robust to handle the unreliable results.
BUG=171146
TEST=fast/text/hyphens.html passes in a standalone webkit/chromium/mac build
when using ninja.
TBR=tony
Review URL: https://codereview.chromium.org/12035002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177952 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/support/test_webkit_platform_support.cc | 8 | ||||
-rw-r--r-- | webkit/support/webkit_support.cc | 12 | ||||
-rw-r--r-- | webkit/support/webkit_support.h | 11 |
3 files changed, 24 insertions, 7 deletions
diff --git a/webkit/support/test_webkit_platform_support.cc b/webkit/support/test_webkit_platform_support.cc index 73c02ca..a6cf5a9 100644 --- a/webkit/support/test_webkit_platform_support.cc +++ b/webkit/support/test_webkit_platform_support.cc @@ -546,12 +546,8 @@ size_t TestWebKitPlatformSupport::computeLastHyphenLocation( if (!hyphen_dictionary_) { // Initialize the hyphen library with a sample dictionary. To avoid test // flakiness, this code synchronously loads the dictionary. - FilePath path; - if (!PathService::Get(base::DIR_SOURCE_ROOT, &path)) - return 0; - path = path.AppendASCII("third_party"); - path = path.AppendASCII("hyphen"); - path = path.AppendASCII("hyph_en_US.dic"); + FilePath path = webkit_support::GetChromiumRootDirFilePath(); + path = path.Append(FILE_PATH_LITERAL("third_party/hyphen/hyph_en_US.dic")); std::string dictionary; if (!file_util::ReadFileToString(path, &dictionary)) return 0; diff --git a/webkit/support/webkit_support.cc b/webkit/support/webkit_support.cc index 2dd97e4..757ab62 100644 --- a/webkit/support/webkit_support.cc +++ b/webkit/support/webkit_support.cc @@ -352,6 +352,18 @@ void SetUpTestEnvironmentImpl(bool unit_test_mode, namespace webkit_support { +FilePath GetChromiumRootDirFilePath() { + FilePath basePath; + PathService::Get(base::DIR_SOURCE_ROOT, &basePath); + if (file_util::PathExists( + basePath.Append(FILE_PATH_LITERAL("third_party/WebKit")))) { + // We're in a WebKit-in-chrome checkout. + return basePath; + } + return GetWebKitRootDirFilePath() + .Append(FILE_PATH_LITERAL("Source/WebKit/chromium")); +} + void SetUpTestEnvironment() { SetUpTestEnvironment(NULL); } diff --git a/webkit/support/webkit_support.h b/webkit/support/webkit_support.h index d6b505a..3120d0b 100644 --- a/webkit/support/webkit_support.h +++ b/webkit/support/webkit_support.h @@ -8,7 +8,6 @@ #include <string> #include "base/basictypes.h" -#include "base/string16.h" #include "third_party/WebKit/Source/Platform/chromium/public/Platform.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebFileSystem.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h" @@ -18,6 +17,8 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgentClient.h" #include "ui/base/keycodes/keyboard_codes.h" +class FilePath; + namespace WebKit { class WebApplicationCacheHost; class WebApplicationCacheHostClient; @@ -49,6 +50,14 @@ class MediaStreamClient; // implementation classes. namespace webkit_support { +// DIR_SOURCE_ROOT does not return a reliable result for standalone WebKit +// builds. This reliably returns the root of the chromium source, which is the +// directory containing all dependencies pulled by gclient. In a +// webkit-in-chromium build, this is the root directory of the checkout. In a +// standalone webkit build, it is Source/WebKit/chromium relative from the +// checkout's root directory. +FilePath GetChromiumRootDirFilePath(); + // Initializes or terminates a test environment. // |unit_test_mode| should be set to true when running in a TestSuite, in which // case no AtExitManager is created and ICU is not initialized (as it is already |