Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / ash / test / ash_test_helper.h
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.
4
5 #ifndef ASH_TEST_ASH_TEST_HELPER_H_
6 #define ASH_TEST_ASH_TEST_HELPER_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10
11 namespace aura {
12 class Window;
13 }  // namespace aura
14
15 namespace base {
16 class MessageLoopForUI;
17 }  // namespace base
18
19 namespace ui {
20 class ScopedAnimationDurationScaleMode;
21 }  // namespace ui
22
23 namespace views {
24 namespace corewm {
25 class WMState;
26 }
27 }
28
29 namespace ash {
30 namespace test {
31
32 class TestScreenshotDelegate;
33 class TestShellDelegate;
34
35 // A helper class that does common initialization required for Ash. Creates a
36 // root window and an ash::Shell instance with a test delegate.
37 class AshTestHelper {
38  public:
39   explicit AshTestHelper(base::MessageLoopForUI* message_loop);
40   ~AshTestHelper();
41
42   // Creates the ash::Shell and performs associated initialization.
43   // Set |start_session| to true if the user should log in before
44   // the test is run.
45   void SetUp(bool start_session);
46
47   // Destroys the ash::Shell and performs associated cleanup.
48   void TearDown();
49
50   // Returns a root Window. Usually this is the active root Window, but that
51   // method can return NULL sometimes, and in those cases, we fall back on the
52   // primary root Window.
53   aura::Window* CurrentContext();
54
55   void RunAllPendingInMessageLoop();
56
57   base::MessageLoopForUI* message_loop() { return message_loop_; }
58   TestShellDelegate* test_shell_delegate() { return test_shell_delegate_; }
59   TestScreenshotDelegate* test_screenshot_delegate() {
60     return test_screenshot_delegate_;
61   }
62
63  private:
64   base::MessageLoopForUI* message_loop_;  // Not owned.
65   TestShellDelegate* test_shell_delegate_;  // Owned by ash::Shell.
66   scoped_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_;
67
68   // Owned by ash::AcceleratorController
69   TestScreenshotDelegate* test_screenshot_delegate_;
70
71   scoped_ptr<views::corewm::WMState> wm_state_;
72
73   // Check if DBus Thread Manager was initialized here.
74   bool dbus_thread_manager_initialized_;
75
76   DISALLOW_COPY_AND_ASSIGN(AshTestHelper);
77 };
78
79 }  // namespace test
80 }  // namespace ash
81
82 #endif  // ASH_TEST_ASH_TEST_HELPER_H_