| 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 "chrome/test/base/view_event_test_platform_part.h" | 5 #include "chrome/test/base/view_event_test_platform_part.h" |
| 6 | 6 |
| 7 #include <memory> |
| 8 |
| 7 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
| 8 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 9 #include "ash/shell_init_params.h" | 11 #include "ash/shell_init_params.h" |
| 10 #include "ash/test/ash_test_helper.h" | 12 #include "ash/test/ash_test_helper.h" |
| 11 #include "ash/test/test_session_state_delegate.h" | 13 #include "ash/test/test_session_state_delegate.h" |
| 12 #include "ash/test/test_shell_delegate.h" | 14 #include "ash/test/test_shell_delegate.h" |
| 13 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 14 #include "base/macros.h" | 16 #include "base/macros.h" |
| 15 #include "chromeos/audio/cras_audio_handler.h" | 17 #include "chromeos/audio/cras_audio_handler.h" |
| 16 #include "chromeos/dbus/dbus_thread_manager.h" | 18 #include "chromeos/dbus/dbus_thread_manager.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 31 ui::ContextFactory* context_factory); | 33 ui::ContextFactory* context_factory); |
| 32 ~ViewEventTestPlatformPartChromeOS() override; | 34 ~ViewEventTestPlatformPartChromeOS() override; |
| 33 | 35 |
| 34 // Overridden from ViewEventTestPlatformPart: | 36 // Overridden from ViewEventTestPlatformPart: |
| 35 gfx::NativeWindow GetContext() override { | 37 gfx::NativeWindow GetContext() override { |
| 36 return ash::Shell::GetPrimaryRootWindow(); | 38 return ash::Shell::GetPrimaryRootWindow(); |
| 37 } | 39 } |
| 38 | 40 |
| 39 private: | 41 private: |
| 40 wm::WMState wm_state_; | 42 wm::WMState wm_state_; |
| 43 std::unique_ptr<aura::Env> env_; |
| 41 | 44 |
| 42 DISALLOW_COPY_AND_ASSIGN(ViewEventTestPlatformPartChromeOS); | 45 DISALLOW_COPY_AND_ASSIGN(ViewEventTestPlatformPartChromeOS); |
| 43 }; | 46 }; |
| 44 | 47 |
| 45 ViewEventTestPlatformPartChromeOS::ViewEventTestPlatformPartChromeOS( | 48 ViewEventTestPlatformPartChromeOS::ViewEventTestPlatformPartChromeOS( |
| 46 ui::ContextFactory* context_factory) { | 49 ui::ContextFactory* context_factory) { |
| 47 // Ash Shell can't just live on its own without a browser process, we need to | 50 // Ash Shell can't just live on its own without a browser process, we need to |
| 48 // also create the message center. | 51 // also create the message center. |
| 49 message_center::MessageCenter::Initialize(); | 52 message_center::MessageCenter::Initialize(); |
| 50 chromeos::DBusThreadManager::Initialize(); | 53 chromeos::DBusThreadManager::Initialize(); |
| 51 bluez::BluezDBusManager::Initialize( | 54 bluez::BluezDBusManager::Initialize( |
| 52 chromeos::DBusThreadManager::Get()->GetSystemBus(), | 55 chromeos::DBusThreadManager::Get()->GetSystemBus(), |
| 53 chromeos::DBusThreadManager::Get()->IsUsingStub( | 56 chromeos::DBusThreadManager::Get()->IsUsingStub( |
| 54 chromeos::DBusClientBundle::BLUETOOTH)); | 57 chromeos::DBusClientBundle::BLUETOOTH)); |
| 55 chromeos::CrasAudioHandler::InitializeForTesting(); | 58 chromeos::CrasAudioHandler::InitializeForTesting(); |
| 56 chromeos::NetworkHandler::Initialize(); | 59 chromeos::NetworkHandler::Initialize(); |
| 57 | 60 |
| 58 aura::Env::CreateInstance(true); | 61 env_ = aura::Env::CreateInstance(); |
| 59 ash::test::TestShellDelegate* shell_delegate = | 62 ash::test::TestShellDelegate* shell_delegate = |
| 60 new ash::test::TestShellDelegate(); | 63 new ash::test::TestShellDelegate(); |
| 61 ash::ShellInitParams init_params; | 64 ash::ShellInitParams init_params; |
| 62 init_params.delegate = shell_delegate; | 65 init_params.delegate = shell_delegate; |
| 63 init_params.context_factory = context_factory; | 66 init_params.context_factory = context_factory; |
| 64 init_params.blocking_pool = content::BrowserThread::GetBlockingPool(); | 67 init_params.blocking_pool = content::BrowserThread::GetBlockingPool(); |
| 65 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 68 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 66 ash::switches::kAshHostWindowBounds, "0+0-1280x800"); | 69 ash::switches::kAshHostWindowBounds, "0+0-1280x800"); |
| 67 ash::Shell::CreateInstance(init_params); | 70 ash::Shell::CreateInstance(init_params); |
| 68 ash::test::AshTestHelper::GetTestSessionStateDelegate()-> | 71 ash::test::AshTestHelper::GetTestSessionStateDelegate()-> |
| 69 SetActiveUserSessionStarted(true); | 72 SetActiveUserSessionStarted(true); |
| 70 GetContext()->GetHost()->Show(); | 73 GetContext()->GetHost()->Show(); |
| 71 } | 74 } |
| 72 | 75 |
| 73 ViewEventTestPlatformPartChromeOS::~ViewEventTestPlatformPartChromeOS() { | 76 ViewEventTestPlatformPartChromeOS::~ViewEventTestPlatformPartChromeOS() { |
| 74 ash::Shell::DeleteInstance(); | 77 ash::Shell::DeleteInstance(); |
| 75 aura::Env::DeleteInstance(); | 78 env_.reset(); |
| 76 | 79 |
| 77 chromeos::NetworkHandler::Shutdown(); | 80 chromeos::NetworkHandler::Shutdown(); |
| 78 chromeos::CrasAudioHandler::Shutdown(); | 81 chromeos::CrasAudioHandler::Shutdown(); |
| 79 bluez::BluezDBusManager::Shutdown(); | 82 bluez::BluezDBusManager::Shutdown(); |
| 80 chromeos::DBusThreadManager::Shutdown(); | 83 chromeos::DBusThreadManager::Shutdown(); |
| 81 // Ash Shell can't just live on its own without a browser process, we need to | 84 // Ash Shell can't just live on its own without a browser process, we need to |
| 82 // also shut down the message center. | 85 // also shut down the message center. |
| 83 message_center::MessageCenter::Shutdown(); | 86 message_center::MessageCenter::Shutdown(); |
| 84 } | 87 } |
| 85 | 88 |
| 86 } // namespace | 89 } // namespace |
| 87 | 90 |
| 88 // static | 91 // static |
| 89 ViewEventTestPlatformPart* ViewEventTestPlatformPart::Create( | 92 ViewEventTestPlatformPart* ViewEventTestPlatformPart::Create( |
| 90 ui::ContextFactory* context_factory) { | 93 ui::ContextFactory* context_factory) { |
| 91 return new ViewEventTestPlatformPartChromeOS(context_factory); | 94 return new ViewEventTestPlatformPartChromeOS(context_factory); |
| 92 } | 95 } |
| OLD | NEW |