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

Unified Diff: ui/aura/window_unittest.cc

Issue 10545140: aura: Window should notify WindowDelegate of bounds changed if Layer cannot. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 8 years, 6 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 | « ui/aura/window.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/window_unittest.cc
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
index 722d7dd3731b868a3010ce8a6b027372bac36ebc..ab150fe4c0dd0b2c4b5a024dcc9fc20f12ec11d0 100644
--- a/ui/aura/window_unittest.cc
+++ b/ui/aura/window_unittest.cc
@@ -2213,5 +2213,49 @@ TEST_F(WindowTest, DelegateNotifiedAsBoundsChange) {
EXPECT_NE("0,0 100x100", window->bounds().ToString());
}
+// Verifies the delegate is notified when the actual bounds of the layer
+// change even when the window is not the layer's delegate
+TEST_F(WindowTest, DelegateNotifiedAsBoundsChangeInHiddenLayer) {
+ BoundsChangeDelegate delegate;
+
+ // We cannot short-circuit animations in this test.
+ ui::LayerAnimator::set_disable_animations_for_test(false);
+
+ scoped_ptr<Window> window(
+ CreateTestWindowWithDelegate(&delegate, 1,
+ gfx::Rect(0, 0, 100, 100), NULL));
+ window->layer()->GetAnimator()->set_disable_timer_for_test(true);
+
+ delegate.clear_bounds_changed();
+
+ // Suppress paint on the window since it is hidden (should reset the layer's
+ // delegate to NULL)
+ window->SuppressPaint();
+ EXPECT_EQ(NULL, window->layer()->delegate());
+
+ // Animate to a different position.
+ {
+ ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
+ window->SetBounds(gfx::Rect(100, 100, 110, 100));
+ }
+
+ // Layer delegate is NULL but we should still get bounds changed notification.
+ EXPECT_EQ("100,100 110x100", window->GetTargetBounds().ToString());
+ EXPECT_TRUE(delegate.bounds_changed());
+
+ delegate.clear_bounds_changed();
+
+ // Animate to the end: will *not* notify of the change since we are hidden.
+ base::TimeTicks start_time =
+ window->layer()->GetAnimator()->last_step_time();
+ ui::AnimationContainerElement* element = window->layer()->GetAnimator();
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
+
+ // No bounds changed notification at the end of animation since layer
+ // delegate is NULL.
+ EXPECT_FALSE(delegate.bounds_changed());
+ EXPECT_NE("0,0 100x100", window->bounds().ToString());
+}
+
} // namespace test
} // namespace aura
« no previous file with comments | « ui/aura/window.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698