| 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 "chromeos/network/network_handler.h" | |
| 19 #include "ui/aura/env.h" | 18 #include "ui/aura/env.h" |
| 20 #include "ui/aura/input_state_lookup.h" | 19 #include "ui/aura/input_state_lookup.h" |
| 21 #include "ui/aura/test/env_test_helper.h" | 20 #include "ui/aura/test/env_test_helper.h" |
| 22 #include "ui/base/ime/input_method_initializer.h" | 21 #include "ui/base/ime/input_method_initializer.h" |
| 23 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 22 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 24 #include "ui/wm/core/focus_controller.h" | 23 #include "ui/wm/core/focus_controller.h" |
| 25 #include "ui/wm/core/input_method_event_filter.h" | 24 #include "ui/wm/core/input_method_event_filter.h" |
| 26 | 25 |
| 27 #if defined(USE_X11) | 26 #if defined(USE_X11) |
| 28 #include "ui/base/x/x11_util.h" | 27 #include "ui/base/x/x11_util.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 45 CHECK(teardown_called_) << "AthenaTestHelper::TearDown() never called."; | 44 CHECK(teardown_called_) << "AthenaTestHelper::TearDown() never called."; |
| 46 } | 45 } |
| 47 | 46 |
| 48 void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) { | 47 void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) { |
| 49 setup_called_ = true; | 48 setup_called_ = true; |
| 50 file_thread_.reset(new base::Thread("FileThread")); | 49 file_thread_.reset(new base::Thread("FileThread")); |
| 51 base::Thread::Options options(base::MessageLoop::TYPE_IO, 0); | 50 base::Thread::Options options(base::MessageLoop::TYPE_IO, 0); |
| 52 file_thread_->StartWithOptions(options); | 51 file_thread_->StartWithOptions(options); |
| 53 | 52 |
| 54 chromeos::DBusThreadManager::Initialize(); | 53 chromeos::DBusThreadManager::Initialize(); |
| 55 chromeos::NetworkHandler::Initialize(); | |
| 56 ui::InitializeInputMethodForTesting(); | 54 ui::InitializeInputMethodForTesting(); |
| 57 aura::Env::CreateInstance(true); | 55 aura::Env::CreateInstance(true); |
| 58 aura::Env::GetInstance()->set_context_factory(context_factory); | 56 aura::Env::GetInstance()->set_context_factory(context_factory); |
| 59 | 57 |
| 60 // Unit tests generally don't want to query the system, rather use the state | 58 // Unit tests generally don't want to query the system, rather use the state |
| 61 // from RootWindow. | 59 // from RootWindow. |
| 62 aura::test::EnvTestHelper(aura::Env::GetInstance()) | 60 aura::test::EnvTestHelper(aura::Env::GetInstance()) |
| 63 .SetInputStateLookup(scoped_ptr<aura::InputStateLookup>()); | 61 .SetInputStateLookup(scoped_ptr<aura::InputStateLookup>()); |
| 64 | 62 |
| 65 // TODO(oshima): Use a BlockingPool task runner. | 63 // TODO(oshima): Use a BlockingPool task runner. |
| 66 athena::StartAthenaEnv(file_thread_->message_loop_proxy()); | 64 athena::StartAthenaEnv(file_thread_->message_loop_proxy()); |
| 67 athena::ExtensionsDelegate::CreateExtensionsDelegateForTest(); | 65 athena::ExtensionsDelegate::CreateExtensionsDelegateForTest(); |
| 68 athena::StartAthenaSession(new SampleActivityFactory(), | 66 athena::StartAthenaSession(new SampleActivityFactory(), |
| 69 make_scoped_ptr(new TestAppModelBuilder()), | 67 make_scoped_ptr(new TestAppModelBuilder()), |
| 70 CreateSearchControllerFactory(NULL)); | 68 CreateSearchControllerFactory(NULL)); |
| 71 } | 69 } |
| 72 | 70 |
| 73 void AthenaTestHelper::TearDown() { | 71 void AthenaTestHelper::TearDown() { |
| 74 teardown_called_ = true; | 72 teardown_called_ = true; |
| 75 | 73 |
| 76 athena::ShutdownAthena(); | 74 athena::ShutdownAthena(); |
| 77 aura::Env::DeleteInstance(); | 75 aura::Env::DeleteInstance(); |
| 78 | 76 |
| 79 #if defined(USE_X11) | 77 #if defined(USE_X11) |
| 80 ui::test::ResetXCursorCache(); | 78 ui::test::ResetXCursorCache(); |
| 81 #endif | 79 #endif |
| 82 | 80 |
| 83 ui::ShutdownInputMethodForTesting(); | 81 ui::ShutdownInputMethodForTesting(); |
| 84 chromeos::NetworkHandler::Shutdown(); | |
| 85 chromeos::DBusThreadManager::Shutdown(); | 82 chromeos::DBusThreadManager::Shutdown(); |
| 86 } | 83 } |
| 87 | 84 |
| 88 aura::Window* AthenaTestHelper::GetRootWindow() { | 85 aura::Window* AthenaTestHelper::GetRootWindow() { |
| 89 return GetHost()->window(); | 86 return GetHost()->window(); |
| 90 } | 87 } |
| 91 | 88 |
| 92 aura::WindowTreeHost* AthenaTestHelper::GetHost() { | 89 aura::WindowTreeHost* AthenaTestHelper::GetHost() { |
| 93 return AthenaEnv::Get()->GetHost(); | 90 return AthenaEnv::Get()->GetHost(); |
| 94 } | 91 } |
| 95 | 92 |
| 96 void AthenaTestHelper::RunAllPendingInMessageLoop() { | 93 void AthenaTestHelper::RunAllPendingInMessageLoop() { |
| 97 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them | 94 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them |
| 98 // use run_loop.QuitClosure(). | 95 // use run_loop.QuitClosure(). |
| 99 base::RunLoop run_loop; | 96 base::RunLoop run_loop; |
| 100 run_loop.RunUntilIdle(); | 97 run_loop.RunUntilIdle(); |
| 101 } | 98 } |
| 102 | 99 |
| 103 } // namespace test | 100 } // namespace test |
| 104 } // namespace athena | 101 } // namespace athena |
| OLD | NEW |