diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-19 16:47:44 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-19 16:47:44 +0000 |
commit | f9b7eeab4dd12df02205de7a76daf295ff3d125b (patch) | |
tree | ba833190024bc63cd3592ab1ebc61390ab5a81e6 /ui/wm | |
parent | bf9c2b1de590fe21c106afab5e01e4b96dcfdc11 (diff) | |
download | chromium_src-f9b7eeab4dd12df02205de7a76daf295ff3d125b.zip chromium_src-f9b7eeab4dd12df02205de7a76daf295ff3d125b.tar.gz chromium_src-f9b7eeab4dd12df02205de7a76daf295ff3d125b.tar.bz2 |
Reset owner upon acquisition
BUG=351463
TEST=WindowTest.AcquireLayer, WindowUtilTest.RecreaetLayers
Review URL: https://codereview.chromium.org/202163003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258004 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/wm')
-rw-r--r-- | ui/wm/core/window_util_unittest.cc | 52 | ||||
-rw-r--r-- | ui/wm/wm.gyp | 1 |
2 files changed, 53 insertions, 0 deletions
diff --git a/ui/wm/core/window_util_unittest.cc b/ui/wm/core/window_util_unittest.cc new file mode 100644 index 0000000..bcbf3e5 --- /dev/null +++ b/ui/wm/core/window_util_unittest.cc @@ -0,0 +1,52 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/wm/core/window_util.h" + +#include "base/memory/scoped_ptr.h" +#include "ui/aura/test/aura_test_base.h" +#include "ui/aura/test/test_windows.h" +#include "ui/aura/window.h" +#include "ui/compositor/layer.h" +#include "ui/compositor/layer_tree_owner.h" + +namespace wm { + +typedef aura::test::AuraTestBase WindowUtilTest; + +// Test if the recreate layers does not recreate layers that have +// already been acquired. +TEST_F(WindowUtilTest, RecreateLayers) { + scoped_ptr<aura::Window> window1( + aura::test::CreateTestWindowWithId(0, NULL)); + window1->SetName("1"); + scoped_ptr<aura::Window> window11( + aura::test::CreateTestWindowWithId(1, window1.get())); + window11->SetName("11"); + scoped_ptr<aura::Window> window12( + aura::test::CreateTestWindowWithId(2, window1.get())); + window12->SetName("12"); + + ASSERT_EQ(2u, window1->layer()->children().size()); + EXPECT_EQ("11 1", window1->layer()->children()[0]->name()); + EXPECT_EQ("12 2", window1->layer()->children()[1]->name()); + + scoped_ptr<ui::Layer> acquired(window11->AcquireLayer()); + EXPECT_TRUE(acquired.get()); + EXPECT_EQ(acquired.get(), window11->layer()); + + scoped_ptr<ui::LayerTreeOwner> tree = + wm::RecreateLayers(window1.get()); + + // The detached layer should not have the layer that has + // already been detached. + ASSERT_EQ(1u, tree->root()->children().size()); + EXPECT_EQ("12 2", tree->root()->children()[0]->name()); + + // The original window should have both. + ASSERT_EQ(2u, window1->layer()->children().size()); + EXPECT_EQ("11 1", window1->layer()->children()[0]->name()); + EXPECT_EQ("12 2", window1->layer()->children()[1]->name()); +} +} // namespace wm diff --git a/ui/wm/wm.gyp b/ui/wm/wm.gyp index 9e7a308..a1960ec 100644 --- a/ui/wm/wm.gyp +++ b/ui/wm/wm.gyp @@ -130,6 +130,7 @@ 'core/transient_window_stacking_client_unittest.cc', 'core/visibility_controller_unittest.cc', 'core/window_animations_unittest.cc', + 'core/window_util_unittest.cc', ], }, ], |