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.
5 #include "ash/frame/default_header_painter.h"
7 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
9 #include "ash/test/ash_test_base.h"
10 #include "ash/wm/window_state.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "ui/gfx/font_list.h"
13 #include "ui/views/test/test_views.h"
14 #include "ui/views/widget/widget.h"
15 #include "ui/views/window/non_client_view.h"
17 using ash::HeaderPainter
;
18 using views::NonClientFrameView
;
23 class DefaultHeaderPainterTest
: public ash::test::AshTestBase
{
25 // Creates a test widget that owns its native widget.
26 Widget
* CreateTestWidget() {
27 Widget
* widget
= new Widget
;
28 Widget::InitParams params
;
29 params
.ownership
= Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET
;
30 params
.context
= CurrentContext();
36 // Ensure the title text is vertically aligned with the window icon.
37 TEST_F(DefaultHeaderPainterTest
, TitleIconAlignment
) {
38 scoped_ptr
<Widget
> w(CreateTestWidget());
39 ash::FrameCaptionButtonContainerView
container(w
.get());
40 views::StaticSizedView
window_icon(gfx::Size(16, 16));
41 window_icon
.SetBounds(0, 0, 16, 16);
42 w
->SetBounds(gfx::Rect(0, 0, 500, 500));
45 DefaultHeaderPainter painter
;
47 w
->non_client_view()->frame_view(),
49 painter
.UpdateLeftHeaderView(&window_icon
);
50 painter
.LayoutHeader();
51 gfx::Rect title_bounds
= painter
.GetTitleBounds();
52 EXPECT_EQ(window_icon
.bounds().CenterPoint().y(),
53 title_bounds
.CenterPoint().y());