| 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 2213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2224 TEST_F(WindowTest, RootWindowSetWhenReparenting) { | 2224 TEST_F(WindowTest, RootWindowSetWhenReparenting) { |
| 2225 Window parent1(NULL); | 2225 Window parent1(NULL); |
| 2226 parent1.Init(aura::WINDOW_LAYER_NOT_DRAWN); | 2226 parent1.Init(aura::WINDOW_LAYER_NOT_DRAWN); |
| 2227 Window parent2(NULL); | 2227 Window parent2(NULL); |
| 2228 parent2.Init(aura::WINDOW_LAYER_NOT_DRAWN); | 2228 parent2.Init(aura::WINDOW_LAYER_NOT_DRAWN); |
| 2229 ParentWindow(&parent1); | 2229 ParentWindow(&parent1); |
| 2230 ParentWindow(&parent2); | 2230 ParentWindow(&parent2); |
| 2231 parent1.SetBounds(gfx::Rect(10, 10, 300, 300)); | 2231 parent1.SetBounds(gfx::Rect(10, 10, 300, 300)); |
| 2232 parent2.SetBounds(gfx::Rect(20, 20, 300, 300)); | 2232 parent2.SetBounds(gfx::Rect(20, 20, 300, 300)); |
| 2233 | 2233 |
| 2234 BoundsChangedWindowObserver observer; | |
| 2235 Window child(NULL); | 2234 Window child(NULL); |
| 2236 child.Init(aura::WINDOW_LAYER_NOT_DRAWN); | 2235 child.Init(aura::WINDOW_LAYER_NOT_DRAWN); |
| 2237 child.SetBounds(gfx::Rect(5, 5, 100, 100)); | 2236 child.SetBounds(gfx::Rect(5, 5, 100, 100)); |
| 2238 parent1.AddChild(&child); | 2237 parent1.AddChild(&child); |
| 2239 | 2238 |
| 2240 // We need animations to start in order to observe the bounds changes. | 2239 // We need animations to start in order to observe the bounds changes. |
| 2241 ui::ScopedAnimationDurationScaleMode animation_duration_mode( | 2240 ui::ScopedAnimationDurationScaleMode animation_duration_mode( |
| 2242 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); | 2241 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); |
| 2243 ui::ScopedLayerAnimationSettings settings1(child.layer()->GetAnimator()); | 2242 ui::ScopedLayerAnimationSettings settings1(child.layer()->GetAnimator()); |
| 2244 settings1.SetTransitionDuration(base::TimeDelta::FromMilliseconds(100)); | 2243 settings1.SetTransitionDuration(base::TimeDelta::FromMilliseconds(100)); |
| 2245 gfx::Rect new_bounds(gfx::Rect(35, 35, 50, 50)); | 2244 gfx::Rect new_bounds(gfx::Rect(35, 35, 50, 50)); |
| 2246 child.SetBounds(new_bounds); | 2245 child.SetBounds(new_bounds); |
| 2247 | 2246 |
| 2247 BoundsChangedWindowObserver observer; |
| 2248 child.AddObserver(&observer); | 2248 child.AddObserver(&observer); |
| 2249 | 2249 |
| 2250 // Reparenting the |child| will cause it to get moved. During this move | 2250 // Reparenting the |child| will cause it to get moved. During this move |
| 2251 // the window should still have root window set. | 2251 // the window should still have root window set. |
| 2252 parent2.AddChild(&child); | 2252 parent2.AddChild(&child); |
| 2253 EXPECT_TRUE(observer.root_set()); | 2253 EXPECT_TRUE(observer.root_set()); |
| 2254 | 2254 |
| 2255 // Animations should stop and the bounds should be as set before the |child| | 2255 // Animations should stop and the bounds should be as set before the |child| |
| 2256 // got reparented. | 2256 // got reparented. |
| 2257 EXPECT_EQ(new_bounds.ToString(), child.GetTargetBounds().ToString()); | 2257 EXPECT_EQ(new_bounds.ToString(), child.GetTargetBounds().ToString()); |
| (...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3344 BuildRootLayerTreeDescription(*root.layer())) | 3344 BuildRootLayerTreeDescription(*root.layer())) |
| 3345 << "layer tree doesn't match at " << i; | 3345 << "layer tree doesn't match at " << i; |
| 3346 EXPECT_EQ(data[i].expected_description, | 3346 EXPECT_EQ(data[i].expected_description, |
| 3347 BuildRootWindowTreeDescription(root)) | 3347 BuildRootWindowTreeDescription(root)) |
| 3348 << "window tree doesn't match at " << i; | 3348 << "window tree doesn't match at " << i; |
| 3349 } | 3349 } |
| 3350 } | 3350 } |
| 3351 | 3351 |
| 3352 } // namespace test | 3352 } // namespace test |
| 3353 } // namespace aura | 3353 } // namespace aura |
| OLD | NEW |