[Chromoting] Update size to use inner/outer bounds
[chromium-blink-merge.git] / chrome / test / base / view_event_test_platform_part_chromeos.cc
blob4e9b12e9a4e3bb0e931e8e21a7831652fbb104a7
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/test_session_state_delegate.h"
10 #include "ash/test/test_shell_delegate.h"
11 #include "chromeos/audio/cras_audio_handler.h"
12 #include "chromeos/dbus/dbus_thread_manager.h"
13 #include "chromeos/network/network_handler.h"
14 #include "ui/aura/env.h"
15 #include "ui/aura/window_tree_host.h"
16 #include "ui/message_center/message_center.h"
17 #include "ui/wm/core/wm_state.h"
19 namespace {
21 // ViewEventTestPlatformPart implementation for ChromeOS (chromeos=1).
22 class ViewEventTestPlatformPartChromeOS : public ViewEventTestPlatformPart {
23 public:
24 explicit ViewEventTestPlatformPartChromeOS(
25 ui::ContextFactory* context_factory);
26 virtual ~ViewEventTestPlatformPartChromeOS();
28 // Overridden from ViewEventTestPlatformPart:
29 virtual gfx::NativeWindow GetContext() override {
30 return ash::Shell::GetPrimaryRootWindow();
33 private:
34 wm::WMState wm_state_;
36 DISALLOW_COPY_AND_ASSIGN(ViewEventTestPlatformPartChromeOS);
39 ViewEventTestPlatformPartChromeOS::ViewEventTestPlatformPartChromeOS(
40 ui::ContextFactory* context_factory) {
41 // Ash Shell can't just live on its own without a browser process, we need to
42 // also create the message center.
43 message_center::MessageCenter::Initialize();
44 chromeos::DBusThreadManager::Initialize();
45 chromeos::CrasAudioHandler::InitializeForTesting();
46 chromeos::NetworkHandler::Initialize();
47 ash::test::TestShellDelegate* shell_delegate =
48 new ash::test::TestShellDelegate();
49 ash::ShellInitParams init_params;
50 init_params.delegate = shell_delegate;
51 init_params.context_factory = context_factory;
52 ash::Shell::CreateInstance(init_params);
53 shell_delegate->test_session_state_delegate()->SetActiveUserSessionStarted(
54 true);
55 GetContext()->GetHost()->Show();
58 ViewEventTestPlatformPartChromeOS::~ViewEventTestPlatformPartChromeOS() {
59 ash::Shell::DeleteInstance();
60 chromeos::NetworkHandler::Shutdown();
61 chromeos::CrasAudioHandler::Shutdown();
62 chromeos::DBusThreadManager::Shutdown();
63 // Ash Shell can't just live on its own without a browser process, we need to
64 // also shut down the message center.
65 message_center::MessageCenter::Shutdown();
67 aura::Env::DeleteInstance();
70 } // namespace
72 // static
73 ViewEventTestPlatformPart* ViewEventTestPlatformPart::Create(
74 ui::ContextFactory* context_factory) {
75 return new ViewEventTestPlatformPartChromeOS(context_factory);