Index: chrome/test/base/chrome_views_test_helper_chromeos.cc |
diff --git a/chrome/test/base/chrome_views_test_helper_chromeos.cc b/chrome/test/base/chrome_views_test_helper_chromeos.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8646b746f607cbd98f8bb84e51e2a25a2c366be5 |
--- /dev/null |
+++ b/chrome/test/base/chrome_views_test_helper_chromeos.cc |
@@ -0,0 +1,75 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/test/base/chrome_views_test_helper.h" |
+ |
+#include "ash/shell.h" |
+#include "ash/shell_init_params.h" |
+#include "ash/test/test_session_state_delegate.h" |
+#include "ash/test/test_shell_delegate.h" |
+#include "chromeos/audio/cras_audio_handler.h" |
+#include "chromeos/dbus/dbus_thread_manager.h" |
+#include "chromeos/network/network_handler.h" |
+#include "ui/aura/env.h" |
+#include "ui/aura/window_tree_host.h" |
+#include "ui/message_center/message_center.h" |
+#include "ui/wm/core/wm_state.h" |
+ |
+namespace { |
+ |
+// ChromeViewsTestHelper implementation for ChromeOS (chromeos=1). |
+class ChromeViewsTestHelperChromeOS : public ChromeViewsTestHelper { |
+ public: |
+ ChromeViewsTestHelperChromeOS() {} |
+ |
+ // Overridden from ChromeViewsTestHelper: |
+ virtual gfx::NativeWindow PlatformSetUp( |
+ ui::ContextFactory* context_factory) OVERRIDE; |
+ virtual void PlatformTearDown() OVERRIDE; |
+ |
+ private: |
+ wm::WMState wm_state_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ChromeViewsTestHelperChromeOS); |
+}; |
+ |
+gfx::NativeWindow ChromeViewsTestHelperChromeOS::PlatformSetUp( |
+ ui::ContextFactory* context_factory) { |
+ // Ash Shell can't just live on its own without a browser process, we need to |
+ // also create the message center. |
+ message_center::MessageCenter::Initialize(); |
+ chromeos::DBusThreadManager::InitializeWithStub(); |
+ chromeos::CrasAudioHandler::InitializeForTesting(); |
+ chromeos::NetworkHandler::Initialize(); |
+ ash::test::TestShellDelegate* shell_delegate = |
+ new ash::test::TestShellDelegate(); |
+ ash::ShellInitParams init_params; |
+ init_params.delegate = shell_delegate; |
+ init_params.context_factory = context_factory; |
+ ash::Shell::CreateInstance(init_params); |
+ shell_delegate->test_session_state_delegate()->SetActiveUserSessionStarted( |
+ true); |
+ gfx::NativeWindow context = ash::Shell::GetPrimaryRootWindow(); |
+ context->GetHost()->Show(); |
+ return context; |
+} |
+ |
+void ChromeViewsTestHelperChromeOS::PlatformTearDown() { |
+ ash::Shell::DeleteInstance(); |
+ chromeos::NetworkHandler::Shutdown(); |
+ chromeos::CrasAudioHandler::Shutdown(); |
+ chromeos::DBusThreadManager::Shutdown(); |
+ // Ash Shell can't just live on its own without a browser process, we need to |
+ // also shut down the message center. |
+ message_center::MessageCenter::Shutdown(); |
+ |
+ aura::Env::DeleteInstance(); |
+} |
+ |
+} // namespace |
+ |
+// static |
+ChromeViewsTestHelper* ChromeViewsTestHelper::Create() { |
+ return new ChromeViewsTestHelperChromeOS(); |
+} |