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

Unified Diff: cc/surfaces/display_scheduler_unittest.cc

Issue 1132753008: Replaced TestNowSource with SimpleTestTickClock. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased again. Replaces TimeSource with TickClock in TestAlwaysFailTimeSource Created 5 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
Index: cc/surfaces/display_scheduler_unittest.cc
diff --git a/cc/surfaces/display_scheduler_unittest.cc b/cc/surfaces/display_scheduler_unittest.cc
index 7fedbc77c64519b0d5146f9b41ce1206b0fda0a2..8d5e6bccb4d62833d9761b9227cc531406113bce 100644
--- a/cc/surfaces/display_scheduler_unittest.cc
+++ b/cc/surfaces/display_scheduler_unittest.cc
@@ -6,11 +6,11 @@
#include "base/logging.h"
#include "base/test/null_task_runner.h"
+#include "base/test/simple_test_tick_clock.h"
#include "base/trace_event/trace_event.h"
#include "cc/output/begin_frame_args.h"
#include "cc/surfaces/display.h"
#include "cc/test/scheduler_test_common.h"
-#include "cc/test/test_now_source.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace cc {
@@ -68,9 +68,9 @@ class TestDisplayScheduler : public DisplayScheduler {
class DisplaySchedulerTest : public testing::Test {
public:
- DisplaySchedulerTest() {
+ DisplaySchedulerTest() : now_src_(new base::SimpleTestTickClock()) {
const int max_pending_swaps = 1;
- now_src_ = TestNowSource::Create();
+ now_src_->Advance(base::TimeDelta::FromInternalValue(10000));
null_task_runner_ = make_scoped_refptr(new base::NullTaskRunner);
client_ = make_scoped_ptr(new FakeDisplaySchedulerClient);
scheduler_ = make_scoped_ptr(
@@ -83,7 +83,7 @@ class DisplaySchedulerTest : public testing::Test {
void SetUp() override { scheduler_->SetRootSurfaceResourcesLocked(false); }
void BeginFrameForTest() {
- base::TimeTicks frame_time = now_src_->Now();
+ base::TimeTicks frame_time = now_src_->NowTicks();
base::TimeDelta interval = BeginFrameArgs::DefaultInterval();
base::TimeTicks deadline = frame_time + interval -
BeginFrameArgs::DefaultEstimatedParentDrawTime();
@@ -93,11 +93,11 @@ class DisplaySchedulerTest : public testing::Test {
}
protected:
- TestNowSource& now_src() { return *now_src_; }
+ base::SimpleTestTickClock& now_src() { return *now_src_; }
FakeDisplaySchedulerClient& client() { return *client_; }
DisplayScheduler& scheduler() { return *scheduler_; }
- scoped_refptr<TestNowSource> now_src_;
+ scoped_ptr<base::SimpleTestTickClock> now_src_;
scoped_refptr<base::NullTaskRunner> null_task_runner_;
FakeBeginFrameSource fake_begin_frame_source_;
@@ -108,10 +108,10 @@ class DisplaySchedulerTest : public testing::Test {
TEST_F(DisplaySchedulerTest, EntireDisplayDamagedDrawsImmediately) {
SurfaceId root_surface_id(1);
BeginFrameForTest();
- EXPECT_LT(now_src().Now(),
+ EXPECT_LT(now_src().NowTicks(),
scheduler_->DesiredBeginFrameDeadlineTimeForTest());
scheduler_->EntireDisplayDamaged(root_surface_id);
- EXPECT_GE(now_src().Now(),
+ EXPECT_GE(now_src().NowTicks(),
scheduler_->DesiredBeginFrameDeadlineTimeForTest());
}
@@ -135,12 +135,12 @@ TEST_F(DisplaySchedulerTest, SurfaceDamaged) {
// Damage only from surface 2 (inactive) does not trigger deadline early.
BeginFrameForTest();
scheduler_->SurfaceDamaged(sid2);
- EXPECT_LT(now_src().Now(),
+ EXPECT_LT(now_src().NowTicks(),
scheduler_->DesiredBeginFrameDeadlineTimeForTest());
// Damage from surface 1 triggers deadline early.
scheduler_->SurfaceDamaged(sid1);
- EXPECT_GE(now_src().Now(),
+ EXPECT_GE(now_src().NowTicks(),
scheduler_->DesiredBeginFrameDeadlineTimeForTest());
scheduler_->BeginFrameDeadlineForTest();
@@ -152,13 +152,13 @@ TEST_F(DisplaySchedulerTest, SurfaceDamaged) {
// Deadline doesn't trigger early until surface 1 and 2 are both damaged.
BeginFrameForTest();
- EXPECT_LT(now_src().Now(),
+ EXPECT_LT(now_src().NowTicks(),
scheduler_->DesiredBeginFrameDeadlineTimeForTest());
scheduler_->SurfaceDamaged(sid1);
- EXPECT_LT(now_src().Now(),
+ EXPECT_LT(now_src().NowTicks(),
scheduler_->DesiredBeginFrameDeadlineTimeForTest());
scheduler_->SurfaceDamaged(sid2);
- EXPECT_GE(now_src().Now(),
+ EXPECT_GE(now_src().NowTicks(),
scheduler_->DesiredBeginFrameDeadlineTimeForTest());
scheduler_->BeginFrameDeadlineForTest();
@@ -171,10 +171,10 @@ TEST_F(DisplaySchedulerTest, SurfaceDamaged) {
// Deadline should trigger early if child surfaces are idle and
// we get damage on the root surface.
BeginFrameForTest();
- EXPECT_LT(now_src().Now(),
+ EXPECT_LT(now_src().NowTicks(),
scheduler_->DesiredBeginFrameDeadlineTimeForTest());
scheduler_->SurfaceDamaged(root_surface_id);
- EXPECT_GE(now_src().Now(),
+ EXPECT_GE(now_src().NowTicks(),
scheduler_->DesiredBeginFrameDeadlineTimeForTest());
scheduler_->BeginFrameDeadlineForTest();
}
@@ -184,7 +184,7 @@ TEST_F(DisplaySchedulerTest, OutputSurfaceLost) {
// DrawAndSwap normally.
BeginFrameForTest();
- EXPECT_LT(now_src().Now(),
+ EXPECT_LT(now_src().NowTicks(),
scheduler_->DesiredBeginFrameDeadlineTimeForTest());
EXPECT_EQ(0, client_->draw_and_swap_count());
scheduler_->SurfaceDamaged(sid1);
@@ -193,10 +193,10 @@ TEST_F(DisplaySchedulerTest, OutputSurfaceLost) {
// Deadline triggers immediately on OutputSurfaceLost.
BeginFrameForTest();
- EXPECT_LT(now_src().Now(),
+ EXPECT_LT(now_src().NowTicks(),
scheduler_->DesiredBeginFrameDeadlineTimeForTest());
scheduler_->OutputSurfaceLost();
- EXPECT_GE(now_src().Now(),
+ EXPECT_GE(now_src().NowTicks(),
scheduler_->DesiredBeginFrameDeadlineTimeForTest());
// Deadline does not DrawAndSwap after OutputSurfaceLost.
@@ -212,7 +212,7 @@ TEST_F(DisplaySchedulerTest, RootSurfaceResourcesLocked) {
// DrawAndSwap normally.
BeginFrameForTest();
- EXPECT_LT(now_src().Now(),
+ EXPECT_LT(now_src().NowTicks(),
scheduler_->DesiredBeginFrameDeadlineTimeForTest());
EXPECT_EQ(0, client_->draw_and_swap_count());
scheduler_->SurfaceDamaged(sid1);
@@ -220,7 +220,7 @@ TEST_F(DisplaySchedulerTest, RootSurfaceResourcesLocked) {
EXPECT_EQ(1, client_->draw_and_swap_count());
// Deadline triggers late while root resources are locked.
- late_deadline = now_src().Now() + BeginFrameArgs::DefaultInterval();
+ late_deadline = now_src().NowTicks() + BeginFrameArgs::DefaultInterval();
BeginFrameForTest();
scheduler_->SurfaceDamaged(sid1);
EXPECT_GT(late_deadline, scheduler_->DesiredBeginFrameDeadlineTimeForTest());
@@ -234,7 +234,7 @@ TEST_F(DisplaySchedulerTest, RootSurfaceResourcesLocked) {
EXPECT_EQ(1, client_->draw_and_swap_count());
// Deadline triggers normally when root resources are unlocked.
- late_deadline = now_src().Now() + BeginFrameArgs::DefaultInterval();
+ late_deadline = now_src().NowTicks() + BeginFrameArgs::DefaultInterval();
BeginFrameForTest();
scheduler_->SurfaceDamaged(sid1);
EXPECT_EQ(late_deadline, scheduler_->DesiredBeginFrameDeadlineTimeForTest());
@@ -264,7 +264,7 @@ TEST_F(DisplaySchedulerTest, DidSwapBuffers) {
// DrawAndSwap normally.
BeginFrameForTest();
- EXPECT_LT(now_src().Now(),
+ EXPECT_LT(now_src().NowTicks(),
scheduler_->DesiredBeginFrameDeadlineTimeForTest());
EXPECT_EQ(2, client_->draw_and_swap_count());
scheduler_->SurfaceDamaged(sid1);
@@ -288,11 +288,11 @@ TEST_F(DisplaySchedulerTest, DidSwapBuffers) {
// Deadline triggers normally once not swap throttled.
// Damage from previous BeginFrame should cary over, so don't damage again.
- late_deadline = now_src().Now() + BeginFrameArgs::DefaultInterval();
+ late_deadline = now_src().NowTicks() + BeginFrameArgs::DefaultInterval();
scheduler_->DidSwapBuffersComplete();
BeginFrameForTest();
EXPECT_GT(scheduler_->DesiredBeginFrameDeadlineTimeForTest(),
- now_src().Now());
+ now_src().NowTicks());
EXPECT_LT(scheduler_->DesiredBeginFrameDeadlineTimeForTest(), late_deadline);
// Still waiting for surface 2. Once it updates, deadline should trigger
// immediately again.

Powered by Google App Engine
This is Rietveld 408576698