summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarfield Tan <xutan@google.com>2019-11-21 16:42:13 -0800
committerGarfield Tan <xutan@google.com>2020-05-28 14:03:21 -0700
commite9c615175652b213d79711543a6e169f75c48541 (patch)
treeaf9f7608c962fe8afa638078873565b17d65acfb
parentc15eb91b043426d054983ca31205f9db86f5436f (diff)
Stop loading animation for addtional cursor type.
In the test below it only expects MockSprite#setIcon() being called once, but with animation it may be called multiple times. Bug: 144947344 Test: atest PoitnerControllerTest#updatePointerIcon Change-Id: I5c4908fb8301cae144fd637c831f2012a35862e3 Merged-In: I5c4908fb8301cae144fd637c831f2012a35862e3
-rw-r--r--libs/input/tests/PointerController_test.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/libs/input/tests/PointerController_test.cpp b/libs/input/tests/PointerController_test.cpp
index 92efb4ea86ff..b36406d6a703 100644
--- a/libs/input/tests/PointerController_test.cpp
+++ b/libs/input/tests/PointerController_test.cpp
@@ -32,8 +32,8 @@ enum TestCursorType {
CURSOR_TYPE_HOVER,
CURSOR_TYPE_TOUCH,
CURSOR_TYPE_ANCHOR,
- CURSOR_TYPE_ADDITIONAL_1,
- CURSOR_TYPE_ADDITIONAL_2,
+ CURSOR_TYPE_ADDITIONAL,
+ CURSOR_TYPE_ADDITIONAL_ANIM,
CURSOR_TYPE_CUSTOM = -1,
};
@@ -79,13 +79,18 @@ void MockPointerControllerPolicyInterface::loadAdditionalMouseResources(
SpriteIcon icon;
PointerAnimation anim;
- for (int32_t cursorType : {CURSOR_TYPE_ADDITIONAL_1, CURSOR_TYPE_ADDITIONAL_2}) {
- loadPointerIconForType(&icon, cursorType);
- anim.animationFrames.push_back(icon);
- anim.durationPerFrame = 10;
- (*outResources)[cursorType] = icon;
- (*outAnimationResources)[cursorType] = anim;
- }
+ // CURSOR_TYPE_ADDITIONAL doesn't have animation resource.
+ int32_t cursorType = CURSOR_TYPE_ADDITIONAL;
+ loadPointerIconForType(&icon, cursorType);
+ (*outResources)[cursorType] = icon;
+
+ // CURSOR_TYPE_ADDITIONAL_ANIM has animation resource.
+ cursorType = CURSOR_TYPE_ADDITIONAL_ANIM;
+ loadPointerIconForType(&icon, cursorType);
+ anim.animationFrames.push_back(icon);
+ anim.durationPerFrame = 10;
+ (*outResources)[cursorType] = icon;
+ (*outAnimationResources)[cursorType] = anim;
}
int32_t MockPointerControllerPolicyInterface::getDefaultPointerIconId() {
@@ -178,7 +183,7 @@ TEST_F(PointerControllerTest, useDefaultCursorTypeByDefault) {
TEST_F(PointerControllerTest, updatePointerIcon) {
mPointerController->unfade(PointerController::TRANSITION_IMMEDIATE);
- int32_t type = CURSOR_TYPE_ADDITIONAL_1;
+ int32_t type = CURSOR_TYPE_ADDITIONAL;
std::pair<float, float> hotspot = getHotSpotCoordinatesForType(type);
EXPECT_CALL(*mPointerSprite, setVisible(true));
EXPECT_CALL(*mPointerSprite, setAlpha(1.0f));