Skip to content

Commit

Permalink
Improve cursor compositing checks in unittests
Browse files Browse the repository at this point in the history
This CL changes a few tests to take advantage of the fact that updating
a preference involving cursor compositing already asks the
CursorWindowManager to update its status.

Change-Id: I12b9fa3a6f4b8f24a5629dbba503af8ad6ccf619
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2959888
Reviewed-by: James Cook <jamescook@chromium.org>
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Cr-Commit-Position: refs/heads/master@{#892132}
  • Loading branch information
hferreiro authored and Chromium LUCI CQ committed Jun 14, 2021
1 parent b55dd31 commit 5fc72d5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
3 changes: 0 additions & 3 deletions ash/display/cursor_window_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class CursorWindowControllerTest : public AshTestBase {
// feature using it and is turned off.
Shell::Get()->accessibility_controller()->high_contrast().SetEnabled(
enabled);
Shell::Get()->UpdateCursorCompositingEnabled();
}

CursorWindowController* cursor_window_controller() {
Expand Down Expand Up @@ -203,12 +202,10 @@ TEST_F(CursorWindowControllerTest, ShouldEnableCursorCompositing) {

// Enable large cursor, cursor compositing should be enabled.
prefs->SetBoolean(prefs::kAccessibilityLargeCursorEnabled, true);
Shell::Get()->UpdateCursorCompositingEnabled();
EXPECT_TRUE(cursor_window_controller()->is_cursor_compositing_enabled());

// Disable large cursor, cursor compositing should be disabled.
prefs->SetBoolean(prefs::kAccessibilityLargeCursorEnabled, false);
Shell::Get()->UpdateCursorCompositingEnabled();
EXPECT_FALSE(cursor_window_controller()->is_cursor_compositing_enabled());
}

Expand Down
4 changes: 1 addition & 3 deletions ash/system/night_light/night_light_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ class NightLightCrtcTest : public NightLightTest {
return Shell::Get()
->window_tree_host_manager()
->cursor_window_controller()
->ShouldEnableCursorCompositing();
->is_cursor_compositing_enabled();
}

std::string GetLoggerActionsAndClear() {
Expand Down Expand Up @@ -1401,13 +1401,11 @@ TEST_F(NightLightCrtcTest, TestAllDisplaysSupportCrtcMatrix) {
for (const auto* const pref : {prefs::kAccessibilityLargeCursorEnabled,
prefs::kAccessibilityHighContrastEnabled}) {
user1_pref_service()->SetBoolean(pref, true);
Shell::Get()->UpdateCursorCompositingEnabled();
EXPECT_TRUE(IsCursorCompositingEnabled());

// Disabling the accessibility feature should revert back to the hardware
// cursor.
user1_pref_service()->SetBoolean(pref, false);
Shell::Get()->UpdateCursorCompositingEnabled();
EXPECT_FALSE(IsCursorCompositingEnabled());
}
}
Expand Down
8 changes: 2 additions & 6 deletions ash/utility/screenshot_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "ash/utility/screenshot_controller.h"

#include "ash/accessibility/accessibility_controller_impl.h"
#include "ash/display/cursor_window_controller.h"
#include "ash/display/mirror_window_test_api.h"
#include "ash/display/mouse_cursor_event_filter.h"
Expand All @@ -20,7 +21,6 @@
#include "ui/aura/env.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/cursor_size.h"
#include "ui/compositor/layer.h"
#include "ui/display/types/display_constants.h"
#include "ui/events/test/event_generator.h"
Expand Down Expand Up @@ -304,11 +304,7 @@ TEST_F(PartialScreenshotControllerTest, CursorVisibilityTest) {
// Make sure ScreenshotController doesn't prevent handling of large
// cursor. See http://crbug.com/459214
TEST_F(PartialScreenshotControllerTest, LargeCursor) {
Shell::Get()->cursor_manager()->SetCursorSize(ui::CursorSize::kLarge);
Shell::Get()
->window_tree_host_manager()
->cursor_window_controller()
->SetCursorCompositingEnabled(true);
Shell::Get()->accessibility_controller()->large_cursor().SetEnabled(true);

// Large cursor is represented as cursor window.
MirrorWindowTestApi test_api;
Expand Down

0 comments on commit 5fc72d5

Please sign in to comment.