• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 class ViewsDelegate;
25 }
26 
27 namespace ash {
28 namespace test {
29 
30 class TestScreenshotDelegate;
31 class TestShellDelegate;
32 
33 // A helper class that does common initialization required for Ash. Creates a
34 // root window and an ash::Shell instance with a test delegate.
35 class AshTestHelper {
36  public:
37   explicit AshTestHelper(base::MessageLoopForUI* message_loop);
38   ~AshTestHelper();
39 
40   // Creates the ash::Shell and performs associated initialization.
41   // Set |start_session| to true if the user should log in before
42   // the test is run.
43   void SetUp(bool start_session);
44 
45   // Destroys the ash::Shell and performs associated cleanup.
46   void TearDown();
47 
48   // Returns a root Window. Usually this is the active root Window, but that
49   // method can return NULL sometimes, and in those cases, we fall back on the
50   // primary root Window.
51   aura::Window* CurrentContext();
52 
53   void RunAllPendingInMessageLoop();
54 
message_loop()55   base::MessageLoopForUI* message_loop() { return message_loop_; }
test_shell_delegate()56   TestShellDelegate* test_shell_delegate() { return test_shell_delegate_; }
set_test_shell_delegate(TestShellDelegate * test_shell_delegate)57   void set_test_shell_delegate(TestShellDelegate* test_shell_delegate) {
58     test_shell_delegate_ = test_shell_delegate;
59   }
test_screenshot_delegate()60   TestScreenshotDelegate* test_screenshot_delegate() {
61     return test_screenshot_delegate_;
62   }
63 
64   // True if the running environment supports multiple displays,
65   // or false otherwise (e.g. win8 bot).
66   static bool SupportsMultipleDisplays();
67 
68   // True if the running environment supports host window resize,
69   // or false otherwise (e.g. win8 bot).
70   static bool SupportsHostWindowResize();
71 
72  private:
73   base::MessageLoopForUI* message_loop_;  // Not owned.
74   TestShellDelegate* test_shell_delegate_;  // Owned by ash::Shell.
75   scoped_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_;
76 
77   // Owned by ash::AcceleratorController
78   TestScreenshotDelegate* test_screenshot_delegate_;
79 
80   scoped_ptr<views::ViewsDelegate> views_delegate_;
81 
82   // Check if DBus Thread Manager was initialized here.
83   bool dbus_thread_manager_initialized_;
84 
85   DISALLOW_COPY_AND_ASSIGN(AshTestHelper);
86 };
87 
88 }  // namespace test
89 }  // namespace ash
90 
91 #endif  // ASH_TEST_ASH_TEST_HELPER_H_
92