diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-22 17:52:33 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-22 17:52:33 +0000 |
commit | b2640f064bd51b655344d49f55a071f5cca3aaea (patch) | |
tree | 22781bb5111970feae4890c4e06bc5564e63bafa /cc | |
parent | 8c2476c2c85d1891cbdc1c306cc2a630e10cb516 (diff) | |
download | chromium_src-b2640f064bd51b655344d49f55a071f5cca3aaea.zip chromium_src-b2640f064bd51b655344d49f55a071f5cca3aaea.tar.gz chromium_src-b2640f064bd51b655344d49f55a071f5cca3aaea.tar.bz2 |
cc: Add more verbose output when Scheduler unit tests fail.
This will help track down failures on the android bots, especially
for the SchedulerTest.RequestCommit test.
BUG=
R=enne@chromium.org
Review URL: https://codereview.chromium.org/15747008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201569 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/scheduler/scheduler_unittest.cc | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/cc/scheduler/scheduler_unittest.cc b/cc/scheduler/scheduler_unittest.cc index 3a8e8e3..c6cba47 100644 --- a/cc/scheduler/scheduler_unittest.cc +++ b/cc/scheduler/scheduler_unittest.cc @@ -11,6 +11,18 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#define EXPECT_ACTION(action, client, action_index, expected_num_actions) \ + EXPECT_EQ(expected_num_actions, client.num_actions_()); \ + ASSERT_LT(action_index, client.num_actions_()); \ + do { \ + EXPECT_STREQ(action, client.Action(action_index)); \ + for (int i = expected_num_actions; i < client.num_actions_(); ++i) \ + ADD_FAILURE() << "Unexpected action: " << client.Action(i); \ + } while (false) + +#define EXPECT_SINGLE_ACTION(action, client) \ + EXPECT_ACTION(action, client, 0, 1) + namespace cc { namespace { @@ -96,29 +108,25 @@ TEST(SchedulerTest, RequestCommit) { scheduler->SetVisible(true); scheduler->SetCanDraw(true); - EXPECT_EQ(1, client.num_actions_()); - EXPECT_STREQ("ScheduledActionBeginOutputSurfaceCreation", client.Action(0)); + EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); client.Reset(); scheduler->DidCreateAndInitializeOutputSurface(); // SetNeedsCommit should begin the frame. scheduler->SetNeedsCommit(); - EXPECT_EQ(1, client.num_actions_()); - EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(0)); + EXPECT_SINGLE_ACTION("ScheduledActionBeginFrame", client); EXPECT_FALSE(time_source->Active()); client.Reset(); // BeginFrameComplete should commit scheduler->BeginFrameComplete(); - EXPECT_EQ(1, client.num_actions_()); - EXPECT_STREQ("ScheduledActionCommit", client.Action(0)); + EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); EXPECT_TRUE(time_source->Active()); client.Reset(); // Tick should draw. time_source->Tick(); - EXPECT_EQ(1, client.num_actions_()); - EXPECT_STREQ("ScheduledActionDrawAndSwapIfPossible", client.Action(0)); + EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client); EXPECT_FALSE(time_source->Active()); client.Reset(); @@ -138,15 +146,13 @@ TEST(SchedulerTest, RequestCommitAfterBeginFrame) { scheduler->SetVisible(true); scheduler->SetCanDraw(true); - EXPECT_EQ(1, client.num_actions_()); - EXPECT_STREQ("ScheduledActionBeginOutputSurfaceCreation", client.Action(0)); + EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); client.Reset(); scheduler->DidCreateAndInitializeOutputSurface(); // SetNedsCommit should begin the frame. scheduler->SetNeedsCommit(); - EXPECT_EQ(1, client.num_actions_()); - EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(0)); + EXPECT_SINGLE_ACTION("ScheduledActionBeginFrame", client); client.Reset(); // Now SetNeedsCommit again. Calling here means we need a second frame. @@ -155,16 +161,14 @@ TEST(SchedulerTest, RequestCommitAfterBeginFrame) { // Since, another commit is needed, BeginFrameComplete should commit, // then begin another frame. scheduler->BeginFrameComplete(); - EXPECT_EQ(1, client.num_actions_()); - EXPECT_STREQ("ScheduledActionCommit", client.Action(0)); + EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); client.Reset(); // Tick should draw but then begin another frame. time_source->Tick(); EXPECT_FALSE(time_source->Active()); - EXPECT_EQ(2, client.num_actions_()); - EXPECT_STREQ("ScheduledActionDrawAndSwapIfPossible", client.Action(0)); - EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(1)); + EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); + EXPECT_ACTION("ScheduledActionBeginFrame", client, 1, 2); client.Reset(); } @@ -180,17 +184,17 @@ TEST(SchedulerTest, TextureAcquisitionCollision) { scheduler->SetVisible(true); scheduler->SetCanDraw(true); - EXPECT_EQ(1, client.num_actions_()); - EXPECT_STREQ("ScheduledActionBeginOutputSurfaceCreation", client.Action(0)); + EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); client.Reset(); scheduler->DidCreateAndInitializeOutputSurface(); scheduler->SetNeedsCommit(); scheduler->SetMainThreadNeedsLayerTextures(); - EXPECT_EQ(2, client.num_actions_()); - EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(0)); - EXPECT_STREQ("ScheduledActionAcquireLayerTexturesForMainThread", - client.Action(1)); + EXPECT_ACTION("ScheduledActionBeginFrame", client, 0, 2); + EXPECT_ACTION("ScheduledActionAcquireLayerTexturesForMainThread", + client, + 1, + 2); client.Reset(); // Compositor not scheduled to draw because textures are locked by main thread @@ -209,11 +213,12 @@ TEST(SchedulerTest, TextureAcquisitionCollision) { // Once compositor draw complete, the delayed texture acquisition fires. time_source->Tick(); - EXPECT_EQ(3, client.num_actions_()); - EXPECT_STREQ("ScheduledActionDrawAndSwapIfPossible", client.Action(0)); - EXPECT_STREQ("ScheduledActionAcquireLayerTexturesForMainThread", - client.Action(1)); - EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(2)); + EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 3); + EXPECT_ACTION("ScheduledActionAcquireLayerTexturesForMainThread", + client, + 1, + 3); + EXPECT_ACTION("ScheduledActionBeginFrame", client, 2, 3); client.Reset(); } @@ -229,8 +234,7 @@ TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) { scheduler->SetVisible(true); scheduler->SetCanDraw(true); - EXPECT_EQ(1, client.num_actions_()); - EXPECT_STREQ("ScheduledActionBeginOutputSurfaceCreation", client.Action(0)); + EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); client.Reset(); scheduler->DidCreateAndInitializeOutputSurface(); @@ -241,7 +245,6 @@ TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) { // Verify that pending texture acquisition fires when visibility // is lost in order to avoid a deadlock. scheduler->SetVisible(false); - EXPECT_EQ(1, client.num_actions_()); EXPECT_STREQ("ScheduledActionAcquireLayerTexturesForMainThread", client.Action(0)); client.Reset(); @@ -250,8 +253,7 @@ TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) { // compositor is waiting for first draw should result in a request // for a new frame in order to escape a deadlock. scheduler->SetVisible(true); - EXPECT_EQ(1, client.num_actions_()); - EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(0)); + EXPECT_SINGLE_ACTION("ScheduledActionBeginFrame", client); client.Reset(); } |