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 #include "ui/views/test/test_views.h"
7 #include "ui/events/event.h"
8 #include "ui/views/widget/native_widget_private.h"
9 #include "ui/views/widget/widget.h"
13 StaticSizedView::StaticSizedView(const gfx::Size
& size
)
14 // Default GetMinimumSize() is GetPreferredSize(). Default GetMaximumSize()
20 StaticSizedView::~StaticSizedView() {}
22 gfx::Size
StaticSizedView::GetPreferredSize() const {
26 gfx::Size
StaticSizedView::GetMinimumSize() const {
30 gfx::Size
StaticSizedView::GetMaximumSize() const {
34 ProportionallySizedView::ProportionallySizedView(int factor
)
35 : factor_(factor
), preferred_width_(-1) {}
37 ProportionallySizedView::~ProportionallySizedView() {}
39 int ProportionallySizedView::GetHeightForWidth(int w
) const {
43 gfx::Size
ProportionallySizedView::GetPreferredSize() const {
44 if (preferred_width_
>= 0)
45 return gfx::Size(preferred_width_
, GetHeightForWidth(preferred_width_
));
46 return View::GetPreferredSize();
49 CloseWidgetView::CloseWidgetView(ui::EventType event_type
)
50 : event_type_(event_type
) {
53 void CloseWidgetView::OnEvent(ui::Event
* event
) {
54 if (event
->type() == event_type_
) {
55 // Go through NativeWidgetPrivate to simulate what happens if the OS
56 // deletes the NativeWindow out from under us.
57 // TODO(tapted): Change this to WidgetTest::SimulateNativeDestroy for a more
58 // authentic test on Mac.
59 GetWidget()->native_widget_private()->CloseNow();
62 if (!event
->IsTouchEvent())