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