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

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

Issue 11825015: [Cleanup] consolidate DISABLED macros in mouse_cursor_event_filter_unittests.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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
« no previous file with comments | « ash/test/ash_test_base.h ('k') | ash/wm/activation_controller_unittest.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/screen_ash.h"
12 #include "ash/shell.h" 13 #include "ash/shell.h"
13 #include "ash/test/display_manager_test_api.h" 14 #include "ash/test/display_manager_test_api.h"
14 #include "ash/test/test_shell_delegate.h" 15 #include "ash/test/test_shell_delegate.h"
15 #include "ash/wm/coordinate_conversion.h" 16 #include "ash/wm/coordinate_conversion.h"
16 #include "base/command_line.h" 17 #include "base/command_line.h"
17 #include "base/run_loop.h" 18 #include "base/run_loop.h"
18 #include "content/public/test/web_contents_tester.h" 19 #include "content/public/test/web_contents_tester.h"
19 #include "ui/aura/aura_switches.h" 20 #include "ui/aura/aura_switches.h"
20 #include "ui/aura/client/aura_constants.h" 21 #include "ui/aura/client/aura_constants.h"
22 #include "ui/aura/client/screen_position_client.h"
21 #include "ui/aura/env.h" 23 #include "ui/aura/env.h"
22 #include "ui/aura/root_window.h" 24 #include "ui/aura/root_window.h"
25 #include "ui/aura/test/event_generator.h"
23 #include "ui/aura/test/test_window_delegate.h" 26 #include "ui/aura/test/test_window_delegate.h"
24 #include "ui/aura/window_delegate.h" 27 #include "ui/aura/window_delegate.h"
25 #include "ui/base/ime/text_input_test_support.h" 28 #include "ui/base/ime/text_input_test_support.h"
26 #include "ui/compositor/layer_animator.h" 29 #include "ui/compositor/layer_animator.h"
27 #include "ui/gfx/display.h" 30 #include "ui/gfx/display.h"
28 #include "ui/gfx/screen.h" 31 #include "ui/gfx/screen.h"
29 32
30 #if defined(OS_WIN) 33 #if defined(OS_WIN)
31 #include "ui/aura/root_window_host_win.h" 34 #include "ui/aura/root_window_host_win.h"
32 #endif 35 #endif
33 36
34 namespace ash { 37 namespace ash {
35 namespace test { 38 namespace test {
39 namespace {
40
41 class AshEventGeneratorDelegate : public aura::test::EventGeneratorDelegate {
42 public:
43 AshEventGeneratorDelegate() {}
44 virtual ~AshEventGeneratorDelegate() {}
45
46 // aura::test::EventGeneratorDelegate overrides:
47 aura::RootWindow* GetRootWindowAt(
48 const gfx::Point& point_in_screen) const OVERRIDE {
49 gfx::Screen* screen = Shell::GetInstance()->screen();
50 gfx::Display display = screen->GetDisplayNearestPoint(point_in_screen);
51 return Shell::GetInstance()->display_controller()->
52 GetRootWindowForDisplayId(display.id());
53 }
54
55 aura::client::ScreenPositionClient* GetScreenPositionClient(
56 const aura::Window* window) const OVERRIDE {
57 return aura::client::GetScreenPositionClient(window->GetRootWindow());
58 }
59
60 private:
61 DISALLOW_COPY_AND_ASSIGN(AshEventGeneratorDelegate);
62 };
63
64 } // namespace
36 65
37 content::WebContents* AshTestViewsDelegate::CreateWebContents( 66 content::WebContents* AshTestViewsDelegate::CreateWebContents(
38 content::BrowserContext* browser_context, 67 content::BrowserContext* browser_context,
39 content::SiteInstance* site_instance) { 68 content::SiteInstance* site_instance) {
40 return content::WebContentsTester::CreateTestWebContents(browser_context, 69 return content::WebContentsTester::CreateTestWebContents(browser_context,
41 site_instance); 70 site_instance);
42 } 71 }
43 72
44 AshTestBase::AshTestBase() : test_shell_delegate_(NULL) { 73 AshTestBase::AshTestBase()
74 : test_shell_delegate_(NULL) {
45 } 75 }
46 76
47 AshTestBase::~AshTestBase() { 77 AshTestBase::~AshTestBase() {
48 } 78 }
49 79
50 void AshTestBase::SetUp() { 80 void AshTestBase::SetUp() {
51 // Use the origin (1,1) so that it doesn't over 81 // Use the origin (1,1) so that it doesn't over
52 // lap with the native mouse cursor. 82 // lap with the native mouse cursor.
53 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 83 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
54 switches::kAuraHostWindowSize, "1+1-800x600"); 84 switches::kAuraHostWindowSize, "1+1-800x600");
(...skipping 18 matching lines...) Expand all
73 // Flush the message loop to finish pending release tasks. 103 // Flush the message loop to finish pending release tasks.
74 RunAllPendingInMessageLoop(); 104 RunAllPendingInMessageLoop();
75 105
76 // Tear down the shell. 106 // Tear down the shell.
77 Shell::DeleteInstance(); 107 Shell::DeleteInstance();
78 aura::Env::DeleteInstance(); 108 aura::Env::DeleteInstance();
79 ui::TextInputTestSupport::Shutdown(); 109 ui::TextInputTestSupport::Shutdown();
80 #if defined(OS_WIN) 110 #if defined(OS_WIN)
81 aura::test::SetUsePopupAsRootWindowForTest(false); 111 aura::test::SetUsePopupAsRootWindowForTest(false);
82 #endif 112 #endif
113 event_generator_.reset();
114 }
115
116 aura::test::EventGenerator& AshTestBase::GetEventGenerator() {
117 if (!event_generator_.get()) {
118 event_generator_.reset(
119 new aura::test::EventGenerator(new AshEventGeneratorDelegate()));
120 }
121 return *event_generator_.get();
83 } 122 }
84 123
85 void AshTestBase::ChangeDisplayConfig(float scale, 124 void AshTestBase::ChangeDisplayConfig(float scale,
86 const gfx::Rect& bounds_in_pixel) { 125 const gfx::Rect& bounds_in_pixel) {
87 gfx::Display display = 126 gfx::Display display =
88 gfx::Display(Shell::GetScreen()->GetPrimaryDisplay().id()); 127 gfx::Display(Shell::GetScreen()->GetPrimaryDisplay().id());
89 display.SetScaleAndBounds(scale, bounds_in_pixel); 128 display.SetScaleAndBounds(scale, bounds_in_pixel);
90 std::vector<gfx::Display> displays; 129 std::vector<gfx::Display> displays;
91 displays.push_back(display); 130 displays.push_back(display);
92 Shell::GetInstance()->display_manager()->OnNativeDisplaysChanged(displays); 131 Shell::GetInstance()->display_manager()->OnNativeDisplaysChanged(displays);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 void AshTestBase::SetUserLoggedIn(bool user_logged_in) { 219 void AshTestBase::SetUserLoggedIn(bool user_logged_in) {
181 test_shell_delegate_->SetUserLoggedIn(user_logged_in); 220 test_shell_delegate_->SetUserLoggedIn(user_logged_in);
182 } 221 }
183 222
184 void AshTestBase::SetCanLockScreen(bool can_lock_screen) { 223 void AshTestBase::SetCanLockScreen(bool can_lock_screen) {
185 test_shell_delegate_->SetCanLockScreen(can_lock_screen); 224 test_shell_delegate_->SetCanLockScreen(can_lock_screen);
186 } 225 }
187 226
188 } // namespace test 227 } // namespace test
189 } // namespace ash 228 } // namespace ash
OLDNEW
« no previous file with comments | « ash/test/ash_test_base.h ('k') | ash/wm/activation_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698