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

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

Issue 1568433005: Platform WebUnitTestSupport onion soup: remove more indirect methods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 04524d864aa2ae53d1ee8a65e20dae5db6fd6443..77097c18486d9a3972e86c1770d9bae482234aaa 100644
--- a/third_party/WebKit/Source/platform/testing/UnitTestHelpers.cpp
+++ b/third_party/WebKit/Source/platform/testing/UnitTestHelpers.cpp
@@ -27,12 +27,15 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
+#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
+#include "platform/SharedBuffer.h"
#include "public/platform/Platform.h"
#include "public/platform/WebTaskRunner.h"
#include "public/platform/WebThread.h"
#include "public/platform/WebTraceLocation.h"
#include "public/platform/WebUnitTestSupport.h"
+#include "wtf/text/StringUTF8Adaptor.h"
namespace blink {
namespace testing {
@@ -41,14 +44,14 @@ class QuitTask : public WebTaskRunner::Task {
public:
virtual void run()
{
- Platform::current()->unitTestSupport()->exitRunLoop();
+ exitRunLoop();
}
};
void runPendingTasks()
{
Platform::current()->currentThread()->taskRunner()->postTask(BLINK_FROM_HERE, new QuitTask);
- Platform::current()->unitTestSupport()->enterRunLoop();
+ enterRunLoop();
}
String blinkRootDir()
@@ -60,5 +63,25 @@ String blinkRootDir()
return String::fromUTF8(path.MaybeAsASCII().c_str());
}
+PassRefPtr<SharedBuffer> readFromFile(const String& path)
+{
+ StringUTF8Adaptor utf8(path);
+ base::FilePath file_path = base::FilePath::FromUTF8Unsafe(
+ std::string(utf8.data(), utf8.length()));
+ std::string buffer;
+ base::ReadFileToString(file_path, &buffer);
+ return SharedBuffer::create(buffer.data(), buffer.size());
+}
+
+void enterRunLoop()
+{
+ base::MessageLoop::current()->Run();
+}
+
+void exitRunLoop()
+{
+ base::MessageLoop::current()->QuitWhenIdle();
+}
+
}
}
« no previous file with comments | « third_party/WebKit/Source/platform/testing/UnitTestHelpers.h ('k') | third_party/WebKit/Source/web/tests/FrameTestHelpers.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698