2015-10-15 22:51:46 +00:00
|
|
|
#include "BaseTestCase.h"
|
|
|
|
|
|
|
|
#include "CanvasPixel.h"
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
TEST(CanvasPixel, MaxFragments) {
|
2015-10-15 22:51:46 +00:00
|
|
|
CanvasPixel pixel;
|
|
|
|
|
|
|
|
// One opaque fragment
|
|
|
|
pixel.pushFragment(CanvasFragment(true, Vector3(0.0, 0.0, 0.0), Vector3(), 0, true));
|
|
|
|
|
|
|
|
// Overflow max fragment count with transparent fragments
|
2015-11-09 21:30:46 +00:00
|
|
|
for (int i = 0; i < MAX_FRAGMENTS_PER_PIXEL * 2; i++) {
|
2015-12-17 00:13:20 +00:00
|
|
|
pixel.pushFragment(CanvasFragment(true, Vector3(0.0, 0.0, to_double(i)), Vector3(), 0, false));
|
2015-10-15 22:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT_EQ(MAX_FRAGMENTS_PER_PIXEL, pixel.getFragmentCount());
|
|
|
|
EXPECT_DOUBLE_EQ(pixel.getFragment(0).getZ(), 0.0);
|
|
|
|
EXPECT_EQ(pixel.getFragment(0).getOpaque(), true);
|
2015-12-17 00:13:20 +00:00
|
|
|
EXPECT_DOUBLE_EQ(pixel.getFragment(MAX_FRAGMENTS_PER_PIXEL - 1).getZ(), to_double(MAX_FRAGMENTS_PER_PIXEL * 2 - 1));
|
2015-10-15 22:51:46 +00:00
|
|
|
EXPECT_EQ(pixel.getFragment(MAX_FRAGMENTS_PER_PIXEL - 1).getOpaque(), false);
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
TEST(CanvasPixel, SameTransparent) {
|
2015-10-15 22:51:46 +00:00
|
|
|
CanvasPixel pixel;
|
|
|
|
|
|
|
|
pixel.pushFragment(CanvasFragment(true, Vector3(0.0, 0.0, 1.4), Vector3(), 0, false));
|
|
|
|
pixel.pushFragment(CanvasFragment(true, Vector3(0.0, 0.0, 1.4), Vector3(), 0, false));
|
|
|
|
|
|
|
|
ASSERT_EQ(1, pixel.getFragmentCount());
|
|
|
|
|
|
|
|
pixel.pushFragment(CanvasFragment(true, Vector3(0.0, 0.0, 1.4), Vector3(), 1, false));
|
|
|
|
|
|
|
|
ASSERT_EQ(2, pixel.getFragmentCount());
|
|
|
|
|
|
|
|
EXPECT_EQ(pixel.getFragment(0).getClient(), 0);
|
|
|
|
EXPECT_EQ(pixel.getFragment(1).getClient(), 1);
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
TEST(CanvasPixel, SameOpaque) {
|
2015-10-15 22:51:46 +00:00
|
|
|
CanvasPixel pixel;
|
|
|
|
|
|
|
|
pixel.pushFragment(CanvasFragment(true, Vector3(0.0, 0.0, 1.4), Vector3(), 0, true));
|
|
|
|
pixel.pushFragment(CanvasFragment(true, Vector3(0.0, 0.0, 1.4), Vector3(), 0, true));
|
|
|
|
|
|
|
|
ASSERT_EQ(1, pixel.getFragmentCount());
|
|
|
|
|
|
|
|
pixel.pushFragment(CanvasFragment(true, Vector3(0.0, 0.0, 1.4), Vector3(), 1, true));
|
|
|
|
|
|
|
|
ASSERT_EQ(1, pixel.getFragmentCount());
|
|
|
|
|
|
|
|
EXPECT_EQ(pixel.getFragment(0).getClient(), 0);
|
|
|
|
}
|