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

Unified Diff: third_party/WebKit/Source/platform/BackgroundTaskTest.cpp

Issue 1519863002: Expose WorkerPool to blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: onion soupification Created 5 years 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/BackgroundTaskTest.cpp
diff --git a/third_party/WebKit/Source/platform/BackgroundTaskTest.cpp b/third_party/WebKit/Source/platform/BackgroundTaskTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..554e5bec1dcb626bdb632593019f34cee09ce31c
--- /dev/null
+++ b/third_party/WebKit/Source/platform/BackgroundTaskTest.cpp
@@ -0,0 +1,50 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "platform/BackgroundTask.h"
+
+#include "public/platform/Platform.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+
+namespace {
+
+using namespace blink;
+
+class PingTask : public BackgroundTask {
+public:
+ PingTask(WebWaitableEvent* doneEvent)
+ : m_doneEvent(doneEvent)
+ { }
+
+ void run()
+ {
+ m_doneEvent->signal();
+ }
+
+private:
+ WebWaitableEvent* m_doneEvent;
+};
+
+class BackgroundTaskTest : public testing::Test {
+};
+
+TEST_F(BackgroundTaskTest, RunShortTaskOnBackgroundThread)
+{
+ OwnPtr<WebWaitableEvent> doneEvent = adoptPtr(Platform::current()->createWaitableEvent());
+ BackgroundTask::postOnBackgroundThread(new PingTask(doneEvent.get()), BackgroundTask::TaskSizeShortRunningTask);
+ // Test passes by not hanging on the following wait().
+ doneEvent->wait();
+}
+
+TEST_F(BackgroundTaskTest, RunLongTaskOnBackgroundThread)
+{
+ OwnPtr<WebWaitableEvent> doneEvent = adoptPtr(Platform::current()->createWaitableEvent());
+ BackgroundTask::postOnBackgroundThread(new PingTask(doneEvent.get()), BackgroundTask::TaskSizeLongRunningTask);
+ // Test passes by not hanging on the following wait().
+ doneEvent->wait();
+}
+
+} // unnamed namespace

Powered by Google App Engine
This is Rietveld 408576698