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

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

Issue 1293013002: aura: Require explicit ownership of the Env instance. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 4 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
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 "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_init_params.h" 8 #include "ash/shell_init_params.h"
9 #include "ash/test/ash_test_helper.h" 9 #include "ash/test/ash_test_helper.h"
10 #include "ash/test/test_session_state_delegate.h" 10 #include "ash/test/test_session_state_delegate.h"
(...skipping 15 matching lines...) Expand all
26 ui::ContextFactory* context_factory); 26 ui::ContextFactory* context_factory);
27 ~ViewEventTestPlatformPartChromeOS() override; 27 ~ViewEventTestPlatformPartChromeOS() override;
28 28
29 // Overridden from ViewEventTestPlatformPart: 29 // Overridden from ViewEventTestPlatformPart:
30 gfx::NativeWindow GetContext() override { 30 gfx::NativeWindow GetContext() override {
31 return ash::Shell::GetPrimaryRootWindow(); 31 return ash::Shell::GetPrimaryRootWindow();
32 } 32 }
33 33
34 private: 34 private:
35 wm::WMState wm_state_; 35 wm::WMState wm_state_;
36 scoped_ptr<aura::Env> env_;
36 37
37 DISALLOW_COPY_AND_ASSIGN(ViewEventTestPlatformPartChromeOS); 38 DISALLOW_COPY_AND_ASSIGN(ViewEventTestPlatformPartChromeOS);
38 }; 39 };
39 40
40 ViewEventTestPlatformPartChromeOS::ViewEventTestPlatformPartChromeOS( 41 ViewEventTestPlatformPartChromeOS::ViewEventTestPlatformPartChromeOS(
41 ui::ContextFactory* context_factory) { 42 ui::ContextFactory* context_factory) {
42 // Ash Shell can't just live on its own without a browser process, we need to 43 // Ash Shell can't just live on its own without a browser process, we need to
43 // also create the message center. 44 // also create the message center.
44 message_center::MessageCenter::Initialize(); 45 message_center::MessageCenter::Initialize();
45 chromeos::DBusThreadManager::Initialize(); 46 chromeos::DBusThreadManager::Initialize();
46 chromeos::CrasAudioHandler::InitializeForTesting(); 47 chromeos::CrasAudioHandler::InitializeForTesting();
47 chromeos::NetworkHandler::Initialize(); 48 chromeos::NetworkHandler::Initialize();
48 49
49 aura::Env::CreateInstance(true); 50 env_ = aura::Env::CreateInstance();
50 ash::test::TestShellDelegate* shell_delegate = 51 ash::test::TestShellDelegate* shell_delegate =
51 new ash::test::TestShellDelegate(); 52 new ash::test::TestShellDelegate();
52 ash::ShellInitParams init_params; 53 ash::ShellInitParams init_params;
53 init_params.delegate = shell_delegate; 54 init_params.delegate = shell_delegate;
54 init_params.context_factory = context_factory; 55 init_params.context_factory = context_factory;
55 ash::Shell::CreateInstance(init_params); 56 ash::Shell::CreateInstance(init_params);
56 ash::test::AshTestHelper::GetTestSessionStateDelegate()-> 57 ash::test::AshTestHelper::GetTestSessionStateDelegate()->
57 SetActiveUserSessionStarted(true); 58 SetActiveUserSessionStarted(true);
58 GetContext()->GetHost()->Show(); 59 GetContext()->GetHost()->Show();
59 } 60 }
60 61
61 ViewEventTestPlatformPartChromeOS::~ViewEventTestPlatformPartChromeOS() { 62 ViewEventTestPlatformPartChromeOS::~ViewEventTestPlatformPartChromeOS() {
62 ash::Shell::DeleteInstance(); 63 ash::Shell::DeleteInstance();
63 aura::Env::DeleteInstance(); 64 env_.reset();
64 65
65 chromeos::NetworkHandler::Shutdown(); 66 chromeos::NetworkHandler::Shutdown();
66 chromeos::CrasAudioHandler::Shutdown(); 67 chromeos::CrasAudioHandler::Shutdown();
67 chromeos::DBusThreadManager::Shutdown(); 68 chromeos::DBusThreadManager::Shutdown();
68 // Ash Shell can't just live on its own without a browser process, we need to 69 // Ash Shell can't just live on its own without a browser process, we need to
69 // also shut down the message center. 70 // also shut down the message center.
70 message_center::MessageCenter::Shutdown(); 71 message_center::MessageCenter::Shutdown();
71 } 72 }
72 73
73 } // namespace 74 } // namespace
74 75
75 // static 76 // static
76 ViewEventTestPlatformPart* ViewEventTestPlatformPart::Create( 77 ViewEventTestPlatformPart* ViewEventTestPlatformPart::Create(
77 ui::ContextFactory* context_factory) { 78 ui::ContextFactory* context_factory) {
78 return new ViewEventTestPlatformPartChromeOS(context_factory); 79 return new ViewEventTestPlatformPartChromeOS(context_factory);
79 } 80 }
OLDNEW
« no previous file with comments | « chrome/test/base/view_event_test_platform_part_ash.cc ('k') | chromecast/browser/cast_browser_main_parts.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698