| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "athena/test/base/athena_test_helper.h" | 5 #include "athena/test/base/athena_test_helper.h" |
| 6 | 6 |
| 7 #include "athena/env/public/athena_env.h" | 7 #include "athena/env/public/athena_env.h" |
| 8 #include "athena/extensions/public/apps_search_controller_factory.h" | 8 #include "athena/extensions/public/apps_search_controller_factory.h" |
| 9 #include "athena/extensions/public/extensions_delegate.h" | 9 #include "athena/extensions/public/extensions_delegate.h" |
| 10 #include "athena/home/public/search_controller_factory.h" | 10 #include "athena/home/public/search_controller_factory.h" |
| 11 #include "athena/main/public/athena_launcher.h" | 11 #include "athena/main/public/athena_launcher.h" |
| 12 #include "athena/test/base/sample_activity_factory.h" | 12 #include "athena/test/base/sample_activity_factory.h" |
| 13 #include "athena/test/base/test_app_model_builder.h" | 13 #include "athena/test/base/test_app_model_builder.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
| 17 #include "chromeos/dbus/dbus_thread_manager.h" | 17 #include "chromeos/dbus/dbus_thread_manager.h" |
| 18 #include "ui/aura/env.h" | 18 #include "ui/aura/env.h" |
| 19 #include "ui/aura/input_state_lookup.h" | 19 #include "ui/aura/input_state_lookup.h" |
| 20 #include "ui/aura/test/env_test_helper.h" | 20 #include "ui/aura/test/env_test_helper.h" |
| 21 #include "ui/base/ime/input_method_initializer.h" | 21 #include "ui/base/ime/input_method_initializer.h" |
| 22 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 22 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 23 #include "ui/wm/core/focus_controller.h" | 23 #include "ui/wm/core/focus_controller.h" |
| 24 #include "ui/wm/core/input_method_event_filter.h" | 24 #include "ui/wm/core/input_method_event_filter.h" |
| 25 #include "ui/wm/core/user_activity_detector.h" |
| 25 | 26 |
| 26 #if defined(USE_X11) | 27 #if defined(USE_X11) |
| 27 #include "ui/base/x/x11_util.h" | 28 #include "ui/base/x/x11_util.h" |
| 28 #endif | 29 #endif |
| 29 | 30 |
| 30 namespace athena { | 31 namespace athena { |
| 31 namespace test { | 32 namespace test { |
| 32 | 33 |
| 33 AthenaTestHelper::AthenaTestHelper(base::MessageLoopForUI* message_loop) | 34 AthenaTestHelper::AthenaTestHelper(base::MessageLoopForUI* message_loop) |
| 34 : setup_called_(false), teardown_called_(false) { | 35 : setup_called_(false), teardown_called_(false) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 53 chromeos::DBusThreadManager::Initialize(); | 54 chromeos::DBusThreadManager::Initialize(); |
| 54 ui::InitializeInputMethodForTesting(); | 55 ui::InitializeInputMethodForTesting(); |
| 55 aura::Env::CreateInstance(true); | 56 aura::Env::CreateInstance(true); |
| 56 aura::Env::GetInstance()->set_context_factory(context_factory); | 57 aura::Env::GetInstance()->set_context_factory(context_factory); |
| 57 | 58 |
| 58 // Unit tests generally don't want to query the system, rather use the state | 59 // Unit tests generally don't want to query the system, rather use the state |
| 59 // from RootWindow. | 60 // from RootWindow. |
| 60 aura::test::EnvTestHelper(aura::Env::GetInstance()) | 61 aura::test::EnvTestHelper(aura::Env::GetInstance()) |
| 61 .SetInputStateLookup(scoped_ptr<aura::InputStateLookup>()); | 62 .SetInputStateLookup(scoped_ptr<aura::InputStateLookup>()); |
| 62 | 63 |
| 64 // UserActivityDetector must be created before the athena environment is |
| 65 // started. |
| 66 wm::UserActivityDetector::Create(); |
| 67 |
| 63 // TODO(oshima): Use a BlockingPool task runner. | 68 // TODO(oshima): Use a BlockingPool task runner. |
| 64 athena::StartAthenaEnv(file_thread_->message_loop_proxy()); | 69 athena::StartAthenaEnv(file_thread_->message_loop_proxy()); |
| 65 athena::ExtensionsDelegate::CreateExtensionsDelegateForTest(); | 70 athena::ExtensionsDelegate::CreateExtensionsDelegateForTest(); |
| 66 athena::StartAthenaSession(new SampleActivityFactory(), | 71 athena::StartAthenaSession(new SampleActivityFactory(), |
| 67 make_scoped_ptr(new TestAppModelBuilder()), | 72 make_scoped_ptr(new TestAppModelBuilder()), |
| 68 CreateSearchControllerFactory(nullptr)); | 73 CreateSearchControllerFactory(nullptr)); |
| 69 } | 74 } |
| 70 | 75 |
| 71 void AthenaTestHelper::TearDown() { | 76 void AthenaTestHelper::TearDown() { |
| 72 teardown_called_ = true; | 77 teardown_called_ = true; |
| 73 | 78 |
| 74 athena::ShutdownAthena(); | 79 athena::ShutdownAthena(); |
| 80 wm::UserActivityDetector::Shutdown(); |
| 75 aura::Env::DeleteInstance(); | 81 aura::Env::DeleteInstance(); |
| 76 | 82 |
| 77 #if defined(USE_X11) | 83 #if defined(USE_X11) |
| 78 ui::test::ResetXCursorCache(); | 84 ui::test::ResetXCursorCache(); |
| 79 #endif | 85 #endif |
| 80 | 86 |
| 81 ui::ShutdownInputMethodForTesting(); | 87 ui::ShutdownInputMethodForTesting(); |
| 82 chromeos::DBusThreadManager::Shutdown(); | 88 chromeos::DBusThreadManager::Shutdown(); |
| 83 } | 89 } |
| 84 | 90 |
| 85 aura::Window* AthenaTestHelper::GetRootWindow() { | 91 aura::Window* AthenaTestHelper::GetRootWindow() { |
| 86 return GetHost()->window(); | 92 return GetHost()->window(); |
| 87 } | 93 } |
| 88 | 94 |
| 89 aura::WindowTreeHost* AthenaTestHelper::GetHost() { | 95 aura::WindowTreeHost* AthenaTestHelper::GetHost() { |
| 90 return AthenaEnv::Get()->GetHost(); | 96 return AthenaEnv::Get()->GetHost(); |
| 91 } | 97 } |
| 92 | 98 |
| 93 void AthenaTestHelper::RunAllPendingInMessageLoop() { | 99 void AthenaTestHelper::RunAllPendingInMessageLoop() { |
| 94 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them | 100 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them |
| 95 // use run_loop.QuitClosure(). | 101 // use run_loop.QuitClosure(). |
| 96 base::RunLoop run_loop; | 102 base::RunLoop run_loop; |
| 97 run_loop.RunUntilIdle(); | 103 run_loop.RunUntilIdle(); |
| 98 } | 104 } |
| 99 | 105 |
| 100 } // namespace test | 106 } // namespace test |
| 101 } // namespace athena | 107 } // namespace athena |
| OLD | NEW |