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 RootWindow; 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 ash { 24 namespace test { 25 26 class 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. 30 class AshTestHelper { 31 public: 32 explicit AshTestHelper(base::MessageLoopForUI* message_loop); 33 ~AshTestHelper(); 34 35 // Creates the ash::Shell and performs associated initialization. 36 // Set |start_session| to true if the user should log in before 37 // the test is run. 38 void SetUp(bool start_session); 39 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_ 65