Commit bfce8ff1 authored by Manu Cornet's avatar Manu Cornet Committed by Commit Bot

CrOS Desks: Add unit test to check shelf animation

Bug: 1021691, 1017435, 1019531
Change-Id: I62368e4167a747227007543118d1a0ed2bf9ffbe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1905746Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Manu Cornet <manucornet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713997}
parent 4d12d8d8
......@@ -10,7 +10,10 @@
#include "ash/public/cpp/event_rewriter_controller.h"
#include "ash/public/cpp/multi_user_window_manager.h"
#include "ash/public/cpp/multi_user_window_manager_delegate.h"
#include "ash/public/cpp/shelf_types.h"
#include "ash/screen_util.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shell.h"
#include "ash/sticky_keys/sticky_keys_controller.h"
#include "ash/style/ash_color_provider.h"
......@@ -43,12 +46,14 @@
#include "ash/wm/workspace_controller.h"
#include "base/stl_util.h"
#include "base/test/scoped_feature_list.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/session_manager/session_manager_types.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/window_parenting_client.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/base/ui_base_types.h"
#include "ui/chromeos/events/event_rewriter_chromeos.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/compositor_extra/shadow.h"
#include "ui/display/display.h"
#include "ui/display/test/display_manager_test_api.h"
......@@ -2042,6 +2047,48 @@ TEST_F(DesksTest, MiniViewsTouchGestures) {
EXPECT_TRUE(controller->desks()[0]->is_active());
}
TEST_F(DesksTest, AutohiddenShelfAnimatesAfterDeskSwitch) {
Shelf* shelf = GetPrimaryShelf();
ShelfWidget* shelf_widget = shelf->shelf_widget();
const gfx::Rect shown_shelf_bounds = shelf_widget->GetWindowBoundsInScreen();
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
// Enable animations so that we can make sure that they occur.
ui::ScopedAnimationDurationScaleMode regular_animations(
ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
NewDesk();
// Create a window on the first desk so that the shelf will auto-hide there.
std::unique_ptr<views::Widget> widget = CreateTestWidget();
widget->Maximize();
// LayoutShelf() forces the animation to completion, at which point the
// shelf should go off the screen.
shelf->shelf_layout_manager()->LayoutShelf();
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
const gfx::Rect hidden_shelf_bounds = shelf_widget->GetWindowBoundsInScreen();
EXPECT_NE(shown_shelf_bounds, hidden_shelf_bounds);
// Go to the second desk.
ActivateDesk(DesksController::Get()->desks()[1].get());
// The shelf should now want to show itself, but as the shelf animation is
// just starting, it should still be hidden. If this fails, the change was
// not animated.
EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
EXPECT_EQ(shelf_widget->GetWindowBoundsInScreen(), hidden_shelf_bounds);
// Let's wait until the shelf animates to a fully shown state.
while (shelf_widget->GetWindowBoundsInScreen() != shown_shelf_bounds) {
base::RunLoop run_loop;
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, run_loop.QuitClosure(),
base::TimeDelta::FromMilliseconds(200));
run_loop.Run();
}
EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
}
class DesksWithSplitViewTest : public AshTestBase {
public:
DesksWithSplitViewTest() = default;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment