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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/window.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/aura/window.h" 5 #include "ui/aura/window.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 2195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2206 2206
2207 // Animate to the end, which should notify of the change. 2207 // Animate to the end, which should notify of the change.
2208 base::TimeTicks start_time = 2208 base::TimeTicks start_time =
2209 window->layer()->GetAnimator()->last_step_time(); 2209 window->layer()->GetAnimator()->last_step_time();
2210 ui::AnimationContainerElement* element = window->layer()->GetAnimator(); 2210 ui::AnimationContainerElement* element = window->layer()->GetAnimator();
2211 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); 2211 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
2212 EXPECT_TRUE(delegate.bounds_changed()); 2212 EXPECT_TRUE(delegate.bounds_changed());
2213 EXPECT_NE("0,0 100x100", window->bounds().ToString()); 2213 EXPECT_NE("0,0 100x100", window->bounds().ToString());
2214 } 2214 }
2215 2215
2216 // Verifies the delegate is notified when the actual bounds of the layer
2217 // change even when the window is not the layer's delegate
2218 TEST_F(WindowTest, DelegateNotifiedAsBoundsChangeInHiddenLayer) {
2219 BoundsChangeDelegate delegate;
2220
2221 // We cannot short-circuit animations in this test.
2222 ui::LayerAnimator::set_disable_animations_for_test(false);
2223
2224 scoped_ptr<Window> window(
2225 CreateTestWindowWithDelegate(&delegate, 1,
2226 gfx::Rect(0, 0, 100, 100), NULL));
2227 window->layer()->GetAnimator()->set_disable_timer_for_test(true);
2228
2229 delegate.clear_bounds_changed();
2230
2231 // Suppress paint on the window since it is hidden (should reset the layer's
2232 // delegate to NULL)
2233 window->SuppressPaint();
2234 EXPECT_EQ(NULL, window->layer()->delegate());
2235
2236 // Animate to a different position.
2237 {
2238 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
2239 window->SetBounds(gfx::Rect(100, 100, 110, 100));
2240 }
2241
2242 // Layer delegate is NULL but we should still get bounds changed notification.
2243 EXPECT_EQ("100,100 110x100", window->GetTargetBounds().ToString());
2244 EXPECT_TRUE(delegate.bounds_changed());
2245
2246 delegate.clear_bounds_changed();
2247
2248 // Animate to the end: will *not* notify of the change since we are hidden.
2249 base::TimeTicks start_time =
2250 window->layer()->GetAnimator()->last_step_time();
2251 ui::AnimationContainerElement* element = window->layer()->GetAnimator();
2252 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
2253
2254 // No bounds changed notification at the end of animation since layer
2255 // delegate is NULL.
2256 EXPECT_FALSE(delegate.bounds_changed());
2257 EXPECT_NE("0,0 100x100", window->bounds().ToString());
2258 }
2259
2216 } // namespace test 2260 } // namespace test
2217 } // namespace aura 2261 } // namespace aura
OLDNEW
« 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