diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /gfx/layers/apz/test/gtest/TestGestureDetector.cpp | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/layers/apz/test/gtest/TestGestureDetector.cpp')
-rw-r--r-- | gfx/layers/apz/test/gtest/TestGestureDetector.cpp | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/gfx/layers/apz/test/gtest/TestGestureDetector.cpp b/gfx/layers/apz/test/gtest/TestGestureDetector.cpp index 8256667d6b..f5024e8208 100644 --- a/gfx/layers/apz/test/gtest/TestGestureDetector.cpp +++ b/gfx/layers/apz/test/gtest/TestGestureDetector.cpp @@ -10,6 +10,7 @@ #include "APZCBasicTester.h" #include "APZTestCommon.h" #include "InputUtils.h" +#include "apz/src/InputBlockState.h" #include "mozilla/StaticPrefs_apz.h" // Note: There are additional tests that test gesture detection behaviour @@ -553,6 +554,83 @@ class APZCLongPressTester : public APZCGestureDetectorTester { apzc->AssertStateIsReset(); } + + // Tests a scenario that after a long-press event happened the original touch + // block initiated by a touch-start event and the touch block initiated by a + // long-tap event have been discarded when a new touch-start event happens. + void DoLongPressDiscardTouchBlockTest(bool aWithTouchMove) { + // Set apz.content_response_timeout > ui.click_hold_context_menus.delay and + // apz.touch_start_tolerance explicitly to match Android preferences. + SCOPED_GFX_PREF_INT("apz.content_response_timeout", 60); + SCOPED_GFX_PREF_INT("ui.click_hold_context_menus.delay", 30); + SCOPED_GFX_PREF_FLOAT("apz.touch_start_tolerance", 0.06); + + MockFunction<void(std::string checkPointName)> check; + { + InSequence s; + EXPECT_CALL(check, Call("pre long-tap dispatch")); + EXPECT_CALL(*mcc, HandleTap(TapType::eLongTap, LayoutDevicePoint(10, 10), + 0, apzc->GetGuid(), _, _)) + .Times(1); + EXPECT_CALL(check, Call("post long-tap dispatch")); + + // If a touch-move happens while long-tap is happening, there's no + // eLongTapUp event. + if (!aWithTouchMove) { + EXPECT_CALL(*mcc, + HandleTap(TapType::eLongTapUp, LayoutDevicePoint(10, 20), 0, + apzc->GetGuid(), _, _)) + .Times(1); + } + EXPECT_CALL(*mcc, HandleTap(TapType::eLongTap, LayoutDevicePoint(10, 10), + 0, apzc->GetGuid(), _, _)) + .Times(1); + } + + // Keep touching for a while to trigger a long tap event. + uint64_t firstTouchBlockId = + TouchDown(apzc, ScreenIntPoint(10, 10), mcc->Time()).mInputBlockId; + TouchBlockState* firstTouchBlock = + tm->GetInputQueue()->GetCurrentTouchBlock(); + EXPECT_NE(firstTouchBlock, nullptr); + EXPECT_EQ(tm->GetInputQueue()->GetBlockForId(firstTouchBlockId), + firstTouchBlock); + + // Wait for a long tap. + check.Call("pre long-tap dispatch"); + mcc->AdvanceByMillis(30); + check.Call("post long-tap dispatch"); + + // Now the current touch block is not the first touch block, it should be + // a new touch block for the long tap event. + TouchBlockState* secondTouchBlock = + tm->GetInputQueue()->GetCurrentTouchBlock(); + EXPECT_NE(secondTouchBlock, firstTouchBlock); + EXPECT_TRUE(secondTouchBlock->ForLongTap()); + uint64_t secondTouchBlockId = secondTouchBlock->GetBlockId(); + + if (aWithTouchMove) { + mcc->AdvanceByMillis(10); + TouchMove(apzc, ScreenIntPoint(10, 20), mcc->Time()); + } + + // Finish the first touch block. + mcc->AdvanceByMillis(10); + TouchUp(apzc, ScreenIntPoint(10, 20), mcc->Time()); + + // And start a new touch block. + mcc->AdvanceByMillis(10); + uint64_t newTouchBlockId = + TouchDown(apzc, ScreenIntPoint(10, 10), mcc->Time()).mInputBlockId; + + mcc->AdvanceByMillis(10); + // Now the original touch block and the touch block for long-tap should have + // been discarded from the input queue. + EXPECT_EQ(tm->GetInputQueue()->GetBlockForId(firstTouchBlockId), nullptr); + EXPECT_EQ(tm->GetInputQueue()->GetBlockForId(secondTouchBlockId), nullptr); + EXPECT_EQ(tm->GetInputQueue()->GetBlockForId(newTouchBlockId), + tm->GetInputQueue()->GetCurrentBlock()); + } }; TEST_F(APZCLongPressTester, LongPress) { @@ -563,6 +641,28 @@ TEST_F(APZCLongPressTester, LongPressPreventDefault) { DoLongPressPreventDefaultTest(kDefaultTouchBehavior); } +TEST_F(APZCLongPressTester, LongPressDiscardBlock) { + DoLongPressDiscardTouchBlockTest(true /* with touch-move */); +} + +// Similar to above LongPressDiscardBlock but APZ is waiting for responses from +// the content. +TEST_F(APZCLongPressTester, LongPressDiscardBlock2) { + MakeApzcWaitForMainThread(); + DoLongPressDiscardTouchBlockTest(true /* with touch-move */); +} + +// Similar to above LongPressDiscardBlock/LongPressDiscardBlock2 without +// touch-move events. +TEST_F(APZCLongPressTester, LongPressDiscardBlock3) { + DoLongPressDiscardTouchBlockTest(false /* without touch-move */); +} + +TEST_F(APZCLongPressTester, LongPressDiscardBlock4) { + MakeApzcWaitForMainThread(); + DoLongPressDiscardTouchBlockTest(false /* without touch-move */); +} + TEST_F(APZCGestureDetectorTester, DoubleTap) { MakeApzcWaitForMainThread(); MakeApzcZoomable(); |