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

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

Issue 1867223004: Convert //ash from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 8 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/frame/default_header_painter.h ('k') | ash/frame/frame_border_hit_test_controller.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 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 "ash/frame/default_header_painter.h" 5 #include "ash/frame/default_header_painter.h"
6 6
7 #include <memory>
8
7 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" 9 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
8 #include "ash/shell.h" 10 #include "ash/shell.h"
9 #include "ash/test/ash_test_base.h" 11 #include "ash/test/ash_test_base.h"
10 #include "ash/wm/window_state.h" 12 #include "ash/wm/window_state.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "ui/gfx/font_list.h" 13 #include "ui/gfx/font_list.h"
13 #include "ui/views/test/test_views.h" 14 #include "ui/views/test/test_views.h"
14 #include "ui/views/widget/widget.h" 15 #include "ui/views/widget/widget.h"
15 #include "ui/views/window/non_client_view.h" 16 #include "ui/views/window/non_client_view.h"
16 17
17 using ash::HeaderPainter; 18 using ash::HeaderPainter;
18 using views::NonClientFrameView; 19 using views::NonClientFrameView;
19 using views::Widget; 20 using views::Widget;
20 21
21 namespace ash { 22 namespace ash {
22 23
23 class DefaultHeaderPainterTest : public ash::test::AshTestBase { 24 class DefaultHeaderPainterTest : public ash::test::AshTestBase {
24 public: 25 public:
25 // Creates a test widget that owns its native widget. 26 // Creates a test widget that owns its native widget.
26 Widget* CreateTestWidget() { 27 Widget* CreateTestWidget() {
27 Widget* widget = new Widget; 28 Widget* widget = new Widget;
28 Widget::InitParams params; 29 Widget::InitParams params;
29 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 30 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
30 params.context = CurrentContext(); 31 params.context = CurrentContext();
31 widget->Init(params); 32 widget->Init(params);
32 return widget; 33 return widget;
33 } 34 }
34 }; 35 };
35 36
36 // Ensure the title text is vertically aligned with the window icon. 37 // Ensure the title text is vertically aligned with the window icon.
37 TEST_F(DefaultHeaderPainterTest, TitleIconAlignment) { 38 TEST_F(DefaultHeaderPainterTest, TitleIconAlignment) {
38 scoped_ptr<Widget> w(CreateTestWidget()); 39 std::unique_ptr<Widget> w(CreateTestWidget());
39 ash::FrameCaptionButtonContainerView container(w.get()); 40 ash::FrameCaptionButtonContainerView container(w.get());
40 views::StaticSizedView window_icon(gfx::Size(16, 16)); 41 views::StaticSizedView window_icon(gfx::Size(16, 16));
41 window_icon.SetBounds(0, 0, 16, 16); 42 window_icon.SetBounds(0, 0, 16, 16);
42 w->SetBounds(gfx::Rect(0, 0, 500, 500)); 43 w->SetBounds(gfx::Rect(0, 0, 500, 500));
43 w->Show(); 44 w->Show();
44 45
45 DefaultHeaderPainter painter; 46 DefaultHeaderPainter painter;
46 painter.Init(w.get(), 47 painter.Init(w.get(),
47 w->non_client_view()->frame_view(), 48 w->non_client_view()->frame_view(),
48 &container); 49 &container);
49 painter.UpdateLeftHeaderView(&window_icon); 50 painter.UpdateLeftHeaderView(&window_icon);
50 painter.LayoutHeader(); 51 painter.LayoutHeader();
51 gfx::Rect title_bounds = painter.GetTitleBounds(); 52 gfx::Rect title_bounds = painter.GetTitleBounds();
52 EXPECT_EQ(window_icon.bounds().CenterPoint().y(), 53 EXPECT_EQ(window_icon.bounds().CenterPoint().y(),
53 title_bounds.CenterPoint().y()); 54 title_bounds.CenterPoint().y());
54 } 55 }
55 56
56 // Ensure the light icons are used when appropriate. 57 // Ensure the light icons are used when appropriate.
57 TEST_F(DefaultHeaderPainterTest, LightIcons) { 58 TEST_F(DefaultHeaderPainterTest, LightIcons) {
58 scoped_ptr<Widget> w(CreateTestWidget()); 59 std::unique_ptr<Widget> w(CreateTestWidget());
59 ash::FrameCaptionButtonContainerView container(w.get()); 60 ash::FrameCaptionButtonContainerView container(w.get());
60 views::StaticSizedView window_icon(gfx::Size(16, 16)); 61 views::StaticSizedView window_icon(gfx::Size(16, 16));
61 window_icon.SetBounds(0, 0, 16, 16); 62 window_icon.SetBounds(0, 0, 16, 16);
62 w->SetBounds(gfx::Rect(0, 0, 500, 500)); 63 w->SetBounds(gfx::Rect(0, 0, 500, 500));
63 w->Show(); 64 w->Show();
64 65
65 DefaultHeaderPainter painter; 66 DefaultHeaderPainter painter;
66 painter.Init(w.get(), w->non_client_view()->frame_view(), &container); 67 painter.Init(w.get(), w->non_client_view()->frame_view(), &container);
67 68
68 // Check by default light icons are not used. 69 // Check by default light icons are not used.
(...skipping 19 matching lines...) Expand all
88 // Check not so light or dark colors. 89 // Check not so light or dark colors.
89 painter.SetFrameColors(SkColorSetRGB(70, 70, 70), 90 painter.SetFrameColors(SkColorSetRGB(70, 70, 70),
90 SkColorSetRGB(200, 200, 200)); 91 SkColorSetRGB(200, 200, 200));
91 painter.mode_ = HeaderPainter::MODE_ACTIVE; 92 painter.mode_ = HeaderPainter::MODE_ACTIVE;
92 EXPECT_TRUE(painter.ShouldUseLightImages()); 93 EXPECT_TRUE(painter.ShouldUseLightImages());
93 painter.mode_ = HeaderPainter::MODE_INACTIVE; 94 painter.mode_ = HeaderPainter::MODE_INACTIVE;
94 EXPECT_FALSE(painter.ShouldUseLightImages()); 95 EXPECT_FALSE(painter.ShouldUseLightImages());
95 } 96 }
96 97
97 } // namespace ash 98 } // namespace ash
OLDNEW
« no previous file with comments | « ash/frame/default_header_painter.h ('k') | ash/frame/frame_border_hit_test_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698