This source file includes following definitions.
- CreateTestWidget
- TEST_F
#include "ash/frame/default_header_painter.h"
#include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/window_state.h"
#include "base/memory/scoped_ptr.h"
#include "grit/ash_resources.h"
#include "ui/gfx/font_list.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/non_client_view.h"
using ash::HeaderPainter;
using views::NonClientFrameView;
using views::Widget;
namespace ash {
class DefaultHeaderPainterTest : public ash::test::AshTestBase {
public:
Widget* CreateTestWidget() {
Widget* widget = new Widget;
Widget::InitParams params;
params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.context = CurrentContext();
widget->Init(params);
return widget;
}
};
TEST_F(DefaultHeaderPainterTest, TitleIconAlignment) {
scoped_ptr<Widget> w(CreateTestWidget());
ash::FrameCaptionButtonContainerView container(w.get(),
ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED);
views::View window_icon;
window_icon.SetBounds(0, 0, 16, 16);
w->SetBounds(gfx::Rect(0, 0, 500, 500));
w->Show();
DefaultHeaderPainter painter;
painter.Init(w.get(),
w->non_client_view()->frame_view(),
&window_icon,
&container);
painter.LayoutHeader();
gfx::Rect title_bounds = painter.GetTitleBounds();
EXPECT_EQ(window_icon.bounds().CenterPoint().y(),
title_bounds.CenterPoint().y());
}
}