Skip to content

Commit

Permalink
Make flaky VisualAt test more verbose (#174)
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <[email protected]>
  • Loading branch information
chapulina authored Nov 9, 2020
1 parent 1233f20 commit 2b903c8
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions test/integration/camera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,30 +227,44 @@ void CameraTest::VisualAt(const std::string &_renderEngine)
camera->SetHFOV(IGN_PI / 2);
root->AddChild(camera);

// render a frame
camera->Update();
// render a few frames
for (auto i = 0; i < 30; ++i)
{
camera->Update();
}

EXPECT_EQ(800u, camera->ImageWidth());
EXPECT_EQ(600u, camera->ImageHeight());

for (auto x = 0u; x < camera->ImageWidth(); x = x + 100)
{
auto vis = camera->VisualAt(math::Vector2i(x, camera->ImageHeight() / 2));

if (x <= 100)
{
EXPECT_EQ(nullptr, vis);
EXPECT_EQ(nullptr, vis);
}
else if (x > 100 && x <= 300)
{
ASSERT_NE(nullptr, vis);
EXPECT_EQ("sphere", vis->Name());
// Don't end test here on failure, this condition is flaky
EXPECT_NE(nullptr, vis) << x;
if (vis)
{
EXPECT_EQ("sphere", vis->Name());
}
}
else if (x > 300 && x <= 400)
{
EXPECT_EQ(nullptr, vis);
}
else if (x > 400 && x <= 700)
{
ASSERT_NE(nullptr, vis);
EXPECT_EQ("box", vis->Name());
// Don't end test here on failure, this condition is flaky
EXPECT_NE(nullptr, vis) << x;
if (vis)
{
EXPECT_EQ("box", vis->Name());
}
}
else
{
Expand Down

0 comments on commit 2b903c8

Please sign in to comment.