| 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" |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 window2->SetBounds(gfx::Rect(11, 21, 301, 401)); | 234 window2->SetBounds(gfx::Rect(11, 21, 301, 401)); |
| 235 AddTransientChild(window1.get(), window2.get()); | 235 AddTransientChild(window1.get(), window2.get()); |
| 236 aura::client::SetHideOnDeactivate(window2.get(), true); | 236 aura::client::SetHideOnDeactivate(window2.get(), true); |
| 237 window2->Show(); | 237 window2->Show(); |
| 238 ActivateWindow(window2.get()); | 238 ActivateWindow(window2.get()); |
| 239 | 239 |
| 240 // window1 is now inactive, but its shadow should still appear active. | 240 // window1 is now inactive, but its shadow should still appear active. |
| 241 EXPECT_EQ(Shadow::STYLE_ACTIVE, shadow1->style()); | 241 EXPECT_EQ(Shadow::STYLE_ACTIVE, shadow1->style()); |
| 242 } | 242 } |
| 243 | 243 |
| 244 TEST_F(ShadowControllerTest, AlwaysActive) { | |
| 245 ShadowController::TestApi api(shadow_controller()); | |
| 246 | |
| 247 scoped_ptr<aura::Window> window1(new aura::Window(NULL)); | |
| 248 window1->SetType(ui::wm::WINDOW_TYPE_NORMAL); | |
| 249 window1->Init(aura::WINDOW_LAYER_TEXTURED); | |
| 250 ParentWindow(window1.get()); | |
| 251 window1->SetBounds(gfx::Rect(10, 20, 300, 400)); | |
| 252 SetShadowType(window1.get(), SHADOW_TYPE_RECTANGULAR_ALWAYS_ACTIVE); | |
| 253 window1->Show(); | |
| 254 | |
| 255 // Showing the window with SHADOW_TYPE_RECTANGULAR_ALWAYS_ACTIVE should | |
| 256 // have active shadow. | |
| 257 EXPECT_EQ(Shadow::STYLE_ACTIVE, | |
| 258 api.GetShadowForWindow(window1.get())->style()); | |
| 259 | |
| 260 scoped_ptr<aura::Window> window2(new aura::Window(NULL)); | |
| 261 window2->SetType(ui::wm::WINDOW_TYPE_NORMAL); | |
| 262 window2->Init(aura::WINDOW_LAYER_TEXTURED); | |
| 263 ParentWindow(window2.get()); | |
| 264 window2->SetBounds(gfx::Rect(11, 21, 301, 401)); | |
| 265 window2->Show(); | |
| 266 | |
| 267 // Setting SHADOW_TYPE_RECTANGULAR_ALWAYS_ACTIVE to the visible window | |
| 268 // should set the active shadow. | |
| 269 EXPECT_EQ(Shadow::STYLE_INACTIVE, | |
| 270 api.GetShadowForWindow(window2.get())->style()); | |
| 271 SetShadowType(window2.get(), SHADOW_TYPE_RECTANGULAR_ALWAYS_ACTIVE); | |
| 272 EXPECT_EQ(Shadow::STYLE_ACTIVE, | |
| 273 api.GetShadowForWindow(window2.get())->style()); | |
| 274 | |
| 275 // Activation should not change the shadow style. | |
| 276 ActivateWindow(window2.get()); | |
| 277 EXPECT_EQ(Shadow::STYLE_ACTIVE, | |
| 278 api.GetShadowForWindow(window1.get())->style()); | |
| 279 EXPECT_EQ(Shadow::STYLE_ACTIVE, | |
| 280 api.GetShadowForWindow(window2.get())->style()); | |
| 281 | |
| 282 ActivateWindow(window1.get()); | |
| 283 EXPECT_EQ(Shadow::STYLE_ACTIVE, | |
| 284 api.GetShadowForWindow(window1.get())->style()); | |
| 285 EXPECT_EQ(Shadow::STYLE_ACTIVE, | |
| 286 api.GetShadowForWindow(window2.get())->style()); | |
| 287 | |
| 288 // Restore the style to plain RECTANGULAR and make sure the inactive window | |
| 289 // gets the inactive shadow. | |
| 290 SetShadowType(window1.get(), SHADOW_TYPE_RECTANGULAR); | |
| 291 SetShadowType(window2.get(), SHADOW_TYPE_RECTANGULAR); | |
| 292 EXPECT_EQ(Shadow::STYLE_ACTIVE, | |
| 293 api.GetShadowForWindow(window1.get())->style()); | |
| 294 EXPECT_EQ(Shadow::STYLE_INACTIVE, | |
| 295 api.GetShadowForWindow(window2.get())->style()); | |
| 296 } | |
| 297 | |
| 298 } // namespace wm | 244 } // namespace wm |
| OLD | NEW |