Commit 2502230c authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

splitview: Fix animation not showing up when exiting overview.

[1] changed overview to release overview session and then pass that
object to its observers. Splitview was querying overview controller
for overview session which would be null, so it wouldnt remove the snap
window from overview list, which would cause its animation to be
supressed.

This cl change splitview to remove the window in OnOverviewEnded and
use the overview session object before snapping.

[1]: https://chromium-review.googlesource.com/c/chromium/src/+/1406169

Test: manual
Bug: 929658
Change-Id: Iabab38034bea49cdafd1a3ad24310298ca8826de
Reviewed-on: https://chromium-review.googlesource.com/c/1459066Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#630106}
parent 5beff680
......@@ -247,6 +247,8 @@ class ASH_EXPORT OverviewSession : public display::DisplayObserver,
return grid_list_;
}
size_t num_items_for_testing() const { return num_items_; }
// display::DisplayObserver:
void OnDisplayRemoved(const display::Display& display) override;
void OnDisplayMetricsChanged(const display::Display& display,
......
......@@ -728,6 +728,12 @@ void SplitViewController::OnOverviewModeEnding(
for (const auto& overview_item : windows) {
aura::Window* window = overview_item->GetWindow();
if (CanSnapInSplitview(window) && window != GetDefaultSnappedWindow()) {
// Remove the overview item before snapping because the overview session
// is unavailable to retrieve outside this function after
// OnOverviewEnding is notified.
overview_item->RestoreWindow(/*reset_transform=*/false);
overview_session->RemoveOverviewItem(overview_item.get(),
/*reposition=*/false);
SnapWindow(window, (default_snap_position_ == LEFT) ? RIGHT : LEFT);
// If ending overview causes a window to snap, also do not do exiting
// overview animation.
......
......@@ -32,7 +32,7 @@ class Layer;
} // namespace ui
namespace ash {
class OverviewSession;
class SplitViewControllerTest;
class SplitViewDivider;
class SplitViewOverviewSessionTest;
......
......@@ -1788,6 +1788,52 @@ TEST_F(SplitViewControllerTest, PinnedWindowDisallowsSplitView) {
EXPECT_FALSE(ShouldAllowSplitView());
}
// TestShellObserver which tracks how many overview items there are when
// overview mode is about to end.
class TestOverviewItemsOnOverviewModeEndObserver : public ShellObserver {
public:
TestOverviewItemsOnOverviewModeEndObserver() {
Shell::Get()->AddShellObserver(this);
}
~TestOverviewItemsOnOverviewModeEndObserver() override {
Shell::Get()->RemoveShellObserver(this);
}
void OnOverviewModeEnding(OverviewSession* overview_session) override {
items_on_last_overview_end_ = overview_session->num_items_for_testing();
}
int items_on_last_overview_end() const { return items_on_last_overview_end_; }
private:
int items_on_last_overview_end_ = 0;
DISALLOW_COPY_AND_ASSIGN(TestOverviewItemsOnOverviewModeEndObserver);
};
TEST_F(SplitViewControllerTest, ItemsRemovedFromOverviewOnSnap) {
const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
ToggleOverview();
ASSERT_EQ(2u, Shell::Get()
->overview_controller()
->overview_session()
->num_items_for_testing());
split_view_controller()->SnapWindow(window1.get(), SplitViewController::LEFT);
ASSERT_TRUE(Shell::Get()->overview_controller()->IsSelecting());
EXPECT_EQ(1u, Shell::Get()
->overview_controller()
->overview_session()
->num_items_for_testing());
// Create |observer| after splitview is entered so that it gets notified after
// splitview does, and so will notice the changes splitview made to overview
// on overview end.
TestOverviewItemsOnOverviewModeEndObserver observer;
ToggleOverview();
EXPECT_EQ(0, observer.items_on_last_overview_end());
}
// Test the tab-dragging related functionalities in tablet mode. Tab(s) can be
// dragged out of a window and then put in split view mode or merge into another
// window.
......
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