diff options
-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 |