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

Unified Diff: cc/output/output_surface_unittest.cc

Issue 17362002: cc: Remove FakeThread, use SingleThreadTaskRunner in scheduling classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rm-fakethread: rebase Created 7 years, 6 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
« no previous file with comments | « cc/output/output_surface.cc ('k') | cc/resources/resource_update_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/output_surface_unittest.cc
diff --git a/cc/output/output_surface_unittest.cc b/cc/output/output_surface_unittest.cc
index 7dcb1cce0fe59ea65f5f6cc51634e3c0a85a9cf5..e42777aeca5174138bab8a88cc9d1a43857595da 100644
--- a/cc/output/output_surface_unittest.cc
+++ b/cc/output/output_surface_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/test/test_simple_task_runner.h"
#include "cc/output/output_surface.h"
#include "cc/output/output_surface_client.h"
#include "cc/output/software_output_device.h"
@@ -208,13 +209,14 @@ TEST(OutputSurfaceTest, BeginFrameEmulation) {
EXPECT_FALSE(client.deferred_initialize_called());
// Initialize BeginFrame emulation
- FakeThread impl_thread;
+ scoped_refptr<base::TestSimpleTaskRunner> task_runner =
+ new base::TestSimpleTaskRunner;
bool throttle_frame_production = true;
const base::TimeDelta display_refresh_interval =
base::TimeDelta::FromMicroseconds(16666);
output_surface.InitializeBeginFrameEmulation(
- &impl_thread,
+ task_runner.get(),
throttle_frame_production,
display_refresh_interval);
@@ -225,17 +227,17 @@ TEST(OutputSurfaceTest, BeginFrameEmulation) {
EXPECT_EQ(output_surface.pending_swap_buffers(), 0);
// We should not have a pending task until a BeginFrame has been requested.
- EXPECT_FALSE(impl_thread.HasPendingTask());
+ EXPECT_FALSE(task_runner->HasPendingTask());
output_surface.SetNeedsBeginFrame(true);
- EXPECT_TRUE(impl_thread.HasPendingTask());
+ EXPECT_TRUE(task_runner->HasPendingTask());
// BeginFrame should be called on the first tick.
- impl_thread.RunPendingTask();
+ task_runner->RunPendingTasks();
EXPECT_EQ(client.begin_frame_count(), 1);
EXPECT_EQ(output_surface.pending_swap_buffers(), 0);
// BeginFrame should not be called when there is a pending BeginFrame.
- impl_thread.RunPendingTask();
+ task_runner->RunPendingTasks();
EXPECT_EQ(client.begin_frame_count(), 1);
EXPECT_EQ(output_surface.pending_swap_buffers(), 0);
@@ -243,7 +245,7 @@ TEST(OutputSurfaceTest, BeginFrameEmulation) {
output_surface.DidSwapBuffersForTesting();
EXPECT_EQ(client.begin_frame_count(), 1);
EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
- impl_thread.RunPendingTask();
+ task_runner->RunPendingTasks();
EXPECT_EQ(client.begin_frame_count(), 2);
EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
@@ -251,7 +253,7 @@ TEST(OutputSurfaceTest, BeginFrameEmulation) {
output_surface.DidSwapBuffersForTesting();
EXPECT_EQ(client.begin_frame_count(), 2);
EXPECT_EQ(output_surface.pending_swap_buffers(), 2);
- impl_thread.RunPendingTask();
+ task_runner->RunPendingTasks();
EXPECT_EQ(client.begin_frame_count(), 2);
EXPECT_EQ(output_surface.pending_swap_buffers(), 2);
@@ -259,21 +261,21 @@ TEST(OutputSurfaceTest, BeginFrameEmulation) {
output_surface.OnSwapBuffersCompleteForTesting();
EXPECT_EQ(client.begin_frame_count(), 2);
EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
- impl_thread.RunPendingTask();
+ task_runner->RunPendingTasks();
EXPECT_EQ(client.begin_frame_count(), 3);
EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
// Calling SetNeedsBeginFrame again indicates a swap did not occur but
// the client still wants another BeginFrame.
output_surface.SetNeedsBeginFrame(true);
- impl_thread.RunPendingTask();
+ task_runner->RunPendingTasks();
EXPECT_EQ(client.begin_frame_count(), 4);
EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
// Disabling SetNeedsBeginFrame should prevent further BeginFrames.
output_surface.SetNeedsBeginFrame(false);
- impl_thread.RunPendingTask();
- EXPECT_FALSE(impl_thread.HasPendingTask());
+ task_runner->RunPendingTasks();
+ EXPECT_FALSE(task_runner->HasPendingTask());
EXPECT_EQ(client.begin_frame_count(), 4);
EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
« no previous file with comments | « cc/output/output_surface.cc ('k') | cc/resources/resource_update_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698