Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1188)

Unified Diff: third_party/WebKit/Source/platform/testing/UnitTestHelpers.cpp

Issue 2654933003: platform/testing/{URL|Unit}TestHelpers improvements (Closed)
Patch Set: cleanup Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/testing/UnitTestHelpers.cpp
diff --git a/third_party/WebKit/Source/platform/testing/UnitTestHelpers.cpp b/third_party/WebKit/Source/platform/testing/UnitTestHelpers.cpp
index 950dbccbe3cd8717392f81619c851ba25dec90be..5c716e57529df2f329d58da06ed952f5389b11fc 100644
--- a/third_party/WebKit/Source/platform/testing/UnitTestHelpers.cpp
+++ b/third_party/WebKit/Source/platform/testing/UnitTestHelpers.cpp
@@ -44,6 +44,17 @@
namespace blink {
namespace testing {
+namespace {
+
+base::FilePath blinkRootFilePath() {
+ base::FilePath path;
+ base::PathService::Get(base::DIR_SOURCE_ROOT, &path);
+ return base::MakeAbsoluteFilePath(
+ path.Append(FILE_PATH_LITERAL("third_party/WebKit")));
+}
+
+} // namespace
+
void runPendingTasks() {
Platform::current()->currentThread()->getWebTaskRunner()->postTask(
BLINK_FROM_HERE, WTF::bind(&exitRunLoop));
@@ -61,21 +72,6 @@ void runDelayedTasks(double delayMs) {
enterRunLoop();
}
-String blinkRootDir() {
- base::FilePath path;
- base::PathService::Get(base::DIR_SOURCE_ROOT, &path);
- path = path.Append(FILE_PATH_LITERAL("third_party/WebKit"));
- path = base::MakeAbsoluteFilePath(path);
- return String::fromUTF8(path.MaybeAsASCII().c_str());
-}
-
-PassRefPtr<SharedBuffer> readFromFile(const String& path) {
- base::FilePath filePath = blink::WebStringToFilePath(path);
- std::string buffer;
- base::ReadFileToString(filePath, &buffer);
- return SharedBuffer::create(buffer.data(), buffer.size());
-}
-
void enterRunLoop() {
base::RunLoop().Run();
}
@@ -88,5 +84,32 @@ void yieldCurrentThread() {
base::PlatformThread::YieldCurrentThread();
}
+String blinkRootDir() {
+ base::FilePath path = blinkRootFilePath();
+ return String::fromUTF8(path.AsUTF8Unsafe().c_str());
kinuko 2017/01/26 09:32:41 FilePathToWebString(path)
Takashi Toyoshima 2017/01/26 10:57:57 Done.
+}
+
+String webTestDataPath(const std::string& relativePath) {
+ base::FilePath path = blinkRootFilePath()
+ .Append(FILE_PATH_LITERAL("Source/web/tests/data"))
+ .Append(relativePath);
+ return String::fromUTF8(path.AsUTF8Unsafe().c_str());
kinuko 2017/01/26 09:32:41 ditto
Takashi Toyoshima 2017/01/26 10:57:57 Done.
+}
+
+String platformTestDataPath(const std::string& relativePath) {
+ base::FilePath path =
+ blinkRootFilePath()
+ .Append(FILE_PATH_LITERAL("Source/platform/testing/data"))
+ .Append(relativePath);
+ return String::fromUTF8(path.AsUTF8Unsafe().c_str());
kinuko 2017/01/26 09:32:41 ditto
Takashi Toyoshima 2017/01/26 10:57:57 Done.
+}
+
+PassRefPtr<SharedBuffer> readFromFile(const String& path) {
+ base::FilePath filePath = blink::WebStringToFilePath(path);
+ std::string buffer;
+ base::ReadFileToString(filePath, &buffer);
+ return SharedBuffer::create(buffer.data(), buffer.size());
+}
+
} // namespace testing
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698