aura_test_helper.h revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
1// Copyright (c) 2012 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.
4
5#ifndef UI_AURA_TEST_AURA_TEST_HELPER_H_
6#define UI_AURA_TEST_AURA_TEST_HELPER_H_
7
8#include "base/basictypes.h"
9#include "base/memory/scoped_ptr.h"
10
11class MessageLoopForUI;
12
13namespace ui {
14class InputMethod;
15class ScopedAnimationDurationScaleMode;
16}
17
18namespace aura {
19class RootWindow;
20class TestScreen;
21namespace client {
22class DefaultCaptureClient;
23class FocusClient;
24}
25namespace test {
26class TestActivationClient;
27class TestStackingClient;
28
29// A helper class owned by tests that does common initialization required for
30// Aura use. This class creates a root window with clients and other objects
31// that are necessary to run test on Aura.
32class AuraTestHelper {
33 public:
34  explicit AuraTestHelper(MessageLoopForUI* message_loop);
35  ~AuraTestHelper();
36
37  // Creates and initializes (shows and sizes) the RootWindow for use in tests.
38  void SetUp();
39
40  // Clean up objects that are created for tests. This also deletes the Env
41  // object.
42  void TearDown();
43
44  // Flushes message loop.
45  void RunAllPendingInMessageLoop();
46
47  RootWindow* root_window() { return root_window_.get(); }
48
49  TestScreen* test_screen() { return test_screen_.get(); }
50
51 private:
52  MessageLoopForUI* message_loop_;
53  bool setup_called_;
54  bool teardown_called_;
55  bool owns_root_window_;
56  scoped_ptr<RootWindow> root_window_;
57  scoped_ptr<TestStackingClient> stacking_client_;
58  scoped_ptr<TestActivationClient> test_activation_client_;
59  scoped_ptr<client::DefaultCaptureClient> capture_client_;
60  scoped_ptr<ui::InputMethod> test_input_method_;
61  scoped_ptr<client::FocusClient> focus_client_;
62  scoped_ptr<TestScreen> test_screen_;
63  scoped_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_;
64
65  DISALLOW_COPY_AND_ASSIGN(AuraTestHelper);
66};
67
68}  // namespace test
69}  // namespace aura
70
71#endif  // UI_AURA_TEST_AURA_TEST_HELPER_H_
72