aura_test_helper.h revision 5c02ac1a9c1b504631c0a3d2b6e737b5d738bae1
1// Copyright (c) 2012 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 UI_AURA_TEST_AURA_TEST_HELPER_H_ 6#define UI_AURA_TEST_AURA_TEST_HELPER_H_ 7 8#include "base/basictypes.h" 9#include "base/memory/scoped_ptr.h" 10#include "ui/aura/window_event_dispatcher.h" 11#include "ui/aura/window_tree_host.h" 12 13namespace base { 14class MessageLoopForUI; 15} 16 17namespace ui { 18class InputMethod; 19class ScopedAnimationDurationScaleMode; 20} 21 22namespace aura { 23class TestScreen; 24namespace client { 25class DefaultCaptureClient; 26class FocusClient; 27} 28namespace test { 29class TestWindowTreeClient; 30 31// A helper class owned by tests that does common initialization required for 32// Aura use. This class creates a root window with clients and other objects 33// that are necessary to run test on Aura. 34class AuraTestHelper { 35 public: 36 explicit AuraTestHelper(base::MessageLoopForUI* message_loop); 37 ~AuraTestHelper(); 38 39 // Creates and initializes (shows and sizes) the RootWindow for use in tests. 40 void SetUp(); 41 42 // Clean up objects that are created for tests. This also deletes the Env 43 // object. 44 void TearDown(); 45 46 // Flushes message loop. 47 void RunAllPendingInMessageLoop(); 48 49 Window* root_window() { return host_->window(); } 50 ui::EventProcessor* event_processor() { return host_->event_processor(); } 51 WindowTreeHost* host() { return host_.get(); } 52 53 TestScreen* test_screen() { return test_screen_.get(); } 54 55 private: 56 base::MessageLoopForUI* message_loop_; 57 bool setup_called_; 58 bool teardown_called_; 59 bool owns_host_; 60 scoped_ptr<WindowTreeHost> host_; 61 scoped_ptr<TestWindowTreeClient> stacking_client_; 62 scoped_ptr<client::DefaultCaptureClient> capture_client_; 63 scoped_ptr<ui::InputMethod> test_input_method_; 64 scoped_ptr<client::FocusClient> focus_client_; 65 scoped_ptr<TestScreen> test_screen_; 66 scoped_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_; 67 68 DISALLOW_COPY_AND_ASSIGN(AuraTestHelper); 69}; 70 71} // namespace test 72} // namespace aura 73 74#endif // UI_AURA_TEST_AURA_TEST_HELPER_H_ 75