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

Side by Side Diff: ui/aura/window_unittest.cc

Issue 241983003: Stops animations when removing a window from its parent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Stops animations when removing a window from its parent (comment) Created 6 years, 8 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
« ui/aura/window.cc ('K') | « 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 <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 2226 matching lines...) Expand 10 before | Expand all | Expand 10 after
2237 Window child(NULL); 2237 Window child(NULL);
2238 child.Init(aura::WINDOW_LAYER_NOT_DRAWN); 2238 child.Init(aura::WINDOW_LAYER_NOT_DRAWN);
2239 child.SetBounds(gfx::Rect(5, 5, 100, 100)); 2239 child.SetBounds(gfx::Rect(5, 5, 100, 100));
2240 parent1.AddChild(&child); 2240 parent1.AddChild(&child);
2241 2241
2242 // We need animations to start in order to observe the bounds changes. 2242 // We need animations to start in order to observe the bounds changes.
2243 ui::ScopedAnimationDurationScaleMode animation_duration_mode( 2243 ui::ScopedAnimationDurationScaleMode animation_duration_mode(
2244 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); 2244 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
2245 ui::ScopedLayerAnimationSettings settings1(child.layer()->GetAnimator()); 2245 ui::ScopedLayerAnimationSettings settings1(child.layer()->GetAnimator());
2246 settings1.SetTransitionDuration(base::TimeDelta::FromMilliseconds(100)); 2246 settings1.SetTransitionDuration(base::TimeDelta::FromMilliseconds(100));
2247 child.SetBounds(gfx::Rect(35, 35, 100, 100)); 2247 gfx::Rect new_bounds(gfx::Rect(35, 35, 50, 50));
2248 child.SetBounds(new_bounds);
2248 2249
2249 BoundsChangedWindowObserver observer; 2250 BoundsChangedWindowObserver observer;
2250 child.AddObserver(&observer); 2251 child.AddObserver(&observer);
2251 2252
2252 // Reparenting the |child| will cause it to get moved. During this move 2253 // Reparenting the |child| will cause it to get moved. During this move
2253 // the window should still have root window set. 2254 // the window should still have root window set.
2254 parent2.AddChild(&child); 2255 parent2.AddChild(&child);
2255 EXPECT_TRUE(observer.root_set()); 2256 EXPECT_TRUE(observer.root_set());
2256 2257
2257 // TODO(varkha): Check that the target bounds didn't change after reparenting. 2258 // Animations should stop and the bounds should be as set before the |child|
2259 // got reparented.
2260 EXPECT_EQ(new_bounds.ToString(), child.GetTargetBounds().ToString());
2261 EXPECT_EQ(new_bounds.ToString(), child.bounds().ToString());
2262 EXPECT_EQ("55,55 50x50", child.GetBoundsInRootWindow().ToString());
2258 } 2263 }
2259 2264
2260 TEST_F(WindowTest, OwnedByParentFalse) { 2265 TEST_F(WindowTest, OwnedByParentFalse) {
2261 // By default, a window is owned by its parent. If this is set to false, the 2266 // By default, a window is owned by its parent. If this is set to false, the
2262 // window will not be destroyed when its parent is. 2267 // window will not be destroyed when its parent is.
2263 2268
2264 scoped_ptr<Window> w1(new Window(NULL)); 2269 scoped_ptr<Window> w1(new Window(NULL));
2265 w1->Init(aura::WINDOW_LAYER_NOT_DRAWN); 2270 w1->Init(aura::WINDOW_LAYER_NOT_DRAWN);
2266 scoped_ptr<Window> w2(new Window(NULL)); 2271 scoped_ptr<Window> w2(new Window(NULL));
2267 w2->set_owned_by_parent(false); 2272 w2->set_owned_by_parent(false);
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
3342 BuildRootLayerTreeDescription(*root.layer())) 3347 BuildRootLayerTreeDescription(*root.layer()))
3343 << "layer tree doesn't match at " << i; 3348 << "layer tree doesn't match at " << i;
3344 EXPECT_EQ(data[i].expected_description, 3349 EXPECT_EQ(data[i].expected_description,
3345 BuildRootWindowTreeDescription(root)) 3350 BuildRootWindowTreeDescription(root))
3346 << "window tree doesn't match at " << i; 3351 << "window tree doesn't match at " << i;
3347 } 3352 }
3348 } 3353 }
3349 3354
3350 } // namespace test 3355 } // namespace test
3351 } // namespace aura 3356 } // namespace aura
OLDNEW
« ui/aura/window.cc ('K') | « ui/aura/window.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698