#include "athena/test/athena_test_helper.h"
-#include "athena/main/athena_launcher.h"
+#include "athena/env/public/athena_env.h"
+#include "athena/extensions/public/extensions_delegate.h"
+#include "athena/main/public/athena_launcher.h"
#include "athena/test/sample_activity_factory.h"
#include "athena/test/test_app_model_builder.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "ui/aura/client/aura_constants.h"
+#include "base/threading/thread.h"
+#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/network/network_handler.h"
#include "ui/aura/env.h"
#include "ui/aura/input_state_lookup.h"
#include "ui/aura/test/env_test_helper.h"
-#include "ui/aura/test/test_focus_client.h"
-#include "ui/aura/test/test_screen.h"
-#include "ui/aura/window_event_dispatcher.h"
#include "ui/base/ime/input_method_initializer.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
-#include "ui/gfx/screen.h"
-#include "ui/wm/core/default_activation_client.h"
+#include "ui/wm/core/focus_controller.h"
#include "ui/wm/core/input_method_event_filter.h"
#if defined(USE_X11)
void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) {
setup_called_ = true;
+ file_thread_.reset(new base::Thread("FileThread"));
+ base::Thread::Options options(base::MessageLoop::TYPE_IO, 0);
+ file_thread_->StartWithOptions(options);
+ chromeos::DBusThreadManager::Initialize();
+ chromeos::NetworkHandler::Initialize();
+ ui::InitializeInputMethodForTesting();
aura::Env::CreateInstance(true);
aura::Env::GetInstance()->set_context_factory(context_factory);
aura::test::EnvTestHelper(aura::Env::GetInstance())
.SetInputStateLookup(scoped_ptr<aura::InputStateLookup>());
- ui::InitializeInputMethodForTesting();
-
- const gfx::Size host_size(800, 600);
- test_screen_.reset(aura::TestScreen::Create(host_size));
- gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get());
- host_.reset(test_screen_->CreateHostForPrimaryDisplay());
-
- input_method_filter_.reset(new ::wm::InputMethodEventFilter(
- root_window()->GetHost()->GetAcceleratedWidget()));
- input_method_filter_->SetInputMethodPropertyInRootWindow(
- root_window());
-
- // TODO(oshima): Switch to athena implementation.
- focus_client_.reset(new aura::test::TestFocusClient);
- aura::client::SetFocusClient(root_window(),
- focus_client_.get());
- new ::wm::DefaultActivationClient(root_window());
-
- root_window()->Show();
- // Ensure width != height so tests won't confuse them.
- host()->SetBounds(gfx::Rect(host_size));
-
- athena::StartAthena(root_window(),
- new SampleActivityFactory(),
- new TestAppModelBuilder());
+ // TODO(oshima): Use a BlockingPool task runner.
+ athena::StartAthenaEnv(file_thread_->message_loop_proxy());
+ athena::ExtensionsDelegate::CreateExtensionsDelegateForTest();
+ athena::StartAthenaSession(new SampleActivityFactory(),
+ new TestAppModelBuilder());
}
void AthenaTestHelper::TearDown() {
teardown_called_ = true;
athena::ShutdownAthena();
-
- aura::client::SetFocusClient(root_window(), NULL);
- focus_client_.reset();
- input_method_filter_.reset();
-
- host_.reset();
- ui::GestureRecognizer::Reset();
- test_screen_.reset();
- gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL);
+ aura::Env::DeleteInstance();
#if defined(USE_X11)
ui::test::ResetXCursorCache();
#endif
ui::ShutdownInputMethodForTesting();
+ chromeos::NetworkHandler::Shutdown();
+ chromeos::DBusThreadManager::Shutdown();
+}
- aura::Env::DeleteInstance();
+aura::Window* AthenaTestHelper::GetRootWindow() {
+ return GetHost()->window();
+}
+
+aura::WindowTreeHost* AthenaTestHelper::GetHost() {
+ return AthenaEnv::Get()->GetHost();
}
void AthenaTestHelper::RunAllPendingInMessageLoop() {