Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: ash/wm/shadow_controller_unittest.cc

Issue 9414028: Aura: New window shadows, desktop background debug toggle (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "ash/wm/shadow_controller.h" 5 #include "ash/wm/shadow_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/test/aura_shell_test_base.h" 11 #include "ash/test/aura_shell_test_base.h"
12 #include "ash/wm/shadow.h" 12 #include "ash/wm/shadow.h"
13 #include "ash/wm/shadow_types.h" 13 #include "ash/wm/shadow_types.h"
14 #include "ash/wm/window_properties.h" 14 #include "ash/wm/window_properties.h"
15 #include "ash/wm/window_util.h"
15 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
16 #include "ui/aura/root_window.h" 17 #include "ui/aura/root_window.h"
17 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
18 #include "ui/gfx/compositor/layer.h" 19 #include "ui/gfx/compositor/layer.h"
19 20
20 namespace ash { 21 namespace ash {
21 namespace test { 22 namespace internal {
22 23
23 typedef ash::test::AuraShellTestBase ShadowControllerTest; 24 typedef ash::test::AuraShellTestBase ShadowControllerTest;
24 25
25 // Tests that various methods in Window update the Shadow object as expected. 26 // Tests that various methods in Window update the Shadow object as expected.
26 TEST_F(ShadowControllerTest, Shadow) { 27 TEST_F(ShadowControllerTest, Shadow) {
27 scoped_ptr<aura::Window> window(new aura::Window(NULL)); 28 scoped_ptr<aura::Window> window(new aura::Window(NULL));
28 window->SetType(aura::client::WINDOW_TYPE_NORMAL); 29 window->SetType(aura::client::WINDOW_TYPE_NORMAL);
29 window->Init(ui::Layer::LAYER_TEXTURED); 30 window->Init(ui::Layer::LAYER_TEXTURED);
30 window->SetParent(NULL); 31 window->SetParent(NULL);
31 32
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 EXPECT_EQ(gfx::Rect(kOldBounds.size()).ToString(), 81 EXPECT_EQ(gfx::Rect(kOldBounds.size()).ToString(),
81 shadow->content_bounds().ToString()); 82 shadow->content_bounds().ToString());
82 83
83 // When we change the window's bounds, the shadow's should be updated too. 84 // When we change the window's bounds, the shadow's should be updated too.
84 gfx::Rect kNewBounds(50, 60, 500, 400); 85 gfx::Rect kNewBounds(50, 60, 500, 400);
85 window->SetBounds(kNewBounds); 86 window->SetBounds(kNewBounds);
86 EXPECT_EQ(gfx::Rect(kNewBounds.size()).ToString(), 87 EXPECT_EQ(gfx::Rect(kNewBounds.size()).ToString(),
87 shadow->content_bounds().ToString()); 88 shadow->content_bounds().ToString());
88 } 89 }
89 90
90 } // namespace test 91 // Tests that activating a window changes the shadow style.
92 TEST_F(ShadowControllerTest, ShadowStyle) {
93 ShadowController::TestApi api(
94 ash::Shell::GetInstance()->shadow_controller());
95
96 scoped_ptr<aura::Window> window1(new aura::Window(NULL));
97 window1->SetType(aura::client::WINDOW_TYPE_NORMAL);
98 window1->Init(ui::Layer::LAYER_TEXTURED);
99 window1->SetParent(NULL);
100 window1->SetBounds(gfx::Rect(10, 20, 300, 400));
101 window1->Show();
102 ActivateWindow(window1.get());
103
104 // window1 is active, so style should have active appearance.
105 Shadow* shadow1 = api.GetShadowForWindow(window1.get());
106 ASSERT_TRUE(shadow1 != NULL);
107 EXPECT_EQ(Shadow::STYLE_ACTIVE, shadow1->style());
108
109 // Create another window and activate it.
110 scoped_ptr<aura::Window> window2(new aura::Window(NULL));
111 window2->SetType(aura::client::WINDOW_TYPE_NORMAL);
112 window2->Init(ui::Layer::LAYER_TEXTURED);
113 window2->SetParent(NULL);
114 window2->SetBounds(gfx::Rect(11, 21, 301, 401));
115 window2->Show();
116 ActivateWindow(window2.get());
117
118 // window1 is now inactive, so shadow should go inactive.
119 Shadow* shadow2 = api.GetShadowForWindow(window2.get());
120 ASSERT_TRUE(shadow2 != NULL);
121 EXPECT_EQ(Shadow::STYLE_INACTIVE, shadow1->style());
122 EXPECT_EQ(Shadow::STYLE_ACTIVE, shadow2->style());
123 }
124
125 } // namespace internal
91 } // namespace ash 126 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698