Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / test / base / view_event_test_platform_part_chromeos.cc
blobd1e996367e375920035df38b37595650abaede5e
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
3 // found in the LICENSE file.
5 #include "chrome/test/base/view_event_test_platform_part.h"
7 #include "ash/shell.h"
8 #include "ash/shell_init_params.h"
9 #include "ash/test/ash_test_helper.h"
10 #include "ash/test/test_session_state_delegate.h"
11 #include "ash/test/test_shell_delegate.h"
12 #include "chromeos/audio/cras_audio_handler.h"
13 #include "chromeos/dbus/dbus_thread_manager.h"
14 #include "chromeos/network/network_handler.h"
15 #include "ui/aura/env.h"
16 #include "ui/aura/window_tree_host.h"
17 #include "ui/message_center/message_center.h"
18 #include "ui/wm/core/wm_state.h"
20 namespace {
22 // ViewEventTestPlatformPart implementation for ChromeOS (chromeos=1).
23 class ViewEventTestPlatformPartChromeOS : public ViewEventTestPlatformPart {
24 public:
25 explicit ViewEventTestPlatformPartChromeOS(
26 ui::ContextFactory* context_factory);
27 ~ViewEventTestPlatformPartChromeOS() override;
29 // Overridden from ViewEventTestPlatformPart:
30 gfx::NativeWindow GetContext() override {
31 return ash::Shell::GetPrimaryRootWindow();
34 private:
35 wm::WMState wm_state_;
37 DISALLOW_COPY_AND_ASSIGN(ViewEventTestPlatformPartChromeOS);
40 ViewEventTestPlatformPartChromeOS::ViewEventTestPlatformPartChromeOS(
41 ui::ContextFactory* context_factory) {
42 // Ash Shell can't just live on its own without a browser process, we need to
43 // also create the message center.
44 message_center::MessageCenter::Initialize();
45 chromeos::DBusThreadManager::Initialize();
46 chromeos::CrasAudioHandler::InitializeForTesting();
47 chromeos::NetworkHandler::Initialize();
48 ash::test::TestShellDelegate* shell_delegate =
49 new ash::test::TestShellDelegate();
50 ash::ShellInitParams init_params;
51 init_params.delegate = shell_delegate;
52 init_params.context_factory = context_factory;
53 ash::Shell::CreateInstance(init_params);
54 ash::test::AshTestHelper::GetTestSessionStateDelegate()->
55 SetActiveUserSessionStarted(true);
56 GetContext()->GetHost()->Show();
59 ViewEventTestPlatformPartChromeOS::~ViewEventTestPlatformPartChromeOS() {
60 ash::Shell::DeleteInstance();
61 chromeos::NetworkHandler::Shutdown();
62 chromeos::CrasAudioHandler::Shutdown();
63 chromeos::DBusThreadManager::Shutdown();
64 // Ash Shell can't just live on its own without a browser process, we need to
65 // also shut down the message center.
66 message_center::MessageCenter::Shutdown();
68 aura::Env::DeleteInstance();
71 } // namespace
73 // static
74 ViewEventTestPlatformPart* ViewEventTestPlatformPart::Create(
75 ui::ContextFactory* context_factory) {
76 return new ViewEventTestPlatformPartChromeOS(context_factory);