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