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

Side by Side Diff: third_party/WebKit/Source/platform/WebTaskRunnerTest.cpp

Issue 2876513002: Use WTF::TimeDelta to specify delays on WebTaskRunner (Closed)
Patch Set: mac fix Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/WebTaskRunner.h" 5 #include "platform/WebTaskRunner.h"
6 6
7 #include "platform/scheduler/test/fake_web_task_runner.h" 7 #include "platform/scheduler/test/fake_web_task_runner.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace blink { 10 namespace blink {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 TaskHandle handle = task_runner->PostCancellableTask( 46 TaskHandle handle = task_runner->PostCancellableTask(
47 BLINK_FROM_HERE, WTF::Bind(&Increment, WTF::Unretained(&count))); 47 BLINK_FROM_HERE, WTF::Bind(&Increment, WTF::Unretained(&count)));
48 EXPECT_EQ(0, count); 48 EXPECT_EQ(0, count);
49 EXPECT_TRUE(handle.IsActive()); 49 EXPECT_TRUE(handle.IsActive());
50 task_runner->RunUntilIdle(); 50 task_runner->RunUntilIdle();
51 EXPECT_EQ(1, count); 51 EXPECT_EQ(1, count);
52 EXPECT_FALSE(handle.IsActive()); 52 EXPECT_FALSE(handle.IsActive());
53 53
54 count = 0; 54 count = 0;
55 handle = task_runner->PostDelayedCancellableTask( 55 handle = task_runner->PostDelayedCancellableTask(
56 BLINK_FROM_HERE, WTF::Bind(&Increment, WTF::Unretained(&count)), 1); 56 BLINK_FROM_HERE, WTF::Bind(&Increment, WTF::Unretained(&count)),
57 TimeDelta::FromMilliseconds(1));
57 EXPECT_EQ(0, count); 58 EXPECT_EQ(0, count);
58 EXPECT_TRUE(handle.IsActive()); 59 EXPECT_TRUE(handle.IsActive());
59 task_runner->RunUntilIdle(); 60 task_runner->RunUntilIdle();
60 EXPECT_EQ(1, count); 61 EXPECT_EQ(1, count);
61 EXPECT_FALSE(handle.IsActive()); 62 EXPECT_FALSE(handle.IsActive());
62 63
63 // Cancel a task. 64 // Cancel a task.
64 count = 0; 65 count = 0;
65 handle = task_runner->PostCancellableTask( 66 handle = task_runner->PostCancellableTask(
66 BLINK_FROM_HERE, WTF::Bind(&Increment, WTF::Unretained(&count))); 67 BLINK_FROM_HERE, WTF::Bind(&Increment, WTF::Unretained(&count)));
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 queue = task_runner->TakePendingTasksForTesting(); 147 queue = task_runner->TakePendingTasksForTesting();
147 ASSERT_EQ(1u, queue.size()); 148 ASSERT_EQ(1u, queue.size());
148 EXPECT_FALSE(queue[0].first.IsCancelled()); 149 EXPECT_FALSE(queue[0].first.IsCancelled());
149 EXPECT_TRUE(handle.IsActive()); 150 EXPECT_TRUE(handle.IsActive());
150 helper.RevokeWeakPtrs(); 151 helper.RevokeWeakPtrs();
151 EXPECT_TRUE(queue[0].first.IsCancelled()); 152 EXPECT_TRUE(queue[0].first.IsCancelled());
152 EXPECT_FALSE(handle.IsActive()); 153 EXPECT_FALSE(handle.IsActive());
153 } 154 }
154 155
155 } // namespace blink 156 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/WebTaskRunner.cpp ('k') | third_party/WebKit/Source/platform/WebThreadSupportingGC.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698