Drive: Add BatchableRequest subclass.
[chromium-blink-merge.git] / ui / views / test / test_views.h
blob143d646378249916977947f132eb4d23788c838f
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"
12 namespace views {
14 // A view that requests a set amount of space.
15 class StaticSizedView : public View {
16 public:
17 explicit StaticSizedView(const gfx::Size& size);
18 ~StaticSizedView() override;
20 gfx::Size GetPreferredSize() const override;
22 private:
23 gfx::Size size_;
25 DISALLOW_COPY_AND_ASSIGN(StaticSizedView);
28 // A view that accomodates testing layouts that use GetHeightForWidth.
29 class ProportionallySizedView : public View {
30 public:
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;
39 private:
40 // The multiplicative factor between width and height, i.e.
41 // height = width * factor_.
42 int factor_;
44 // The width used as the preferred size. -1 if not used.
45 int preferred_width_;
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 {
53 public:
54 explicit CloseWidgetView(ui::EventType event_type);
56 // ui::EventHandler override:
57 void OnEvent(ui::Event* event) override;
59 private:
60 const ui::EventType event_type_;
62 DISALLOW_COPY_AND_ASSIGN(CloseWidgetView);
65 } // namespace views
67 #endif // UI_VIEWS_TEST_TEST_VIEWS_H_