Commit ad3a62cd authored by sadrul@chromium.org's avatar sadrul@chromium.org

aura: Allow specifying the size of TestScreen when creating it.

BUG=380215
R=jamescook@chromium.org, sky@chromium.org
TBR=pfeldman@ for content/shell changes

Review URL: https://codereview.chromium.org/345603003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278697 0039d316-1c4b-4281-b951-d872f2087c98
parent 3a6d917a
...@@ -224,16 +224,16 @@ void ShellDesktopController::OnHostCloseRequested( ...@@ -224,16 +224,16 @@ void ShellDesktopController::OnHostCloseRequested(
} }
void ShellDesktopController::CreateRootWindow() { void ShellDesktopController::CreateRootWindow() {
test_screen_.reset(aura::TestScreen::Create());
// TODO(jamescook): Replace this with a real Screen implementation.
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get());
// TODO(mukai): Set up input method.
// Set up basic pieces of ui::wm. // Set up basic pieces of ui::wm.
gfx::Size size = GetPrimaryDisplaySize(); gfx::Size size = GetPrimaryDisplaySize();
if (size.IsEmpty()) if (size.IsEmpty())
size = gfx::Size(1280, 720); size = gfx::Size(1280, 720);
test_screen_.reset(aura::TestScreen::Create(size));
// TODO(jamescook): Replace this with a real Screen implementation.
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get());
// TODO(mukai): Set up input method.
host_.reset(aura::WindowTreeHost::Create(gfx::Rect(size))); host_.reset(aura::WindowTreeHost::Create(gfx::Rect(size)));
host_->InitHost(); host_->InitHost();
aura::client::SetWindowTreeClient(host_->window(), this); aura::client::SetWindowTreeClient(host_->window(), this);
......
...@@ -56,7 +56,8 @@ void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) { ...@@ -56,7 +56,8 @@ void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) {
ui::InitializeInputMethodForTesting(); ui::InitializeInputMethodForTesting();
test_screen_.reset(aura::TestScreen::Create()); const gfx::Size host_size(800, 600);
test_screen_.reset(aura::TestScreen::Create(host_size));
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get());
host_.reset(test_screen_->CreateHostForPrimaryDisplay()); host_.reset(test_screen_->CreateHostForPrimaryDisplay());
...@@ -73,7 +74,7 @@ void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) { ...@@ -73,7 +74,7 @@ void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) {
root_window()->Show(); root_window()->Show();
// Ensure width != height so tests won't confuse them. // Ensure width != height so tests won't confuse them.
host()->SetBounds(gfx::Rect(800, 600)); host()->SetBounds(gfx::Rect(host_size));
athena::StartAthena(root_window(), athena::StartAthena(root_window(),
new SampleActivityFactory(), new SampleActivityFactory(),
......
...@@ -79,7 +79,7 @@ class SigninErrorNotifierTest : public AshTestBase { ...@@ -79,7 +79,7 @@ class SigninErrorNotifierTest : public AshTestBase {
// Set up screen for Windows. // Set up screen for Windows.
#if defined(OS_WIN) #if defined(OS_WIN)
aura::TestScreen* test_screen = aura::TestScreen::Create(); aura::TestScreen* test_screen = aura::TestScreen::Create(gfx::Size());
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen); gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen);
gfx::Screen::SetScreenTypeDelegate(new ScreenTypeDelegateDesktop); gfx::Screen::SetScreenTypeDelegate(new ScreenTypeDelegateDesktop);
#endif #endif
......
...@@ -109,7 +109,7 @@ class SyncErrorNotifierTest : public AshTestBase { ...@@ -109,7 +109,7 @@ class SyncErrorNotifierTest : public AshTestBase {
// Set up a desktop screen for Windows to hold native widgets, used when // Set up a desktop screen for Windows to hold native widgets, used when
// adding desktop widgets (i.e., message center notifications). // adding desktop widgets (i.e., message center notifications).
#if defined(OS_WIN) #if defined(OS_WIN)
aura::TestScreen* test_screen = aura::TestScreen::Create(); aura::TestScreen* test_screen = aura::TestScreen::Create(gfx::Size());
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen); gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen);
gfx::Screen::SetScreenTypeDelegate(new ScreenTypeDelegateDesktop); gfx::Screen::SetScreenTypeDelegate(new ScreenTypeDelegateDesktop);
#endif #endif
......
...@@ -48,7 +48,7 @@ class TouchEmulatorTest : public testing::Test, ...@@ -48,7 +48,7 @@ class TouchEmulatorTest : public testing::Test,
virtual void SetUp() OVERRIDE { virtual void SetUp() OVERRIDE {
#if defined(USE_AURA) #if defined(USE_AURA)
aura::Env::CreateInstance(true); aura::Env::CreateInstance(true);
screen_.reset(aura::TestScreen::Create()); screen_.reset(aura::TestScreen::Create(gfx::Size()));
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get());
#endif #endif
......
...@@ -454,7 +454,7 @@ class RenderWidgetHostTest : public testing::Test { ...@@ -454,7 +454,7 @@ class RenderWidgetHostTest : public testing::Test {
ImageTransportFactory::InitializeForUnitTests( ImageTransportFactory::InitializeForUnitTests(
scoped_ptr<ui::ContextFactory>(new ui::InProcessContextFactory)); scoped_ptr<ui::ContextFactory>(new ui::InProcessContextFactory));
aura::Env::CreateInstance(true); aura::Env::CreateInstance(true);
screen_.reset(aura::TestScreen::Create()); screen_.reset(aura::TestScreen::Create(gfx::Size()));
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get());
#endif #endif
host_.reset( host_.reset(
......
...@@ -16,7 +16,7 @@ namespace content { ...@@ -16,7 +16,7 @@ namespace content {
// static // static
void Shell::PlatformInitialize(const gfx::Size& default_window_size) { void Shell::PlatformInitialize(const gfx::Size& default_window_size) {
CHECK(!platform_); CHECK(!platform_);
aura::TestScreen* screen = aura::TestScreen::Create(); aura::TestScreen* screen = aura::TestScreen::Create(gfx::Size());
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen); gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen);
platform_ = new ShellPlatformDataAura(default_window_size); platform_ = new ShellPlatformDataAura(default_window_size);
} }
......
...@@ -423,8 +423,8 @@ void Shell::PlatformInitialize(const gfx::Size& default_window_size) { ...@@ -423,8 +423,8 @@ void Shell::PlatformInitialize(const gfx::Size& default_window_size) {
#endif #endif
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
chromeos::DBusThreadManager::Initialize(); chromeos::DBusThreadManager::Initialize();
gfx::Screen::SetScreenInstance( gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE,
gfx::SCREEN_TYPE_NATIVE, aura::TestScreen::Create()); aura::TestScreen::Create(gfx::Size()));
wm_test_helper_ = new wm::WMTestHelper(default_window_size, wm_test_helper_ = new wm::WMTestHelper(default_window_size,
GetContextFactory()); GetContextFactory());
#else #else
......
...@@ -129,7 +129,8 @@ int DemoMain() { ...@@ -129,7 +129,8 @@ int DemoMain() {
aura::Env::CreateInstance(true); aura::Env::CreateInstance(true);
aura::Env::GetInstance()->set_context_factory(context_factory.get()); aura::Env::GetInstance()->set_context_factory(context_factory.get());
scoped_ptr<aura::TestScreen> test_screen(aura::TestScreen::Create()); scoped_ptr<aura::TestScreen> test_screen(
aura::TestScreen::Create(gfx::Size()));
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen.get()); gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen.get());
scoped_ptr<aura::WindowTreeHost> host( scoped_ptr<aura::WindowTreeHost> host(
test_screen->CreateHostForPrimaryDisplay()); test_screen->CreateHostForPrimaryDisplay());
......
...@@ -64,7 +64,8 @@ void AuraTestHelper::SetUp(ui::ContextFactory* context_factory) { ...@@ -64,7 +64,8 @@ void AuraTestHelper::SetUp(ui::ContextFactory* context_factory) {
ui::InitializeInputMethodForTesting(); ui::InitializeInputMethodForTesting();
test_screen_.reset(TestScreen::Create()); gfx::Size host_size(800, 600);
test_screen_.reset(TestScreen::Create(host_size));
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get());
host_.reset(test_screen_->CreateHostForPrimaryDisplay()); host_.reset(test_screen_->CreateHostForPrimaryDisplay());
...@@ -79,7 +80,7 @@ void AuraTestHelper::SetUp(ui::ContextFactory* context_factory) { ...@@ -79,7 +80,7 @@ void AuraTestHelper::SetUp(ui::ContextFactory* context_factory) {
root_window()->Show(); root_window()->Show();
// Ensure width != height so tests won't confuse them. // Ensure width != height so tests won't confuse them.
host()->SetBounds(gfx::Rect(800, 600)); host()->SetBounds(gfx::Rect(host_size));
} }
void AuraTestHelper::TearDown() { void AuraTestHelper::TearDown() {
......
...@@ -17,10 +17,11 @@ ...@@ -17,10 +17,11 @@
namespace aura { namespace aura {
// static // static
TestScreen* TestScreen::Create() { TestScreen* TestScreen::Create(const gfx::Size& size) {
const gfx::Size kDefaultSize(800, 600);
// Use (0,0) because the desktop aura tests are executed in // Use (0,0) because the desktop aura tests are executed in
// native environment where the display's origin is (0,0). // native environment where the display's origin is (0,0).
return new TestScreen(gfx::Rect(0, 0, 800, 600)); return new TestScreen(gfx::Rect(size.IsEmpty() ? kDefaultSize : size));
} }
// static // static
......
...@@ -23,7 +23,9 @@ class WindowTreeHost; ...@@ -23,7 +23,9 @@ class WindowTreeHost;
class TestScreen : public gfx::Screen, class TestScreen : public gfx::Screen,
public WindowObserver { public WindowObserver {
public: public:
static TestScreen* Create(); // Creates a gfx::Screen of the specified size. If no size is specified, then
// creates a 800x600 screen. |size| is in physical pixels.
static TestScreen* Create(const gfx::Size& size);
// Creates a TestScreen that uses fullscreen for the display. // Creates a TestScreen that uses fullscreen for the display.
static TestScreen* CreateFullscreen(); static TestScreen* CreateFullscreen();
virtual ~TestScreen(); virtual ~TestScreen();
......
...@@ -62,11 +62,12 @@ ViewsContentClientMainPartsChromeOS::ViewsContentClientMainPartsChromeOS( ...@@ -62,11 +62,12 @@ ViewsContentClientMainPartsChromeOS::ViewsContentClientMainPartsChromeOS(
void ViewsContentClientMainPartsChromeOS::PreMainMessageLoopRun() { void ViewsContentClientMainPartsChromeOS::PreMainMessageLoopRun() {
ViewsContentClientMainPartsAura::PreMainMessageLoopRun(); ViewsContentClientMainPartsAura::PreMainMessageLoopRun();
gfx::Screen::SetScreenInstance( gfx::Size host_size(800, 600);
gfx::SCREEN_TYPE_NATIVE, aura::TestScreen::Create()); gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE,
aura::TestScreen::Create(host_size));
// Set up basic pieces of views::corewm. // Set up basic pieces of views::corewm.
wm_test_helper_.reset(new ::wm::WMTestHelper(gfx::Size(800, 600), wm_test_helper_.reset(
content::GetContextFactory())); new ::wm::WMTestHelper(host_size, content::GetContextFactory()));
// Ensure the X window gets mapped. // Ensure the X window gets mapped.
wm_test_helper_->host()->Show(); wm_test_helper_->host()->Show();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment