Commit fd59990b authored by Alex Newcomer's avatar Alex Newcomer Committed by Commit Bot

cros: Prevent double animation of the hotseat when going to overview

Check for the sys tray when checking if an event is within the shelf
window. Also added a test.
TEST=automated

Bug: 1006032
Change-Id: I1e36b8d4ce761d7cebce8c0e5f312ea881ec23e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1825485
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Reviewed-by: default avatarManu Cornet <manucornet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700330}
parent ad9b79d8
...@@ -1743,9 +1743,12 @@ bool ShelfLayoutManager::IsShelfWindow(aura::Window* window) { ...@@ -1743,9 +1743,12 @@ bool ShelfLayoutManager::IsShelfWindow(aura::Window* window) {
shelf_widget_->navigation_widget()->GetNativeWindow(); shelf_widget_->navigation_widget()->GetNativeWindow();
const aura::Window* hotseat_window = const aura::Window* hotseat_window =
shelf_widget_->hotseat_widget()->GetNativeWindow(); shelf_widget_->hotseat_widget()->GetNativeWindow();
const aura::Window* status_area_window =
shelf_widget_->status_area_widget()->GetNativeWindow();
return (shelf_window && shelf_window->Contains(window)) || return (shelf_window && shelf_window->Contains(window)) ||
(navigation_window && navigation_window->Contains(window)) || (navigation_window && navigation_window->Contains(window)) ||
(hotseat_window && hotseat_window->Contains(window)); (hotseat_window && hotseat_window->Contains(window)) ||
(status_area_window && status_area_window->Contains(window));
} }
bool ShelfLayoutManager::IsStatusAreaWindow(aura::Window* window) { bool ShelfLayoutManager::IsStatusAreaWindow(aura::Window* window) {
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "ash/shelf/shelf_view_test_api.h" #include "ash/shelf/shelf_view_test_api.h"
#include "ash/shelf/shelf_widget.h" #include "ash/shelf/shelf_widget.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/system/overview/overview_button_tray.h"
#include "ash/system/status_area_widget.h" #include "ash/system/status_area_widget.h"
#include "ash/system/status_area_widget_test_helper.h" #include "ash/system/status_area_widget_test_helper.h"
#include "ash/system/unified/unified_system_tray.h" #include "ash/system/unified/unified_system_tray.h"
...@@ -3188,6 +3189,31 @@ class HotseatShelfLayoutManagerTest ...@@ -3188,6 +3189,31 @@ class HotseatShelfLayoutManagerTest
DISALLOW_COPY_AND_ASSIGN(HotseatShelfLayoutManagerTest); DISALLOW_COPY_AND_ASSIGN(HotseatShelfLayoutManagerTest);
}; };
// Records HotseatState transitions.
class HotseatStateWatcher : public ShelfLayoutManagerObserver {
public:
HotseatStateWatcher(ShelfLayoutManager* shelf_layout_manager)
: shelf_layout_manager_(shelf_layout_manager) {
shelf_layout_manager_->AddObserver(this);
}
~HotseatStateWatcher() override {
shelf_layout_manager_->RemoveObserver(this);
}
void OnHotseatStateChanged(HotseatState state) override {
state_changes_.push_back(state);
}
void CheckEqual(std::vector<HotseatState> state_changes) {
EXPECT_EQ(state_changes_, state_changes);
}
private:
ShelfLayoutManager* shelf_layout_manager_;
std::vector<HotseatState> state_changes_;
DISALLOW_COPY_AND_ASSIGN(HotseatStateWatcher);
};
// Used to test autohide and always shown shelf. // Used to test autohide and always shown shelf.
INSTANTIATE_TEST_SUITE_P(, INSTANTIATE_TEST_SUITE_P(,
HotseatShelfLayoutManagerTest, HotseatShelfLayoutManagerTest,
...@@ -3445,6 +3471,31 @@ TEST_P(HotseatShelfLayoutManagerTest, ReleasingSlowDragAboveThreshold) { ...@@ -3445,6 +3471,31 @@ TEST_P(HotseatShelfLayoutManagerTest, ReleasingSlowDragAboveThreshold) {
EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, GetPrimaryShelf()->GetAutoHideState()); EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, GetPrimaryShelf()->GetAutoHideState());
} }
// Tests that showing overview after showing the hotseat results in only one
// animation, to |kShown|.
TEST_P(HotseatShelfLayoutManagerTest, ShowingOverviewFromShownAnimatesOnce) {
GetPrimaryShelf()->SetAutoHideBehavior(GetParam());
TabletModeControllerTestApi().EnterTabletMode();
std::unique_ptr<aura::Window> window =
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
wm::ActivateWindow(window.get());
std::unique_ptr<HotseatStateWatcher> state_watcher_ =
std::make_unique<HotseatStateWatcher>(GetShelfLayoutManager());
SwipeUpOnShelf();
ASSERT_EQ(HotseatState::kExtended, GetShelfLayoutManager()->hotseat_state());
const gfx::Point overview_button_center = GetPrimaryShelf()
->shelf_widget()
->status_area_widget()
->overview_button_tray()
->GetBoundsInScreen()
.CenterPoint();
GetEventGenerator()->GestureTapAt(overview_button_center);
state_watcher_->CheckEqual({HotseatState::kExtended, HotseatState::kShown});
}
class ShelfLayoutManagerKeyboardTest : public AshTestBase { class ShelfLayoutManagerKeyboardTest : public AshTestBase {
public: public:
ShelfLayoutManagerKeyboardTest() = default; ShelfLayoutManagerKeyboardTest() = 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