| OLD | NEW |
| 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 <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1616 TestProperty* p3 = new TestProperty(); | 1616 TestProperty* p3 = new TestProperty(); |
| 1617 w->SetProperty(kOwnedKey, p3); | 1617 w->SetProperty(kOwnedKey, p3); |
| 1618 EXPECT_EQ(p3, w->GetProperty(kOwnedKey)); | 1618 EXPECT_EQ(p3, w->GetProperty(kOwnedKey)); |
| 1619 EXPECT_EQ(p2, TestProperty::last_deleted()); | 1619 EXPECT_EQ(p2, TestProperty::last_deleted()); |
| 1620 w.reset(); | 1620 w.reset(); |
| 1621 EXPECT_EQ(p3, TestProperty::last_deleted()); | 1621 EXPECT_EQ(p3, TestProperty::last_deleted()); |
| 1622 } | 1622 } |
| 1623 | 1623 |
| 1624 TEST_F(WindowTest, SetBoundsInternalShouldCheckTargetBounds) { | 1624 TEST_F(WindowTest, SetBoundsInternalShouldCheckTargetBounds) { |
| 1625 // We cannot short-circuit animations in this test. | 1625 // We cannot short-circuit animations in this test. |
| 1626 ui::ScopedAnimationDurationScaleMode normal_duration_mode( | 1626 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
| 1627 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); | 1627 ui::ScopedAnimationDurationScaleMode::TEST_DURATION); |
| 1628 | 1628 |
| 1629 scoped_ptr<Window> w1( | 1629 scoped_ptr<Window> w1( |
| 1630 CreateTestWindowWithBounds(gfx::Rect(0, 0, 100, 100), root_window())); | 1630 CreateTestWindowWithBounds(gfx::Rect(0, 0, 100, 100), root_window())); |
| 1631 | 1631 |
| 1632 EXPECT_FALSE(!w1->layer()); | 1632 EXPECT_FALSE(!w1->layer()); |
| 1633 w1->layer()->GetAnimator()->set_disable_timer_for_test(true); | 1633 w1->layer()->GetAnimator()->set_disable_timer_for_test(true); |
| 1634 ui::LayerAnimator* animator = w1->layer()->GetAnimator(); | 1634 ui::LayerAnimator* animator = w1->layer()->GetAnimator(); |
| 1635 | 1635 |
| 1636 EXPECT_EQ("0,0 100x100", w1->bounds().ToString()); | 1636 EXPECT_EQ("0,0 100x100", w1->bounds().ToString()); |
| 1637 EXPECT_EQ("0,0 100x100", w1->layer()->GetTargetBounds().ToString()); | 1637 EXPECT_EQ("0,0 100x100", w1->layer()->GetTargetBounds().ToString()); |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2235 parent1.SetBounds(gfx::Rect(10, 10, 300, 300)); | 2235 parent1.SetBounds(gfx::Rect(10, 10, 300, 300)); |
| 2236 parent2.SetBounds(gfx::Rect(20, 20, 300, 300)); | 2236 parent2.SetBounds(gfx::Rect(20, 20, 300, 300)); |
| 2237 | 2237 |
| 2238 BoundsChangedWindowObserver observer; | 2238 BoundsChangedWindowObserver observer; |
| 2239 Window child(NULL); | 2239 Window child(NULL); |
| 2240 child.Init(aura::WINDOW_LAYER_NOT_DRAWN); | 2240 child.Init(aura::WINDOW_LAYER_NOT_DRAWN); |
| 2241 child.SetBounds(gfx::Rect(5, 5, 100, 100)); | 2241 child.SetBounds(gfx::Rect(5, 5, 100, 100)); |
| 2242 parent1.AddChild(&child); | 2242 parent1.AddChild(&child); |
| 2243 | 2243 |
| 2244 // We need animations to start in order to observe the bounds changes. | 2244 // We need animations to start in order to observe the bounds changes. |
| 2245 ui::ScopedAnimationDurationScaleMode animation_duration_mode( | 2245 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
| 2246 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); | 2246 ui::ScopedAnimationDurationScaleMode::TEST_DURATION); |
| 2247 ui::ScopedLayerAnimationSettings settings1(child.layer()->GetAnimator()); | 2247 ui::ScopedLayerAnimationSettings settings1(child.layer()->GetAnimator()); |
| 2248 settings1.SetTransitionDuration(base::TimeDelta::FromMilliseconds(100)); | 2248 settings1.SetTransitionDuration(base::TimeDelta::FromMilliseconds(100)); |
| 2249 gfx::Rect new_bounds(gfx::Rect(35, 35, 50, 50)); | 2249 gfx::Rect new_bounds(gfx::Rect(35, 35, 50, 50)); |
| 2250 child.SetBounds(new_bounds); | 2250 child.SetBounds(new_bounds); |
| 2251 | 2251 |
| 2252 child.AddObserver(&observer); | 2252 child.AddObserver(&observer); |
| 2253 | 2253 |
| 2254 // Reparenting the |child| will cause it to get moved. During this move | 2254 // Reparenting the |child| will cause it to get moved. During this move |
| 2255 // the window should still have root window set. | 2255 // the window should still have root window set. |
| 2256 parent2.AddChild(&child); | 2256 parent2.AddChild(&child); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2350 }; | 2350 }; |
| 2351 | 2351 |
| 2352 } // namespace | 2352 } // namespace |
| 2353 | 2353 |
| 2354 // Verifies the delegate is notified when the actual bounds of the layer | 2354 // Verifies the delegate is notified when the actual bounds of the layer |
| 2355 // change. | 2355 // change. |
| 2356 TEST_F(WindowTest, DelegateNotifiedAsBoundsChange) { | 2356 TEST_F(WindowTest, DelegateNotifiedAsBoundsChange) { |
| 2357 BoundsChangeDelegate delegate; | 2357 BoundsChangeDelegate delegate; |
| 2358 | 2358 |
| 2359 // We cannot short-circuit animations in this test. | 2359 // We cannot short-circuit animations in this test. |
| 2360 ui::ScopedAnimationDurationScaleMode normal_duration_mode( | 2360 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
| 2361 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); | 2361 ui::ScopedAnimationDurationScaleMode::TEST_DURATION); |
| 2362 | 2362 |
| 2363 scoped_ptr<Window> window( | 2363 scoped_ptr<Window> window( |
| 2364 CreateTestWindowWithDelegate(&delegate, 1, | 2364 CreateTestWindowWithDelegate(&delegate, 1, |
| 2365 gfx::Rect(0, 0, 100, 100), root_window())); | 2365 gfx::Rect(0, 0, 100, 100), root_window())); |
| 2366 window->layer()->GetAnimator()->set_disable_timer_for_test(true); | 2366 window->layer()->GetAnimator()->set_disable_timer_for_test(true); |
| 2367 | 2367 |
| 2368 delegate.clear_bounds_changed(); | 2368 delegate.clear_bounds_changed(); |
| 2369 | 2369 |
| 2370 // Animate to a different position. | 2370 // Animate to a different position. |
| 2371 { | 2371 { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2385 EXPECT_TRUE(delegate.bounds_changed()); | 2385 EXPECT_TRUE(delegate.bounds_changed()); |
| 2386 EXPECT_NE("0,0 100x100", window->bounds().ToString()); | 2386 EXPECT_NE("0,0 100x100", window->bounds().ToString()); |
| 2387 } | 2387 } |
| 2388 | 2388 |
| 2389 // Verifies the delegate is notified when the actual bounds of the layer | 2389 // Verifies the delegate is notified when the actual bounds of the layer |
| 2390 // change even when the window is not the layer's delegate | 2390 // change even when the window is not the layer's delegate |
| 2391 TEST_F(WindowTest, DelegateNotifiedAsBoundsChangeInHiddenLayer) { | 2391 TEST_F(WindowTest, DelegateNotifiedAsBoundsChangeInHiddenLayer) { |
| 2392 BoundsChangeDelegate delegate; | 2392 BoundsChangeDelegate delegate; |
| 2393 | 2393 |
| 2394 // We cannot short-circuit animations in this test. | 2394 // We cannot short-circuit animations in this test. |
| 2395 ui::ScopedAnimationDurationScaleMode normal_duration_mode( | 2395 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
| 2396 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); | 2396 ui::ScopedAnimationDurationScaleMode::TEST_DURATION); |
| 2397 | 2397 |
| 2398 scoped_ptr<Window> window( | 2398 scoped_ptr<Window> window( |
| 2399 CreateTestWindowWithDelegate(&delegate, 1, | 2399 CreateTestWindowWithDelegate(&delegate, 1, |
| 2400 gfx::Rect(0, 0, 100, 100), root_window())); | 2400 gfx::Rect(0, 0, 100, 100), root_window())); |
| 2401 window->layer()->GetAnimator()->set_disable_timer_for_test(true); | 2401 window->layer()->GetAnimator()->set_disable_timer_for_test(true); |
| 2402 | 2402 |
| 2403 delegate.clear_bounds_changed(); | 2403 delegate.clear_bounds_changed(); |
| 2404 | 2404 |
| 2405 // Suppress paint on the window since it is hidden (should reset the layer's | 2405 // Suppress paint on the window since it is hidden (should reset the layer's |
| 2406 // delegate to NULL) | 2406 // delegate to NULL) |
| (...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3388 | 3388 |
| 3389 bool animation_completed_; | 3389 bool animation_completed_; |
| 3390 bool animation_aborted_; | 3390 bool animation_aborted_; |
| 3391 | 3391 |
| 3392 DISALLOW_COPY_AND_ASSIGN(TestLayerAnimationObserver); | 3392 DISALLOW_COPY_AND_ASSIGN(TestLayerAnimationObserver); |
| 3393 }; | 3393 }; |
| 3394 | 3394 |
| 3395 } | 3395 } |
| 3396 | 3396 |
| 3397 TEST_F(WindowTest, WindowDestroyCompletesAnimations) { | 3397 TEST_F(WindowTest, WindowDestroyCompletesAnimations) { |
| 3398 ui::ScopedAnimationDurationScaleMode normal_duration_mode( | 3398 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
| 3399 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); | 3399 ui::ScopedAnimationDurationScaleMode::TEST_DURATION); |
| 3400 scoped_refptr<ui::LayerAnimator> animator = | 3400 scoped_refptr<ui::LayerAnimator> animator = |
| 3401 ui::LayerAnimator::CreateImplicitAnimator(); | 3401 ui::LayerAnimator::CreateImplicitAnimator(); |
| 3402 TestLayerAnimationObserver observer; | 3402 TestLayerAnimationObserver observer; |
| 3403 animator->AddObserver(&observer); | 3403 animator->AddObserver(&observer); |
| 3404 // Make sure destroying a Window completes the animation. | 3404 // Make sure destroying a Window completes the animation. |
| 3405 { | 3405 { |
| 3406 scoped_ptr<Window> window(CreateTestWindowWithId(1, root_window())); | 3406 scoped_ptr<Window> window(CreateTestWindowWithId(1, root_window())); |
| 3407 window->layer()->SetAnimator(animator); | 3407 window->layer()->SetAnimator(animator); |
| 3408 | 3408 |
| 3409 gfx::Transform transform; | 3409 gfx::Transform transform; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 3438 | 3438 |
| 3439 EXPECT_TRUE(animator); | 3439 EXPECT_TRUE(animator); |
| 3440 EXPECT_FALSE(animator->is_animating()); | 3440 EXPECT_FALSE(animator->is_animating()); |
| 3441 EXPECT_TRUE(observer.animation_completed()); | 3441 EXPECT_TRUE(observer.animation_completed()); |
| 3442 EXPECT_FALSE(observer.animation_aborted()); | 3442 EXPECT_FALSE(observer.animation_aborted()); |
| 3443 animator->RemoveObserver(&observer); | 3443 animator->RemoveObserver(&observer); |
| 3444 } | 3444 } |
| 3445 | 3445 |
| 3446 } // namespace test | 3446 } // namespace test |
| 3447 } // namespace aura | 3447 } // namespace aura |
| OLD | NEW |