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 void set_minimum_size(const gfx::Size
& minimum_size
) {
21 minimum_size_
= minimum_size
;
24 void set_maximum_size(const gfx::Size
& maximum_size
) {
25 maximum_size_
= maximum_size
;
29 gfx::Size
GetPreferredSize() const override
;
30 gfx::Size
GetMinimumSize() const override
;
31 gfx::Size
GetMaximumSize() const override
;
35 gfx::Size minimum_size_
;
36 gfx::Size maximum_size_
;
38 DISALLOW_COPY_AND_ASSIGN(StaticSizedView
);
41 // A view that accomodates testing layouts that use GetHeightForWidth.
42 class ProportionallySizedView
: public View
{
44 explicit ProportionallySizedView(int factor
);
45 ~ProportionallySizedView() override
;
47 void set_preferred_width(int width
) { preferred_width_
= width
; }
49 int GetHeightForWidth(int w
) const override
;
50 gfx::Size
GetPreferredSize() const override
;
53 // The multiplicative factor between width and height, i.e.
54 // height = width * factor_.
57 // The width used as the preferred size. -1 if not used.
60 DISALLOW_COPY_AND_ASSIGN(ProportionallySizedView
);
63 // Class that closes the widget (which ends up deleting it immediately) when the
64 // appropriate event is received.
65 class CloseWidgetView
: public View
{
67 explicit CloseWidgetView(ui::EventType event_type
);
69 // ui::EventHandler override:
70 void OnEvent(ui::Event
* event
) override
;
73 const ui::EventType event_type_
;
75 DISALLOW_COPY_AND_ASSIGN(CloseWidgetView
);
80 #endif // UI_VIEWS_TEST_TEST_VIEWS_H_