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

Side by Side Diff: ash/common/frame/default_header_painter_unittest.cc

Issue 2734653002: chromeos: Move files in //ash/common to //ash (Closed)
Patch Set: fix a11y tests, fix docs Created 3 years, 9 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 | « ash/common/frame/default_header_painter.cc ('k') | ash/common/frame/frame_border_hit_test.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/common/frame/default_header_painter.h"
6
7 #include <memory>
8
9 #include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h "
10 #include "ash/public/cpp/shell_window_ids.h"
11 #include "ash/test/ash_test_base.h"
12 #include "ui/views/test/test_views.h"
13 #include "ui/views/widget/widget.h"
14 #include "ui/views/window/non_client_view.h"
15
16 using ash::HeaderPainter;
17 using views::NonClientFrameView;
18 using views::Widget;
19
20 namespace ash {
21
22 using DefaultHeaderPainterTest = test::AshTestBase;
23
24 // Ensure the title text is vertically aligned with the window icon.
25 TEST_F(DefaultHeaderPainterTest, TitleIconAlignment) {
26 std::unique_ptr<Widget> w = CreateTestWidget(
27 nullptr, kShellWindowId_DefaultContainer, gfx::Rect(1, 2, 3, 4));
28 ash::FrameCaptionButtonContainerView container(w.get());
29 views::StaticSizedView window_icon(gfx::Size(16, 16));
30 window_icon.SetBounds(0, 0, 16, 16);
31 w->SetBounds(gfx::Rect(0, 0, 500, 500));
32 w->Show();
33
34 DefaultHeaderPainter painter;
35 painter.Init(w.get(), w->non_client_view()->frame_view(), &container);
36 painter.UpdateLeftHeaderView(&window_icon);
37 painter.LayoutHeader();
38 gfx::Rect title_bounds = painter.GetTitleBounds();
39 EXPECT_EQ(window_icon.bounds().CenterPoint().y(),
40 title_bounds.CenterPoint().y());
41 }
42
43 // Ensure the light icons are used when appropriate.
44 TEST_F(DefaultHeaderPainterTest, LightIcons) {
45 std::unique_ptr<Widget> w = CreateTestWidget(
46 nullptr, kShellWindowId_DefaultContainer, gfx::Rect(1, 2, 3, 4));
47 ash::FrameCaptionButtonContainerView container(w.get());
48 views::StaticSizedView window_icon(gfx::Size(16, 16));
49 window_icon.SetBounds(0, 0, 16, 16);
50 w->SetBounds(gfx::Rect(0, 0, 500, 500));
51 w->Show();
52
53 DefaultHeaderPainter painter;
54 painter.Init(w.get(), w->non_client_view()->frame_view(), &container);
55
56 // Check by default light icons are not used.
57 painter.mode_ = HeaderPainter::MODE_ACTIVE;
58 EXPECT_FALSE(painter.ShouldUseLightImages());
59 painter.mode_ = HeaderPainter::MODE_INACTIVE;
60 EXPECT_FALSE(painter.ShouldUseLightImages());
61
62 // Check that setting dark colors should use light icons.
63 painter.SetFrameColors(SkColorSetRGB(0, 0, 0), SkColorSetRGB(0, 0, 0));
64 painter.mode_ = HeaderPainter::MODE_ACTIVE;
65 EXPECT_TRUE(painter.ShouldUseLightImages());
66 painter.mode_ = HeaderPainter::MODE_INACTIVE;
67 EXPECT_TRUE(painter.ShouldUseLightImages());
68
69 // Check that inactive and active colors are used properly.
70 painter.SetFrameColors(SkColorSetRGB(0, 0, 0), SkColorSetRGB(255, 255, 255));
71 painter.mode_ = HeaderPainter::MODE_ACTIVE;
72 EXPECT_TRUE(painter.ShouldUseLightImages());
73 painter.mode_ = HeaderPainter::MODE_INACTIVE;
74 EXPECT_FALSE(painter.ShouldUseLightImages());
75
76 // Check not so light or dark colors.
77 painter.SetFrameColors(SkColorSetRGB(70, 70, 70),
78 SkColorSetRGB(200, 200, 200));
79 painter.mode_ = HeaderPainter::MODE_ACTIVE;
80 EXPECT_TRUE(painter.ShouldUseLightImages());
81 painter.mode_ = HeaderPainter::MODE_INACTIVE;
82 EXPECT_FALSE(painter.ShouldUseLightImages());
83 }
84
85 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/frame/default_header_painter.cc ('k') | ash/common/frame/frame_border_hit_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698