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

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

Issue 11419271: Revert "Use WS_POPUP for ash_unittests" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
« no previous file with comments | « ash/screen_ash_unittest.cc ('k') | ash/test/display_manager_test_api.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_base.h" 5 #include "ash/test/ash_test_base.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/display/display_controller.h" 10 #include "ash/display/display_controller.h"
11 #include "ash/display/display_manager.h" 11 #include "ash/display/display_manager.h"
12 #include "ash/shell.h" 12 #include "ash/shell.h"
13 #include "ash/test/display_manager_test_api.h" 13 #include "ash/test/display_manager_test_api.h"
14 #include "ash/test/test_shell_delegate.h" 14 #include "ash/test/test_shell_delegate.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/run_loop.h" 16 #include "base/run_loop.h"
17 #include "content/public/test/web_contents_tester.h" 17 #include "content/public/test/web_contents_tester.h"
18 #include "ui/aura/aura_switches.h" 18 #include "ui/aura/aura_switches.h"
19 #include "ui/aura/client/aura_constants.h" 19 #include "ui/aura/client/aura_constants.h"
20 #include "ui/aura/env.h" 20 #include "ui/aura/env.h"
21 #include "ui/aura/root_window.h" 21 #include "ui/aura/root_window.h"
22 #include "ui/aura/test/test_window_delegate.h" 22 #include "ui/aura/test/test_window_delegate.h"
23 #include "ui/aura/window_delegate.h" 23 #include "ui/aura/window_delegate.h"
24 #include "ui/base/ime/text_input_test_support.h" 24 #include "ui/base/ime/text_input_test_support.h"
25 #include "ui/compositor/layer_animator.h" 25 #include "ui/compositor/layer_animator.h"
26 #include "ui/gfx/display.h" 26 #include "ui/gfx/display.h"
27 #include "ui/gfx/screen.h" 27 #include "ui/gfx/screen.h"
28 28
29 #if defined(OS_WIN)
30 #include "ui/aura/root_window_host_win.h"
31 #endif
32
33 namespace ash { 29 namespace ash {
34 namespace test { 30 namespace test {
35 31
36 content::WebContents* AshTestViewsDelegate::CreateWebContents( 32 content::WebContents* AshTestViewsDelegate::CreateWebContents(
37 content::BrowserContext* browser_context, 33 content::BrowserContext* browser_context,
38 content::SiteInstance* site_instance) { 34 content::SiteInstance* site_instance) {
39 return content::WebContentsTester::CreateTestWebContents(browser_context, 35 return content::WebContentsTester::CreateTestWebContents(browser_context,
40 site_instance); 36 site_instance);
41 } 37 }
42 38
43 AshTestBase::AshTestBase() : test_shell_delegate_(NULL) { 39 AshTestBase::AshTestBase() : test_shell_delegate_(NULL) {
44 } 40 }
45 41
46 AshTestBase::~AshTestBase() { 42 AshTestBase::~AshTestBase() {
47 } 43 }
48 44
49 void AshTestBase::SetUp() { 45 void AshTestBase::SetUp() {
50 // Use the origin (1,1) so that it doesn't over
51 // lap with the native mouse cursor.
52 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 46 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
53 switches::kAuraHostWindowSize, "1+1-800x600"); 47 switches::kAuraHostWindowSize, "0+0-800x600");
54 #if defined(OS_WIN)
55 aura::test::SetUsePopupAsRootWindowForTest(true);
56 #endif
57 // Disable animations during tests. 48 // Disable animations during tests.
58 ui::LayerAnimator::set_disable_animations_for_test(true); 49 ui::LayerAnimator::set_disable_animations_for_test(true);
59 ui::TextInputTestSupport::Initialize(); 50 ui::TextInputTestSupport::Initialize();
60 // Creates Shell and hook with Desktop. 51 // Creates Shell and hook with Desktop.
61 test_shell_delegate_ = new TestShellDelegate; 52 test_shell_delegate_ = new TestShellDelegate;
62 ash::Shell::CreateInstance(test_shell_delegate_); 53 ash::Shell::CreateInstance(test_shell_delegate_);
63 Shell::GetPrimaryRootWindow()->Show(); 54 Shell::GetPrimaryRootWindow()->Show();
64 Shell::GetPrimaryRootWindow()->ShowRootWindow(); 55 Shell::GetPrimaryRootWindow()->ShowRootWindow();
65 // Move the mouse cursor to (0,0) so that native events doesn't 56 // Move the mouse cursor to far away so that native events doesn't
66 // interfere test expectations. 57 // interfere test expectations.
67 Shell::GetPrimaryRootWindow()->MoveCursorTo(gfx::Point(0, 0)); 58 Shell::GetPrimaryRootWindow()->MoveCursorTo(gfx::Point(-1000, -1000));
68 Shell::GetInstance()->cursor_manager()->ShowCursor(true); 59 Shell::GetInstance()->cursor_manager()->ShowCursor(true);
69 } 60 }
70 61
71 void AshTestBase::TearDown() { 62 void AshTestBase::TearDown() {
72 // Flush the message loop to finish pending release tasks. 63 // Flush the message loop to finish pending release tasks.
73 RunAllPendingInMessageLoop(); 64 RunAllPendingInMessageLoop();
74 65
75 // Tear down the shell. 66 // Tear down the shell.
76 Shell::DeleteInstance(); 67 Shell::DeleteInstance();
77 aura::Env::DeleteInstance(); 68 aura::Env::DeleteInstance();
78 ui::TextInputTestSupport::Shutdown(); 69 ui::TextInputTestSupport::Shutdown();
79 #if defined(OS_WIN)
80 aura::test::SetUsePopupAsRootWindowForTest(false);
81 #endif
82 } 70 }
83 71
84 void AshTestBase::ChangeDisplayConfig(float scale, 72 void AshTestBase::ChangeDisplayConfig(float scale,
85 const gfx::Rect& bounds_in_pixel) { 73 const gfx::Rect& bounds_in_pixel) {
86 gfx::Display display = 74 gfx::Display display =
87 gfx::Display(Shell::GetScreen()->GetPrimaryDisplay().id()); 75 gfx::Display(Shell::GetScreen()->GetPrimaryDisplay().id());
88 display.SetScaleAndBounds(scale, bounds_in_pixel); 76 display.SetScaleAndBounds(scale, bounds_in_pixel);
89 std::vector<gfx::Display> displays; 77 std::vector<gfx::Display> displays;
90 displays.push_back(display); 78 displays.push_back(display);
91 Shell::GetInstance()->display_manager()->OnNativeDisplaysChanged(displays); 79 Shell::GetInstance()->display_manager()->OnNativeDisplaysChanged(displays);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 void AshTestBase::SetUserLoggedIn(bool user_logged_in) { 148 void AshTestBase::SetUserLoggedIn(bool user_logged_in) {
161 test_shell_delegate_->SetUserLoggedIn(user_logged_in); 149 test_shell_delegate_->SetUserLoggedIn(user_logged_in);
162 } 150 }
163 151
164 void AshTestBase::SetCanLockScreen(bool can_lock_screen) { 152 void AshTestBase::SetCanLockScreen(bool can_lock_screen) {
165 test_shell_delegate_->SetCanLockScreen(can_lock_screen); 153 test_shell_delegate_->SetCanLockScreen(can_lock_screen);
166 } 154 }
167 155
168 } // namespace test 156 } // namespace test
169 } // namespace ash 157 } // namespace ash
OLDNEW
« no previous file with comments | « ash/screen_ash_unittest.cc ('k') | ash/test/display_manager_test_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698