| OLD | NEW |
| 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/common/ash_switches.h" | 10 #include "ash/common/ash_switches.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 DISALLOW_COPY_AND_ASSIGN(AshEventGeneratorDelegate); | 86 DISALLOW_COPY_AND_ASSIGN(AshEventGeneratorDelegate); |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 } // namespace | 89 } // namespace |
| 90 | 90 |
| 91 ///////////////////////////////////////////////////////////////////////////// | 91 ///////////////////////////////////////////////////////////////////////////// |
| 92 | 92 |
| 93 AshTestBase::AshTestBase() | 93 AshTestBase::AshTestBase() |
| 94 : setup_called_(false), | 94 : setup_called_(false), teardown_called_(false), start_session_(true) { |
| 95 teardown_called_(false), | |
| 96 start_session_(true) { | |
| 97 #if defined(USE_X11) | 95 #if defined(USE_X11) |
| 98 // This is needed for tests which use this base class but are run in browser | 96 // This is needed for tests which use this base class but are run in browser |
| 99 // test binaries so don't get the default initialization in the unit test | 97 // test binaries so don't get the default initialization in the unit test |
| 100 // suite. | 98 // suite. |
| 101 gfx::InitializeThreadedX11(); | 99 gfx::InitializeThreadedX11(); |
| 102 #endif | 100 #endif |
| 103 | 101 |
| 104 thread_bundle_.reset(new content::TestBrowserThreadBundle); | 102 thread_bundle_.reset(new content::TestBrowserThreadBundle); |
| 105 // Must initialize |ash_test_helper_| here because some tests rely on | 103 // Must initialize |ash_test_helper_| here because some tests rely on |
| 106 // AshTestBase methods before they call AshTestBase::SetUp(). | 104 // AshTestBase methods before they call AshTestBase::SetUp(). |
| (...skipping 12 matching lines...) Expand all Loading... |
| 119 | 117 |
| 120 // Clears the saved state so that test doesn't use on the wrong | 118 // Clears the saved state so that test doesn't use on the wrong |
| 121 // default state. | 119 // default state. |
| 122 shell::ToplevelWindow::ClearSavedStateForTest(); | 120 shell::ToplevelWindow::ClearSavedStateForTest(); |
| 123 | 121 |
| 124 // TODO(jamescook): Can we do this without changing command line? | 122 // TODO(jamescook): Can we do this without changing command line? |
| 125 // Use the origin (1,1) so that it doesn't over | 123 // Use the origin (1,1) so that it doesn't over |
| 126 // lap with the native mouse cursor. | 124 // lap with the native mouse cursor. |
| 127 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 125 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 128 if (!command_line->HasSwitch(switches::kAshHostWindowBounds)) { | 126 if (!command_line->HasSwitch(switches::kAshHostWindowBounds)) { |
| 129 command_line->AppendSwitchASCII( | 127 command_line->AppendSwitchASCII(switches::kAshHostWindowBounds, |
| 130 switches::kAshHostWindowBounds, "1+1-800x600"); | 128 "1+1-800x600"); |
| 131 } | 129 } |
| 132 #if defined(OS_WIN) | 130 #if defined(OS_WIN) |
| 133 ui::test::SetUsePopupAsRootWindowForTest(true); | 131 ui::test::SetUsePopupAsRootWindowForTest(true); |
| 134 #endif | 132 #endif |
| 135 ash_test_helper_->SetUp(start_session_); | 133 ash_test_helper_->SetUp(start_session_); |
| 136 | 134 |
| 137 Shell::GetPrimaryRootWindow()->Show(); | 135 Shell::GetPrimaryRootWindow()->Show(); |
| 138 Shell::GetPrimaryRootWindow()->GetHost()->Show(); | 136 Shell::GetPrimaryRootWindow()->GetHost()->Show(); |
| 139 // Move the mouse cursor to far away so that native events doesn't | 137 // Move the mouse cursor to far away so that native events doesn't |
| 140 // interfere test expectations. | 138 // interfere test expectations. |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 ::wm::ConvertPointFromScreen(root, &origin); | 270 ::wm::ConvertPointFromScreen(root, &origin); |
| 273 window->SetBounds(gfx::Rect(origin, bounds.size())); | 271 window->SetBounds(gfx::Rect(origin, bounds.size())); |
| 274 aura::client::ParentWindowWithContext(window, root, bounds); | 272 aura::client::ParentWindowWithContext(window, root, bounds); |
| 275 } | 273 } |
| 276 window->SetProperty(aura::client::kCanMaximizeKey, true); | 274 window->SetProperty(aura::client::kCanMaximizeKey, true); |
| 277 window->SetProperty(aura::client::kCanMinimizeKey, true); | 275 window->SetProperty(aura::client::kCanMinimizeKey, true); |
| 278 return window; | 276 return window; |
| 279 } | 277 } |
| 280 | 278 |
| 281 void AshTestBase::ParentWindowInPrimaryRootWindow(aura::Window* window) { | 279 void AshTestBase::ParentWindowInPrimaryRootWindow(aura::Window* window) { |
| 282 aura::client::ParentWindowWithContext( | 280 aura::client::ParentWindowWithContext(window, Shell::GetPrimaryRootWindow(), |
| 283 window, Shell::GetPrimaryRootWindow(), gfx::Rect()); | 281 gfx::Rect()); |
| 284 } | 282 } |
| 285 | 283 |
| 286 void AshTestBase::RunAllPendingInMessageLoop() { | 284 void AshTestBase::RunAllPendingInMessageLoop() { |
| 287 ash_test_helper_->RunAllPendingInMessageLoop(); | 285 ash_test_helper_->RunAllPendingInMessageLoop(); |
| 288 } | 286 } |
| 289 | 287 |
| 290 TestScreenshotDelegate* AshTestBase::GetScreenshotDelegate() { | 288 TestScreenshotDelegate* AshTestBase::GetScreenshotDelegate() { |
| 291 return ash_test_helper_->test_screenshot_delegate(); | 289 return ash_test_helper_->test_screenshot_delegate(); |
| 292 } | 290 } |
| 293 | 291 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 354 |
| 357 void AshTestBase::DisableIME() { | 355 void AshTestBase::DisableIME() { |
| 358 Shell::GetInstance()->RemovePreTargetHandler( | 356 Shell::GetInstance()->RemovePreTargetHandler( |
| 359 Shell::GetInstance() | 357 Shell::GetInstance() |
| 360 ->window_tree_host_manager() | 358 ->window_tree_host_manager() |
| 361 ->input_method_event_handler()); | 359 ->input_method_event_handler()); |
| 362 } | 360 } |
| 363 | 361 |
| 364 } // namespace test | 362 } // namespace test |
| 365 } // namespace ash | 363 } // namespace ash |
| OLD | NEW |