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

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

Issue 9289036: aura: Add Layer::LAYER_SOLID_COLOR to compositor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update WorkspaceManagerTest Created 8 years, 11 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
« no previous file with comments | « ash/wm/power_button_controller.cc ('k') | ash/wm/toplevel_layout_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "ui/aura/root_window.h" 16 #include "ui/aura/root_window.h"
17 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
18 #include "ui/gfx/compositor/layer.h" 18 #include "ui/gfx/compositor/layer.h"
19 19
20 namespace ash { 20 namespace ash {
21 namespace test { 21 namespace test {
22 22
23 typedef ash::test::AuraShellTestBase ShadowControllerTest; 23 typedef ash::test::AuraShellTestBase ShadowControllerTest;
24 24
25 // Tests that various methods in Window update the Shadow object as expected. 25 // Tests that various methods in Window update the Shadow object as expected.
26 TEST_F(ShadowControllerTest, Shadow) { 26 TEST_F(ShadowControllerTest, Shadow) {
27 scoped_ptr<aura::Window> window(new aura::Window(NULL)); 27 scoped_ptr<aura::Window> window(new aura::Window(NULL));
28 window->SetType(aura::client::WINDOW_TYPE_NORMAL); 28 window->SetType(aura::client::WINDOW_TYPE_NORMAL);
29 window->Init(ui::Layer::LAYER_HAS_TEXTURE); 29 window->Init(ui::Layer::LAYER_TEXTURED);
30 window->SetParent(NULL); 30 window->SetParent(NULL);
31 31
32 // We should create the shadow before the window is visible (the shadow's 32 // We should create the shadow before the window is visible (the shadow's
33 // layer won't get drawn yet since it's a child of the window's layer). 33 // layer won't get drawn yet since it's a child of the window's layer).
34 internal::ShadowController::TestApi api( 34 internal::ShadowController::TestApi api(
35 ash::Shell::GetInstance()->shadow_controller()); 35 ash::Shell::GetInstance()->shadow_controller());
36 const internal::Shadow* shadow = api.GetShadowForWindow(window.get()); 36 const internal::Shadow* shadow = api.GetShadowForWindow(window.get());
37 ASSERT_TRUE(shadow != NULL); 37 ASSERT_TRUE(shadow != NULL);
38 EXPECT_TRUE(shadow->layer()->visible()); 38 EXPECT_TRUE(shadow->layer()->visible());
39 39
(...skipping 16 matching lines...) Expand all
56 window->parent()->RemoveChild(window.get()); 56 window->parent()->RemoveChild(window.get());
57 aura::Window* window_ptr = window.get(); 57 aura::Window* window_ptr = window.get();
58 window.reset(); 58 window.reset();
59 EXPECT_TRUE(api.GetShadowForWindow(window_ptr) == NULL); 59 EXPECT_TRUE(api.GetShadowForWindow(window_ptr) == NULL);
60 } 60 }
61 61
62 // Tests that the window's shadow's bounds are updated correctly. 62 // Tests that the window's shadow's bounds are updated correctly.
63 TEST_F(ShadowControllerTest, ShadowBounds) { 63 TEST_F(ShadowControllerTest, ShadowBounds) {
64 scoped_ptr<aura::Window> window(new aura::Window(NULL)); 64 scoped_ptr<aura::Window> window(new aura::Window(NULL));
65 window->SetType(aura::client::WINDOW_TYPE_NORMAL); 65 window->SetType(aura::client::WINDOW_TYPE_NORMAL);
66 window->Init(ui::Layer::LAYER_HAS_TEXTURE); 66 window->Init(ui::Layer::LAYER_TEXTURED);
67 window->SetParent(NULL); 67 window->SetParent(NULL);
68 window->Show(); 68 window->Show();
69 69
70 const gfx::Rect kOldBounds(20, 30, 400, 300); 70 const gfx::Rect kOldBounds(20, 30, 400, 300);
71 window->SetBounds(kOldBounds); 71 window->SetBounds(kOldBounds);
72 72
73 // When the shadow is first created, it should use the window's size (but 73 // When the shadow is first created, it should use the window's size (but
74 // remain at the origin, since it's a child of the window's layer). 74 // remain at the origin, since it's a child of the window's layer).
75 internal::SetShadowType(window.get(), internal::SHADOW_TYPE_RECTANGULAR); 75 internal::SetShadowType(window.get(), internal::SHADOW_TYPE_RECTANGULAR);
76 internal::ShadowController::TestApi api( 76 internal::ShadowController::TestApi api(
77 ash::Shell::GetInstance()->shadow_controller()); 77 ash::Shell::GetInstance()->shadow_controller());
78 const internal::Shadow* shadow = api.GetShadowForWindow(window.get()); 78 const internal::Shadow* shadow = api.GetShadowForWindow(window.get());
79 ASSERT_TRUE(shadow != NULL); 79 ASSERT_TRUE(shadow != NULL);
80 EXPECT_EQ(gfx::Rect(kOldBounds.size()).ToString(), 80 EXPECT_EQ(gfx::Rect(kOldBounds.size()).ToString(),
81 shadow->content_bounds().ToString()); 81 shadow->content_bounds().ToString());
82 82
83 // When we change the window's bounds, the shadow's should be updated too. 83 // When we change the window's bounds, the shadow's should be updated too.
84 gfx::Rect kNewBounds(50, 60, 500, 400); 84 gfx::Rect kNewBounds(50, 60, 500, 400);
85 window->SetBounds(kNewBounds); 85 window->SetBounds(kNewBounds);
86 EXPECT_EQ(gfx::Rect(kNewBounds.size()).ToString(), 86 EXPECT_EQ(gfx::Rect(kNewBounds.size()).ToString(),
87 shadow->content_bounds().ToString()); 87 shadow->content_bounds().ToString());
88 } 88 }
89 89
90 } // namespace test 90 } // namespace test
91 } // namespace ash 91 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/power_button_controller.cc ('k') | ash/wm/toplevel_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698