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

Side by Side Diff: ui/wm/core/shadow_unittest.cc

Issue 2596743002: Replace WM shadow types (on/off) and styles (small/inactive/active) (Closed)
Patch Set: one more mechanical change Created 3 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
« no previous file with comments | « ui/wm/core/shadow_types.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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.h" 5 #include "ui/wm/core/shadow.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "ui/aura/test/aura_test_base.h" 8 #include "ui/aura/test/aura_test_base.h"
9 #include "ui/wm/core/shadow_types.h"
9 10
10 namespace wm { 11 namespace wm {
11 namespace { 12 namespace {
12 13
13 gfx::Insets InsetsForElevation(int elevation) { 14 gfx::Insets InsetsForElevation(int elevation) {
14 return -gfx::Insets(2 * elevation) + gfx::Insets(elevation, 0, -elevation, 0); 15 return -gfx::Insets(2 * elevation) + gfx::Insets(elevation, 0, -elevation, 0);
15 } 16 }
16 17
17 using ShadowTest = aura::test::AuraTestBase; 18 using ShadowTest = aura::test::AuraTestBase;
18 19
19 // Test if the proper content bounds is calculated based on the current style. 20 // Test if the proper content bounds is calculated based on the current style.
20 TEST_F(ShadowTest, SetContentBounds) { 21 TEST_F(ShadowTest, SetContentBounds) {
21 // Verify that layer bounds are outset from content bounds. 22 // Verify that layer bounds are outset from content bounds.
22 Shadow shadow; 23 Shadow shadow;
23 { 24 {
24 shadow.Init(Shadow::STYLE_ACTIVE); 25 shadow.Init(ShadowElevation::LARGE);
25 gfx::Rect content_bounds(100, 100, 300, 300); 26 gfx::Rect content_bounds(100, 100, 300, 300);
26 shadow.SetContentBounds(content_bounds); 27 shadow.SetContentBounds(content_bounds);
27 EXPECT_EQ(content_bounds, shadow.content_bounds()); 28 EXPECT_EQ(content_bounds, shadow.content_bounds());
28 gfx::Rect shadow_bounds(content_bounds); 29 gfx::Rect shadow_bounds(content_bounds);
29 shadow_bounds.Inset(InsetsForElevation(24)); 30 shadow_bounds.Inset(InsetsForElevation(24));
30 EXPECT_EQ(shadow_bounds, shadow.layer()->bounds()); 31 EXPECT_EQ(shadow_bounds, shadow.layer()->bounds());
31 } 32 }
32 33
33 { 34 {
34 shadow.SetStyle(Shadow::STYLE_SMALL); 35 shadow.SetElevation(ShadowElevation::SMALL);
35 gfx::Rect content_bounds(100, 100, 300, 300); 36 gfx::Rect content_bounds(100, 100, 300, 300);
36 shadow.SetContentBounds(content_bounds); 37 shadow.SetContentBounds(content_bounds);
37 EXPECT_EQ(content_bounds, shadow.content_bounds()); 38 EXPECT_EQ(content_bounds, shadow.content_bounds());
38 gfx::Rect shadow_bounds(content_bounds); 39 gfx::Rect shadow_bounds(content_bounds);
39 shadow_bounds.Inset(InsetsForElevation(6)); 40 shadow_bounds.Inset(InsetsForElevation(6));
40 EXPECT_EQ(shadow_bounds, shadow.layer()->bounds()); 41 EXPECT_EQ(shadow_bounds, shadow.layer()->bounds());
41 } 42 }
42 } 43 }
43 44
44 // Test that the elevation is reduced when the contents are too small to handle 45 // Test that the elevation is reduced when the contents are too small to handle
45 // the full elevation. 46 // the full elevation.
46 TEST_F(ShadowTest, AdjustElevationForSmallContents) { 47 TEST_F(ShadowTest, AdjustElevationForSmallContents) {
47 Shadow shadow; 48 Shadow shadow;
48 shadow.Init(Shadow::STYLE_ACTIVE); 49 shadow.Init(ShadowElevation::LARGE);
49 { 50 {
50 gfx::Rect content_bounds(100, 100, 300, 300); 51 gfx::Rect content_bounds(100, 100, 300, 300);
51 shadow.SetContentBounds(content_bounds); 52 shadow.SetContentBounds(content_bounds);
52 gfx::Rect shadow_bounds(content_bounds); 53 gfx::Rect shadow_bounds(content_bounds);
53 shadow_bounds.Inset(InsetsForElevation(24)); 54 shadow_bounds.Inset(InsetsForElevation(24));
54 EXPECT_EQ(shadow_bounds, shadow.layer()->bounds()); 55 EXPECT_EQ(shadow_bounds, shadow.layer()->bounds());
55 } 56 }
56 57
57 { 58 {
58 constexpr int kWidth = 80; 59 constexpr int kWidth = 80;
59 gfx::Rect content_bounds(100, 100, kWidth, 300); 60 gfx::Rect content_bounds(100, 100, kWidth, 300);
60 shadow.SetContentBounds(content_bounds); 61 shadow.SetContentBounds(content_bounds);
61 gfx::Rect shadow_bounds(content_bounds); 62 gfx::Rect shadow_bounds(content_bounds);
62 shadow_bounds.Inset(InsetsForElevation((kWidth - 4) / 4)); 63 shadow_bounds.Inset(InsetsForElevation((kWidth - 4) / 4));
63 EXPECT_EQ(shadow_bounds, shadow.layer()->bounds()); 64 EXPECT_EQ(shadow_bounds, shadow.layer()->bounds());
64 } 65 }
65 66
66 { 67 {
67 constexpr int kHeight = 80; 68 constexpr int kHeight = 80;
68 gfx::Rect content_bounds(100, 100, 300, kHeight); 69 gfx::Rect content_bounds(100, 100, 300, kHeight);
69 shadow.SetContentBounds(content_bounds); 70 shadow.SetContentBounds(content_bounds);
70 gfx::Rect shadow_bounds(content_bounds); 71 gfx::Rect shadow_bounds(content_bounds);
71 shadow_bounds.Inset(InsetsForElevation((kHeight - 4) / 4)); 72 shadow_bounds.Inset(InsetsForElevation((kHeight - 4) / 4));
72 EXPECT_EQ(shadow_bounds, shadow.layer()->bounds()); 73 EXPECT_EQ(shadow_bounds, shadow.layer()->bounds());
73 } 74 }
74 } 75 }
75 76
76 } // namespace 77 } // namespace
77 } // namespace wm 78 } // namespace wm
OLDNEW
« no previous file with comments | « ui/wm/core/shadow_types.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698