0

exo_unittests: fix remaining test failures for reactive frame submission.

This CL:
- lowers refresh rate for mock time mode to save cost when fast forwarding for a long duration;
- for pointer tests, parameterizes for both reactive frame submission enabled/disabled cases, fixes tests and removes unnecessary RunUntilIdle();
- minor update of shell_surface_presentation_time_recorder_unittest.

Bug: 1408614
Change-Id: I2e2b566363fd24c5d4c45f2915efaba74bbc2b8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4205069
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
Commit-Queue: Yuzhu Shen <yzshen@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1111919}
This commit is contained in:
Yuzhu Shen
2023-03-02 00:04:29 +00:00
committed by Chromium LUCI CQ
parent a63a77ab86
commit 0c765a8089
10 changed files with 109 additions and 74 deletions

@ -146,7 +146,10 @@ void AshTestBase::SetUp(std::unique_ptr<TestShellDelegate> delegate) {
params.pixel_test_init_params = std::move(pixel_test_init_params);
}
ash_test_helper_ = std::make_unique<AshTestHelper>();
test_context_factories_ =
std::make_unique<ui::TestContextFactories>(/*enable_pixel_output=*/false);
ash_test_helper_ = std::make_unique<AshTestHelper>(
test_context_factories_->GetContextFactory());
ash_test_helper_->SetUp(std::move(params));
}

@ -27,6 +27,7 @@
#include "third_party/skia/include/core/SkColor.h"
#include "ui/aura/client/window_types.h"
#include "ui/aura/env.h"
#include "ui/compositor/test/test_context_factories.h"
#include "ui/display/display.h"
#include "ui/events/event_constants.h"
#include "ui/events/test/event_generator.h"
@ -266,6 +267,13 @@ class AshTestBase : public testing::Test {
TestingPrefServiceSimple* local_state() { return &local_state_; }
AshTestHelper* ash_test_helper() { return ash_test_helper_.get(); }
// Returns nullptr before SetUp() is called.
ui::InProcessContextFactory* GetContextFactory() {
return test_context_factories_
? test_context_factories_->GetContextFactory()
: nullptr;
}
void SetUserPref(const std::string& user_email,
const std::string& path,
const base::Value& value);
@ -381,6 +389,8 @@ class AshTestBase : public testing::Test {
// `PrepareForPixelDiffTest()`.
std::unique_ptr<AshPixelDiffer> pixel_differ_;
std::unique_ptr<ui::TestContextFactories> test_context_factories_;
// Must be constructed after |task_environment_|.
std::unique_ptr<AshTestHelper> ash_test_helper_;

@ -284,6 +284,8 @@ class TaskEnvironment {
// specifically handle more time than expected to have passed.
void AdvanceClock(TimeDelta delta);
bool UsesMockTime() const { return !!mock_clock_; }
// Only valid for instances using TimeSource::MOCK_TIME. Returns a
// TickClock whose time is updated by FastForward(By|UntilNoTasksRemain).
const TickClock* GetMockTickClock() const;

@ -7,7 +7,6 @@
#include "ash/constants/app_types.h"
#include "ash/constants/ash_features.h"
#include "ash/drag_drop/drag_drop_controller.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/shell.h"
#include "ash/wm/desks/desks_util.h"
#include "ash/wm/window_positioning_utils.h"
@ -24,13 +23,13 @@
#include "components/exo/pointer_stylus_delegate.h"
#include "components/exo/relative_pointer_delegate.h"
#include "components/exo/seat.h"
#include "components/exo/security_delegate.h"
#include "components/exo/shell_surface.h"
#include "components/exo/sub_surface.h"
#include "components/exo/surface.h"
#include "components/exo/test/exo_test_base.h"
#include "components/exo/test/exo_test_data_exchange_delegate.h"
#include "components/exo/test/exo_test_helper.h"
#include "components/exo/test/mock_security_delegate.h"
#include "components/exo/test/shell_surface_builder.h"
#include "components/exo/test/surface_tree_host_test_util.h"
#include "components/exo/wm_helper.h"
@ -47,7 +46,6 @@
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom-shared.h"
#include "ui/events/base_event_utils.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
#include "ui/events/test/event_generator.h"
#include "ui/events/test/events_test_utils.h"
#include "ui/events/types/event_type.h"
@ -157,9 +155,16 @@ class TestDataSourceDelegate : public DataSourceDelegate {
}
};
class PointerTest : public test::ExoTestBase {
class PointerTest : public test::ExoTestBase,
public testing::WithParamInterface<bool> {
public:
PointerTest() = default;
PointerTest() {
if (GetParam()) {
feature_list_.InitAndEnableFeature(kExoReactiveFrameSubmission);
} else {
feature_list_.InitAndDisableFeature(kExoReactiveFrameSubmission);
}
}
PointerTest(const PointerTest&) = delete;
PointerTest& operator=(const PointerTest&) = delete;
@ -171,6 +176,9 @@ class PointerTest : public test::ExoTestBase {
// consumed before starting. See https://crbug.com/854674.
base::RunLoop().RunUntilIdle();
}
private:
base::test::ScopedFeatureList feature_list_;
};
class PointerConstraintTest : public PointerTest {
@ -233,7 +241,14 @@ class PointerConstraintTest : public PointerTest {
aura::client::FocusClient* focus_client_;
};
TEST_F(PointerTest, SetCursor) {
// Instantiate the values of disabling/enabling reactive frame submission in the
// parameterized tests.
INSTANTIATE_TEST_SUITE_P(All, PointerTest, testing::Values(false, true));
INSTANTIATE_TEST_SUITE_P(All,
PointerConstraintTest,
testing::Values(false, true));
TEST_P(PointerTest, SetCursor) {
auto shell_surface = test::ShellSurfaceBuilder({10, 10}).BuildShellSurface();
auto* surface = shell_surface->surface_for_testing();
@ -257,7 +272,7 @@ TEST_F(PointerTest, SetCursor) {
// Set pointer surface.
pointer->SetCursor(pointer_surface.get(), gfx::Point(5, 5));
test::WaitForLastFramePresentation(pointer.get());
test::WaitForLastFrameAck(pointer.get());
const viz::CompositorRenderPass* last_render_pass;
{
@ -273,7 +288,7 @@ TEST_F(PointerTest, SetCursor) {
// Adjust hotspot.
pointer->SetCursor(pointer_surface.get(), gfx::Point());
test::WaitForLastFramePresentation(pointer.get());
test::WaitForLastFrameAck(pointer.get());
// Verify that adjustment to hotspot resulted in new frame.
{
@ -292,7 +307,7 @@ TEST_F(PointerTest, SetCursor) {
pointer.reset();
}
TEST_F(PointerTest, SetCursorNull) {
TEST_P(PointerTest, SetCursorNull) {
auto shell_surface = test::ShellSurfaceBuilder({10, 10}).BuildShellSurface();
auto* surface = shell_surface->surface_for_testing();
@ -308,7 +323,6 @@ TEST_F(PointerTest, SetCursorNull) {
generator.MoveMouseTo(surface->window()->GetBoundsInScreen().origin());
pointer->SetCursor(nullptr, gfx::Point());
base::RunLoop().RunUntilIdle();
EXPECT_EQ(nullptr, pointer->root_surface());
aura::client::CursorClient* cursor_client = aura::client::GetCursorClient(
@ -319,7 +333,7 @@ TEST_F(PointerTest, SetCursorNull) {
pointer.reset();
}
TEST_F(PointerTest, SetCursorType) {
TEST_P(PointerTest, SetCursorType) {
auto shell_surface = test::ShellSurfaceBuilder({10, 10}).BuildShellSurface();
auto* surface = shell_surface->surface_for_testing();
@ -335,7 +349,6 @@ TEST_F(PointerTest, SetCursorType) {
generator.MoveMouseTo(surface->window()->GetBoundsInScreen().origin());
pointer->SetCursorType(ui::mojom::CursorType::kIBeam);
base::RunLoop().RunUntilIdle();
EXPECT_EQ(nullptr, pointer->root_surface());
aura::client::CursorClient* cursor_client = aura::client::GetCursorClient(
@ -351,7 +364,7 @@ TEST_F(PointerTest, SetCursorType) {
pointer_surface->Commit();
pointer->SetCursor(pointer_surface.get(), gfx::Point());
base::RunLoop().RunUntilIdle();
test::WaitForLastFrameAck(pointer.get());
{
viz::SurfaceId surface_id = pointer->host_window()->GetSurfaceId();
@ -365,7 +378,6 @@ TEST_F(PointerTest, SetCursorType) {
// Set the pointer type after the pointer surface is specified.
pointer->SetCursorType(ui::mojom::CursorType::kCross);
base::RunLoop().RunUntilIdle();
EXPECT_EQ(nullptr, pointer->root_surface());
EXPECT_EQ(ui::mojom::CursorType::kCross, cursor_client->GetCursor().type());
@ -374,7 +386,7 @@ TEST_F(PointerTest, SetCursorType) {
pointer.reset();
}
TEST_F(PointerTest, SetCursorTypeOutsideOfSurface) {
TEST_P(PointerTest, SetCursorTypeOutsideOfSurface) {
auto shell_surface = test::ShellSurfaceBuilder({10, 10}).BuildShellSurface();
auto* surface = shell_surface->surface_for_testing();
@ -389,7 +401,6 @@ TEST_F(PointerTest, SetCursorTypeOutsideOfSurface) {
gfx::Vector2d(1, 1));
pointer->SetCursorType(ui::mojom::CursorType::kIBeam);
base::RunLoop().RunUntilIdle();
EXPECT_EQ(nullptr, pointer->root_surface());
aura::client::CursorClient* cursor_client = aura::client::GetCursorClient(
@ -402,7 +413,7 @@ TEST_F(PointerTest, SetCursorTypeOutsideOfSurface) {
pointer.reset();
}
TEST_F(PointerTest, SetCursorAndSetCursorType) {
TEST_P(PointerTest, SetCursorAndSetCursorType) {
auto shell_surface = test::ShellSurfaceBuilder({10, 10}).BuildShellSurface();
auto* surface = shell_surface->surface_for_testing();
@ -442,7 +453,6 @@ TEST_F(PointerTest, SetCursorAndSetCursorType) {
// Set the cursor type to the kNone through SetCursorType.
pointer->SetCursorType(ui::mojom::CursorType::kNone);
EXPECT_TRUE(pointer->GetActivePresentationCallbacksForTesting().empty());
base::RunLoop().RunUntilIdle();
EXPECT_EQ(nullptr, pointer->root_surface());
// Set the same pointer surface again.
@ -464,7 +474,7 @@ TEST_F(PointerTest, SetCursorAndSetCursorType) {
pointer.reset();
}
TEST_F(PointerTest, SetCursorNullAndSetCursorType) {
TEST_P(PointerTest, SetCursorNullAndSetCursorType) {
auto shell_surface = test::ShellSurfaceBuilder({10, 10}).BuildShellSurface();
auto* surface = shell_surface->surface_for_testing();
@ -481,7 +491,6 @@ TEST_F(PointerTest, SetCursorNullAndSetCursorType) {
// Set nullptr surface.
pointer->SetCursor(nullptr, gfx::Point());
base::RunLoop().RunUntilIdle();
EXPECT_EQ(nullptr, pointer->root_surface());
aura::client::CursorClient* cursor_client = aura::client::GetCursorClient(
@ -490,13 +499,11 @@ TEST_F(PointerTest, SetCursorNullAndSetCursorType) {
// Set the cursor type.
pointer->SetCursorType(ui::mojom::CursorType::kIBeam);
base::RunLoop().RunUntilIdle();
EXPECT_EQ(nullptr, pointer->root_surface());
EXPECT_EQ(ui::mojom::CursorType::kIBeam, cursor_client->GetCursor().type());
// Set nullptr surface again.
pointer->SetCursor(nullptr, gfx::Point());
base::RunLoop().RunUntilIdle();
EXPECT_EQ(nullptr, pointer->root_surface());
EXPECT_EQ(ui::mojom::CursorType::kNone, cursor_client->GetCursor().type());
@ -504,7 +511,7 @@ TEST_F(PointerTest, SetCursorNullAndSetCursorType) {
pointer.reset();
}
TEST_F(PointerTest, OnPointerEnter) {
TEST_P(PointerTest, OnPointerEnter) {
auto shell_surface = test::ShellSurfaceBuilder({10, 10}).BuildShellSurface();
auto* surface = shell_surface->surface_for_testing();
@ -523,7 +530,7 @@ TEST_F(PointerTest, OnPointerEnter) {
pointer.reset();
}
TEST_F(PointerTest, OnPointerLeave) {
TEST_P(PointerTest, OnPointerLeave) {
auto shell_surface = test::ShellSurfaceBuilder({10, 10}).BuildShellSurface();
auto* surface = shell_surface->surface_for_testing();
@ -551,7 +558,7 @@ TEST_F(PointerTest, OnPointerLeave) {
pointer.reset();
}
TEST_F(PointerTest, OnPointerMotion) {
TEST_P(PointerTest, OnPointerMotion) {
auto shell_surface = test::ShellSurfaceBuilder({10, 10}).BuildShellSurface();
auto* surface = shell_surface->surface_for_testing();
@ -619,7 +626,7 @@ TEST_F(PointerTest, OnPointerMotion) {
pointer.reset();
}
TEST_F(PointerTest, OnPointerButton) {
TEST_P(PointerTest, OnPointerButton) {
auto shell_surface = test::ShellSurfaceBuilder({10, 10}).BuildShellSurface();
auto* surface = shell_surface->surface_for_testing();
@ -645,7 +652,7 @@ TEST_F(PointerTest, OnPointerButton) {
pointer.reset();
}
TEST_F(PointerTest, OnPointerButtonWithAttemptToStartDrag) {
TEST_P(PointerTest, OnPointerButtonWithAttemptToStartDrag) {
auto shell_surface = test::ShellSurfaceBuilder({10, 10}).BuildShellSurface();
auto* surface = shell_surface->surface_for_testing();
@ -674,7 +681,7 @@ TEST_F(PointerTest, OnPointerButtonWithAttemptToStartDrag) {
pointer.reset();
}
TEST_F(PointerTest, OnPointerScroll) {
TEST_P(PointerTest, OnPointerScroll) {
auto shell_surface = test::ShellSurfaceBuilder({10, 10}).BuildShellSurface();
auto* surface = shell_surface->surface_for_testing();
@ -705,7 +712,7 @@ TEST_F(PointerTest, OnPointerScroll) {
pointer.reset();
}
TEST_F(PointerTest, OnPointerScrollWithThreeFinger) {
TEST_P(PointerTest, OnPointerScrollWithThreeFinger) {
auto shell_surface = test::ShellSurfaceBuilder({10, 10}).BuildShellSurface();
auto* surface = shell_surface->surface_for_testing();
@ -736,7 +743,7 @@ TEST_F(PointerTest, OnPointerScrollWithThreeFinger) {
pointer.reset();
}
TEST_F(PointerTest, OnPointerScrollDiscrete) {
TEST_P(PointerTest, OnPointerScrollDiscrete) {
auto shell_surface = test::ShellSurfaceBuilder({10, 10}).BuildShellSurface();
auto* surface = shell_surface->surface_for_testing();
@ -760,7 +767,7 @@ TEST_F(PointerTest, OnPointerScrollDiscrete) {
pointer.reset();
}
TEST_F(PointerTest, RegisterPointerEventsOnModal) {
TEST_P(PointerTest, RegisterPointerEventsOnModal) {
// Create modal surface.
auto shell_surface = test::ShellSurfaceBuilder({5, 5})
.SetCanMinimize(false)
@ -809,7 +816,7 @@ TEST_F(PointerTest, RegisterPointerEventsOnModal) {
pointer.reset();
}
TEST_F(PointerTest, IgnorePointerEventsOnNonModalWhenModalIsOpen) {
TEST_P(PointerTest, IgnorePointerEventsOnNonModalWhenModalIsOpen) {
// Create surface for non-modal window.
auto shell_surface = test::ShellSurfaceBuilder({10, 10}).BuildShellSurface();
auto* surface = shell_surface->surface_for_testing();
@ -872,7 +879,7 @@ TEST_F(PointerTest, IgnorePointerEventsOnNonModalWhenModalIsOpen) {
pointer.reset();
}
TEST_F(PointerTest, IgnorePointerLeaveOnModal) {
TEST_P(PointerTest, IgnorePointerLeaveOnModal) {
// Create modal surface.
auto shell_surface = test::ShellSurfaceBuilder({5, 5})
.SetCanMinimize(false)
@ -913,7 +920,7 @@ TEST_F(PointerTest, IgnorePointerLeaveOnModal) {
pointer.reset();
}
TEST_F(PointerTest, RegisterPointerEventsOnNonModal) {
TEST_P(PointerTest, RegisterPointerEventsOnNonModal) {
// Create surface for non-modal window.
auto shell_surface = test::ShellSurfaceBuilder({10, 10}).BuildShellSurface();
auto* surface = shell_surface->surface_for_testing();
@ -974,7 +981,7 @@ TEST_F(PointerTest, RegisterPointerEventsOnNonModal) {
pointer.reset();
}
TEST_F(PointerTest, DragDropAbort) {
TEST_P(PointerTest, DragDropAbort) {
Seat seat(std::make_unique<TestDataExchangeDelegate>());
MockPointerDelegate pointer_delegate;
std::unique_ptr<Pointer> pointer(new Pointer(&pointer_delegate, &seat));
@ -1006,7 +1013,7 @@ TEST_F(PointerTest, DragDropAbort) {
pointer.reset();
}
TEST_F(PointerTest, DragDropAndPointerEnterLeaveEvents) {
TEST_P(PointerTest, DragDropAndPointerEnterLeaveEvents) {
Seat seat(std::make_unique<TestDataExchangeDelegate>());
MockPointerDelegate pointer_delegate;
std::unique_ptr<Pointer> pointer(new Pointer(&pointer_delegate, &seat));
@ -1062,7 +1069,7 @@ TEST_F(PointerTest, DragDropAndPointerEnterLeaveEvents) {
pointer.reset();
}
TEST_F(PointerTest, DragDropAndPointerEnterLeaveEvents_NoOpOnTouchDrag) {
TEST_P(PointerTest, DragDropAndPointerEnterLeaveEvents_NoOpOnTouchDrag) {
Seat seat(std::make_unique<TestDataExchangeDelegate>());
MockPointerDelegate pointer_delegate;
std::unique_ptr<Pointer> pointer(new Pointer(&pointer_delegate, &seat));
@ -1108,7 +1115,7 @@ TEST_F(PointerTest, DragDropAndPointerEnterLeaveEvents_NoOpOnTouchDrag) {
pointer.reset();
}
TEST_F(PointerTest, IgnoresHandledEvents) {
TEST_P(PointerTest, IgnoresHandledEvents) {
// A very dumb handler that simply marks all events as handled. This is needed
// allows us to mark a mouse event as handled as it gets processed by the
// event processor.
@ -1147,7 +1154,7 @@ TEST_F(PointerTest, IgnoresHandledEvents) {
ash::Shell::Get()->RemovePreTargetHandler(&handler);
}
TEST_F(PointerTest, IgnoresCursorHideEvents) {
TEST_P(PointerTest, IgnoresCursorHideEvents) {
Seat seat(std::make_unique<TestDataExchangeDelegate>());
testing::NiceMock<MockPointerDelegate> pointer_delegate;
auto pointer = std::make_unique<Pointer>(&pointer_delegate, &seat);
@ -1229,7 +1236,7 @@ class PointerDragDropObserver : public WMHelper::DragDropObserver {
// Test for crbug.com/1307143: It ensures no "pointer enter" event is
// processed in case the target surface is destroyed during the drop action.
TEST_F(PointerTest,
TEST_P(PointerTest,
DragDropAndPointerEnterLeaveEvents_NoEnterOnSurfaceDestroy) {
Seat seat(std::make_unique<TestDataExchangeDelegate>());
MockPointerDelegate pointer_delegate;
@ -1295,7 +1302,7 @@ TEST_F(PointerTest,
// Test for crbug.com/1307143: It ensures no "pointer enter" event is
// processed in case the target surface parent is destroyed during the drop
// action.
TEST_F(PointerTest,
TEST_P(PointerTest,
DragDropAndPointerEnterLeaveEvents_NoEnterOnParentSurfaceDestroy) {
Seat seat(std::make_unique<TestDataExchangeDelegate>());
MockPointerDelegate pointer_delegate;
@ -1356,7 +1363,7 @@ TEST_F(PointerTest,
pointer.reset();
}
TEST_F(PointerTest, OnPointerRelativeMotion) {
TEST_P(PointerTest, OnPointerRelativeMotion) {
auto shell_surface = test::ShellSurfaceBuilder({10, 10}).BuildShellSurface();
auto* surface = shell_surface->surface_for_testing();
@ -1468,7 +1475,11 @@ class PointerOrdinalMotionTest : public PointerTest {
base::test::ScopedFeatureList scoped_feature_list_;
};
TEST_F(PointerOrdinalMotionTest, OrdinalMotionOverridesRelativeMotion) {
INSTANTIATE_TEST_SUITE_P(All,
PointerOrdinalMotionTest,
testing::Values(false, true));
TEST_P(PointerOrdinalMotionTest, OrdinalMotionOverridesRelativeMotion) {
auto shell_surface = test::ShellSurfaceBuilder({10, 10}).BuildShellSurface();
auto* surface = shell_surface->surface_for_testing();
@ -1508,7 +1519,7 @@ TEST_F(PointerOrdinalMotionTest, OrdinalMotionOverridesRelativeMotion) {
pointer->UnregisterRelativePointerDelegate(&relative_delegate);
}
TEST_F(PointerConstraintTest, ConstrainPointer) {
TEST_P(PointerConstraintTest, ConstrainPointer) {
EXPECT_TRUE(pointer_->ConstrainPointer(&constraint_delegate_));
EXPECT_CALL(delegate_, OnPointerEnter(surface_, gfx::PointF(), 0));
@ -1545,7 +1556,7 @@ TEST_F(PointerConstraintTest, ConstrainPointer) {
pointer_.reset();
}
TEST_F(PointerConstraintTest, CanOnlyConstrainPermittedWindows) {
TEST_P(PointerConstraintTest, CanOnlyConstrainPermittedWindows) {
std::unique_ptr<ShellSurface> shell_surface =
test::ShellSurfaceBuilder({10, 10}).BuildShellSurface();
EXPECT_CALL(constraint_delegate_, GetConstrainedSurface())
@ -1561,7 +1572,7 @@ TEST_F(PointerConstraintTest, CanOnlyConstrainPermittedWindows) {
pointer_.reset();
}
TEST_F(PointerConstraintTest, OneConstraintPerSurface) {
TEST_P(PointerConstraintTest, OneConstraintPerSurface) {
ON_CALL(constraint_delegate_, IsPersistent())
.WillByDefault(testing::Return(false));
EXPECT_TRUE(pointer_->ConstrainPointer(&constraint_delegate_));
@ -1585,7 +1596,7 @@ TEST_F(PointerConstraintTest, OneConstraintPerSurface) {
pointer_.reset();
}
TEST_F(PointerConstraintTest, OneShotConstraintActivatedOnFirstFocus) {
TEST_P(PointerConstraintTest, OneShotConstraintActivatedOnFirstFocus) {
auto second_shell_surface = BuildShellSurfaceWhichPermitsPointerLock();
Surface* second_surface = second_shell_surface->surface_for_testing();
@ -1612,7 +1623,7 @@ TEST_F(PointerConstraintTest, OneShotConstraintActivatedOnFirstFocus) {
pointer_.reset();
}
TEST_F(PointerConstraintTest, UnconstrainPointerWhenSurfaceIsDestroyed) {
TEST_P(PointerConstraintTest, UnconstrainPointerWhenSurfaceIsDestroyed) {
EXPECT_TRUE(pointer_->ConstrainPointer(&constraint_delegate_));
EXPECT_CALL(delegate_, OnPointerEnter(surface_, gfx::PointF(), 0));
@ -1629,7 +1640,7 @@ TEST_F(PointerConstraintTest, UnconstrainPointerWhenSurfaceIsDestroyed) {
pointer_.reset();
}
TEST_F(PointerConstraintTest, UnconstrainPointerWhenWindowLosesFocus) {
TEST_P(PointerConstraintTest, UnconstrainPointerWhenWindowLosesFocus) {
ON_CALL(constraint_delegate_, IsPersistent())
.WillByDefault(testing::Return(false));
EXPECT_TRUE(pointer_->ConstrainPointer(&constraint_delegate_));
@ -1648,7 +1659,7 @@ TEST_F(PointerConstraintTest, UnconstrainPointerWhenWindowLosesFocus) {
pointer_.reset();
}
TEST_F(PointerConstraintTest, PersistentConstraintActivatedOnRefocus) {
TEST_P(PointerConstraintTest, PersistentConstraintActivatedOnRefocus) {
ON_CALL(constraint_delegate_, IsPersistent())
.WillByDefault(testing::Return(true));
EXPECT_TRUE(pointer_->ConstrainPointer(&constraint_delegate_));
@ -1667,7 +1678,7 @@ TEST_F(PointerConstraintTest, PersistentConstraintActivatedOnRefocus) {
pointer_.reset();
}
TEST_F(PointerConstraintTest, MultipleSurfacesCanBeConstrained) {
TEST_P(PointerConstraintTest, MultipleSurfacesCanBeConstrained) {
// Arrange: First surface + persistent constraint
ON_CALL(constraint_delegate_, IsPersistent())
.WillByDefault(testing::Return(true));
@ -1713,7 +1724,7 @@ TEST_F(PointerConstraintTest, MultipleSurfacesCanBeConstrained) {
pointer_.reset();
}
TEST_F(PointerConstraintTest, UserActionPreventsConstraint) {
TEST_P(PointerConstraintTest, UserActionPreventsConstraint) {
ON_CALL(constraint_delegate_, IsPersistent())
.WillByDefault(testing::Return(false));
EXPECT_TRUE(pointer_->ConstrainPointer(&constraint_delegate_));
@ -1754,7 +1765,7 @@ TEST_F(PointerConstraintTest, UserActionPreventsConstraint) {
pointer_.reset();
}
TEST_F(PointerConstraintTest, UserCanBreakAndActivatePersistentConstraint) {
TEST_P(PointerConstraintTest, UserCanBreakAndActivatePersistentConstraint) {
ON_CALL(constraint_delegate_, IsPersistent())
.WillByDefault(testing::Return(true));
EXPECT_TRUE(pointer_->ConstrainPointer(&constraint_delegate_));
@ -1779,7 +1790,7 @@ TEST_F(PointerConstraintTest, UserCanBreakAndActivatePersistentConstraint) {
pointer_.reset();
}
TEST_F(PointerConstraintTest, DefaultSecurityDeletegate) {
TEST_P(PointerConstraintTest, DefaultSecurityDeletegate) {
auto default_security_delegate =
SecurityDelegate::GetDefaultSecurityDelegate();
auto shell_surface = test::ShellSurfaceBuilder({10, 10})
@ -1824,7 +1835,7 @@ TEST_F(PointerConstraintTest, DefaultSecurityDeletegate) {
pointer_.reset();
}
TEST_F(PointerConstraintTest, NoPointerMotionEventWhenUnconstrainingPointer) {
TEST_P(PointerConstraintTest, NoPointerMotionEventWhenUnconstrainingPointer) {
testing::MockFunction<void(std::string check_point_name)> check;
{
testing::InSequence s;
@ -1853,7 +1864,7 @@ TEST_F(PointerConstraintTest, NoPointerMotionEventWhenUnconstrainingPointer) {
pointer_.reset();
}
TEST_F(PointerConstraintTest, ConstrainPointerWithUncommittedShellSurface) {
TEST_P(PointerConstraintTest, ConstrainPointerWithUncommittedShellSurface) {
std::unique_ptr<ShellSurface> uncommitted_shell_surface =
test::ShellSurfaceBuilder({10, 10}).SetNoCommit().BuildShellSurface();
@ -1879,7 +1890,7 @@ TEST_F(PointerConstraintTest, ConstrainPointerWithUncommittedShellSurface) {
pointer_.reset();
}
TEST_F(PointerTest, PointerStylus) {
TEST_P(PointerTest, PointerStylus) {
auto shell_surface = test::ShellSurfaceBuilder({10, 10}).BuildShellSurface();
auto* surface = shell_surface->surface_for_testing();
@ -1910,7 +1921,7 @@ TEST_F(PointerTest, PointerStylus) {
pointer.reset();
}
TEST_F(PointerTest, PointerStylus2) {
TEST_P(PointerTest, PointerStylus2) {
auto shell_surface = test::ShellSurfaceBuilder({10, 10}).BuildShellSurface();
auto* surface = shell_surface->surface_for_testing();
@ -1948,7 +1959,7 @@ TEST_F(PointerTest, PointerStylus2) {
pointer.reset();
}
TEST_F(PointerTest, DontSendMouseEventDuringMove) {
TEST_P(PointerTest, DontSendMouseEventDuringMove) {
Seat seat;
testing::NiceMock<MockPointerDelegate> pointer_delegate;
auto pointer = std::make_unique<Pointer>(&pointer_delegate, &seat);

@ -11,8 +11,8 @@
#include "base/run_loop.h"
#include "base/time/time.h"
#include "components/exo/test/exo_test_base.h"
#include "components/exo/test/exo_test_helper.h"
#include "components/exo/test/shell_surface_builder.h"
#include "components/exo/test/surface_tree_host_test_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "ui/gfx/presentation_feedback.h"
@ -180,7 +180,7 @@ TEST_F(ShellSurfacePresentationTimeRecorderTest,
// Fake frame submission. No FakeFrameSubmitAndPresent() because it depends
// on `recorder_`.
root_surface()->Commit();
base::RunLoop().RunUntilIdle();
test::WaitForLastFramePresentation(shell_surface_.get());
}
TEST_F(ShellSurfacePresentationTimeRecorderTest,

@ -50,6 +50,12 @@ ExoTestBase::~ExoTestBase() = default;
void ExoTestBase::SetUp() {
SetUp(nullptr);
if (task_environment()->UsesMockTime()) {
// Reduce the refresh rate to save cost for fast forwarding when mock time
// is used.
GetContextFactory()->SetRefreshRateForTests(10.0);
}
}
void ExoTestBase::TearDown() {

@ -192,8 +192,8 @@ InProcessContextFactory::~InProcessContextFactory() {
DCHECK(per_compositor_data_.empty());
}
void InProcessContextFactory::SetUseFastRefreshRateForTests() {
refresh_rate_ = 200.0;
void InProcessContextFactory::SetRefreshRateForTests(double refresh_rate) {
refresh_rate_ = refresh_rate;
}
void InProcessContextFactory::CreateLayerTreeFrameSink(

@ -54,9 +54,13 @@ class InProcessContextFactory : public ContextFactory {
return frame_sink_manager_;
}
// Set refresh rate will be set to 200 to spend less time waiting for
// BeginFrame when used for tests.
void SetUseFastRefreshRateForTests();
// Setting a higher refresh rate will spend less time waiting for BeginFrame;
// while setting a lower refresh rate will reduce the workload per unit of
// time, which could be useful, e.g., when using mock time and fast forwarding
// by a long duration.
//
// Takes effect for the next CreateLayerTreeFrameSink() call.
void SetRefreshRateForTests(double refresh_rate);
// ContextFactory implementation.
void CreateLayerTreeFrameSink(base::WeakPtr<Compositor> compositor) override;

@ -10,7 +10,6 @@
#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
#include "ui/compositor/compositor_switches.h"
#include "ui/compositor/test/in_process_context_factory.h"
#include "ui/gl/gl_implementation.h"
namespace ui {
@ -29,7 +28,8 @@ TestContextFactories::TestContextFactories(bool enable_pixel_output,
implicit_factory_ = std::make_unique<InProcessContextFactory>(
host_frame_sink_manager_.get(), frame_sink_manager_.get(),
output_to_window);
implicit_factory_->SetUseFastRefreshRateForTests();
// Set to a high refresh rate to spend less time waiting for BeginFrame.
implicit_factory_->SetRefreshRateForTests(200.0);
// Directly connect without using Mojo.
frame_sink_manager_->SetLocalClient(host_frame_sink_manager_.get());
@ -38,7 +38,7 @@ TestContextFactories::TestContextFactories(bool enable_pixel_output,
TestContextFactories::~TestContextFactories() = default;
ContextFactory* TestContextFactories::GetContextFactory() const {
ui::InProcessContextFactory* TestContextFactories::GetContextFactory() const {
return implicit_factory_.get();
}

@ -7,6 +7,8 @@
#include <memory>
#include "ui/compositor/test/in_process_context_factory.h"
namespace gl {
class DisableNullDrawGLBindings;
}
@ -19,9 +21,6 @@ class FrameSinkManagerImpl;
namespace ui {
class InProcessContextFactory;
class ContextFactory;
// Set up the compositor ContextFactory for a test environment. Unit tests that
// do not have a full content environment need to call this before initializing
// the Compositor. Some tests expect pixel output, and they should pass true for
@ -37,7 +36,7 @@ class TestContextFactories {
TestContextFactories(const TestContextFactories&) = delete;
TestContextFactories& operator=(const TestContextFactories&) = delete;
ContextFactory* GetContextFactory() const;
ui::InProcessContextFactory* GetContextFactory() const;
private:
std::unique_ptr<gl::DisableNullDrawGLBindings> disable_null_draw_;