From c39be8f0c897d5f57305e3a36b2a5f74ea15d3e1 Mon Sep 17 00:00:00 2001 From: "oshima@chromium.org" Date: Fri, 15 Jun 2012 22:58:36 +0000 Subject: Basic tests for extended desktop mode BUG=123160 TEST=extended_desktop_unittests Review URL: https://chromiumcodereview.appspot.com/10536187 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142513 0039d316-1c4b-4281-b951-d872f2087c98 --- ash/test/ash_test_base.cc | 23 +++++++++++++++++++++++ ash/test/ash_test_base.h | 9 +++++++++ 2 files changed, 32 insertions(+) (limited to 'ash/test') diff --git a/ash/test/ash_test_base.cc b/ash/test/ash_test_base.cc index ad9066b..323790c 100644 --- a/ash/test/ash_test_base.cc +++ b/ash/test/ash_test_base.cc @@ -4,10 +4,12 @@ #include "ash/test/ash_test_base.h" +#include #include #include "ash/shell.h" #include "ash/test/test_shell_delegate.h" +#include "base/string_split.h" #include "content/public/test/web_contents_tester.h" #include "ui/aura/env.h" #include "ui/aura/monitor_manager.h" @@ -19,6 +21,21 @@ namespace ash { namespace test { +namespace { + +std::vector CreateDisplaysFromString( + const std::string specs) { + std::vector displays; + std::vector parts; + base::SplitString(specs, ',', &parts); + for (std::vector::const_iterator iter = parts.begin(); + iter != parts.end(); ++iter) { + displays.push_back(aura::MonitorManager::CreateMonitorFromSpec(*iter)); + } + return displays; +} + +} // namespace content::WebContents* AshTestViewsDelegate::CreateWebContents( content::BrowserContext* browser_context, @@ -65,6 +82,12 @@ void AshTestBase::ChangeMonitorConfig(float scale, displays); } +void AshTestBase::UpdateMonitor(const std::string& display_specs) { + std::vector displays = CreateDisplaysFromString(display_specs); + aura::Env::GetInstance()->monitor_manager()-> + OnNativeMonitorsChanged(displays); +} + void AshTestBase::RunAllPendingInMessageLoop() { #if !defined(OS_MACOSX) message_loop_.RunAllPendingWithDispatcher( diff --git a/ash/test/ash_test_base.h b/ash/test/ash_test_base.h index 2ca9246..559b370 100644 --- a/ash/test/ash_test_base.h +++ b/ash/test/ash_test_base.h @@ -6,6 +6,8 @@ #define ASH_TEST_ASH_TEST_BASE_H_ #pragma once +#include + #include "ash/shell.h" #include "base/compiler_specific.h" #include "base/message_loop.h" @@ -38,6 +40,13 @@ class AshTestBase : public testing::Test { // and |scale|. void ChangeMonitorConfig(float scale, const gfx::Rect& bounds); + // Update the display configuration as given in |display_specs|. The + // format of |display_spec| is a list of comma separated spec for + // each displays. Please refer to the comment in + // | aura::MonitorManager::CreateMonitorFromSpec| for the format of + // the display spec. + void UpdateMonitor(const std::string& display_specs); + protected: void RunAllPendingInMessageLoop(); -- cgit v1.1