Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Unified Diff: ash/wm/overview/window_selector_unittest.cc

Issue 2337383003: [ash-md] Corrects a crash when a window is destroyed after leaving overview (Closed)
Patch Set: [ash-md] Corrects a crash when a window is destroyed after leaving overview Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/wm/overview/window_selector_item.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/overview/window_selector_unittest.cc
diff --git a/ash/wm/overview/window_selector_unittest.cc b/ash/wm/overview/window_selector_unittest.cc
index 9042d0eaddbee8c86c176ccbb45c84e2a53f063e..e58d821634b54f45580dabaf216846ee76de5990 100644
--- a/ash/wm/overview/window_selector_unittest.cc
+++ b/ash/wm/overview/window_selector_unittest.cc
@@ -60,6 +60,7 @@
#include "ui/display/manager/display_layout.h"
#include "ui/events/event_utils.h"
#include "ui/events/test/event_generator.h"
+#include "ui/gfx/animation/slide_animation.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/safe_integer_conversions.h"
@@ -273,6 +274,13 @@ class WindowSelectorTest
return *iter;
}
+ gfx::SlideAnimation* GetBackgroundViewAnimationForWindow(
+ int grid_index,
+ aura::Window* window) {
+ return GetWindowItemForWindow(grid_index, window)
+ ->GetBackgroundViewAnimation();
+ }
+
// Selects |window| in the active overview session by cycling through all
// windows in overview until it is found. Returns true if |window| was found,
// false otherwise.
@@ -1286,6 +1294,38 @@ TEST_P(WindowSelectorTest, DISABLED_MinimizedWindowVisibility) {
}
}
+// Tests that it is safe to destroy a window while the overview header animation
+// is still active. See http://crbug.com/646350.
+TEST_P(WindowSelectorTest, SafeToDestroyWindowDuringAnimation) {
+ gfx::Rect bounds(0, 0, 400, 400);
+ {
+ // Quickly enter and exit overview mode to activate header animations.
+ std::unique_ptr<aura::Window> window(CreateWindow(bounds));
+ ui::ScopedAnimationDurationScaleMode test_duration_mode(
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
+ ToggleOverview();
+ EXPECT_TRUE(IsSelecting());
+
+ gfx::SlideAnimation* animation =
+ GetBackgroundViewAnimationForWindow(0, window.get());
+ if (ash::MaterialDesignController::IsOverviewMaterial())
+ ASSERT_TRUE(!!animation);
sky 2016/09/15 03:01:00 Double negatives are hard to read. ASSERT_NE(nullp
varkha 2016/09/15 03:54:18 Done.
+ ToggleOverview();
+ EXPECT_FALSE(IsSelecting());
+ if (animation)
+ EXPECT_TRUE(animation->is_animating());
+
+ // Close the window while the overview header animation is active.
+ window.reset();
+
+ // Progress animation to the end - should not crash.
+ if (animation) {
+ animation->SetCurrentValue(1.0);
+ animation->Reset(1.0);
+ }
+ }
+}
+
// Tests that a bounds change during overview is corrected for.
TEST_P(WindowSelectorTest, BoundsChangeDuringOverview) {
std::unique_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 400, 400)));
« no previous file with comments | « ash/common/wm/overview/window_selector_item.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698