Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(886)

Side by Side Diff: chrome/test/base/view_event_test_platform_part_chromeos.cc

Issue 1871253002: aura: Require explicit ownership of the Env instance. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tot.merge Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/test/test_suite.cc ('k') | chrome/test/base/view_event_test_platform_part_default.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « ash/test/test_suite.cc ('k') | chrome/test/base/view_event_test_platform_part_default.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698