Index: third_party/WebKit/Source/platform/scheduler/CancellableTaskFactoryTest.cpp |
diff --git a/third_party/WebKit/Source/platform/scheduler/CancellableTaskFactoryTest.cpp b/third_party/WebKit/Source/platform/scheduler/CancellableTaskFactoryTest.cpp |
index 579f4e10a81676c21d4097def29bdb1513a508cd..fcb6d78c46d49f5dafcb448d8691aa5ded1dbf48 100644 |
--- a/third_party/WebKit/Source/platform/scheduler/CancellableTaskFactoryTest.cpp |
+++ b/third_party/WebKit/Source/platform/scheduler/CancellableTaskFactoryTest.cpp |
@@ -6,6 +6,8 @@ |
#include "platform/heap/Handle.h" |
#include "testing/gtest/include/gtest/gtest.h" |
+#include "wtf/PtrUtil.h" |
+#include <memory> |
namespace blink { |
@@ -33,7 +35,7 @@ TEST_F(CancellableTaskFactoryTest, IsPending_TaskNotCreated) |
TEST_F(CancellableTaskFactoryTest, IsPending_TaskCreated) |
{ |
TestCancellableTaskFactory factory(nullptr); |
- OwnPtr<WebTaskRunner::Task> task = adoptPtr(factory.cancelAndCreate()); |
+ std::unique_ptr<WebTaskRunner::Task> task = wrapUnique(factory.cancelAndCreate()); |
EXPECT_TRUE(factory.isPending()); |
} |
@@ -46,7 +48,7 @@ TEST_F(CancellableTaskFactoryTest, IsPending_TaskCreatedAndRun) |
{ |
TestCancellableTaskFactory factory(WTF::bind(&EmptyFn)); |
{ |
- OwnPtr<WebTaskRunner::Task> task = adoptPtr(factory.cancelAndCreate()); |
+ std::unique_ptr<WebTaskRunner::Task> task = wrapUnique(factory.cancelAndCreate()); |
task->run(); |
} |
@@ -64,7 +66,7 @@ TEST_F(CancellableTaskFactoryTest, IsPending_TaskCreatedAndDestroyed) |
TEST_F(CancellableTaskFactoryTest, IsPending_TaskCreatedAndCancelled) |
{ |
TestCancellableTaskFactory factory(nullptr); |
- OwnPtr<WebTaskRunner::Task> task = adoptPtr(factory.cancelAndCreate()); |
+ std::unique_ptr<WebTaskRunner::Task> task = wrapUnique(factory.cancelAndCreate()); |
factory.cancel(); |
EXPECT_FALSE(factory.isPending()); |
@@ -72,7 +74,7 @@ TEST_F(CancellableTaskFactoryTest, IsPending_TaskCreatedAndCancelled) |
class TestClass { |
public: |
- OwnPtr<CancellableTaskFactory> m_factory; |
+ std::unique_ptr<CancellableTaskFactory> m_factory; |
TestClass() |
: m_factory(CancellableTaskFactory::create(this, &TestClass::TestFn)) |
@@ -88,7 +90,7 @@ public: |
TEST_F(CancellableTaskFactoryTest, IsPending_InCallback) |
{ |
TestClass testClass; |
- OwnPtr<WebTaskRunner::Task> task = adoptPtr(testClass.m_factory->cancelAndCreate()); |
+ std::unique_ptr<WebTaskRunner::Task> task = wrapUnique(testClass.m_factory->cancelAndCreate()); |
task->run(); |
} |
@@ -101,7 +103,7 @@ TEST_F(CancellableTaskFactoryTest, Run_ClosureIsExecuted) |
{ |
int executionCount = 0; |
TestCancellableTaskFactory factory(WTF::bind(&AddOne, &executionCount)); |
- OwnPtr<WebTaskRunner::Task> task = adoptPtr(factory.cancelAndCreate()); |
+ std::unique_ptr<WebTaskRunner::Task> task = wrapUnique(factory.cancelAndCreate()); |
task->run(); |
EXPECT_EQ(1, executionCount); |
@@ -111,7 +113,7 @@ TEST_F(CancellableTaskFactoryTest, Run_ClosureIsExecutedOnlyOnce) |
{ |
int executionCount = 0; |
TestCancellableTaskFactory factory(WTF::bind(&AddOne, &executionCount)); |
- OwnPtr<WebTaskRunner::Task> task = adoptPtr(factory.cancelAndCreate()); |
+ std::unique_ptr<WebTaskRunner::Task> task = wrapUnique(factory.cancelAndCreate()); |
task->run(); |
task->run(); |
task->run(); |
@@ -123,10 +125,10 @@ TEST_F(CancellableTaskFactoryTest, Run_ClosureIsExecutedOnlyOnce) |
TEST_F(CancellableTaskFactoryTest, Run_FactoryDestructionPreventsExecution) |
{ |
int executionCount = 0; |
- OwnPtr<WebTaskRunner::Task> task; |
+ std::unique_ptr<WebTaskRunner::Task> task; |
{ |
TestCancellableTaskFactory factory(WTF::bind(&AddOne, &executionCount)); |
- task = adoptPtr(factory.cancelAndCreate()); |
+ task = wrapUnique(factory.cancelAndCreate()); |
} |
task->run(); |
@@ -138,15 +140,15 @@ TEST_F(CancellableTaskFactoryTest, Run_TasksInSequence) |
int executionCount = 0; |
TestCancellableTaskFactory factory(WTF::bind(&AddOne, &executionCount)); |
- OwnPtr<WebTaskRunner::Task> taskA = adoptPtr(factory.cancelAndCreate()); |
+ std::unique_ptr<WebTaskRunner::Task> taskA = wrapUnique(factory.cancelAndCreate()); |
taskA->run(); |
EXPECT_EQ(1, executionCount); |
- OwnPtr<WebTaskRunner::Task> taskB = adoptPtr(factory.cancelAndCreate()); |
+ std::unique_ptr<WebTaskRunner::Task> taskB = wrapUnique(factory.cancelAndCreate()); |
taskB->run(); |
EXPECT_EQ(2, executionCount); |
- OwnPtr<WebTaskRunner::Task> taskC = adoptPtr(factory.cancelAndCreate()); |
+ std::unique_ptr<WebTaskRunner::Task> taskC = wrapUnique(factory.cancelAndCreate()); |
taskC->run(); |
EXPECT_EQ(3, executionCount); |
} |
@@ -155,7 +157,7 @@ TEST_F(CancellableTaskFactoryTest, Cancel) |
{ |
int executionCount = 0; |
TestCancellableTaskFactory factory(WTF::bind(&AddOne, &executionCount)); |
- OwnPtr<WebTaskRunner::Task> task = adoptPtr(factory.cancelAndCreate()); |
+ std::unique_ptr<WebTaskRunner::Task> task = wrapUnique(factory.cancelAndCreate()); |
factory.cancel(); |
task->run(); |
@@ -167,8 +169,8 @@ TEST_F(CancellableTaskFactoryTest, CreatingANewTaskCancelsPreviousOnes) |
int executionCount = 0; |
TestCancellableTaskFactory factory(WTF::bind(&AddOne, &executionCount)); |
- OwnPtr<WebTaskRunner::Task> taskA = adoptPtr(factory.cancelAndCreate()); |
- OwnPtr<WebTaskRunner::Task> taskB = adoptPtr(factory.cancelAndCreate()); |
+ std::unique_ptr<WebTaskRunner::Task> taskA = wrapUnique(factory.cancelAndCreate()); |
+ std::unique_ptr<WebTaskRunner::Task> taskB = wrapUnique(factory.cancelAndCreate()); |
taskA->run(); |
EXPECT_EQ(0, executionCount); |
@@ -201,7 +203,7 @@ public: |
static int s_destructed; |
static int s_invoked; |
- OwnPtr<CancellableTaskFactory> m_factory; |
+ std::unique_ptr<CancellableTaskFactory> m_factory; |
}; |
int GCObject::s_destructed = 0; |
@@ -212,7 +214,7 @@ int GCObject::s_invoked = 0; |
TEST(CancellableTaskFactoryTest, GarbageCollectedWeak) |
{ |
GCObject* object = new GCObject(); |
- OwnPtr<WebTaskRunner::Task> task = adoptPtr(object->m_factory->cancelAndCreate()); |
+ std::unique_ptr<WebTaskRunner::Task> task = wrapUnique(object->m_factory->cancelAndCreate()); |
object = nullptr; |
ThreadHeap::collectAllGarbage(); |
task->run(); |