blob: f4d7706469f31429ebab9e0d413cbcfc28b5aafa [file] [log] [blame]
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +01001// 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
11namespace aura {
12class RootWindow;
13} // namespace aura
14
15namespace base {
16class MessageLoopForUI;
17} // namespace base
18
19namespace ui {
20class ScopedAnimationDurationScaleMode;
21} // namespace ui
22
23namespace ash {
24namespace test {
25
26class TestShellDelegate;
27
28// A helper class that does common initialization required for Ash. Creates a
29// root window and an ash::Shell instance with a test delegate.
30class AshTestHelper {
31 public:
32 explicit AshTestHelper(base::MessageLoopForUI* message_loop);
33 ~AshTestHelper();
34
35 // Creates the ash::Shell and performs associated initialization.
Ben Murdochbb1529c2013-08-08 10:24:53 +010036 // Set |start_session| to true if the user should log in before
37 // the test is run.
38 void SetUp(bool start_session);
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010039
40 // Destroys the ash::Shell and performs associated cleanup.
41 void TearDown();
42
43 // Returns a RootWindow. Usually this is the active RootWindow, but that
44 // method can return NULL sometimes, and in those cases, we fall back on the
45 // primary RootWindow.
46 aura::RootWindow* CurrentContext();
47
48 void RunAllPendingInMessageLoop();
49
50 base::MessageLoopForUI* message_loop() { return message_loop_; }
51 TestShellDelegate* test_shell_delegate() { return test_shell_delegate_; }
52
53 private:
54 base::MessageLoopForUI* message_loop_; // Not owned.
55 TestShellDelegate* test_shell_delegate_; // Owned by ash::Shell.
56 scoped_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_;
57
58 DISALLOW_COPY_AND_ASSIGN(AshTestHelper);
59};
60
61} // namespace test
62} // namespace ash
63
64#endif // ASH_TEST_ASH_TEST_HELPER_H_