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