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

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

Issue 11428066: 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
29 namespace ash { 33 namespace ash {
30 namespace test { 34 namespace test {
31 35
32 content::WebContents* AshTestViewsDelegate::CreateWebContents( 36 content::WebContents* AshTestViewsDelegate::CreateWebContents(
33 content::BrowserContext* browser_context, 37 content::BrowserContext* browser_context,
34 content::SiteInstance* site_instance) { 38 content::SiteInstance* site_instance) {
35 return content::WebContentsTester::CreateTestWebContents(browser_context, 39 return content::WebContentsTester::CreateTestWebContents(browser_context,
36 site_instance); 40 site_instance);
37 } 41 }
38 42
39 AshTestBase::AshTestBase() : test_shell_delegate_(NULL) { 43 AshTestBase::AshTestBase() : test_shell_delegate_(NULL) {
40 } 44 }
41 45
42 AshTestBase::~AshTestBase() { 46 AshTestBase::~AshTestBase() {
43 } 47 }
44 48
45 void AshTestBase::SetUp() { 49 void AshTestBase::SetUp() {
50 // Use the origin (1,1) so that it doesn't over
51 // lap with the native mouse cursor.
46 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 52 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
47 switches::kAuraHostWindowSize, "0+0-800x600"); 53 switches::kAuraHostWindowSize, "1+1-800x600");
54 #if defined(OS_WIN)
55 aura::test::SetUsePopupAsRootWindowForTest(true);
56 #endif
48 // Disable animations during tests. 57 // Disable animations during tests.
49 ui::LayerAnimator::set_disable_animations_for_test(true); 58 ui::LayerAnimator::set_disable_animations_for_test(true);
50 ui::TextInputTestSupport::Initialize(); 59 ui::TextInputTestSupport::Initialize();
51 // Creates Shell and hook with Desktop. 60 // Creates Shell and hook with Desktop.
52 test_shell_delegate_ = new TestShellDelegate; 61 test_shell_delegate_ = new TestShellDelegate;
53 ash::Shell::CreateInstance(test_shell_delegate_); 62 ash::Shell::CreateInstance(test_shell_delegate_);
54 Shell::GetPrimaryRootWindow()->Show(); 63 Shell::GetPrimaryRootWindow()->Show();
55 Shell::GetPrimaryRootWindow()->ShowRootWindow(); 64 Shell::GetPrimaryRootWindow()->ShowRootWindow();
56 // Move the mouse cursor to far away so that native events doesn't 65 // Move the mouse cursor to far away so that native events doesn't
57 // interfere test expectations. 66 // interfere test expectations.
58 Shell::GetPrimaryRootWindow()->MoveCursorTo(gfx::Point(-1000, -1000)); 67 Shell::GetPrimaryRootWindow()->MoveCursorTo(gfx::Point(-1000, -1000));
59 Shell::GetInstance()->cursor_manager()->ShowCursor(true); 68 Shell::GetInstance()->cursor_manager()->ShowCursor(true);
60 } 69 }
61 70
62 void AshTestBase::TearDown() { 71 void AshTestBase::TearDown() {
63 // Flush the message loop to finish pending release tasks. 72 // Flush the message loop to finish pending release tasks.
64 RunAllPendingInMessageLoop(); 73 RunAllPendingInMessageLoop();
65 74
66 // Tear down the shell. 75 // Tear down the shell.
67 Shell::DeleteInstance(); 76 Shell::DeleteInstance();
68 aura::Env::DeleteInstance(); 77 aura::Env::DeleteInstance();
69 ui::TextInputTestSupport::Shutdown(); 78 ui::TextInputTestSupport::Shutdown();
79 #if defined(OS_WIN)
80 aura::test::SetUsePopupAsRootWindowForTest(false);
81 #endif
70 } 82 }
71 83
72 void AshTestBase::ChangeDisplayConfig(float scale, 84 void AshTestBase::ChangeDisplayConfig(float scale,
73 const gfx::Rect& bounds_in_pixel) { 85 const gfx::Rect& bounds_in_pixel) {
74 gfx::Display display = 86 gfx::Display display =
75 gfx::Display(Shell::GetScreen()->GetPrimaryDisplay().id()); 87 gfx::Display(Shell::GetScreen()->GetPrimaryDisplay().id());
76 display.SetScaleAndBounds(scale, bounds_in_pixel); 88 display.SetScaleAndBounds(scale, bounds_in_pixel);
77 std::vector<gfx::Display> displays; 89 std::vector<gfx::Display> displays;
78 displays.push_back(display); 90 displays.push_back(display);
79 Shell::GetInstance()->display_manager()->OnNativeDisplaysChanged(displays); 91 Shell::GetInstance()->display_manager()->OnNativeDisplaysChanged(displays);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 void AshTestBase::SetUserLoggedIn(bool user_logged_in) { 160 void AshTestBase::SetUserLoggedIn(bool user_logged_in) {
149 test_shell_delegate_->SetUserLoggedIn(user_logged_in); 161 test_shell_delegate_->SetUserLoggedIn(user_logged_in);
150 } 162 }
151 163
152 void AshTestBase::SetCanLockScreen(bool can_lock_screen) { 164 void AshTestBase::SetCanLockScreen(bool can_lock_screen) {
153 test_shell_delegate_->SetCanLockScreen(can_lock_screen); 165 test_shell_delegate_->SetCanLockScreen(can_lock_screen);
154 } 166 }
155 167
156 } // namespace test 168 } // namespace test
157 } // namespace ash 169 } // 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