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/wm/core/shadow_controller.h" | 5 #include "ui/wm/core/shadow_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "ui/aura/client/aura_constants.h" |
11 #include "ui/aura/client/window_tree_client.h" | 12 #include "ui/aura/client/window_tree_client.h" |
12 #include "ui/aura/test/aura_test_base.h" | 13 #include "ui/aura/test/aura_test_base.h" |
13 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
14 #include "ui/aura/window_event_dispatcher.h" | 15 #include "ui/aura/window_event_dispatcher.h" |
15 #include "ui/compositor/layer.h" | 16 #include "ui/compositor/layer.h" |
16 #include "ui/wm/core/default_activation_client.h" | 17 #include "ui/wm/core/default_activation_client.h" |
17 #include "ui/wm/core/shadow.h" | 18 #include "ui/wm/core/shadow.h" |
18 #include "ui/wm/core/shadow_types.h" | 19 #include "ui/wm/core/shadow_types.h" |
19 #include "ui/wm/core/window_util.h" | 20 #include "ui/wm/core/window_util.h" |
20 #include "ui/wm/core/wm_state.h" | 21 #include "ui/wm/core/wm_state.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 window2->Show(); | 148 window2->Show(); |
148 ActivateWindow(window2.get()); | 149 ActivateWindow(window2.get()); |
149 | 150 |
150 // window1 is now inactive, so shadow should go inactive. | 151 // window1 is now inactive, so shadow should go inactive. |
151 Shadow* shadow2 = api.GetShadowForWindow(window2.get()); | 152 Shadow* shadow2 = api.GetShadowForWindow(window2.get()); |
152 ASSERT_TRUE(shadow2 != NULL); | 153 ASSERT_TRUE(shadow2 != NULL); |
153 EXPECT_EQ(Shadow::STYLE_INACTIVE, shadow1->style()); | 154 EXPECT_EQ(Shadow::STYLE_INACTIVE, shadow1->style()); |
154 EXPECT_EQ(Shadow::STYLE_ACTIVE, shadow2->style()); | 155 EXPECT_EQ(Shadow::STYLE_ACTIVE, shadow2->style()); |
155 } | 156 } |
156 | 157 |
| 158 // Tests that shadow gets updated when the window show state chagnes. |
| 159 TEST_F(ShadowControllerTest, ShowState) { |
| 160 ShadowController::TestApi api(shadow_controller()); |
| 161 |
| 162 scoped_ptr<aura::Window> window(new aura::Window(NULL)); |
| 163 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| 164 window->Init(aura::WINDOW_LAYER_TEXTURED); |
| 165 ParentWindow(window.get()); |
| 166 window->Show(); |
| 167 |
| 168 Shadow* shadow = api.GetShadowForWindow(window.get()); |
| 169 ASSERT_TRUE(shadow != NULL); |
| 170 EXPECT_EQ(Shadow::STYLE_INACTIVE, shadow->style()); |
| 171 |
| 172 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 173 EXPECT_FALSE(shadow->layer()->visible()); |
| 174 |
| 175 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 176 EXPECT_TRUE(shadow->layer()->visible()); |
| 177 |
| 178 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 179 EXPECT_FALSE(shadow->layer()->visible()); |
| 180 } |
| 181 |
157 // Tests that we use smaller shadows for tooltips and menus. | 182 // Tests that we use smaller shadows for tooltips and menus. |
158 TEST_F(ShadowControllerTest, SmallShadowsForTooltipsAndMenus) { | 183 TEST_F(ShadowControllerTest, SmallShadowsForTooltipsAndMenus) { |
159 ShadowController::TestApi api(shadow_controller()); | 184 ShadowController::TestApi api(shadow_controller()); |
160 | 185 |
161 scoped_ptr<aura::Window> tooltip_window(new aura::Window(NULL)); | 186 scoped_ptr<aura::Window> tooltip_window(new aura::Window(NULL)); |
162 tooltip_window->SetType(ui::wm::WINDOW_TYPE_TOOLTIP); | 187 tooltip_window->SetType(ui::wm::WINDOW_TYPE_TOOLTIP); |
163 tooltip_window->Init(aura::WINDOW_LAYER_TEXTURED); | 188 tooltip_window->Init(aura::WINDOW_LAYER_TEXTURED); |
164 ParentWindow(tooltip_window.get()); | 189 ParentWindow(tooltip_window.get()); |
165 tooltip_window->SetBounds(gfx::Rect(10, 20, 300, 400)); | 190 tooltip_window->SetBounds(gfx::Rect(10, 20, 300, 400)); |
166 tooltip_window->Show(); | 191 tooltip_window->Show(); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 // gets the inactive shadow. | 289 // gets the inactive shadow. |
265 SetShadowType(window1.get(), SHADOW_TYPE_RECTANGULAR); | 290 SetShadowType(window1.get(), SHADOW_TYPE_RECTANGULAR); |
266 SetShadowType(window2.get(), SHADOW_TYPE_RECTANGULAR); | 291 SetShadowType(window2.get(), SHADOW_TYPE_RECTANGULAR); |
267 EXPECT_EQ(Shadow::STYLE_ACTIVE, | 292 EXPECT_EQ(Shadow::STYLE_ACTIVE, |
268 api.GetShadowForWindow(window1.get())->style()); | 293 api.GetShadowForWindow(window1.get())->style()); |
269 EXPECT_EQ(Shadow::STYLE_INACTIVE, | 294 EXPECT_EQ(Shadow::STYLE_INACTIVE, |
270 api.GetShadowForWindow(window2.get())->style()); | 295 api.GetShadowForWindow(window2.get())->style()); |
271 } | 296 } |
272 | 297 |
273 } // namespace wm | 298 } // namespace wm |
OLD | NEW |