Loading libs/input/tests/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -43,12 +43,15 @@ cc_test { }, shared_libs: [ "libandroid_runtime", "libbase", "libinput", "libinputservice", "libhwui", "libgui", "libutils", ], static_libs: [ "libflagtest", "libgmock", "libgtest", ], Loading libs/input/tests/PointerController_test.cpp +36 −1 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ * limitations under the License. */ #include <com_android_input_flags.h> #include <flag_macros.h> #include <gmock/gmock.h> #include <gtest/gtest.h> #include <input/PointerController.h> Loading @@ -28,6 +30,8 @@ namespace android { namespace input_flags = com::android::input::flags; enum TestCursorType { CURSOR_TYPE_DEFAULT = 0, CURSOR_TYPE_HOVER, Loading Loading @@ -261,7 +265,20 @@ TEST_F(PointerControllerTest, useStylusTypeForStylusHover) { mPointerController->reloadPointerResources(); } TEST_F(PointerControllerTest, updatePointerIcon) { TEST_F_WITH_FLAGS(PointerControllerTest, setPresentationBeforeDisplayViewportDoesNotLoadResources, REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(input_flags, enable_pointer_choreographer))) { // Setting the presentation mode before a display viewport is set will not load any resources. mPointerController->setPresentation(PointerController::Presentation::POINTER); ASSERT_TRUE(mPolicy->noResourcesAreLoaded()); // When the display is set, then the resources are loaded. ensureDisplayViewportIsSet(); ASSERT_TRUE(mPolicy->allResourcesAreLoaded()); } TEST_F_WITH_FLAGS(PointerControllerTest, updatePointerIcon, REQUIRES_FLAGS_DISABLED(ACONFIG_FLAG(input_flags, enable_pointer_choreographer))) { ensureDisplayViewportIsSet(); mPointerController->setPresentation(PointerController::Presentation::POINTER); mPointerController->unfade(PointerController::Transition::IMMEDIATE); Loading @@ -277,6 +294,24 @@ TEST_F(PointerControllerTest, updatePointerIcon) { mPointerController->updatePointerIcon(static_cast<PointerIconStyle>(type)); } TEST_F_WITH_FLAGS(PointerControllerTest, updatePointerIconWithChoreographer, REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(input_flags, enable_pointer_choreographer))) { // When PointerChoreographer is enabled, the presentation mode is set before the viewport. mPointerController->setPresentation(PointerController::Presentation::POINTER); ensureDisplayViewportIsSet(); mPointerController->unfade(PointerController::Transition::IMMEDIATE); int32_t type = CURSOR_TYPE_ADDITIONAL; std::pair<float, float> hotspot = getHotSpotCoordinatesForType(type); EXPECT_CALL(*mPointerSprite, setVisible(true)); EXPECT_CALL(*mPointerSprite, setAlpha(1.0f)); EXPECT_CALL(*mPointerSprite, setIcon(AllOf(Field(&SpriteIcon::style, static_cast<PointerIconStyle>(type)), Field(&SpriteIcon::hotSpotX, hotspot.first), Field(&SpriteIcon::hotSpotY, hotspot.second)))); mPointerController->updatePointerIcon(static_cast<PointerIconStyle>(type)); } TEST_F(PointerControllerTest, setCustomPointerIcon) { ensureDisplayViewportIsSet(); mPointerController->unfade(PointerController::Transition::IMMEDIATE); Loading Loading
libs/input/tests/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -43,12 +43,15 @@ cc_test { }, shared_libs: [ "libandroid_runtime", "libbase", "libinput", "libinputservice", "libhwui", "libgui", "libutils", ], static_libs: [ "libflagtest", "libgmock", "libgtest", ], Loading
libs/input/tests/PointerController_test.cpp +36 −1 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ * limitations under the License. */ #include <com_android_input_flags.h> #include <flag_macros.h> #include <gmock/gmock.h> #include <gtest/gtest.h> #include <input/PointerController.h> Loading @@ -28,6 +30,8 @@ namespace android { namespace input_flags = com::android::input::flags; enum TestCursorType { CURSOR_TYPE_DEFAULT = 0, CURSOR_TYPE_HOVER, Loading Loading @@ -261,7 +265,20 @@ TEST_F(PointerControllerTest, useStylusTypeForStylusHover) { mPointerController->reloadPointerResources(); } TEST_F(PointerControllerTest, updatePointerIcon) { TEST_F_WITH_FLAGS(PointerControllerTest, setPresentationBeforeDisplayViewportDoesNotLoadResources, REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(input_flags, enable_pointer_choreographer))) { // Setting the presentation mode before a display viewport is set will not load any resources. mPointerController->setPresentation(PointerController::Presentation::POINTER); ASSERT_TRUE(mPolicy->noResourcesAreLoaded()); // When the display is set, then the resources are loaded. ensureDisplayViewportIsSet(); ASSERT_TRUE(mPolicy->allResourcesAreLoaded()); } TEST_F_WITH_FLAGS(PointerControllerTest, updatePointerIcon, REQUIRES_FLAGS_DISABLED(ACONFIG_FLAG(input_flags, enable_pointer_choreographer))) { ensureDisplayViewportIsSet(); mPointerController->setPresentation(PointerController::Presentation::POINTER); mPointerController->unfade(PointerController::Transition::IMMEDIATE); Loading @@ -277,6 +294,24 @@ TEST_F(PointerControllerTest, updatePointerIcon) { mPointerController->updatePointerIcon(static_cast<PointerIconStyle>(type)); } TEST_F_WITH_FLAGS(PointerControllerTest, updatePointerIconWithChoreographer, REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(input_flags, enable_pointer_choreographer))) { // When PointerChoreographer is enabled, the presentation mode is set before the viewport. mPointerController->setPresentation(PointerController::Presentation::POINTER); ensureDisplayViewportIsSet(); mPointerController->unfade(PointerController::Transition::IMMEDIATE); int32_t type = CURSOR_TYPE_ADDITIONAL; std::pair<float, float> hotspot = getHotSpotCoordinatesForType(type); EXPECT_CALL(*mPointerSprite, setVisible(true)); EXPECT_CALL(*mPointerSprite, setAlpha(1.0f)); EXPECT_CALL(*mPointerSprite, setIcon(AllOf(Field(&SpriteIcon::style, static_cast<PointerIconStyle>(type)), Field(&SpriteIcon::hotSpotX, hotspot.first), Field(&SpriteIcon::hotSpotY, hotspot.second)))); mPointerController->updatePointerIcon(static_cast<PointerIconStyle>(type)); } TEST_F(PointerControllerTest, setCustomPointerIcon) { ensureDisplayViewportIsSet(); mPointerController->unfade(PointerController::Transition::IMMEDIATE); Loading