Loading libs/hwui/tests/common/TestUtils.h +11 −0 Original line number Diff line number Diff line Loading @@ -249,6 +249,17 @@ public: static std::unique_ptr<uint16_t[]> asciiToUtf16(const char* str); class MockFunctor : public Functor { public: virtual status_t operator ()(int what, void* data) { mLastMode = what; return DrawGlInfo::kStatusDone; } int getLastMode() const { return mLastMode; } private: int mLastMode = -1; }; private: static void syncHierarchyPropertiesAndDisplayListImpl(RenderNode* node) { node->syncProperties(); Loading libs/hwui/tests/unit/CanvasContextTests.cpp +2 −18 Original line number Diff line number Diff line Loading @@ -43,24 +43,8 @@ RENDERTHREAD_TEST(CanvasContext, create) { canvasContext->destroy(nullptr); } // This must be in an anonymous namespace as this class name is used in multiple // cpp files for different purposes and without the namespace the linker can // arbitrarily choose which class to link against. namespace { class TestFunctor : public Functor { public: bool didProcess = false; virtual status_t operator ()(int what, void* data) { if (what == DrawGlInfo::kModeProcess) { didProcess = true; } return DrawGlInfo::kStatusDone; } }; }; // end anonymous namespace RENDERTHREAD_TEST(CanvasContext, invokeFunctor) { TestFunctor functor; ASSERT_FALSE(functor.didProcess); TestUtils::MockFunctor functor; CanvasContext::invokeFunctor(renderThread, &functor); ASSERT_TRUE(functor.didProcess); ASSERT_EQ(functor.getLastMode(), DrawGlInfo::kModeProcess); } libs/hwui/tests/unit/SkiaDisplayListTests.cpp +2 −17 Original line number Diff line number Diff line Loading @@ -91,27 +91,12 @@ TEST(SkiaDisplayList, reuseDisplayList) { ASSERT_EQ(availableList.get(), nullptr); } // This must be in an anonymous namespace as this class name is used in multiple // cpp files for different purposes and without the namespace the linker can // arbitrarily choose which class to link against. namespace { class TestFunctor : public Functor { public: bool didSync = false; virtual status_t operator ()(int what, void* data) { if (what == DrawGlInfo::kModeSync) { didSync = true; } return DrawGlInfo::kStatusDone; } }; }; // end anonymous namespace TEST(SkiaDisplayList, syncContexts) { SkRect bounds = SkRect::MakeWH(200, 200); SkiaDisplayList skiaDL(bounds); SkCanvas dummyCanvas; TestFunctor functor; TestUtils::MockFunctor functor; skiaDL.mChildFunctors.emplace_back(&functor, nullptr, &dummyCanvas); VectorDrawableRoot vectorDrawable(new VectorDrawable::Group()); Loading @@ -121,7 +106,7 @@ TEST(SkiaDisplayList, syncContexts) { // ensure that the functor and vectorDrawable are properly synced skiaDL.syncContents(); ASSERT_TRUE(functor.didSync); ASSERT_EQ(functor.getLastMode(), DrawGlInfo::kModeSync); ASSERT_EQ(vectorDrawable.mutateProperties()->getBounds(), bounds); } Loading Loading
libs/hwui/tests/common/TestUtils.h +11 −0 Original line number Diff line number Diff line Loading @@ -249,6 +249,17 @@ public: static std::unique_ptr<uint16_t[]> asciiToUtf16(const char* str); class MockFunctor : public Functor { public: virtual status_t operator ()(int what, void* data) { mLastMode = what; return DrawGlInfo::kStatusDone; } int getLastMode() const { return mLastMode; } private: int mLastMode = -1; }; private: static void syncHierarchyPropertiesAndDisplayListImpl(RenderNode* node) { node->syncProperties(); Loading
libs/hwui/tests/unit/CanvasContextTests.cpp +2 −18 Original line number Diff line number Diff line Loading @@ -43,24 +43,8 @@ RENDERTHREAD_TEST(CanvasContext, create) { canvasContext->destroy(nullptr); } // This must be in an anonymous namespace as this class name is used in multiple // cpp files for different purposes and without the namespace the linker can // arbitrarily choose which class to link against. namespace { class TestFunctor : public Functor { public: bool didProcess = false; virtual status_t operator ()(int what, void* data) { if (what == DrawGlInfo::kModeProcess) { didProcess = true; } return DrawGlInfo::kStatusDone; } }; }; // end anonymous namespace RENDERTHREAD_TEST(CanvasContext, invokeFunctor) { TestFunctor functor; ASSERT_FALSE(functor.didProcess); TestUtils::MockFunctor functor; CanvasContext::invokeFunctor(renderThread, &functor); ASSERT_TRUE(functor.didProcess); ASSERT_EQ(functor.getLastMode(), DrawGlInfo::kModeProcess); }
libs/hwui/tests/unit/SkiaDisplayListTests.cpp +2 −17 Original line number Diff line number Diff line Loading @@ -91,27 +91,12 @@ TEST(SkiaDisplayList, reuseDisplayList) { ASSERT_EQ(availableList.get(), nullptr); } // This must be in an anonymous namespace as this class name is used in multiple // cpp files for different purposes and without the namespace the linker can // arbitrarily choose which class to link against. namespace { class TestFunctor : public Functor { public: bool didSync = false; virtual status_t operator ()(int what, void* data) { if (what == DrawGlInfo::kModeSync) { didSync = true; } return DrawGlInfo::kStatusDone; } }; }; // end anonymous namespace TEST(SkiaDisplayList, syncContexts) { SkRect bounds = SkRect::MakeWH(200, 200); SkiaDisplayList skiaDL(bounds); SkCanvas dummyCanvas; TestFunctor functor; TestUtils::MockFunctor functor; skiaDL.mChildFunctors.emplace_back(&functor, nullptr, &dummyCanvas); VectorDrawableRoot vectorDrawable(new VectorDrawable::Group()); Loading @@ -121,7 +106,7 @@ TEST(SkiaDisplayList, syncContexts) { // ensure that the functor and vectorDrawable are properly synced skiaDL.syncContents(); ASSERT_TRUE(functor.didSync); ASSERT_EQ(functor.getLastMode(), DrawGlInfo::kModeSync); ASSERT_EQ(vectorDrawable.mutateProperties()->getBounds(), bounds); } Loading