Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ash / frame / default_header_painter_unittest.cc
blob276829747b183a76ce173ad46a240194c0870d23
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"
8 #include "ash/shell.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 "grit/ash_resources.h"
13 #include "ui/gfx/font_list.h"
14 #include "ui/views/test/test_views.h"
15 #include "ui/views/widget/widget.h"
16 #include "ui/views/window/non_client_view.h"
18 using ash::HeaderPainter;
19 using views::NonClientFrameView;
20 using views::Widget;
22 namespace ash {
24 class DefaultHeaderPainterTest : public ash::test::AshTestBase {
25 public:
26 // Creates a test widget that owns its native widget.
27 Widget* CreateTestWidget() {
28 Widget* widget = new Widget;
29 Widget::InitParams params;
30 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
31 params.context = CurrentContext();
32 widget->Init(params);
33 return widget;
37 // Ensure the title text is vertically aligned with the window icon.
38 TEST_F(DefaultHeaderPainterTest, TitleIconAlignment) {
39 scoped_ptr<Widget> w(CreateTestWidget());
40 ash::FrameCaptionButtonContainerView container(w.get(),
41 ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED);
42 views::StaticSizedView window_icon(gfx::Size(16, 16));
43 window_icon.SetBounds(0, 0, 16, 16);
44 w->SetBounds(gfx::Rect(0, 0, 500, 500));
45 w->Show();
47 DefaultHeaderPainter painter;
48 painter.Init(w.get(),
49 w->non_client_view()->frame_view(),
50 &container);
51 painter.UpdateLeftHeaderView(&window_icon);
52 painter.LayoutHeader();
53 gfx::Rect title_bounds = painter.GetTitleBounds();
54 EXPECT_EQ(window_icon.bounds().CenterPoint().y(),
55 title_bounds.CenterPoint().y());
58 } // namespace ash