1 // Copyright 2013 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 #ifndef UI_VIEWS_TEST_TEST_VIEWS_H_
6 #define UI_VIEWS_TEST_TEST_VIEWS_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "ui/events/event_constants.h"
10 #include "ui/views/view.h"
14 // A view that requests a set amount of space.
15 class StaticSizedView
: public View
{
17 explicit StaticSizedView(const gfx::Size
& size
);
18 ~StaticSizedView() override
;
20 gfx::Size
GetPreferredSize() const override
;
25 DISALLOW_COPY_AND_ASSIGN(StaticSizedView
);
28 // A view that accomodates testing layouts that use GetHeightForWidth.
29 class ProportionallySizedView
: public View
{
31 explicit ProportionallySizedView(int factor
);
32 ~ProportionallySizedView() override
;
34 void set_preferred_width(int width
) { preferred_width_
= width
; }
36 int GetHeightForWidth(int w
) const override
;
37 gfx::Size
GetPreferredSize() const override
;
40 // The multiplicative factor between width and height, i.e.
41 // height = width * factor_.
44 // The width used as the preferred size. -1 if not used.
47 DISALLOW_COPY_AND_ASSIGN(ProportionallySizedView
);
50 // Class that closes the widget (which ends up deleting it immediately) when the
51 // appropriate event is received.
52 class CloseWidgetView
: public View
{
54 explicit CloseWidgetView(ui::EventType event_type
);
56 // ui::EventHandler override:
57 void OnEvent(ui::Event
* event
) override
;
60 const ui::EventType event_type_
;
62 DISALLOW_COPY_AND_ASSIGN(CloseWidgetView
);
67 #endif // UI_VIEWS_TEST_TEST_VIEWS_H_