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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 2039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2050 | 2050 |
2051 scoped_ptr<ui::Layer> old_layer(w.RecreateLayer()); | 2051 scoped_ptr<ui::Layer> old_layer(w.RecreateLayer()); |
2052 layer = w.layer(); | 2052 layer = w.layer(); |
2053 EXPECT_EQ(ui::LAYER_SOLID_COLOR, layer->type()); | 2053 EXPECT_EQ(ui::LAYER_SOLID_COLOR, layer->type()); |
2054 EXPECT_FALSE(layer->scale_content()); | 2054 EXPECT_FALSE(layer->scale_content()); |
2055 EXPECT_FALSE(layer->visible()); | 2055 EXPECT_FALSE(layer->visible()); |
2056 EXPECT_EQ(1u, layer->children().size()); | 2056 EXPECT_EQ(1u, layer->children().size()); |
2057 EXPECT_TRUE(layer->GetMasksToBounds()); | 2057 EXPECT_TRUE(layer->GetMasksToBounds()); |
2058 } | 2058 } |
2059 | 2059 |
| 2060 // Verify that RecreateLayer() stacks the old layer above the newly creatd |
| 2061 // layer. |
| 2062 TEST_F(WindowTest, RecreateLayerZOrder) { |
| 2063 scoped_ptr<Window> w( |
| 2064 CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(0, 0, 100, 100), |
| 2065 root_window())); |
| 2066 scoped_ptr<ui::Layer> old_layer(w->RecreateLayer()); |
| 2067 |
| 2068 const std::vector<ui::Layer*>& child_layers = |
| 2069 root_window()->layer()->children(); |
| 2070 ASSERT_EQ(2u, child_layers.size()); |
| 2071 EXPECT_EQ(w->layer(), child_layers[0]); |
| 2072 EXPECT_EQ(old_layer.get(), child_layers[1]); |
| 2073 } |
| 2074 |
2060 // Ensure that acquiring a layer then recreating a layer does not crash | 2075 // Ensure that acquiring a layer then recreating a layer does not crash |
2061 // and that RecreateLayer returns null. | 2076 // and that RecreateLayer returns null. |
2062 TEST_F(WindowTest, AcquireThenRecreateLayer) { | 2077 TEST_F(WindowTest, AcquireThenRecreateLayer) { |
2063 scoped_ptr<Window> w( | 2078 scoped_ptr<Window> w( |
2064 CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(0, 0, 100, 100), | 2079 CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(0, 0, 100, 100), |
2065 root_window())); | 2080 root_window())); |
2066 scoped_ptr<ui::Layer>acquired_layer(w->AcquireLayer()); | 2081 scoped_ptr<ui::Layer>acquired_layer(w->AcquireLayer()); |
2067 scoped_ptr<ui::Layer>doubly_acquired_layer(w->RecreateLayer()); | 2082 scoped_ptr<ui::Layer>doubly_acquired_layer(w->RecreateLayer()); |
2068 EXPECT_EQ(NULL, doubly_acquired_layer.get()); | 2083 EXPECT_EQ(NULL, doubly_acquired_layer.get()); |
2069 | 2084 |
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3017 o.ValidateState(index++, params); | 3032 o.ValidateState(index++, params); |
3018 | 3033 |
3019 w1.reset(); | 3034 w1.reset(); |
3020 w2.reset(); | 3035 w2.reset(); |
3021 } | 3036 } |
3022 | 3037 |
3023 } | 3038 } |
3024 | 3039 |
3025 } // namespace test | 3040 } // namespace test |
3026 } // namespace aura | 3041 } // namespace aura |
OLD | NEW |