Move render_view_context_menu.* and related files out of tab_contents.
[chromium-blink-merge.git] / ash / wm / custom_frame_view_ash_unittest.cc
blob97d37f19e60ac4617c0ed2c95264bda235a62b87
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"
15 namespace ash {
17 namespace {
19 // A views::WidgetDelegate which uses a CustomFrameViewAsh.
20 class TestWidgetDelegate : public views::WidgetDelegateView {
21 public:
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_;
37 private:
38 // Not owned.
39 CustomFrameViewAsh* custom_frame_view_;
41 DISALLOW_COPY_AND_ASSIGN(TestWidgetDelegate);
44 } // namespace
46 typedef test::AshTestBase CustomFrameViewAshTest;
48 // Test that the height of the header is correct upon initially displaying
49 // the widget.
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();
59 widget->Init(params);
60 widget->Show();
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
67 // header_painter.cc
68 // TODO(pkotwicz): Clean this test up once the separator overlays the window
69 // controls.
70 const int kSeparatorSize = 1;
72 // The header should have enough room for the window controls and the
73 // separator line.
74 EXPECT_EQ(close_button->height() + kSeparatorSize,
75 delegate->custom_frame_view()->GetHeaderView()->height());
77 widget->Maximize();
78 EXPECT_EQ(close_button->height() + kSeparatorSize,
79 delegate->custom_frame_view()->GetHeaderView()->height());
82 } // namespace ash