• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "ui/aura/root_window.h"
11 
12 namespace base {
13 class MessageLoopForUI;
14 }
15 
16 namespace gfx {
17 class SurfaceFactoryOzone;
18 }
19 
20 namespace ui {
21 class InputMethod;
22 class ScopedAnimationDurationScaleMode;
23 }
24 
25 namespace aura {
26 class TestScreen;
27 namespace client {
28 class DefaultActivationClient;
29 class DefaultCaptureClient;
30 class FocusClient;
31 }
32 namespace test {
33 class TestWindowTreeClient;
34 
35 // A helper class owned by tests that does common initialization required for
36 // Aura use. This class creates a root window with clients and other objects
37 // that are necessary to run test on Aura.
38 class AuraTestHelper {
39  public:
40   explicit AuraTestHelper(base::MessageLoopForUI* message_loop);
41   ~AuraTestHelper();
42 
43   // Creates and initializes (shows and sizes) the RootWindow for use in tests.
44   void SetUp();
45 
46   // Clean up objects that are created for tests. This also deletes the Env
47   // object.
48   void TearDown();
49 
50   // Flushes message loop.
51   void RunAllPendingInMessageLoop();
52 
root_window()53   Window* root_window() { return root_window_->window(); }
dispatcher()54   RootWindow* dispatcher() { return root_window_.get(); }
55 
test_screen()56   TestScreen* test_screen() { return test_screen_.get(); }
57 
58  private:
59   base::MessageLoopForUI* message_loop_;
60   bool setup_called_;
61   bool teardown_called_;
62   bool owns_root_window_;
63   scoped_ptr<RootWindow> root_window_;
64   scoped_ptr<TestWindowTreeClient> stacking_client_;
65   scoped_ptr<client::DefaultActivationClient> activation_client_;
66   scoped_ptr<client::DefaultCaptureClient> capture_client_;
67   scoped_ptr<ui::InputMethod> test_input_method_;
68   scoped_ptr<client::FocusClient> focus_client_;
69   scoped_ptr<TestScreen> test_screen_;
70   scoped_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_;
71 
72 #if defined(USE_OZONE)
73   scoped_ptr<gfx::SurfaceFactoryOzone> surface_factory_;
74 #endif
75 
76   DISALLOW_COPY_AND_ASSIGN(AuraTestHelper);
77 };
78 
79 }  // namespace test
80 }  // namespace aura
81 
82 #endif  // UI_AURA_TEST_AURA_TEST_HELPER_H_
83