| 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/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/test/test_shell_delegate.h" | 11 #include "ash/test/test_shell_delegate.h" |
| 12 #include "base/string_split.h" | 12 #include "base/string_split.h" |
| 13 #include "content/public/test/web_contents_tester.h" | 13 #include "content/public/test/web_contents_tester.h" |
| 14 #include "ui/aura/env.h" | 14 #include "ui/aura/env.h" |
| 15 #include "ui/aura/monitor_manager.h" | 15 #include "ui/aura/display_manager.h" |
| 16 #include "ui/aura/root_window.h" | 16 #include "ui/aura/root_window.h" |
| 17 #include "ui/base/ime/text_input_test_support.h" | 17 #include "ui/base/ime/text_input_test_support.h" |
| 18 #include "ui/compositor/layer_animator.h" | 18 #include "ui/compositor/layer_animator.h" |
| 19 #include "ui/gfx/display.h" | 19 #include "ui/gfx/display.h" |
| 20 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" |
| 21 | 21 |
| 22 namespace ash { | 22 namespace ash { |
| 23 namespace test { | 23 namespace test { |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 std::vector<gfx::Display> CreateDisplaysFromString( | 26 std::vector<gfx::Display> CreateDisplaysFromString( |
| 27 const std::string specs) { | 27 const std::string specs) { |
| 28 std::vector<gfx::Display> displays; | 28 std::vector<gfx::Display> displays; |
| 29 std::vector<std::string> parts; | 29 std::vector<std::string> parts; |
| 30 base::SplitString(specs, ',', &parts); | 30 base::SplitString(specs, ',', &parts); |
| 31 for (std::vector<std::string>::const_iterator iter = parts.begin(); | 31 for (std::vector<std::string>::const_iterator iter = parts.begin(); |
| 32 iter != parts.end(); ++iter) { | 32 iter != parts.end(); ++iter) { |
| 33 displays.push_back(aura::MonitorManager::CreateMonitorFromSpec(*iter)); | 33 displays.push_back(aura::DisplayManager::CreateDisplayFromSpec(*iter)); |
| 34 } | 34 } |
| 35 return displays; | 35 return displays; |
| 36 } | 36 } |
| 37 | 37 |
| 38 } // namespace | 38 } // namespace |
| 39 | 39 |
| 40 content::WebContents* AshTestViewsDelegate::CreateWebContents( | 40 content::WebContents* AshTestViewsDelegate::CreateWebContents( |
| 41 content::BrowserContext* browser_context, | 41 content::BrowserContext* browser_context, |
| 42 content::SiteInstance* site_instance) { | 42 content::SiteInstance* site_instance) { |
| 43 return content::WebContentsTester::CreateTestWebContents(browser_context, | 43 return content::WebContentsTester::CreateTestWebContents(browser_context, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 65 void AshTestBase::TearDown() { | 65 void AshTestBase::TearDown() { |
| 66 // Flush the message loop to finish pending release tasks. | 66 // Flush the message loop to finish pending release tasks. |
| 67 RunAllPendingInMessageLoop(); | 67 RunAllPendingInMessageLoop(); |
| 68 | 68 |
| 69 // Tear down the shell. | 69 // Tear down the shell. |
| 70 Shell::DeleteInstance(); | 70 Shell::DeleteInstance(); |
| 71 aura::Env::DeleteInstance(); | 71 aura::Env::DeleteInstance(); |
| 72 ui::TextInputTestSupport::Shutdown(); | 72 ui::TextInputTestSupport::Shutdown(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void AshTestBase::ChangeMonitorConfig(float scale, | 75 void AshTestBase::ChangeDisplayConfig(float scale, |
| 76 const gfx::Rect& bounds_in_pixel) { | 76 const gfx::Rect& bounds_in_pixel) { |
| 77 gfx::Display display = gfx::Display(gfx::Screen::GetPrimaryDisplay().id()); | 77 gfx::Display display = gfx::Display(gfx::Screen::GetPrimaryDisplay().id()); |
| 78 display.SetScaleAndBounds(scale, bounds_in_pixel); | 78 display.SetScaleAndBounds(scale, bounds_in_pixel); |
| 79 std::vector<gfx::Display> displays; | 79 std::vector<gfx::Display> displays; |
| 80 displays.push_back(display); | 80 displays.push_back(display); |
| 81 aura::Env::GetInstance()->monitor_manager()->OnNativeMonitorsChanged( | 81 aura::Env::GetInstance()->display_manager()->OnNativeDisplaysChanged( |
| 82 displays); | 82 displays); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void AshTestBase::UpdateMonitor(const std::string& display_specs) { | 85 void AshTestBase::UpdateDisplay(const std::string& display_specs) { |
| 86 std::vector<gfx::Display> displays = CreateDisplaysFromString(display_specs); | 86 std::vector<gfx::Display> displays = CreateDisplaysFromString(display_specs); |
| 87 aura::Env::GetInstance()->monitor_manager()-> | 87 aura::Env::GetInstance()->display_manager()-> |
| 88 OnNativeMonitorsChanged(displays); | 88 OnNativeDisplaysChanged(displays); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void AshTestBase::RunAllPendingInMessageLoop() { | 91 void AshTestBase::RunAllPendingInMessageLoop() { |
| 92 #if !defined(OS_MACOSX) | 92 #if !defined(OS_MACOSX) |
| 93 message_loop_.RunAllPendingWithDispatcher( | 93 message_loop_.RunAllPendingWithDispatcher( |
| 94 aura::Env::GetInstance()->GetDispatcher()); | 94 aura::Env::GetInstance()->GetDispatcher()); |
| 95 #endif | 95 #endif |
| 96 } | 96 } |
| 97 | 97 |
| 98 } // namespace test | 98 } // namespace test |
| 99 } // namespace ash | 99 } // namespace ash |
| OLD | NEW |