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/wm/custom_frame_view_ash.h"
7 #include "ash/test/ash_test_base.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "grit/ash_resources.h"
10 #include "ui/base/resource/resource_bundle.h"
11 #include "ui/gfx/image/image_skia.h"
12 #include "ui/views/widget/widget.h"
13 #include "ui/views/widget/widget_delegate.h"
19 // A views::WidgetDelegate which uses a CustomFrameViewAsh.
20 class TestWidgetDelegate
: public views::WidgetDelegateView
{
22 TestWidgetDelegate() {
24 virtual ~TestWidgetDelegate() {
27 virtual views::NonClientFrameView
* CreateNonClientFrameView(
28 views::Widget
* widget
) OVERRIDE
{
29 custom_frame_view_
= new CustomFrameViewAsh(widget
);
30 return custom_frame_view_
;
33 CustomFrameViewAsh
* custom_frame_view() {
34 return custom_frame_view_
;
39 CustomFrameViewAsh
* custom_frame_view_
;
41 DISALLOW_COPY_AND_ASSIGN(TestWidgetDelegate
);
46 typedef test::AshTestBase CustomFrameViewAshTest
;
48 // Test that the height of the header is correct upon initially displaying
50 TEST_F(CustomFrameViewAshTest
, HeaderHeight
) {
51 TestWidgetDelegate
* delegate
= new TestWidgetDelegate
;
53 scoped_ptr
<views::Widget
> widget(new views::Widget
);
54 views::Widget::InitParams params
;
55 params
.delegate
= delegate
;
56 params
.ownership
= views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET
;
57 params
.bounds
= gfx::Rect(0, 0, 100, 100);
58 params
.context
= CurrentContext();
62 ui::ResourceBundle
& rb
= ui::ResourceBundle::GetSharedInstance();
63 gfx::ImageSkia
* close_button
=
64 rb
.GetImageSkiaNamed(IDR_AURA_WINDOW_CONTROL_BACKGROUND_H
);
66 // |kSeparatorSize| should match |kHeaderContentSeparatorSize| in
68 // TODO(pkotwicz): Clean this test up once the separator overlays the window
70 const int kSeparatorSize
= 1;
72 // The header should have enough room for the window controls and the
74 EXPECT_EQ(close_button
->height() + kSeparatorSize
,
75 delegate
->custom_frame_view()->GetHeaderView()->height());
78 EXPECT_EQ(close_button
->height() + kSeparatorSize
,
79 delegate
->custom_frame_view()->GetHeaderView()->height());