Loading libs/hwui/unit_tests/FatVectorTests.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -99,9 +99,9 @@ TEST(FatVector, destructorInternal) { FatVector<TestUtils::SignalingDtor, 0> v; v.emplace_back(&count); EXPECT_FALSE(allocationIsInternal(v)); EXPECT_EQ(0, count); EXPECT_EQ(0, count) << "Destruction shouldn't have happened yet"; } EXPECT_EQ(1, count); EXPECT_EQ(1, count) << "Destruction should happen exactly once"; } TEST(FatVector, destructorExternal) { Loading @@ -113,7 +113,7 @@ TEST(FatVector, destructorExternal) { v.emplace_back(&count); EXPECT_TRUE(allocationIsInternal(v)); } EXPECT_EQ(0, count); EXPECT_EQ(0, count) << "Destruction shouldn't have happened yet"; } EXPECT_EQ(10, count); EXPECT_EQ(10, count) << "Destruction should happen exactly once"; } libs/hwui/unit_tests/OpReordererTests.cpp +17 −8 Original line number Diff line number Diff line Loading @@ -44,15 +44,24 @@ LayerUpdateQueue sEmptyLayerUpdateQueue; class TestRendererBase { public: virtual ~TestRendererBase() {} virtual OffscreenBuffer* createLayer(uint32_t, uint32_t) { ADD_FAILURE(); return nullptr; } virtual void startLayer(OffscreenBuffer*) { ADD_FAILURE(); } virtual void endLayer() { ADD_FAILURE(); } virtual OffscreenBuffer* createLayer(uint32_t, uint32_t) { ADD_FAILURE() << "Layer creation not expected in this test"; return nullptr; } virtual void startLayer(OffscreenBuffer*) { ADD_FAILURE() << "Layer repaint not expected in this test"; } virtual void endLayer() { ADD_FAILURE() << "Layer updates not expected in this test"; } virtual void startFrame(uint32_t width, uint32_t height) {} virtual void endFrame() {} // define virtual defaults for direct #define BASE_OP_METHOD(Type) \ virtual void on##Type(const Type&, const BakedOpState&) { ADD_FAILURE(); } virtual void on##Type(const Type&, const BakedOpState&) { \ ADD_FAILURE() << #Type " not expected in this test"; \ } MAP_OPS(BASE_OP_METHOD) int getIndex() { return mIndex; } Loading Loading @@ -370,11 +379,11 @@ public: void onRectOp(const RectOp& op, const BakedOpState& state) override { EXPECT_EQ(1, mIndex++); // verify transform is reset EXPECT_TRUE(state.computedState.transform.isIdentity()); EXPECT_TRUE(state.computedState.transform.isIdentity()) << "Transform should be reset within layer"; // verify damage rect is used as clip EXPECT_EQ(state.computedState.clipRect, Rect(25, 25, 75, 75)); EXPECT_EQ(state.computedState.clipRect, Rect(25, 25, 75, 75)) << "Damage rect should be used to clip layer content"; } void endLayer() override { EXPECT_EQ(2, mIndex++); Loading libs/hwui/unit_tests/RecordingCanvasTests.cpp +10 −13 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ TEST(RecordingCanvas, testSimpleRectRecord) { ASSERT_EQ(Rect(0, 0, 100, 200), op.localClipRect); ASSERT_EQ(Rect(10, 20, 90, 180), op.unmappedBounds); }); ASSERT_EQ(1, count); // only one observed ASSERT_EQ(1, count); } TEST(RecordingCanvas, backgroundAndImage) { Loading Loading @@ -106,7 +106,7 @@ TEST(RecordingCanvas, backgroundAndImage) { } count++; }); ASSERT_EQ(2, count); // two draws observed ASSERT_EQ(2, count); } TEST(RecordingCanvas, saveLayerSimple) { Loading @@ -121,7 +121,9 @@ TEST(RecordingCanvas, saveLayerSimple) { switch(count++) { case 0: EXPECT_EQ(RecordedOpId::BeginLayerOp, op.opId); // TODO: add asserts EXPECT_EQ(Rect(10, 20, 190, 180), op.unmappedBounds); EXPECT_EQ(Rect(0, 0, 200, 200), op.localClipRect); EXPECT_TRUE(op.localMatrix.isIdentity()); break; case 1: EXPECT_EQ(RecordedOpId::RectOp, op.opId); Loading @@ -132,7 +134,7 @@ TEST(RecordingCanvas, saveLayerSimple) { break; case 2: EXPECT_EQ(RecordedOpId::EndLayerOp, op.opId); // TODO: add asserts // Don't bother asserting recording state data - it's not used break; default: ADD_FAILURE(); Loading @@ -155,10 +157,8 @@ TEST(RecordingCanvas, saveLayerViewportCrop) { if (count++ == 1) { Matrix4 expectedMatrix; EXPECT_EQ(RecordedOpId::RectOp, op.opId); // recorded clip rect should be intersection of // viewport and saveLayer bounds, in layer space EXPECT_EQ(Rect(0, 0, 100, 100), op.localClipRect); EXPECT_EQ(Rect(0, 0, 100, 100), op.localClipRect) << "Recorded clip rect should be" " intersection of viewport and saveLayer bounds, in layer space"; EXPECT_EQ(Rect(0, 0, 400, 400), op.unmappedBounds); expectedMatrix.loadTranslate(-100, -100, 0); EXPECT_MATRIX_APPROX_EQ(expectedMatrix, op.localMatrix); Loading @@ -183,14 +183,11 @@ TEST(RecordingCanvas, saveLayerRotateUnclipped) { int count = 0; playbackOps(*dl, [&count](const RecordedOp& op) { if (count++ == 1) { Matrix4 expectedMatrix; EXPECT_EQ(RecordedOpId::RectOp, op.opId); // recorded rect doesn't see rotate, since recorded relative to saveLayer bounds EXPECT_EQ(Rect(0, 0, 100, 100), op.localClipRect); EXPECT_EQ(Rect(0, 0, 100, 100), op.unmappedBounds); expectedMatrix.loadIdentity(); EXPECT_MATRIX_APPROX_EQ(expectedMatrix, op.localMatrix); EXPECT_MATRIX_APPROX_EQ(Matrix4::identity(), op.localMatrix) << "Recorded op shouldn't see any canvas transform before the saveLayer"; } }); EXPECT_EQ(3, count); Loading Loading
libs/hwui/unit_tests/FatVectorTests.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -99,9 +99,9 @@ TEST(FatVector, destructorInternal) { FatVector<TestUtils::SignalingDtor, 0> v; v.emplace_back(&count); EXPECT_FALSE(allocationIsInternal(v)); EXPECT_EQ(0, count); EXPECT_EQ(0, count) << "Destruction shouldn't have happened yet"; } EXPECT_EQ(1, count); EXPECT_EQ(1, count) << "Destruction should happen exactly once"; } TEST(FatVector, destructorExternal) { Loading @@ -113,7 +113,7 @@ TEST(FatVector, destructorExternal) { v.emplace_back(&count); EXPECT_TRUE(allocationIsInternal(v)); } EXPECT_EQ(0, count); EXPECT_EQ(0, count) << "Destruction shouldn't have happened yet"; } EXPECT_EQ(10, count); EXPECT_EQ(10, count) << "Destruction should happen exactly once"; }
libs/hwui/unit_tests/OpReordererTests.cpp +17 −8 Original line number Diff line number Diff line Loading @@ -44,15 +44,24 @@ LayerUpdateQueue sEmptyLayerUpdateQueue; class TestRendererBase { public: virtual ~TestRendererBase() {} virtual OffscreenBuffer* createLayer(uint32_t, uint32_t) { ADD_FAILURE(); return nullptr; } virtual void startLayer(OffscreenBuffer*) { ADD_FAILURE(); } virtual void endLayer() { ADD_FAILURE(); } virtual OffscreenBuffer* createLayer(uint32_t, uint32_t) { ADD_FAILURE() << "Layer creation not expected in this test"; return nullptr; } virtual void startLayer(OffscreenBuffer*) { ADD_FAILURE() << "Layer repaint not expected in this test"; } virtual void endLayer() { ADD_FAILURE() << "Layer updates not expected in this test"; } virtual void startFrame(uint32_t width, uint32_t height) {} virtual void endFrame() {} // define virtual defaults for direct #define BASE_OP_METHOD(Type) \ virtual void on##Type(const Type&, const BakedOpState&) { ADD_FAILURE(); } virtual void on##Type(const Type&, const BakedOpState&) { \ ADD_FAILURE() << #Type " not expected in this test"; \ } MAP_OPS(BASE_OP_METHOD) int getIndex() { return mIndex; } Loading Loading @@ -370,11 +379,11 @@ public: void onRectOp(const RectOp& op, const BakedOpState& state) override { EXPECT_EQ(1, mIndex++); // verify transform is reset EXPECT_TRUE(state.computedState.transform.isIdentity()); EXPECT_TRUE(state.computedState.transform.isIdentity()) << "Transform should be reset within layer"; // verify damage rect is used as clip EXPECT_EQ(state.computedState.clipRect, Rect(25, 25, 75, 75)); EXPECT_EQ(state.computedState.clipRect, Rect(25, 25, 75, 75)) << "Damage rect should be used to clip layer content"; } void endLayer() override { EXPECT_EQ(2, mIndex++); Loading
libs/hwui/unit_tests/RecordingCanvasTests.cpp +10 −13 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ TEST(RecordingCanvas, testSimpleRectRecord) { ASSERT_EQ(Rect(0, 0, 100, 200), op.localClipRect); ASSERT_EQ(Rect(10, 20, 90, 180), op.unmappedBounds); }); ASSERT_EQ(1, count); // only one observed ASSERT_EQ(1, count); } TEST(RecordingCanvas, backgroundAndImage) { Loading Loading @@ -106,7 +106,7 @@ TEST(RecordingCanvas, backgroundAndImage) { } count++; }); ASSERT_EQ(2, count); // two draws observed ASSERT_EQ(2, count); } TEST(RecordingCanvas, saveLayerSimple) { Loading @@ -121,7 +121,9 @@ TEST(RecordingCanvas, saveLayerSimple) { switch(count++) { case 0: EXPECT_EQ(RecordedOpId::BeginLayerOp, op.opId); // TODO: add asserts EXPECT_EQ(Rect(10, 20, 190, 180), op.unmappedBounds); EXPECT_EQ(Rect(0, 0, 200, 200), op.localClipRect); EXPECT_TRUE(op.localMatrix.isIdentity()); break; case 1: EXPECT_EQ(RecordedOpId::RectOp, op.opId); Loading @@ -132,7 +134,7 @@ TEST(RecordingCanvas, saveLayerSimple) { break; case 2: EXPECT_EQ(RecordedOpId::EndLayerOp, op.opId); // TODO: add asserts // Don't bother asserting recording state data - it's not used break; default: ADD_FAILURE(); Loading @@ -155,10 +157,8 @@ TEST(RecordingCanvas, saveLayerViewportCrop) { if (count++ == 1) { Matrix4 expectedMatrix; EXPECT_EQ(RecordedOpId::RectOp, op.opId); // recorded clip rect should be intersection of // viewport and saveLayer bounds, in layer space EXPECT_EQ(Rect(0, 0, 100, 100), op.localClipRect); EXPECT_EQ(Rect(0, 0, 100, 100), op.localClipRect) << "Recorded clip rect should be" " intersection of viewport and saveLayer bounds, in layer space"; EXPECT_EQ(Rect(0, 0, 400, 400), op.unmappedBounds); expectedMatrix.loadTranslate(-100, -100, 0); EXPECT_MATRIX_APPROX_EQ(expectedMatrix, op.localMatrix); Loading @@ -183,14 +183,11 @@ TEST(RecordingCanvas, saveLayerRotateUnclipped) { int count = 0; playbackOps(*dl, [&count](const RecordedOp& op) { if (count++ == 1) { Matrix4 expectedMatrix; EXPECT_EQ(RecordedOpId::RectOp, op.opId); // recorded rect doesn't see rotate, since recorded relative to saveLayer bounds EXPECT_EQ(Rect(0, 0, 100, 100), op.localClipRect); EXPECT_EQ(Rect(0, 0, 100, 100), op.unmappedBounds); expectedMatrix.loadIdentity(); EXPECT_MATRIX_APPROX_EQ(expectedMatrix, op.localMatrix); EXPECT_MATRIX_APPROX_EQ(Matrix4::identity(), op.localMatrix) << "Recorded op shouldn't see any canvas transform before the saveLayer"; } }); EXPECT_EQ(3, count); Loading