Skip to content

Commit

Permalink
ui::Display cleanup: some enums --> enum classes
Browse files Browse the repository at this point in the history
This CL makes Display:: RotationSource, TouchSupport and
AccelerometerSupport enum classes.  Just stumbled upon them while
reading this class and thought why not?

sed -i -e 's/Display::ACCELEROMETER_SUPPORT_/Display::AccelerometerSupport::/g'  `grep -rn "Display::ACCELEROMETER_SUPPORT_" ui ash chrome components extensions | cut -f 1 -d: | uniq`
sed -i -e 's/Display::TOUCH_SUPPORT_/Display::TouchSupport::/g'  `grep -rn "Display::TOUCH_SUPPORT_" ui ash chrome components extensions | cut -f 1 -d: | uniq`
sed -i -e 's/Display::ROTATION_SOURCE_/Display::RotationSource::/g'  `grep -rn "Display::ROTATION_SOURCE_" ui ash chrome components | cut -f 1 -d: | uniq `

Bug: None
Change-Id: Ic470df3b9de4f1b1ea9fbdc218078d6bd4be770e
Reviewed-on: https://chromium-review.googlesource.com/915211
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Mitsuru Oshima (In Tokyo) <oshima@chromium.org>
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537782}
  • Loading branch information
yell0wd0g authored and Commit Bot committed Feb 20, 2018
1 parent 20b0512 commit 8f12ad6
Show file tree
Hide file tree
Showing 35 changed files with 187 additions and 192 deletions.
2 changes: 1 addition & 1 deletion ash/accelerators/accelerator_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ void HandleRotateScreen() {
Shell::Get()->display_manager()->GetDisplayInfo(display.id());
Shell::Get()->display_configuration_controller()->SetDisplayRotation(
display.id(), GetNextRotation(display_info.GetActiveRotation()),
display::Display::ROTATION_SOURCE_USER);
display::Display::RotationSource::USER);
}

void HandleRestoreTab() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ bool UserRotationLocked() {
void SetDisplayRotationById(int64_t display_id,
display::Display::Rotation rotation) {
Shell::Get()->display_manager()->SetDisplayRotation(
display_id, rotation, display::Display::ROTATION_SOURCE_USER);
display_id, rotation, display::Display::RotationSource::USER);
}

void SetInternalDisplayRotation(display::Display::Rotation rotation) {
Expand Down Expand Up @@ -643,7 +643,7 @@ TEST_F(ScreenOrientationControllerTest, RotateInactiveDisplay) {
ScreenOrientationControllerTestApi(
Shell::Get()->screen_orientation_controller())
.SetDisplayRotation(kNewRotation,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);

EXPECT_EQ(kNewRotation, display_manager()
->GetDisplayInfo(kInternalDisplayId)
Expand Down
10 changes: 5 additions & 5 deletions ash/display/display_configuration_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ TEST_F(DisplayConfigurationControllerTest, OnlyHasOneAnimator) {

Shell::Get()->display_manager()->SetDisplayRotation(
display.id(), display::Display::ROTATE_0,
display::Display::RotationSource::ROTATION_SOURCE_USER);
display::Display::RotationSource::USER);
old_screen_rotation_animator->Rotate(
display::Display::ROTATE_90, display::Display::ROTATION_SOURCE_USER,
display::Display::ROTATE_90, display::Display::RotationSource::USER,
DisplayConfigurationController::ANIMATION_SYNC);

ScreenRotationAnimator* new_screen_rotation_animator =
testapi.GetScreenRotationAnimatorForDisplay(display.id());
new_screen_rotation_animator->Rotate(
display::Display::ROTATE_180, display::Display::ROTATION_SOURCE_USER,
display::Display::ROTATE_180, display::Display::RotationSource::USER,
DisplayConfigurationController::ANIMATION_SYNC);
EXPECT_EQ(old_screen_rotation_animator, new_screen_rotation_animator);
}
Expand All @@ -71,7 +71,7 @@ TEST_F(DisplayConfigurationControllerTest, GetTargetRotationWithAnimation) {
DisplayConfigurationControllerTestApi testapi(controller);
controller->SetDisplayRotation(
display.id(), display::Display::ROTATE_180,
display::Display::ROTATION_SOURCE_USER,
display::Display::RotationSource::USER,
DisplayConfigurationController::ANIMATION_ASYNC);
EXPECT_EQ(display::Display::ROTATE_180,
controller->GetTargetRotation(display.id()));
Expand All @@ -86,7 +86,7 @@ TEST_F(DisplayConfigurationControllerSmoothRotationTest,
DisplayConfigurationControllerTestApi testapi(controller);
controller->SetDisplayRotation(
display.id(), display::Display::ROTATE_180,
display::Display::ROTATION_SOURCE_USER,
display::Display::RotationSource::USER,
DisplayConfigurationController::ANIMATION_ASYNC);
EXPECT_EQ(display::Display::ROTATE_180,
controller->GetTargetRotation(display.id()));
Expand Down
32 changes: 16 additions & 16 deletions ash/display/display_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1820,10 +1820,10 @@ TEST_F(DisplayManagerTest, Rotate) {

display_manager()->SetDisplayRotation(internal_display_id,
display::Display::ROTATE_90,
display::Display::ROTATION_SOURCE_USER);
display::Display::RotationSource::USER);
display_manager()->SetDisplayRotation(
internal_display_id, display::Display::ROTATE_0,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);

const display::ManagedDisplayInfo info =
GetDisplayInfoForId(internal_display_id);
Expand All @@ -1842,7 +1842,7 @@ TEST_F(DisplayManagerTest, Rotate) {

display_manager()->SetDisplayRotation(
internal_display_id, display::Display::ROTATE_180,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
const display::ManagedDisplayInfo& post_rotation_info =
display::test::DisplayManagerTestApi(display_manager())
.GetInternalManagedDisplayInfo(internal_display_id);
Expand Down Expand Up @@ -2396,7 +2396,7 @@ TEST_F(DisplayManagerTest, RotateInSoftwareMirroring) {
int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
display_manager()->SetDisplayRotation(
primary_id, display::Display::ROTATE_180,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
SetSoftwareMirrorMode(false);
}

Expand Down Expand Up @@ -2807,11 +2807,11 @@ TEST_F(DisplayManagerTest, NoRotateUnifiedDesktop) {
EXPECT_EQ("1150x500", display.size().ToString());
display_manager()->SetDisplayRotation(
display.id(), display::Display::ROTATE_90,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString());
display_manager()->SetDisplayRotation(
display.id(), display::Display::ROTATE_0,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString());

UpdateDisplay("400x500");
Expand Down Expand Up @@ -3355,9 +3355,9 @@ TEST_F(DisplayManagerTest, CheckInitializationOfRotationProperty) {
display_manager()->GetDisplayInfo(id);

EXPECT_EQ(display::Display::ROTATE_90,
info.GetRotation(display::Display::ROTATION_SOURCE_USER));
info.GetRotation(display::Display::RotationSource::USER));
EXPECT_EQ(display::Display::ROTATE_90,
info.GetRotation(display::Display::ROTATION_SOURCE_ACTIVE));
info.GetRotation(display::Display::RotationSource::ACTIVE));
}

TEST_F(DisplayManagerTest, RejectInvalidLayoutData) {
Expand Down Expand Up @@ -3408,18 +3408,18 @@ TEST_F(DisplayManagerTest, AccelerometerSupport) {
display::test::DisplayManagerTestApi(display_manager())
.SetFirstDisplayAsInternalDisplay();
display::Screen* screen = display::Screen::GetScreen();
EXPECT_EQ(display::Display::ACCELEROMETER_SUPPORT_UNAVAILABLE,
EXPECT_EQ(display::Display::AccelerometerSupport::UNAVAILABLE,
screen->GetPrimaryDisplay().accelerometer_support());

display_manager()->set_internal_display_has_accelerometer(true);
display_manager()->UpdateDisplays();
EXPECT_EQ(display::Display::ACCELEROMETER_SUPPORT_AVAILABLE,
EXPECT_EQ(display::Display::AccelerometerSupport::AVAILABLE,
screen->GetPrimaryDisplay().accelerometer_support());

UpdateDisplay("1000x1000,800x800");
EXPECT_EQ(display::Display::ACCELEROMETER_SUPPORT_AVAILABLE,
EXPECT_EQ(display::Display::AccelerometerSupport::AVAILABLE,
screen->GetPrimaryDisplay().accelerometer_support());
EXPECT_EQ(display::Display::ACCELEROMETER_SUPPORT_UNAVAILABLE,
EXPECT_EQ(display::Display::AccelerometerSupport::UNAVAILABLE,
display_manager()->GetSecondaryDisplay().accelerometer_support());

// Secondary is now primary and should not have accelerometer support.
Expand All @@ -3428,15 +3428,15 @@ TEST_F(DisplayManagerTest, AccelerometerSupport) {
display::CreateDisplayInfo(display_manager()->GetSecondaryDisplay().id(),
gfx::Rect(1, 1, 100, 100)));
display_manager()->OnNativeDisplaysChanged(display_info_list);
EXPECT_EQ(display::Display::ACCELEROMETER_SUPPORT_UNAVAILABLE,
EXPECT_EQ(display::Display::AccelerometerSupport::UNAVAILABLE,
screen->GetPrimaryDisplay().accelerometer_support());

// Re-enable internal display.
display_info_list.clear();
display_info_list.push_back(display::CreateDisplayInfo(
display::Display::InternalDisplayId(), gfx::Rect(1, 1, 100, 100)));
display_manager()->OnNativeDisplaysChanged(display_info_list);
EXPECT_EQ(display::Display::ACCELEROMETER_SUPPORT_AVAILABLE,
EXPECT_EQ(display::Display::AccelerometerSupport::AVAILABLE,
screen->GetPrimaryDisplay().accelerometer_support());
}

Expand Down Expand Up @@ -3693,7 +3693,7 @@ TEST_F(DisplayManagerOrientationTest, SaveRestoreUserRotationLock) {
// Rotate to portrait in clamshell.
configuration_controller->SetDisplayRotation(
screen->GetPrimaryDisplay().id(), display::Display::ROTATE_270,
display::Display::ROTATION_SOURCE_USER);
display::Display::RotationSource::USER);
EXPECT_EQ(display::Display::ROTATE_270,
screen->GetPrimaryDisplay().rotation());
EXPECT_FALSE(display_manager->registered_internal_display_rotation_lock());
Expand Down Expand Up @@ -3893,7 +3893,7 @@ TEST_F(DisplayManagerOrientationTest, DisplayChangeShouldNotSaveUserRotation) {
// Emulate that Animator is calling this async when animation is completed.
display_manager->SetDisplayRotation(
screen->GetPrimaryDisplay().id(), display::Display::ROTATE_90,
display::Display::ROTATION_SOURCE_ACCELEROMETER);
display::Display::RotationSource::ACCELEROMETER);
EXPECT_EQ(display::Display::ROTATE_90,
screen->GetPrimaryDisplay().rotation());

Expand Down
6 changes: 3 additions & 3 deletions ash/display/root_window_transformers_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ TEST_F(RootWindowTransformersTest, RotateAndMagnify) {

display_manager()->SetDisplayRotation(
display1.id(), display::Display::ROTATE_90,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
// Move the cursor to the center of the first root window.
generator1.MoveMouseToInHost(59, 100);

Expand All @@ -199,7 +199,7 @@ TEST_F(RootWindowTransformersTest, RotateAndMagnify) {

display_manager()->SetDisplayRotation(
display2_id, display::Display::ROTATE_270,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
// Move the cursor to the center of the second root window.
generator2.MoveMouseToInHost(151, 199);

Expand All @@ -220,7 +220,7 @@ TEST_F(RootWindowTransformersTest, RotateAndMagnify) {

display_manager()->SetDisplayRotation(
display1.id(), display::Display::ROTATE_180,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
// Move the cursor to the center of the first root window.
generator1.MoveMouseToInHost(59, 99);

Expand Down
14 changes: 7 additions & 7 deletions ash/display/screen_orientation_controller_chromeos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void ScreenOrientationController::UnlockAll() {
SetRotationLockedInternal(false);
if (user_rotation_ != current_rotation_) {
SetDisplayRotation(user_rotation_,
display::Display::ROTATION_SOURCE_ACCELEROMETER,
display::Display::RotationSource::ACCELEROMETER,
DisplayConfigurationController::ANIMATION_SYNC);
}
}
Expand Down Expand Up @@ -341,7 +341,7 @@ void ScreenOrientationController::OnTabletModeEnding() {
// TODO(oshima): Remove if when current_rotation_ is removed.
if (current_rotation_ != user_rotation_) {
SetDisplayRotation(user_rotation_,
display::Display::ROTATION_SOURCE_ACCELEROMETER,
display::Display::RotationSource::ACCELEROMETER,
DisplayConfigurationController::ANIMATION_SYNC);
}
for (auto& observer : observers_)
Expand Down Expand Up @@ -413,12 +413,12 @@ void ScreenOrientationController::LockRotationToOrientation(
case blink::kWebScreenOrientationLockPortraitSecondary:
LockRotation(
OrientationToRotation(natural_orientation_, lock_orientation),
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);

break;
case blink::kWebScreenOrientationLockNatural:
LockRotation(display::Display::ROTATE_0,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
break;
default:
NOTREACHED();
Expand All @@ -442,7 +442,7 @@ void ScreenOrientationController::LockToRotationMatchingOrientation(
SetRotationLockedInternal(true);
} else {
LockRotation(display::Display::ROTATE_0,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
}
} else {
if (rotation == display::Display::ROTATE_90 ||
Expand All @@ -454,7 +454,7 @@ void ScreenOrientationController::LockToRotationMatchingOrientation(
natural_orientation_ == blink::kWebScreenOrientationLockLandscape
? display::Display::ROTATE_270 // portrait in landscape device.
: display::Display::ROTATE_90; // landscape in portrait device.
LockRotation(default_rotation, display::Display::ROTATION_SOURCE_ACTIVE);
LockRotation(default_rotation, display::Display::RotationSource::ACTIVE);
}
}
}
Expand Down Expand Up @@ -507,7 +507,7 @@ void ScreenOrientationController::HandleScreenRotation(
if (new_rotation != current_rotation_ &&
IsRotationAllowedInLockedState(new_rotation)) {
SetDisplayRotation(new_rotation,
display::Display::ROTATION_SOURCE_ACCELEROMETER);
display::Display::RotationSource::ACCELEROMETER);
}
}

Expand Down
12 changes: 6 additions & 6 deletions ash/display/window_tree_host_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ display::ManagedDisplayInfo
CreateDisplayInfo(int64_t id, int y, display::Display::Rotation rotation) {
display::ManagedDisplayInfo info(id, "", false);
info.SetBounds(gfx::Rect(0, y, 500, 500));
info.SetRotation(rotation, display::Display::ROTATION_SOURCE_ACTIVE);
info.SetRotation(rotation, display::Display::RotationSource::ACTIVE);
return info;
}

Expand Down Expand Up @@ -668,14 +668,14 @@ TEST_F(WindowTreeHostManagerTest, BoundsUpdated) {
int64_t primary_id = GetPrimaryDisplay().id();
display_manager()->SetDisplayRotation(
primary_id, display::Display::ROTATE_90,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
EXPECT_EQ(1, observer.GetRotationChangedCountAndReset());
EXPECT_EQ(1, observer.CountAndReset());
EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
display_manager()->SetDisplayRotation(
primary_id, display::Display::ROTATE_90,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
EXPECT_EQ(0, observer.GetRotationChangedCountAndReset());
EXPECT_EQ(0, observer.CountAndReset());
EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
Expand Down Expand Up @@ -1223,7 +1223,7 @@ TEST_F(WindowTreeHostManagerTest, Rotate) {

display_manager()->SetDisplayRotation(
display1.id(), display::Display::ROTATE_90,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString());
EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString());
EXPECT_EQ("200,0 150x200",
Expand All @@ -1243,7 +1243,7 @@ TEST_F(WindowTreeHostManagerTest, Rotate) {

display_manager()->SetDisplayRotation(
display2_id, display::Display::ROTATE_270,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString());
EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString());
EXPECT_EQ("50,120 200x150",
Expand All @@ -1259,7 +1259,7 @@ TEST_F(WindowTreeHostManagerTest, Rotate) {
EXPECT_EQ("180,25", event_handler.GetLocationAndReset());
display_manager()->SetDisplayRotation(
display1.id(), display::Display::ROTATE_180,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);

EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString());
EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString());
Expand Down
18 changes: 9 additions & 9 deletions ash/login/ui/lock_contents_view_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,21 +146,21 @@ TEST_F(LockContentsViewUnitTest, AutoLayoutAfterRotation) {
// Start at 0 degrees (landscape).
display_manager()->SetDisplayRotation(
display.id(), display::Display::ROTATE_0,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
int distance_0deg = calculate_distance();
EXPECT_NE(distance_0deg, 0);

// Rotate the display to 90 degrees (portrait).
display_manager()->SetDisplayRotation(
display.id(), display::Display::ROTATE_90,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
int distance_90deg = calculate_distance();
EXPECT_GT(distance_0deg, distance_90deg);

// Rotate the display back to 0 degrees (landscape).
display_manager()->SetDisplayRotation(
display.id(), display::Display::ROTATE_0,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
int distance_180deg = calculate_distance();
EXPECT_EQ(distance_0deg, distance_180deg);
EXPECT_NE(distance_0deg, distance_90deg);
Expand All @@ -186,19 +186,19 @@ TEST_F(LockContentsViewUnitTest, AutoLayoutExtraSmallUsersListAfterRotation) {
// Start at 0 degrees (landscape).
display_manager()->SetDisplayRotation(
display.id(), display::Display::ROTATE_0,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
EXPECT_EQ(contents->height(), users_list->height());

// Rotate the display to 90 degrees (portrait).
display_manager()->SetDisplayRotation(
display.id(), display::Display::ROTATE_90,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
EXPECT_EQ(contents->height(), users_list->height());

// Rotate the display back to 0 degrees (landscape).
display_manager()->SetDisplayRotation(
display.id(), display::Display::ROTATE_0,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
EXPECT_EQ(contents->height(), users_list->height());
}

Expand Down Expand Up @@ -235,21 +235,21 @@ TEST_F(LockContentsViewUnitTest, AutoLayoutSmallUsersListAfterRotation) {
// Start at 0 degrees (landscape).
display_manager()->SetDisplayRotation(
display.id(), display::Display::ROTATE_0,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
EXPECT_EQ(top_margin(), bottom_margin());
EXPECT_EQ(users_list->height(), users_list->contents()->height());

// Rotate the display to 90 degrees (portrait).
display_manager()->SetDisplayRotation(
display.id(), display::Display::ROTATE_90,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
EXPECT_EQ(top_margin(), bottom_margin());
EXPECT_EQ(users_list->height(), users_list->contents()->height());

// Rotate the display back to 0 degrees (landscape).
display_manager()->SetDisplayRotation(
display.id(), display::Display::ROTATE_0,
display::Display::ROTATION_SOURCE_ACTIVE);
display::Display::RotationSource::ACTIVE);
EXPECT_EQ(top_margin(), bottom_margin());
EXPECT_EQ(users_list->height(), users_list->contents()->height());
}
Expand Down
Loading

0 comments on commit 8f12ad6

Please sign in to comment.