diff options
-rw-r--r-- | cc/cc_tests.gyp | 2 | ||||
-rw-r--r-- | cc/output/begin_frame_args.cc | 14 | ||||
-rw-r--r-- | cc/output/begin_frame_args.h | 2 | ||||
-rw-r--r-- | cc/output/output_surface_unittest.cc | 3 | ||||
-rw-r--r-- | cc/scheduler/scheduler_state_machine_unittest.cc | 109 | ||||
-rw-r--r-- | cc/scheduler/scheduler_unittest.cc | 75 | ||||
-rw-r--r-- | cc/test/begin_frame_args_test.cc | 35 | ||||
-rw-r--r-- | cc/test/begin_frame_args_test.h | 24 | ||||
-rw-r--r-- | cc/test/fake_output_surface.cc | 3 |
9 files changed, 158 insertions, 109 deletions
diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp index 25fb760..dc29a77 100644 --- a/cc/cc_tests.gyp +++ b/cc/cc_tests.gyp @@ -120,6 +120,8 @@ 'cc_tests_support_files': [ 'test/animation_test_common.cc', 'test/animation_test_common.h', + 'test/begin_frame_args_test.cc', + 'test/begin_frame_args_test.h', 'test/fake_content_layer.cc', 'test/fake_content_layer.h', 'test/fake_content_layer_client.cc', diff --git a/cc/output/begin_frame_args.cc b/cc/output/begin_frame_args.cc index 92901af..9766b626 100644 --- a/cc/output/begin_frame_args.cc +++ b/cc/output/begin_frame_args.cc @@ -35,20 +35,6 @@ BeginFrameArgs BeginFrameArgs::CreateForSynchronousCompositor() { DefaultInterval()); } -BeginFrameArgs BeginFrameArgs::CreateForTesting() { - base::TimeTicks now = gfx::FrameTime::Now(); - return BeginFrameArgs(now, - now + (DefaultInterval() / 2), - DefaultInterval()); -} - -BeginFrameArgs BeginFrameArgs::CreateExpiredForTesting() { - base::TimeTicks now = gfx::FrameTime::Now(); - return BeginFrameArgs(now, - now - DefaultInterval(), - DefaultInterval()); -} - // This is a hard-coded deadline adjustment that assumes 60Hz, to be used in // cases where a good estimated draw time is not known. Using 1/3 of the vsync // as the default adjustment gives the Browser the last 1/3 of a frame to diff --git a/cc/output/begin_frame_args.h b/cc/output/begin_frame_args.h index 025a407..2332fd4 100644 --- a/cc/output/begin_frame_args.h +++ b/cc/output/begin_frame_args.h @@ -20,8 +20,6 @@ struct CC_EXPORT BeginFrameArgs { base::TimeTicks deadline, base::TimeDelta interval); static BeginFrameArgs CreateForSynchronousCompositor(); - static BeginFrameArgs CreateForTesting(); - static BeginFrameArgs CreateExpiredForTesting(); // This is the default delta that will be used to adjust the deadline when // proper draw-time estimations are not yet available. diff --git a/cc/output/output_surface_unittest.cc b/cc/output/output_surface_unittest.cc index 05381fc..709e03c 100644 --- a/cc/output/output_surface_unittest.cc +++ b/cc/output/output_surface_unittest.cc @@ -8,6 +8,7 @@ #include "cc/output/managed_memory_policy.h" #include "cc/output/output_surface_client.h" #include "cc/output/software_output_device.h" +#include "cc/test/begin_frame_args_test.h" #include "cc/test/fake_output_surface.h" #include "cc/test/fake_output_surface_client.h" #include "cc/test/scheduler_test_common.h" @@ -45,7 +46,7 @@ class TestOutputSurface : public OutputSurface { } void BeginFrameForTesting() { - client_->BeginFrame(BeginFrameArgs::CreateExpiredForTesting()); + client_->BeginFrame(CreateExpiredBeginFrameArgsForTesting()); } void DidSwapBuffersForTesting() { client_->DidSwapBuffers(); } diff --git a/cc/scheduler/scheduler_state_machine_unittest.cc b/cc/scheduler/scheduler_state_machine_unittest.cc index 067f019..64d1c25 100644 --- a/cc/scheduler/scheduler_state_machine_unittest.cc +++ b/cc/scheduler/scheduler_state_machine_unittest.cc @@ -5,6 +5,7 @@ #include "cc/scheduler/scheduler_state_machine.h" #include "cc/scheduler/scheduler.h" +#include "cc/test/begin_frame_args_test.h" #include "testing/gtest/include/gtest/gtest.h" #define EXPECT_ACTION_UPDATE_STATE(action) \ @@ -131,7 +132,7 @@ TEST(SchedulerStateMachineTest, TestNextActionBeginsMainFrameIfNeeded) { EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); EXPECT_FALSE(state.BeginFrameNeeded()); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); @@ -149,7 +150,7 @@ TEST(SchedulerStateMachineTest, TestNextActionBeginsMainFrameIfNeeded) { EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); EXPECT_FALSE(state.BeginFrameNeeded()); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); } @@ -167,7 +168,7 @@ TEST(SchedulerStateMachineTest, TestNextActionBeginsMainFrameIfNeeded) { EXPECT_TRUE(state.BeginFrameNeeded()); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); } @@ -204,7 +205,7 @@ TEST(SchedulerStateMachineTest, MainFrameBeforeDrawDisabled) { EXPECT_TRUE(state.BeginFrameNeeded()); // Commit to the pending tree. - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); @@ -223,7 +224,7 @@ TEST(SchedulerStateMachineTest, MainFrameBeforeDrawDisabled) { // Verify that the next commit doesn't start until the previous // commit has been drawn. state.SetNeedsCommit(); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); // Make sure that a draw of the active tree doesn't spuriously advance @@ -240,7 +241,7 @@ TEST(SchedulerStateMachineTest, MainFrameBeforeDrawDisabled) { // Verify NotifyReadyToActivate unblocks activation, draw, and // commit in that order. - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); state.NotifyReadyToActivate(); EXPECT_ACTION_UPDATE_STATE( @@ -287,7 +288,7 @@ TEST(SchedulerStateMachineTest, MainFrameBeforeActivationEnabled) { EXPECT_TRUE(state.BeginFrameNeeded()); // Commit to the pending tree. - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); @@ -303,7 +304,7 @@ TEST(SchedulerStateMachineTest, MainFrameBeforeActivationEnabled) { // Verify that the next commit starts while there is still a pending tree. state.SetNeedsCommit(); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); @@ -343,7 +344,7 @@ TEST(SchedulerStateMachineTest, state.SetNeedsRedraw(true); EXPECT_TRUE(state.RedrawPending()); EXPECT_TRUE(state.BeginFrameNeeded()); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); @@ -359,7 +360,7 @@ TEST(SchedulerStateMachineTest, // Failing the draw makes us require a commit. state.DidDrawIfPossibleCompleted( DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); @@ -379,7 +380,7 @@ TEST(SchedulerStateMachineTest, TestFailedDrawForMissingHighResNeedsCommit) { EXPECT_TRUE(state.RedrawPending()); EXPECT_TRUE(state.BeginFrameNeeded()); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); @@ -392,7 +393,7 @@ TEST(SchedulerStateMachineTest, TestFailedDrawForMissingHighResNeedsCommit) { // Missing high res content requires a commit (but not a redraw) state.DidDrawIfPossibleCompleted( DrawSwapReadbackResult::DRAW_ABORTED_MISSING_HIGH_RES_CONTENT); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); EXPECT_FALSE(state.RedrawPending()); @@ -412,7 +413,7 @@ TEST(SchedulerStateMachineTest, state.SetNeedsRedraw(true); EXPECT_TRUE(state.RedrawPending()); EXPECT_TRUE(state.BeginFrameNeeded()); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); @@ -432,7 +433,7 @@ TEST(SchedulerStateMachineTest, // Failing the draw for animation checkerboards makes us require a commit. state.DidDrawIfPossibleCompleted( DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); @@ -455,7 +456,7 @@ void TestFailedDrawsEventuallyForceDrawAfterNextCommit( // Start a commit. state.SetNeedsCommit(); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); @@ -486,7 +487,7 @@ void TestFailedDrawsEventuallyForceDrawAfterNextCommit( EXPECT_TRUE(state.RedrawPending()); // The redraw should be forced at the end of the next BeginImplFrame. - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); if (main_frame_before_draw_enabled) { EXPECT_ACTION_UPDATE_STATE( @@ -528,7 +529,7 @@ TEST(SchedulerStateMachineTest, TestFailedDrawsDoNotRestartForcedDraw) { // Start a commit. state.SetNeedsCommit(); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); @@ -589,7 +590,7 @@ TEST(SchedulerStateMachineTest, TestFailedDrawIsRetriedInNextBeginImplFrame) { // Start a draw. state.SetNeedsRedraw(true); EXPECT_TRUE(state.BeginFrameNeeded()); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); @@ -607,7 +608,7 @@ TEST(SchedulerStateMachineTest, TestFailedDrawIsRetriedInNextBeginImplFrame) { // We should not be trying to draw again now, but we have a commit pending. EXPECT_TRUE(state.BeginFrameNeeded()); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); @@ -631,7 +632,7 @@ TEST(SchedulerStateMachineTest, TestDoestDrawTwiceInSameFrame) { // Draw the first frame. EXPECT_TRUE(state.BeginFrameNeeded()); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); @@ -648,7 +649,7 @@ TEST(SchedulerStateMachineTest, TestDoestDrawTwiceInSameFrame) { // Move to another frame. This should now draw. EXPECT_TRUE(state.BeginFrameNeeded()); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); @@ -797,7 +798,7 @@ TEST(SchedulerStateMachineTest, TestCanRedraw_StopsDraw) { state.SetVisible(false); state.SetNeedsRedraw(true); if (j == 1) - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); state.SetCanDraw(false); EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE, @@ -819,7 +820,7 @@ TEST(SchedulerStateMachineTest, state.SetNeedsRedraw(true); state.SetVisible(true); state.SetCanDraw(false); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); @@ -847,7 +848,7 @@ void TestSetNeedsCommitIsNotLost(bool main_frame_before_draw_enabled) { EXPECT_TRUE(state.BeginFrameNeeded()); // Begin the frame. - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT, @@ -883,7 +884,7 @@ void TestSetNeedsCommitIsNotLost(bool main_frame_before_draw_enabled) { state.begin_impl_frame_state()); EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction()); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_EQ(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING, state.begin_impl_frame_state()); EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction()); @@ -934,7 +935,7 @@ TEST(SchedulerStateMachineTest, TestFullCycle) { state.SetNeedsCommit(); // Begin the frame. - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT, @@ -982,7 +983,7 @@ TEST(SchedulerStateMachineTest, TestFullCycleWithCommitRequestInbetween) { state.SetNeedsCommit(); // Begin the frame. - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT, @@ -1021,7 +1022,7 @@ TEST(SchedulerStateMachineTest, TestFullCycleWithCommitRequestInbetween) { EXPECT_FALSE(state.needs_redraw()); // Next BeginImplFrame should initiate second commit. - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); } @@ -1049,7 +1050,7 @@ TEST(SchedulerStateMachineTest, TestGoesInvisibleBeforeFinishCommit) { state.SetNeedsCommit(); // Begin the frame while visible. - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT, @@ -1079,7 +1080,7 @@ TEST(SchedulerStateMachineTest, TestGoesInvisibleBeforeFinishCommit) { EXPECT_TRUE(state.NeedsCommit()); // Start a new frame. - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); @@ -1118,7 +1119,7 @@ TEST(SchedulerStateMachineTest, AbortBeginMainFrameAndCancelCommit) { // Start a new frame; draw because this is the first frame since output // surface init'd. - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); @@ -1150,14 +1151,14 @@ TEST(SchedulerStateMachineTest, TestFirstContextCreation) { EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); // Check that the first init does not SetNeedsCommit. - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); // Check that a needs commit initiates a BeginMainFrame. state.SetNeedsCommit(); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); } @@ -1187,7 +1188,7 @@ TEST(SchedulerStateMachineTest, TestContextLostWhenCompletelyIdle) { state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); // When the context is recreated, we should begin a commit. - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); } @@ -1211,14 +1212,14 @@ TEST(SchedulerStateMachineTest, EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); // Once context recreation begins, nothing should happen. - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); // While context is recreating, commits shouldn't begin. state.SetNeedsCommit(); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); @@ -1244,7 +1245,7 @@ TEST(SchedulerStateMachineTest, // Once the context is recreated, whether we draw should be based on // SetCanDraw. - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); @@ -1272,7 +1273,7 @@ TEST(SchedulerStateMachineTest, TestContextLostWhileCommitInProgress) { // Set damage and expect a draw. state.SetNeedsRedraw(true); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); @@ -1305,7 +1306,7 @@ TEST(SchedulerStateMachineTest, TestContextLostWhileCommitInProgress) { EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION, state.NextAction()); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_EQ(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING, state.begin_impl_frame_state()); EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); @@ -1337,7 +1338,7 @@ TEST(SchedulerStateMachineTest, // Set damage and expect a draw. state.SetNeedsRedraw(true); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); @@ -1370,7 +1371,7 @@ TEST(SchedulerStateMachineTest, EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION, state.NextAction()); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_EQ(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING, state.begin_impl_frame_state()); EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); @@ -1391,7 +1392,7 @@ TEST(SchedulerStateMachineTest, // After we get a new output surface, the commit flow should start. state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); @@ -1420,7 +1421,7 @@ TEST(SchedulerStateMachineTest, TestFinishAllRenderingWhileContextLost) { // Ask a forced redraw for readback and verify it ocurrs. state.SetNeedsForcedRedrawForReadback(); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); @@ -1470,7 +1471,7 @@ TEST(SchedulerStateMachineTest, DontDrawBeforeCommitAfterLostOutputSurface) { state.DidCreateAndInitializeOutputSurface(); EXPECT_FALSE(state.RedrawPending()); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME, state.NextAction()); } @@ -1563,7 +1564,7 @@ TEST(SchedulerStateMachineTest, DontMakeNewCommitAfterDrawingReplaceCommit) { state.NotifyReadyToCommit(); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); @@ -1668,7 +1669,7 @@ void TestForceCommitWhenReplacementActivationInProgress( } EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); // Perform the draw & swap of replacement commit. @@ -1708,7 +1709,7 @@ void TestForceCommitWhenReplacementActivationInProgress( state.NotifyReadyToActivate(); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_ACTIVATE_PENDING_TREE); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); state.OnBeginImplFrameDeadline(); @@ -1758,7 +1759,7 @@ TEST(SchedulerStateMachineTest, // New commit is requested and scheduled when impl-side painting is in // progress. state.SetNeedsCommit(); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); @@ -1779,7 +1780,7 @@ TEST(SchedulerStateMachineTest, EXPECT_FALSE(state.NeedsCommit()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); // Perform the draw & swap of replacement commit. @@ -2010,7 +2011,7 @@ TEST(SchedulerStateMachineTest, TestTriggerDeadlineEarlyAfterAbortedCommit) { // This test mirrors what happens during the first frame of a scroll gesture. // First we get the input event and a BeginFrame. - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); // As a response the compositor requests a redraw and a commit to tell the // main thread about the new scroll offset. @@ -2044,7 +2045,7 @@ TEST(SchedulerStateMachineTest, TestTriggerDeadlineEarlyForSmoothness) { // This test ensures that impl-draws are prioritized over main thread updates // in prefer smoothness mode. - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); state.SetNeedsRedraw(true); state.SetNeedsCommit(); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); @@ -2073,7 +2074,7 @@ TEST(SchedulerStateMachineTest, TestSetNeedsAnimate) { EXPECT_TRUE(state.BeginFrameNeeded()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); state.OnBeginImplFrameDeadlinePending(); @@ -2099,7 +2100,7 @@ TEST(SchedulerStateMachineTest, TestAnimateBeforeCommit) { EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); EXPECT_TRUE(state.BeginFrameNeeded()); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); EXPECT_ACTION_UPDATE_STATE( SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); @@ -2126,7 +2127,7 @@ TEST(SchedulerStateMachineTest, TestSetNeedsAnimateAfterAnimate) { EXPECT_TRUE(state.BeginFrameNeeded()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); - state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); + state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); state.SetNeedsAnimate(); diff --git a/cc/scheduler/scheduler_unittest.cc b/cc/scheduler/scheduler_unittest.cc index 921b94a..e69e6dd 100644 --- a/cc/scheduler/scheduler_unittest.cc +++ b/cc/scheduler/scheduler_unittest.cc @@ -12,6 +12,7 @@ #include "base/run_loop.h" #include "base/test/test_simple_task_runner.h" #include "base/time/time.h" +#include "cc/test/begin_frame_args_test.h" #include "cc/test/scheduler_test_common.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -213,7 +214,7 @@ void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler, scheduler->NotifyReadyToCommit(); // Go through the motions to draw the commit. if (client_initiates_begin_frame) - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); else client->task_runner().RunPendingTasks(); // Run posted BeginFrame. @@ -225,7 +226,7 @@ void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler, // We need another BeginImplFrame so Scheduler calls // SetNeedsBeginFrame(false). if (client_initiates_begin_frame) - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); else client->task_runner().RunPendingTasks(); // Run posted BeginFrame. @@ -267,7 +268,7 @@ TEST(SchedulerTest, RequestCommit) { EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); client.Reset(); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); @@ -289,7 +290,7 @@ TEST(SchedulerTest, RequestCommit) { client.Reset(); // BeginImplFrame should prepare the draw. - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); @@ -305,7 +306,7 @@ TEST(SchedulerTest, RequestCommit) { // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) // to avoid excessive toggles. - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); client.Reset(); @@ -333,7 +334,7 @@ TEST(SchedulerTest, RequestCommitAfterBeginMainFrameSent) { EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); client.Reset(); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); @@ -363,7 +364,7 @@ TEST(SchedulerTest, RequestCommitAfterBeginMainFrameSent) { client.Reset(); // Since another commit is needed, the next BeginImplFrame should initiate // the second commit. - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); @@ -385,7 +386,7 @@ TEST(SchedulerTest, RequestCommitAfterBeginMainFrameSent) { // On the next BeginImplFrame, verify we go back to a quiescent state and // no longer request BeginImplFrames. - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); client.task_runner().RunPendingTasks(); // Run posted deadline. EXPECT_FALSE(client.needs_begin_frame()); client.Reset(); @@ -434,13 +435,13 @@ TEST(SchedulerTest, RequestRedrawInsideDraw) { EXPECT_TRUE(client.needs_begin_frame()); EXPECT_EQ(0, client.num_draws()); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); client.task_runner().RunPendingTasks(); // Run posted deadline. EXPECT_EQ(1, client.num_draws()); EXPECT_TRUE(scheduler->RedrawPending()); EXPECT_TRUE(client.needs_begin_frame()); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); client.task_runner().RunPendingTasks(); // Run posted deadline. EXPECT_EQ(2, client.num_draws()); EXPECT_FALSE(scheduler->RedrawPending()); @@ -448,7 +449,7 @@ TEST(SchedulerTest, RequestRedrawInsideDraw) { // We stop requesting BeginImplFrames after a BeginImplFrame where we don't // swap. - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); client.task_runner().RunPendingTasks(); // Run posted deadline. EXPECT_EQ(2, client.num_draws()); EXPECT_FALSE(scheduler->RedrawPending()); @@ -474,7 +475,7 @@ TEST(SchedulerTest, RequestRedrawInsideFailedDraw) { EXPECT_EQ(0, client.num_draws()); // Fail the draw. - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); client.task_runner().RunPendingTasks(); // Run posted deadline. EXPECT_EQ(1, client.num_draws()); @@ -485,7 +486,7 @@ TEST(SchedulerTest, RequestRedrawInsideFailedDraw) { EXPECT_TRUE(client.needs_begin_frame()); // Fail the draw again. - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); client.task_runner().RunPendingTasks(); // Run posted deadline. EXPECT_EQ(2, client.num_draws()); EXPECT_TRUE(scheduler->CommitPending()); @@ -494,7 +495,7 @@ TEST(SchedulerTest, RequestRedrawInsideFailedDraw) { // Draw successfully. client.SetDrawWillHappen(true); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); client.task_runner().RunPendingTasks(); // Run posted deadline. EXPECT_EQ(3, client.num_draws()); EXPECT_TRUE(scheduler->CommitPending()); @@ -555,7 +556,7 @@ TEST(SchedulerTest, RequestCommitInsideDraw) { EXPECT_TRUE(client.needs_begin_frame()); client.SetNeedsCommitOnNextDraw(); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); client.SetNeedsCommitOnNextDraw(); client.task_runner().RunPendingTasks(); // Run posted deadline. EXPECT_EQ(1, client.num_draws()); @@ -564,7 +565,7 @@ TEST(SchedulerTest, RequestCommitInsideDraw) { scheduler->NotifyBeginMainFrameStarted(); scheduler->NotifyReadyToCommit(); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); client.task_runner().RunPendingTasks(); // Run posted deadline. EXPECT_EQ(2, client.num_draws()); @@ -574,7 +575,7 @@ TEST(SchedulerTest, RequestCommitInsideDraw) { // We stop requesting BeginImplFrames after a BeginImplFrame where we don't // swap. - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); client.task_runner().RunPendingTasks(); // Run posted deadline. EXPECT_EQ(2, client.num_draws()); EXPECT_FALSE(scheduler->RedrawPending()); @@ -601,7 +602,7 @@ TEST(SchedulerTest, RequestCommitInsideFailedDraw) { EXPECT_EQ(0, client.num_draws()); // Fail the draw. - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); client.task_runner().RunPendingTasks(); // Run posted deadline. EXPECT_EQ(1, client.num_draws()); @@ -612,7 +613,7 @@ TEST(SchedulerTest, RequestCommitInsideFailedDraw) { EXPECT_TRUE(client.needs_begin_frame()); // Fail the draw again. - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); client.task_runner().RunPendingTasks(); // Run posted deadline. EXPECT_EQ(2, client.num_draws()); @@ -622,7 +623,7 @@ TEST(SchedulerTest, RequestCommitInsideFailedDraw) { // Draw successfully. client.SetDrawWillHappen(true); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); client.task_runner().RunPendingTasks(); // Run posted deadline. EXPECT_EQ(3, client.num_draws()); EXPECT_TRUE(scheduler->CommitPending()); @@ -647,7 +648,7 @@ TEST(SchedulerTest, NoSwapWhenDrawFails) { // Draw successfully, this starts a new frame. client.SetNeedsCommitOnNextDraw(); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); client.task_runner().RunPendingTasks(); // Run posted deadline. EXPECT_EQ(1, client.num_draws()); @@ -658,7 +659,7 @@ TEST(SchedulerTest, NoSwapWhenDrawFails) { // Fail to draw, this should not start a frame. client.SetDrawWillHappen(false); client.SetNeedsCommitOnNextDraw(); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); client.task_runner().RunPendingTasks(); // Run posted deadline. EXPECT_EQ(2, client.num_draws()); } @@ -744,7 +745,7 @@ TEST(SchedulerTest, ManageTiles) { // We have no immediate actions to perform, so the BeginImplFrame should post // the deadline task. client.Reset(); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); @@ -772,7 +773,7 @@ TEST(SchedulerTest, ManageTiles) { // We have no immediate actions to perform, so the BeginImplFrame should post // the deadline task. client.Reset(); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); @@ -793,7 +794,7 @@ TEST(SchedulerTest, ManageTiles) { // We need a BeginImplFrame where we don't swap to go idle. client.Reset(); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); client.Reset(); @@ -814,7 +815,7 @@ TEST(SchedulerTest, ManageTiles) { // BeginImplFrame. There will be no draw, only ManageTiles. client.Reset(); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); client.Reset(); @@ -840,7 +841,7 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) { scheduler->SetNeedsManageTiles(); scheduler->SetNeedsRedraw(); client.Reset(); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); @@ -862,7 +863,7 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) { scheduler->SetNeedsManageTiles(); scheduler->SetNeedsRedraw(); client.Reset(); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); @@ -885,7 +886,7 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) { scheduler->SetNeedsManageTiles(); scheduler->SetNeedsRedraw(); client.Reset(); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); @@ -908,7 +909,7 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) { scheduler->SetNeedsManageTiles(); scheduler->SetNeedsRedraw(); client.Reset(); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); @@ -927,7 +928,7 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) { scheduler->SetNeedsManageTiles(); scheduler->SetNeedsRedraw(); client.Reset(); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); @@ -956,7 +957,7 @@ TEST(SchedulerTest, TriggerBeginFrameDeadlineEarly) { client.Reset(); scheduler->SetNeedsRedraw(); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); // The deadline should be zero since there is no work other than drawing // pending. @@ -1012,7 +1013,7 @@ void MainFrameInHighLatencyMode(int64 begin_main_frame_to_commit_estimate_in_ms, client.Reset(); scheduler->SetNeedsCommit(); EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode()); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode()); client.task_runner().RunPendingTasks(); // Run posted deadline. EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); @@ -1024,7 +1025,7 @@ void MainFrameInHighLatencyMode(int64 begin_main_frame_to_commit_estimate_in_ms, client.Reset(); scheduler->SetNeedsCommit(); EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); - scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); + scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); client.task_runner().RunPendingTasks(); // Run posted deadline. EXPECT_EQ(scheduler->MainThreadIsInHighLatencyMode(), @@ -1081,7 +1082,7 @@ TEST(SchedulerTest, PollForCommitCompletion) { scheduler->NotifyReadyToCommit(); scheduler->SetNeedsRedraw(); - BeginFrameArgs frame_args = BeginFrameArgs::CreateForTesting(); + BeginFrameArgs frame_args = CreateBeginFrameArgsForTesting(); frame_args.interval = base::TimeDelta::FromMilliseconds(1000); scheduler->BeginFrame(frame_args); @@ -1154,7 +1155,7 @@ TEST(SchedulerTest, BeginRetroFrame) { // Create a BeginFrame with a long deadline to avoid race conditions. // This is the first BeginFrame, which will be handled immediately. - BeginFrameArgs args = BeginFrameArgs::CreateForTesting(); + BeginFrameArgs args = CreateBeginFrameArgsForTesting(); args.deadline += base::TimeDelta::FromHours(1); scheduler->BeginFrame(args); EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); @@ -1233,7 +1234,7 @@ TEST(SchedulerTest, BeginRetroFrame_SwapThrottled) { // Create a BeginFrame with a long deadline to avoid race conditions. // This is the first BeginFrame, which will be handled immediately. - BeginFrameArgs args = BeginFrameArgs::CreateForTesting(); + BeginFrameArgs args = CreateBeginFrameArgsForTesting(); args.deadline += base::TimeDelta::FromHours(1); scheduler->BeginFrame(args); EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); diff --git a/cc/test/begin_frame_args_test.cc b/cc/test/begin_frame_args_test.cc new file mode 100644 index 0000000..4565a94 --- /dev/null +++ b/cc/test/begin_frame_args_test.cc @@ -0,0 +1,35 @@ +// Copyright 2014 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 "cc/test/begin_frame_args_test.h" + +#include "base/time/time.h" +#include "cc/output/begin_frame_args.h" +#include "ui/gfx/frame_time.h" + +namespace cc { + +BeginFrameArgs CreateBeginFrameArgsForTesting() { + base::TimeTicks now = gfx::FrameTime::Now(); + return BeginFrameArgs::Create(now, + now + (BeginFrameArgs::DefaultInterval() / 2), + BeginFrameArgs::DefaultInterval()); +} + +BeginFrameArgs CreateBeginFrameArgsForTesting(int64 frame_time, + int64 deadline, + int64 interval) { + return BeginFrameArgs::Create(base::TimeTicks::FromInternalValue(frame_time), + base::TimeTicks::FromInternalValue(deadline), + base::TimeDelta::FromInternalValue(interval)); +} + +BeginFrameArgs CreateExpiredBeginFrameArgsForTesting() { + base::TimeTicks now = gfx::FrameTime::Now(); + return BeginFrameArgs::Create(now, + now - BeginFrameArgs::DefaultInterval(), + BeginFrameArgs::DefaultInterval()); +} + +} // namespace cc diff --git a/cc/test/begin_frame_args_test.h b/cc/test/begin_frame_args_test.h new file mode 100644 index 0000000..47a6c80 --- /dev/null +++ b/cc/test/begin_frame_args_test.h @@ -0,0 +1,24 @@ +// Copyright 2014 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. + +#ifndef CC_TEST_BEGIN_FRAME_ARGS_TEST_H_ +#define CC_TEST_BEGIN_FRAME_ARGS_TEST_H_ + +#include <iosfwd> + +#include "base/time/time.h" +#include "cc/output/begin_frame_args.h" + +namespace cc { + +// Functions for quickly creating BeginFrameArgs +BeginFrameArgs CreateBeginFrameArgsForTesting(); +BeginFrameArgs CreateBeginFrameArgsForTesting(int64 frame_time, + int64 deadline, + int64 interval); +BeginFrameArgs CreateExpiredBeginFrameArgsForTesting(); + +} // namespace cc + +#endif // CC_TEST_BEGIN_FRAME_ARGS_TEST_H_ diff --git a/cc/test/fake_output_surface.cc b/cc/test/fake_output_surface.cc index 352b6e4..3346b56 100644 --- a/cc/test/fake_output_surface.cc +++ b/cc/test/fake_output_surface.cc @@ -9,6 +9,7 @@ #include "cc/output/compositor_frame_ack.h" #include "cc/output/output_surface_client.h" #include "cc/resources/returned_resource.h" +#include "cc/test/begin_frame_args_test.h" #include "testing/gtest/include/gtest/gtest.h" namespace cc { @@ -98,7 +99,7 @@ void FakeOutputSurface::SetNeedsBeginFrame(bool enable) { } void FakeOutputSurface::OnBeginFrame() { - client_->BeginFrame(BeginFrameArgs::CreateForTesting()); + client_->BeginFrame(CreateBeginFrameArgsForTesting()); } |