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

Side by Side Diff: ash/test/ash_test_helper.cc

Issue 15025002: Remove ENABLE_MESSAGE_CENTER (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: one moer fix Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ash/test/ash_test_helper.h" 5 #include "ash/test/ash_test_helper.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/test/display_manager_test_api.h" 9 #include "ash/test/display_manager_test_api.h"
10 #include "ash/test/shell_test_api.h" 10 #include "ash/test/shell_test_api.h"
11 #include "ash/test/test_shell_delegate.h" 11 #include "ash/test/test_shell_delegate.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "ui/aura/env.h" 14 #include "ui/aura/env.h"
15 #include "ui/base/ime/text_input_test_support.h" 15 #include "ui/base/ime/text_input_test_support.h"
16 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 16 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
17
18
19 #if defined(ENABLE_MESSAGE_CENTER)
20 #include "ui/message_center/message_center.h" 17 #include "ui/message_center/message_center.h"
21 #endif
22 18
23 namespace ash { 19 namespace ash {
24 namespace test { 20 namespace test {
25 21
26 AshTestHelper::AshTestHelper(base::MessageLoopForUI* message_loop) 22 AshTestHelper::AshTestHelper(base::MessageLoopForUI* message_loop)
27 : message_loop_(message_loop), 23 : message_loop_(message_loop),
28 test_shell_delegate_(NULL) { 24 test_shell_delegate_(NULL) {
29 CHECK(message_loop_); 25 CHECK(message_loop_);
30 } 26 }
31 27
32 AshTestHelper::~AshTestHelper() { 28 AshTestHelper::~AshTestHelper() {
33 } 29 }
34 30
35 void AshTestHelper::SetUp() { 31 void AshTestHelper::SetUp() {
36 // TODO(jennyz): Create mock or test AudioHandler so we can instantiate 32 // TODO(jennyz): Create mock or test AudioHandler so we can instantiate
37 // an ash::Shell with the new CrasAudioHandler. crbug.com/233266 33 // an ash::Shell with the new CrasAudioHandler. crbug.com/233266
38 CommandLine::ForCurrentProcess()->AppendSwitch( 34 CommandLine::ForCurrentProcess()->AppendSwitch(
39 ash::switches::kAshDisableNewAudioHandler); 35 ash::switches::kAshDisableNewAudioHandler);
40 // Disable animations during tests. 36 // Disable animations during tests.
41 zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( 37 zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode(
42 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); 38 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION));
43 ui::TextInputTestSupport::Initialize(); 39 ui::TextInputTestSupport::Initialize();
44 40
45 // Creates Shell and hook with Desktop. 41 // Creates Shell and hook with Desktop.
46 test_shell_delegate_ = new TestShellDelegate; 42 test_shell_delegate_ = new TestShellDelegate;
47 43
48 #if defined(ENABLE_MESSAGE_CENTER)
49 // Creates MessageCenter since g_browser_process is not created in AshTestBase 44 // Creates MessageCenter since g_browser_process is not created in AshTestBase
50 // tests. 45 // tests.
51 message_center::MessageCenter::Initialize(); 46 message_center::MessageCenter::Initialize();
52 #endif
53 ash::Shell::CreateInstance(test_shell_delegate_); 47 ash::Shell::CreateInstance(test_shell_delegate_);
54 Shell* shell = Shell::GetInstance(); 48 Shell* shell = Shell::GetInstance();
55 test::DisplayManagerTestApi(shell->display_manager()). 49 test::DisplayManagerTestApi(shell->display_manager()).
56 DisableChangeDisplayUponHostResize(); 50 DisableChangeDisplayUponHostResize();
57 ShellTestApi(shell).DisableOutputConfiguratorAnimation(); 51 ShellTestApi(shell).DisableOutputConfiguratorAnimation();
58 52
59 } 53 }
60 54
61 void AshTestHelper::TearDown() { 55 void AshTestHelper::TearDown() {
62 // Tear down the shell. 56 // Tear down the shell.
63 Shell::DeleteInstance(); 57 Shell::DeleteInstance();
64 58
65 #if defined(ENABLE_MESSAGE_CENTER)
66 // Remove global message center state. 59 // Remove global message center state.
67 message_center::MessageCenter::Shutdown(); 60 message_center::MessageCenter::Shutdown();
68 #endif
69 61
70 aura::Env::DeleteInstance(); 62 aura::Env::DeleteInstance();
71 ui::TextInputTestSupport::Shutdown(); 63 ui::TextInputTestSupport::Shutdown();
72 64
73 zero_duration_mode_.reset(); 65 zero_duration_mode_.reset();
74 } 66 }
75 67
76 void AshTestHelper::RunAllPendingInMessageLoop() { 68 void AshTestHelper::RunAllPendingInMessageLoop() {
77 #if !defined(OS_MACOSX) 69 #if !defined(OS_MACOSX)
78 DCHECK(MessageLoopForUI::current() == message_loop_); 70 DCHECK(MessageLoopForUI::current() == message_loop_);
79 base::RunLoop run_loop(aura::Env::GetInstance()->GetDispatcher()); 71 base::RunLoop run_loop(aura::Env::GetInstance()->GetDispatcher());
80 run_loop.RunUntilIdle(); 72 run_loop.RunUntilIdle();
81 #endif 73 #endif
82 } 74 }
83 75
84 aura::RootWindow* AshTestHelper::CurrentContext() { 76 aura::RootWindow* AshTestHelper::CurrentContext() {
85 aura::RootWindow* root_window = Shell::GetActiveRootWindow(); 77 aura::RootWindow* root_window = Shell::GetActiveRootWindow();
86 if (!root_window) 78 if (!root_window)
87 root_window = Shell::GetPrimaryRootWindow(); 79 root_window = Shell::GetPrimaryRootWindow();
88 DCHECK(root_window); 80 DCHECK(root_window);
89 return root_window; 81 return root_window;
90 } 82 }
91 83
92 } // namespace test 84 } // namespace test
93 } // namespace ash 85 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698