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 ash { 24 namespace test { 25 26 class TestScreenshotDelegate; 27 class TestShellDelegate; 28 29 // A helper class that does common initialization required for Ash. Creates a 30 // root window and an ash::Shell instance with a test delegate. 31 class AshTestHelper { 32 public: 33 explicit AshTestHelper(base::MessageLoopForUI* message_loop); 34 ~AshTestHelper(); 35 36 // Creates the ash::Shell and performs associated initialization. 37 // Set |start_session| to true if the user should log in before 38 // the test is run. 39 void SetUp(bool start_session); 40 41 // Destroys the ash::Shell and performs associated cleanup. 42 void TearDown(); 43 44 // Returns a root Window. Usually this is the active root Window, but that 45 // method can return NULL sometimes, and in those cases, we fall back on the 46 // primary root Window. 47 aura::Window* CurrentContext(); 48 49 void RunAllPendingInMessageLoop(); 50 51 base::MessageLoopForUI* message_loop() { return message_loop_; } 52 TestShellDelegate* test_shell_delegate() { return test_shell_delegate_; } 53 TestScreenshotDelegate* test_screenshot_delegate() { 54 return test_screenshot_delegate_; 55 } 56 57 private: 58 base::MessageLoopForUI* message_loop_; // Not owned. 59 TestShellDelegate* test_shell_delegate_; // Owned by ash::Shell. 60 scoped_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_; 61 62 // Owned by ash::AcceleratorController 63 TestScreenshotDelegate* test_screenshot_delegate_; 64 65 DISALLOW_COPY_AND_ASSIGN(AshTestHelper); 66 }; 67 68 } // namespace test 69 } // namespace ash 70 71 #endif // ASH_TEST_ASH_TEST_HELPER_H_ 72