15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "ash/scoped_target_root_window.h" 65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/screen_util.h" 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/shell.h" 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/test/ash_test_base.h" 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/test/test_shell_delegate.h" 104e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include "ash/wm/window_positioner.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/wm/window_resizer.h" 1268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)#include "ash/wm/window_state.h" 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/compiler_specific.h" 14a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "chrome/browser/ui/ash/ash_init.h" 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/browser.h" 16424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "chrome/browser/ui/window_sizer/window_sizer_common_unittest.h" 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/chrome_switches.h" 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/test/base/testing_profile.h" 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/test/render_view_test.h" 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "testing/gtest/include/gtest/gtest.h" 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/aura/client/aura_constants.h" 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/aura/env.h" 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/aura/test/test_windows.h" 24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/aura/window_event_dispatcher.h" 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/gfx/screen.h" 26effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "ui/wm/public/activation_client.h" 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 28424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)typedef ash::test::AshTestBase WindowSizerAshTest; 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace { 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// A browser window proxy which is able to associate an aura native window with 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// it. 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TestBrowserWindowAura : public TestBrowserWindow { 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |native_window| will still be owned by the caller after the constructor 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // was called. 38424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) explicit TestBrowserWindowAura(aura::Window* native_window) 39424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) : native_window_(native_window) { 40424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) } 41424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) virtual ~TestBrowserWindowAura() {} 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // TestBrowserWindow overrides: 44424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) virtual void Show() OVERRIDE { 45424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) native_window_->Show(); 46424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) Activate(); 47424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) } 48424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) virtual void Hide() OVERRIDE { 49424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) native_window_->Hide(); 50424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) } 51424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) virtual void Activate() OVERRIDE { 521e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) aura::client::GetActivationClient( 53424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) native_window_->GetRootWindow())->ActivateWindow(native_window_.get()); 54424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) } 55424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) virtual gfx::NativeWindow GetNativeWindow() OVERRIDE { 56424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) return native_window_.get(); 57424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) } 58424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) virtual gfx::Rect GetBounds() const OVERRIDE { 59424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) return native_window_->bounds(); 60424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) } 61424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 62424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) Browser* browser() { return browser_.get(); } 63424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 64424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) void CreateBrowser(const Browser::CreateParams& params) { 65424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) Browser::CreateParams create_params = params; 66424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) create_params.window = this; 67424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_.reset(new Browser(create_params)); 6858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) if (browser_->is_type_tabbed() || browser_->is_app()) { 6968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) ash::wm::GetWindowState(native_window_.get())-> 7058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) set_window_position_managed(true); 7158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) } 72424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) } 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 75424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) scoped_ptr<Browser> browser_; 76424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) scoped_ptr<aura::Window> native_window_; 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowAura); 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 81424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)scoped_ptr<TestBrowserWindowAura> CreateTestBrowserWindow( 82424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) aura::Window* window, 83424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) const gfx::Rect& bounds, 84424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) const Browser::CreateParams& params) { 85424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) if (!bounds.IsEmpty()) 86424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) window->SetBounds(bounds); 87424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) scoped_ptr<TestBrowserWindowAura> browser_window( 88424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) new TestBrowserWindowAura(window)); 89424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_window->CreateBrowser(params); 90424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) return browser_window.Pass(); 91424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)} 92424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 93ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch} // namespace 94ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch 95cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// On desktop linux aura, we currently don't use the ash frame, breaking some 96cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// tests which expect ash sizes: http://crbug.com/303862 97cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#if defined(OS_LINUX) && !defined(OS_CHROMEOS) 98cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#define MAYBE_DefaultSizeCase DISABLED_DefaultSizeCase 99cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#else 100cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#define MAYBE_DefaultSizeCase DefaultSizeCase 101cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#endif 102cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Test that the window is sized appropriately for the first run experience 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// where the default window bounds calculation is invoked. 105cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)TEST_F(WindowSizerAshTest, MAYBE_DefaultSizeCase) { 106f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#if defined(OS_WIN) 107f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) CommandLine::ForCurrentProcess()->AppendSwitch(switches::kOpenAsh); 108f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#endif 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // 4:3 monitor case, 1024x768, no taskbar 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), gfx::Rect(), 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect(), DEFAULT, NULL, gfx::Rect(), &window_bounds); 1134e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) EXPECT_EQ(gfx::Rect(ash::WindowPositioner::kDesktopBorderSize, 1144e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize, 1154e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 1024 - ash::WindowPositioner::kDesktopBorderSize * 2, 1164e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 768 - ash::WindowPositioner::kDesktopBorderSize), 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window_bounds); 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // 4:3 monitor case, 1024x768, taskbar on bottom 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 1222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1024x768, taskbar_bottom_work_area, gfx::Rect(), 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect(), gfx::Rect(), DEFAULT, NULL, gfx::Rect(), 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) &window_bounds); 1254e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) EXPECT_EQ(gfx::Rect(ash::WindowPositioner::kDesktopBorderSize, 1264e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize, 1274e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 1024 - ash::WindowPositioner::kDesktopBorderSize * 2, 1284e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) taskbar_bottom_work_area.height() - 1294e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize), 1304e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) window_bounds); 1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // 4:3 monitor case, 1024x768, taskbar on right 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 1352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1024x768, taskbar_right_work_area, gfx::Rect(), 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect(), gfx::Rect(), DEFAULT, NULL, gfx::Rect(), 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) &window_bounds); 1384e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) EXPECT_EQ(gfx::Rect(ash::WindowPositioner::kDesktopBorderSize, 1394e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize, 1404e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) taskbar_right_work_area.width() - 1414e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize * 2, 1424e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 768 - ash::WindowPositioner::kDesktopBorderSize), 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window_bounds); 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // 4:3 monitor case, 1024x768, taskbar on left 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 1482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1024x768, taskbar_left_work_area, gfx::Rect(), 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect(), gfx::Rect(), DEFAULT, NULL, gfx::Rect(), 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) &window_bounds); 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(gfx::Rect(taskbar_left_work_area.x() + 1524e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize, 1534e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize, 1544e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) taskbar_left_work_area.width() - 1554e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize * 2, 1564e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) taskbar_left_work_area.height() - 1574e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize), 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window_bounds); 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // 4:3 monitor case, 1024x768, taskbar on top 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 1632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1024x768, taskbar_top_work_area, gfx::Rect(), 1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect(), gfx::Rect(), DEFAULT, NULL, gfx::Rect(), 1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) &window_bounds); 1664e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) EXPECT_EQ(gfx::Rect(ash::WindowPositioner::kDesktopBorderSize, 1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) taskbar_top_work_area.y() + 1684e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize, 1694e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 1024 - ash::WindowPositioner::kDesktopBorderSize * 2, 1704e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) taskbar_top_work_area.height() - 1714e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize), 1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window_bounds); 1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // 4:3 monitor case, 1280x1024 1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 1772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1280x1024, p1280x1024, gfx::Rect(), gfx::Rect(), 1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect(), DEFAULT, NULL, gfx::Rect(), &window_bounds); 1794e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) EXPECT_EQ(gfx::Rect((1280 - ash::WindowPositioner::kMaximumWindowWidth) / 2, 1804e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize, 1814e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kMaximumWindowWidth, 1824e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 1024 - ash::WindowPositioner::kDesktopBorderSize), 1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window_bounds); 1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // 4:3 monitor case, 1600x1200 1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 1882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(), gfx::Rect(), 1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect(), DEFAULT, NULL, gfx::Rect(), &window_bounds); 1904e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) EXPECT_EQ(gfx::Rect((1600 - ash::WindowPositioner::kMaximumWindowWidth) / 2, 1914e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize, 1924e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kMaximumWindowWidth, 1934e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 1200 - ash::WindowPositioner::kDesktopBorderSize), 1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window_bounds); 1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // 16:10 monitor case, 1680x1050 1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 1992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1680x1050, p1680x1050, gfx::Rect(), gfx::Rect(), 2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect(), DEFAULT, NULL, gfx::Rect(), &window_bounds); 2014e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) EXPECT_EQ(gfx::Rect((1680 - ash::WindowPositioner::kMaximumWindowWidth) / 2, 2024e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize, 2034e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kMaximumWindowWidth, 2044e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 1050 - ash::WindowPositioner::kDesktopBorderSize), 2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window_bounds); 2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // 16:10 monitor case, 1920x1200 2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 2102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1920x1200, p1920x1200, gfx::Rect(), gfx::Rect(), 2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect(), DEFAULT, NULL, gfx::Rect(), &window_bounds); 2124e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) EXPECT_EQ(gfx::Rect((1920 - ash::WindowPositioner::kMaximumWindowWidth) / 2, 2134e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize, 2144e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kMaximumWindowWidth, 2154e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 1200 - ash::WindowPositioner::kDesktopBorderSize), 2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window_bounds); 2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Test that the next opened window is positioned appropriately given the 2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// bounds of an existing window of the same type. 222424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)TEST_F(WindowSizerAshTest, LastWindowBoundsCase) { 2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // normal, in the middle of the screen somewhere. 2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 2254e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) GetWindowBounds( 2264e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) p1024x768, p1024x768, gfx::Rect(), 2274e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gfx::Rect(ash::WindowPositioner::kDesktopBorderSize, 2284e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize, 500, 400), 2294e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(), 2304e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) &window_bounds); 2314e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) EXPECT_EQ( 2324e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gfx::Rect(kWindowTilePixels + ash::WindowPositioner::kDesktopBorderSize, 2334e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) kWindowTilePixels + ash::WindowPositioner::kDesktopBorderSize, 2344e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 500, 400).ToString(), 2354e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) window_bounds.ToString()); 2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // taskbar on top. 2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 2404e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) GetWindowBounds( 2414e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) p1024x768, taskbar_top_work_area, gfx::Rect(), 2424e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gfx::Rect(ash::WindowPositioner::kDesktopBorderSize, 2434e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize, 500, 400), 2444e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(), 2454e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) &window_bounds); 2464e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) EXPECT_EQ( 2474e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gfx::Rect(kWindowTilePixels + ash::WindowPositioner::kDesktopBorderSize, 2484e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) std::max(kWindowTilePixels + 2494e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize, 2504e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 34 /* toolbar height */), 2514e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 500, 400).ToString(), 2524e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) window_bounds.ToString()); 2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // Too small to satisify the minimum visibility condition. 2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 2574e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) GetWindowBounds( 2584e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) p1024x768, p1024x768, gfx::Rect(), 2594e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gfx::Rect(ash::WindowPositioner::kDesktopBorderSize, 2604e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize, 29, 29), 2614e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(), 2624e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) &window_bounds); 2634e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) EXPECT_EQ( 2644e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gfx::Rect(kWindowTilePixels + ash::WindowPositioner::kDesktopBorderSize, 2654e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) kWindowTilePixels + ash::WindowPositioner::kDesktopBorderSize, 2664e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 30 /* not 29 */, 2674e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 30 /* not 29 */).ToString(), 2684e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) window_bounds.ToString()); 2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // Normal. 2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 2744e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) GetWindowBounds( 2754e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) p1024x768, p1024x768, gfx::Rect(), 2764e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gfx::Rect(ash::WindowPositioner::kDesktopBorderSize, 2774e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize, 500, 400), 2784e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(), 2794e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) &window_bounds); 2804e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) EXPECT_EQ( 2814e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gfx::Rect(kWindowTilePixels + ash::WindowPositioner::kDesktopBorderSize, 2824e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) kWindowTilePixels + ash::WindowPositioner::kDesktopBorderSize, 2834e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 500, 400).ToString(), 2844e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) window_bounds.ToString()); 2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Test that the window opened is sized appropriately given persisted sizes. 289424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)TEST_F(WindowSizerAshTest, PersistedBoundsCase) { 2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // normal, in the middle of the screen somewhere. 2914e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gfx::Rect initial_bounds( 2924e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize, 2934e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize, 500, 400); 2945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 2962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), initial_bounds, 2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect(), PERSISTED, NULL, gfx::Rect(), &window_bounds); 2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(initial_bounds.ToString(), window_bounds.ToString()); 2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // Normal. 3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect initial_bounds(0, 0, 1024, 768); 3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 3052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), initial_bounds, 3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect(), PERSISTED, NULL, gfx::Rect(), &window_bounds); 3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(initial_bounds.ToString(), window_bounds.ToString()); 3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // normal, on non-primary monitor in negative coords. 3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect initial_bounds(-600, 10, 500, 400); 3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 3142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1024x768, p1024x768, left_s1024x768, 3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) initial_bounds, gfx::Rect(), PERSISTED, NULL, gfx::Rect(), 3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) &window_bounds); 3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(initial_bounds.ToString(), window_bounds.ToString()); 3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // normal, on non-primary monitor in negative coords. 3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect initial_bounds(-1024, 0, 1024, 768); 3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 3242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1024x768, p1024x768, left_s1024x768, 3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) initial_bounds, gfx::Rect(), PERSISTED, NULL, gfx::Rect(), 3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) &window_bounds); 3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(initial_bounds.ToString(), window_bounds.ToString()); 3285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // Non-primary monitor resoultion has changed, but the monitor still 3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // completely contains the window. 3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect initial_bounds(1074, 50, 600, 500); 3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 3362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1024x768, p1024x768, gfx::Rect(1024, 0, 800, 600), 3372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) initial_bounds, right_s1024x768, PERSISTED, NULL, 3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect(), &window_bounds); 3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(initial_bounds.ToString(), window_bounds.ToString()); 3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // Non-primary monitor resoultion has changed, and the window is partially 3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // off-screen. 3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect initial_bounds(1274, 50, 600, 500); 3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 3482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1024x768, p1024x768, gfx::Rect(1024, 0, 800, 600), 3492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) initial_bounds, right_s1024x768, PERSISTED, 3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NULL, gfx::Rect(), &window_bounds); 3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ("1224,50 600x500", window_bounds.ToString()); 3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // Non-primary monitor resoultion has changed, and the window is now too 3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // large for the monitor. 3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect initial_bounds(1274, 50, 900, 700); 3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 3602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1024x768, p1024x768, gfx::Rect(1024, 0, 800, 600), 3612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) initial_bounds, right_s1024x768, PERSISTED, 3625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NULL, gfx::Rect(), &window_bounds); 3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ("1024,0 800x600", window_bounds.ToString()); 3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // width and height too small 3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 3684e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) GetWindowBounds( 3694e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) p1024x768, p1024x768, gfx::Rect(), 3704e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gfx::Rect(ash::WindowPositioner::kDesktopBorderSize, 3714e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize, 29, 29), 3724e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gfx::Rect(), PERSISTED, NULL, gfx::Rect(), &window_bounds); 3734e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) EXPECT_EQ(gfx::Rect(ash::WindowPositioner::kDesktopBorderSize, 3744e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize, 3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 30 /* not 29 */, 30 /* not 29 */).ToString(), 3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window_bounds.ToString()); 3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)////////////////////////////////////////////////////////////////////////////// 3815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The following unittests have different results on Mac/non-Mac because we 3825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// reposition windows aggressively on Mac. The *WithAggressiveReposition tests 3835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// are run on Mac, and the *WithNonAggressiveRepositioning tests are run on 3845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// other platforms. 3855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 386424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)TEST_F(WindowSizerAshTest, LastWindowOffscreenWithNonAggressiveRepositioning) { 3875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // taskbar on left. 3885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 3894e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) GetWindowBounds( 3904e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) p1024x768, taskbar_left_work_area, gfx::Rect(), 3914e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gfx::Rect(ash::WindowPositioner::kDesktopBorderSize, 3924e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize, 500, 400), 3934e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(), 3944e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) &window_bounds); 3954e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) EXPECT_EQ( 3964e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gfx::Rect(kWindowTilePixels + ash::WindowPositioner::kDesktopBorderSize, 3974e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) kWindowTilePixels + ash::WindowPositioner::kDesktopBorderSize, 3984e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 500, 400).ToString(), 3994e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) window_bounds.ToString()); 4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // offset would put the new window offscreen at the bottom but the minimum 4035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // visibility condition is barely satisfied without relocation. 4045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 4052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), 4065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect(10, 728, 500, 400), gfx::Rect(), LAST_ACTIVE, 4075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NULL, gfx::Rect(), &window_bounds); 4085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738, 500, 400).ToString(), 4095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window_bounds.ToString()); 4105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // offset would put the new window offscreen at the bottom and the minimum 4135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // visibility condition is satisified by relocation. 4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 4152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), 4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect(10, 729, 500, 400), gfx::Rect(), LAST_ACTIVE, 4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NULL, gfx::Rect(), &window_bounds); 4185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 4195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 738 /* not 739 */, 4205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 500, 4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 400).ToString(), 4225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window_bounds.ToString()); 4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // offset would put the new window offscreen at the right but the minimum 4265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // visibility condition is barely satisfied without relocation. 4275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 4282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), 4295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect(984, 10, 500, 400), gfx::Rect(), LAST_ACTIVE, 4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NULL, gfx::Rect(), &window_bounds); 4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(gfx::Rect(994, 10 + kWindowTilePixels, 500, 400).ToString(), 4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window_bounds.ToString()); 4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // offset would put the new window offscreen at the right and the minimum 4365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // visibility condition is satisified by relocation. 4375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 4382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), 4395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect(985, 10, 500, 400), gfx::Rect(), LAST_ACTIVE, 4405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NULL, gfx::Rect(), &window_bounds); 4415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(gfx::Rect(994 /* not 995 */, 4425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10 + kWindowTilePixels, 4435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 500, 4445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 400).ToString(), 4455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window_bounds.ToString()); 4465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // offset would put the new window offscreen at the bottom right and the 4495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // minimum visibility condition is satisified by relocation. 4505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 4512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), 4525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect(985, 729, 500, 400), gfx::Rect(), LAST_ACTIVE, 4535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NULL, gfx::Rect(), &window_bounds); 4545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(gfx::Rect(994 /* not 995 */, 4555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 738 /* not 739 */, 4565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 500, 4575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 400).ToString(), 4585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window_bounds.ToString()); 4595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 462cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// On desktop linux aura, we currently don't use the ash frame, breaking some 463cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// tests which expect ash sizes: http://crbug.com/303862 464cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#if defined(OS_LINUX) && !defined(OS_CHROMEOS) 465cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#define MAYBE_PlaceNewWindows DISABLED_PlaceNewWindows 466cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#else 467cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#define MAYBE_PlaceNewWindows PlaceNewWindows 468cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#endif 469cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 4705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Test the placement of newly created windows. 471cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)TEST_F(WindowSizerAshTest, MAYBE_PlaceNewWindows) { 4725f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // Create a browser to pass into the GetWindowBounds function. 4735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<TestingProfile> profile(new TestingProfile()); 4745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Creating a popup handler here to make sure it does not interfere with the 4755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // existing windows. 4762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Browser::CreateParams native_params(profile.get(), 4772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) chrome::HOST_DESKTOP_TYPE_ASH); 4785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<Browser> browser( 4792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) chrome::CreateBrowserWithTestWindowForParams(&native_params)); 4805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Creating a popup handler here to make sure it does not interfere with the 4825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // existing windows. 483424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) scoped_ptr<BrowserWindow> browser_window(CreateTestBrowserWindow( 484424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) CreateTestWindowInShellWithId(0), 485424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) gfx::Rect(16, 32, 640, 320), 486424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); 4875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Creating a popup to make sure it does not interfere with the positioning. 489424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) scoped_ptr<TestBrowserWindowAura> browser_popup(CreateTestBrowserWindow( 490424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) CreateTestWindowInShellWithId(1), 491424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) gfx::Rect(16, 32, 128, 256), 492424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), 493424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) chrome::HOST_DESKTOP_TYPE_ASH))); 4945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Creating a panel to make sure it does not interfere with the positioning. 496424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) scoped_ptr<BrowserWindow> browser_panel(CreateTestBrowserWindow( 497424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) CreateTestWindowInShellWithId(2), 498424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) gfx::Rect(32, 48, 256, 512), 499424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), 500424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) chrome::HOST_DESKTOP_TYPE_ASH))); 501424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_window->Show(); 5025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // Make sure that popups do not get changed. 5035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 5042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(), 5052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect(50, 100, 300, 150), bottom_s1600x1200, 506424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) PERSISTED, browser_popup->browser(), 5075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect(), &window_bounds); 5085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ("50,100 300x150", window_bounds.ToString()); 5095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 5105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 511424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_window->Hide(); 5125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // If a window is there but not shown the persisted default should be used. 5135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 5142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(), 5152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect(50, 100, 300, 150), bottom_s1600x1200, 5165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PERSISTED, browser.get(), gfx::Rect(), &window_bounds); 5175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ("50,100 300x150", window_bounds.ToString()); 5185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 5195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { // If a window is there but not shown the default should be returned. 5215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds; 5222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(), 5232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect(), bottom_s1600x1200, 5245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DEFAULT, browser.get(), gfx::Rect(), &window_bounds); 5252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Note: We need to also take the defaults maximum width into account here 5262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // since that might get used if the resolution is too big. 5274e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) EXPECT_EQ( 5284e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gfx::Rect( 5294e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) std::max(ash::WindowPositioner::kDesktopBorderSize, 5304e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) (1600 - ash::WindowPositioner::kMaximumWindowWidth) / 2), 5314e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ash::WindowPositioner::kDesktopBorderSize, 5324e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) std::min(ash::WindowPositioner::kMaximumWindowWidth, 5334e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 1600 - 2 * ash::WindowPositioner::kDesktopBorderSize), 5344e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 1200 - ash::WindowPositioner::kDesktopBorderSize).ToString(), 5354e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) window_bounds.ToString()); 5365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 5375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 539cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// On desktop linux aura, we currently don't use the ash frame, breaking some 540cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// tests which expect ash sizes: http://crbug.com/303862 541cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#if defined(OS_LINUX) && !defined(OS_CHROMEOS) 542cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#define MAYBE_PlaceNewBrowserWindowOnEmptyDesktop DISABLED_PlaceNewBrowserWindowOnEmptyDesktop 543cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#else 544cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#define MAYBE_PlaceNewBrowserWindowOnEmptyDesktop PlaceNewBrowserWindowOnEmptyDesktop 545cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#endif 546cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 547c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Test the placement of newly created windows on an empty desktop. 548c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// This test supplements "PlaceNewWindows" by testing the creation of a newly 549c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// created browser window on an empty desktop. 550cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)TEST_F(WindowSizerAshTest, MAYBE_PlaceNewBrowserWindowOnEmptyDesktop) { 5515f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // Create a browser to pass into the GetWindowBoundsAndShowState function. 552c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) scoped_ptr<TestingProfile> profile(new TestingProfile()); 553c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) Browser::CreateParams native_params(profile.get(), 554c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) chrome::HOST_DESKTOP_TYPE_ASH); 555c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) scoped_ptr<Browser> browser( 556c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) chrome::CreateBrowserWithTestWindowForParams(&native_params)); 557c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 558ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // A common screen size for Chrome OS devices where this behavior is 559ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // desirable. 560ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch const gfx::Rect p1366x768(0, 0, 1366, 768); 561ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch 562c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // If there is no previous state the window should get maximized if the 563ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // screen is less than or equal to our limit (1366 pixels width). 564c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) gfx::Rect window_bounds; 565c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ui::WindowShowState out_show_state1 = ui::SHOW_STATE_DEFAULT; 566c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) GetWindowBoundsAndShowState( 567ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch p1366x768, // The screen resolution. 568ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch p1366x768, // The monitor work area. 569ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch gfx::Rect(), // The second monitor. 570ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch gfx::Rect(), // The (persisted) bounds. 571ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch p1366x768, // The overall work area. 572ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch ui::SHOW_STATE_NORMAL, // The persisted show state. 573ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch ui::SHOW_STATE_DEFAULT, // The last show state. 574ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch DEFAULT, // No persisted values. 575ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch browser.get(), // Use this browser. 576ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch gfx::Rect(), // Don't request valid bounds. 577ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch &window_bounds, 578ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch &out_show_state1); 579c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, out_show_state1); 580c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 581c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // If there is a stored coordinate however, that should be taken instead. 582c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ui::WindowShowState out_show_state2 = ui::SHOW_STATE_DEFAULT; 583c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) GetWindowBoundsAndShowState( 584ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch p1366x768, // The screen resolution. 585ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch p1366x768, // The monitor work area. 586ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch gfx::Rect(), // The second monitor. 587ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch gfx::Rect(50, 100, 300, 150), // The (persisted) bounds. 588ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch p1366x768, // The overall work area. 589ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch ui::SHOW_STATE_NORMAL, // The persisted show state. 590ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch ui::SHOW_STATE_DEFAULT, // The last show state. 591ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch PERSISTED, // Set the persisted values. 592ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch browser.get(), // Use this browser. 593ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch gfx::Rect(), // Don't request valid bounds. 594ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch &window_bounds, 595ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch &out_show_state2); 596c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_EQ(ui::SHOW_STATE_NORMAL, out_show_state2); 597c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_EQ("50,100 300x150", window_bounds.ToString()); 598c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 599ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // A larger monitor should not trigger auto-maximize. 600ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch ui::WindowShowState out_show_state3 = ui::SHOW_STATE_DEFAULT; 601ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch GetWindowBoundsAndShowState( 602ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch p1600x1200, // The screen resolution. 603ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch p1600x1200, // The monitor work area. 604ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch gfx::Rect(), // The second monitor. 605ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch gfx::Rect(), // The (persisted) bounds. 606ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch p1600x1200, // The overall work area. 607ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch ui::SHOW_STATE_NORMAL, // The persisted show state. 608ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch ui::SHOW_STATE_DEFAULT, // The last show state. 609ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch DEFAULT, // No persisted values. 610ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch browser.get(), // Use this browser. 611ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch gfx::Rect(), // Don't request valid bounds. 612ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch &window_bounds, 613ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch &out_show_state3); 614f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#if defined(OS_WIN) 615f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, out_show_state3); 616f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#else 617ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch EXPECT_EQ(ui::SHOW_STATE_DEFAULT, out_show_state3); 618f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#endif 619ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch} 620c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 6212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(OS_CHROMEOS) 6222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define MAYBE_PlaceNewWindowsOnMultipleDisplays PlaceNewWindowsOnMultipleDisplays 6232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#else 6242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// No multiple displays on windows ash. 6252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define MAYBE_PlaceNewWindowsOnMultipleDisplays DISABLED_PlaceNewWindowsOnMultipleDisplays 6262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif 6272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Test the placement of newly created windows on multiple dislays. 629424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)TEST_F(WindowSizerAshTest, MAYBE_PlaceNewWindowsOnMultipleDisplays) { 6302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) UpdateDisplay("1600x1200,1600x1200"); 631424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) gfx::Rect primary_bounds = ash::Shell::GetInstance()->GetScreen()-> 632424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) GetPrimaryDisplay().bounds(); 6335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Rect secondary_bounds = ash::ScreenUtil::GetSecondaryDisplay().bounds(); 6342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 635d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) ash::Shell::GetInstance()->set_target_root_window( 6362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ash::Shell::GetPrimaryRootWindow()); 6372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<TestingProfile> profile(new TestingProfile()); 6392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create browser windows that are used as reference. 641424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) scoped_ptr<BrowserWindow> browser_window(CreateTestBrowserWindow( 642424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) CreateTestWindowInShellWithId(0), 643424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) gfx::Rect(10, 10, 200, 200), 644424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); 6452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) browser_window->Show(); 646424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) EXPECT_EQ(browser_window->GetNativeWindow()->GetRootWindow(), 647d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) ash::Shell::GetTargetRootWindow()); 648424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 649424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) scoped_ptr<BrowserWindow> another_browser_window(CreateTestBrowserWindow( 650424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) CreateTestWindowInShellWithId(1), 651424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) gfx::Rect(400, 10, 300, 300), 652424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); 6532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) another_browser_window->Show(); 6542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Creating a new window to verify the new placement. 656424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) scoped_ptr<TestBrowserWindowAura> new_browser_window(CreateTestBrowserWindow( 657424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) CreateTestWindowInShellWithId(0), 658424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) gfx::Rect(), 659424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) Browser::CreateParams(profile.get(), 660424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) chrome::HOST_DESKTOP_TYPE_ASH))); 6612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Make sure the primary root is active. 6632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(ash::Shell::GetPrimaryRootWindow(), 664d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) ash::Shell::GetTargetRootWindow()); 6652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // First new window should be in the primary. 6672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) { 6682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect window_bounds; 669424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, 670424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) gfx::Rect(), secondary_bounds, 671424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) PERSISTED, new_browser_window->browser(), 672424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) gfx::Rect(), &window_bounds); 673424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) // TODO(oshima): Use exact bounds when the window_sizer_ash is 674424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) // moved to ash and changed to include the result from 675424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) // RearrangeVisibleWindowOnShow. 676424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) EXPECT_TRUE(primary_bounds.Contains(window_bounds)); 6772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 6782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Move the window to the right side of the secondary display and create a new 680424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) // window. It should be opened then on the secondary display. 6812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) { 682424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) gfx::Display second_display = ash::Shell::GetScreen()-> 6832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetDisplayNearestPoint(gfx::Point(1600 + 100,10)); 684424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_window->GetNativeWindow()->SetBoundsInScreen( 685424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) gfx::Rect(secondary_bounds.CenterPoint().x() - 100, 10, 200, 200), 6862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) second_display); 6872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) browser_window->Activate(); 6882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NE(ash::Shell::GetPrimaryRootWindow(), 689d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) ash::Shell::GetTargetRootWindow()); 6902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect window_bounds; 691424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, 692424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) gfx::Rect(), secondary_bounds, 693424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) PERSISTED, new_browser_window->browser(), 694424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) gfx::Rect(), &window_bounds); 695424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) // TODO(oshima): Use exact bounds when the window_sizer_ash is 696424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) // moved to ash and changed to include the result from 697424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) // RearrangeVisibleWindowOnShow. 698424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) EXPECT_TRUE(secondary_bounds.Contains(window_bounds)); 6992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 7002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Activate another window in the primary display and create a new window. 7022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // It should be created in the primary display. 7032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) { 7042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) another_browser_window->Activate(); 7052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(ash::Shell::GetPrimaryRootWindow(), 706d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) ash::Shell::GetTargetRootWindow()); 7072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect window_bounds; 709424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, 710424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) gfx::Rect(), secondary_bounds, 711424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) PERSISTED, new_browser_window->browser(), 712424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) gfx::Rect(), &window_bounds); 713424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) // TODO(oshima): Use exact bounds when the window_sizer_ash is 714424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) // moved to ash and changed to include the result from 715424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) // RearrangeVisibleWindowOnShow. 716424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) EXPECT_TRUE(primary_bounds.Contains(window_bounds)); 7172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 7182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 7192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 720cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// On desktop linux aura, we currently don't use the ash frame, breaking some 721cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// tests which expect ash sizes: http://crbug.com/303862 722cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#if defined(OS_LINUX) && !defined(OS_CHROMEOS) 723cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#define MAYBE_TestShowState DISABLED_TestShowState 724cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#else 725cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#define MAYBE_TestShowState TestShowState 726cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#endif 727cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 7285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Test that the show state is properly returned for non default cases. 729cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)TEST_F(WindowSizerAshTest, MAYBE_TestShowState) { 7305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<TestingProfile> profile(new TestingProfile()); 7315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 732424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) // Creating a browser & window to play with. 733424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) scoped_ptr<TestBrowserWindowAura> browser_window(CreateTestBrowserWindow( 734424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) CreateTestWindowInShellWithId(0), 735424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) gfx::Rect(16, 32, 640, 320), 736424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) Browser::CreateParams(Browser::TYPE_TABBED, profile.get(), 737424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) chrome::HOST_DESKTOP_TYPE_ASH))); 7385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Create also a popup browser since that behaves different. 740424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) scoped_ptr<TestBrowserWindowAura> browser_popup(CreateTestBrowserWindow( 741424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) CreateTestWindowInShellWithId(1), 742424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) gfx::Rect(16, 32, 640, 320), 743424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), 744424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) chrome::HOST_DESKTOP_TYPE_ASH))); 7455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Tabbed windows should retrieve the saved window state - since there is a 7475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // top window. 7485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, 7495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, 7505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ui::SHOW_STATE_NORMAL, 7515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BOTH, 752424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_window->browser(), 7535f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) p1600x1200, 7542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) p1600x1200)); 7555f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // A window that is smaller than the whole work area is set to default state. 7565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(ui::SHOW_STATE_DEFAULT, 7575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GetWindowShowState(ui::SHOW_STATE_DEFAULT, 7585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ui::SHOW_STATE_NORMAL, 7595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BOTH, 760424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_window->browser(), 7615f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) p1280x1024, 7625f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) p1600x1200)); 7635f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // A window that is sized to occupy the whole work area is maximized. 7645f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, 7655f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) GetWindowShowState(ui::SHOW_STATE_DEFAULT, 7665f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) ui::SHOW_STATE_NORMAL, 7675f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) BOTH, 7685f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) browser_window->browser(), 7695f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) p1600x1200, 7702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) p1600x1200)); 7715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Non tabbed windows should always follow the window saved visibility state. 7725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, 7735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, 7745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ui::SHOW_STATE_NORMAL, 7755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BOTH, 776424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_popup->browser(), 7775f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) p1600x1200, 7782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) p1600x1200)); 7795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The non tabbed window will take the status of the last active of its kind. 7805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(ui::SHOW_STATE_NORMAL, 7815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GetWindowShowState(ui::SHOW_STATE_DEFAULT, 7825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ui::SHOW_STATE_NORMAL, 7835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BOTH, 784424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_popup->browser(), 7855f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) p1600x1200, 7862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) p1600x1200)); 7875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Now create a top level window and check again for both. Only the tabbed 7895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // window should follow the top level window's state. 7905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Creating a browser & window to play with. 791424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) scoped_ptr<TestBrowserWindowAura> browser_window2(CreateTestBrowserWindow( 792424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) CreateTestWindowInShellWithId(3), 793424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) gfx::Rect(16, 32, 640, 320), 794424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) Browser::CreateParams(Browser::TYPE_TABBED, profile.get(), 795424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) chrome::HOST_DESKTOP_TYPE_ASH))); 7965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // A tabbed window should now take the top level window state. 7985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(ui::SHOW_STATE_DEFAULT, 7995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, 8005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ui::SHOW_STATE_DEFAULT, 8015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BOTH, 802424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_window->browser(), 8035f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) p1600x1200, 8042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) p1600x1200)); 8055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Non tabbed windows should always follow the window saved visibility state. 8065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, 8075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, 8085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ui::SHOW_STATE_MINIMIZED, 8095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BOTH, 810424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_popup->browser(), 8115f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) p1600x1200, 8122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) p1600x1200)); 8132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 8142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // In smaller screen resolutions we default to maximized if there is no other 8152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // window visible. 8164e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) int min_size = ash::WindowPositioner::GetForceMaximizedWidthLimit() / 2; 8172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (min_size > 0) { 8182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const gfx::Rect tiny_screen(0, 0, min_size, min_size); 8192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(ui::SHOW_STATE_DEFAULT, 8202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, 8212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ui::SHOW_STATE_DEFAULT, 8222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) BOTH, 823424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_window->browser(), 8245f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) tiny_screen, 8252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) tiny_screen)); 826424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_window->Hide(); 8272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, 8282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, 8292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ui::SHOW_STATE_DEFAULT, 8302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) BOTH, 831424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_window2->browser(), 8325f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) tiny_screen, 8332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) tiny_screen)); 8342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 8352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 8365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 8375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Test that the default show state override behavior is properly handled. 839424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)TEST_F(WindowSizerAshTest, TestShowStateDefaults) { 8405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Creating a browser & window to play with. 8415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<TestingProfile> profile(new TestingProfile()); 8425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 843424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) scoped_ptr<TestBrowserWindowAura> browser_window(CreateTestBrowserWindow( 844424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) CreateTestWindowInShellWithId(0), 845424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) gfx::Rect(16, 32, 640, 320), 846424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) Browser::CreateParams(Browser::TYPE_TABBED, profile.get(), 847424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) chrome::HOST_DESKTOP_TYPE_ASH))); 8485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Create also a popup browser since that behaves slightly different for 8505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // defaults. 851424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) scoped_ptr<TestBrowserWindowAura> browser_popup(CreateTestBrowserWindow( 852424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) CreateTestWindowInShellWithId(1), 853424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) gfx::Rect(16, 32, 128, 256), 854424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), 855424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) chrome::HOST_DESKTOP_TYPE_ASH))); 8565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Check that a browser creation state always get used if not given as 858f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // SHOW_STATE_DEFAULT. On Windows ASH it should be SHOW_STATE_MAXIMIZED. 859f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) ui::WindowShowState window_show_state = 860f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, 861f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) ui::SHOW_STATE_MAXIMIZED, 862f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) DEFAULT, 863f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) browser_window->browser(), 8645f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) p1600x1200, 865f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) p1600x1200); 866f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#if defined(OS_WIN) 867f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) EXPECT_EQ(window_show_state, ui::SHOW_STATE_MAXIMIZED); 868f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#else 869f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) EXPECT_EQ(window_show_state, ui::SHOW_STATE_DEFAULT); 870f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#endif 871f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 872424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_window->browser()->set_initial_show_state(ui::SHOW_STATE_MINIMIZED); 8735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, 8745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ui::SHOW_STATE_MAXIMIZED, 8755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BOTH, 876424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_window->browser(), 8775f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) p1600x1200, 8782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) p1600x1200), ui::SHOW_STATE_MINIMIZED); 879424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_window->browser()->set_initial_show_state(ui::SHOW_STATE_NORMAL); 8805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, 8815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ui::SHOW_STATE_MAXIMIZED, 8825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BOTH, 883424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_window->browser(), 8845f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) p1600x1200, 8852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) p1600x1200), ui::SHOW_STATE_NORMAL); 886424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_window->browser()->set_initial_show_state(ui::SHOW_STATE_MAXIMIZED); 8875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(GetWindowShowState(ui::SHOW_STATE_NORMAL, 8885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ui::SHOW_STATE_NORMAL, 8895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BOTH, 890424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_window->browser(), 8915f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) p1600x1200, 8922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) p1600x1200), ui::SHOW_STATE_MAXIMIZED); 8935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Check that setting the maximized command line option is forcing the 8955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // maximized state. 8965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CommandLine::ForCurrentProcess()->AppendSwitch(switches::kStartMaximized); 8975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 898424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_window->browser()->set_initial_show_state(ui::SHOW_STATE_NORMAL); 8995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(GetWindowShowState(ui::SHOW_STATE_NORMAL, 9005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ui::SHOW_STATE_NORMAL, 9015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BOTH, 902424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_window->browser(), 9035f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) p1600x1200, 9042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) p1600x1200), ui::SHOW_STATE_MAXIMIZED); 9055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The popup should favor the initial show state over the command line. 9075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(GetWindowShowState(ui::SHOW_STATE_NORMAL, 9085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ui::SHOW_STATE_NORMAL, 9095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BOTH, 910424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) browser_popup->browser(), 9115f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) p1600x1200, 9122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) p1600x1200), ui::SHOW_STATE_NORMAL); 9135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 914a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 9155f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)TEST_F(WindowSizerAshTest, DefaultStateBecomesMaximized) { 9165f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // Create a browser to pass into the GetWindowBounds function. 9175f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) scoped_ptr<TestingProfile> profile(new TestingProfile()); 9185f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) Browser::CreateParams native_params(profile.get(), 9195f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) chrome::HOST_DESKTOP_TYPE_ASH); 9205f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) scoped_ptr<Browser> browser( 9215f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) chrome::CreateBrowserWithTestWindowForParams(&native_params)); 9225f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 9235f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) gfx::Rect display_bounds = ash::Shell::GetInstance()->GetScreen()-> 9245f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) GetPrimaryDisplay().bounds(); 9255f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) gfx::Rect specified_bounds = display_bounds; 9265f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 9275f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // Make a window bigger than the display work area. 9285f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) specified_bounds.Inset(-20, -20); 9295f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) ui::WindowShowState show_state = ui::SHOW_STATE_DEFAULT; 9305f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) gfx::Rect bounds; 9315f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) WindowSizer::GetBrowserWindowBoundsAndShowState( 9325f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) std::string(), specified_bounds, browser.get(), &bounds, &show_state); 9335f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // The window should start maximized with its restore bounds shrunken. 9345f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, show_state); 9355f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) EXPECT_NE(display_bounds.ToString(), bounds.ToString()); 9365f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) EXPECT_TRUE(display_bounds.Contains(bounds)); 9375f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 9385f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // Make a window smaller than the display work area. 9395f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) specified_bounds.Inset(100, 100); 9405f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) show_state = ui::SHOW_STATE_DEFAULT; 9415f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) WindowSizer::GetBrowserWindowBoundsAndShowState( 9425f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) std::string(), specified_bounds, browser.get(), &bounds, &show_state); 9435f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // The window should start in default state. 9445f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) EXPECT_EQ(ui::SHOW_STATE_DEFAULT, show_state); 9455f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) EXPECT_EQ(specified_bounds.ToString(), bounds.ToString()); 9465f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)} 9475f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 9485f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// Test that the target root window is used as the destination of 949a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// the non browser window. This differ from PersistedBoundsCase 950a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// in that this uses real ash shell implementations + StateProvider 951a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// TargetDisplayProvider, rather than mocks. 952a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)TEST_F(WindowSizerAshTest, DefaultBoundsInTargetDisplay) { 953a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) if (!SupportsMultipleDisplays() || !chrome::ShouldOpenAshOnStartup()) 954a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) return; 955a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) UpdateDisplay("500x500,600x600"); 956a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) { 957a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) aura::Window* first_root = 958a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) ash::Shell::GetAllRootWindows()[0]; 959c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ash::ScopedTargetRootWindow tmp(first_root); 960a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) gfx::Rect bounds; 961a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) ui::WindowShowState show_state; 962a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) WindowSizer::GetBrowserWindowBoundsAndShowState( 963a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) std::string(), 964a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) gfx::Rect(), 965a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) NULL, 966a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) &bounds, 967a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) &show_state); 968a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) EXPECT_TRUE(first_root->GetBoundsInScreen().Contains(bounds)); 969a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) } 970a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) { 971a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) aura::Window* second_root = 972a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) ash::Shell::GetAllRootWindows()[1]; 973c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ash::ScopedTargetRootWindow tmp(second_root); 974a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) gfx::Rect bounds; 975a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) ui::WindowShowState show_state; 976a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) WindowSizer::GetBrowserWindowBoundsAndShowState( 977a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) std::string(), 978a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) gfx::Rect(), 979a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) NULL, 980a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) &bounds, 981a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) &show_state); 982a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) EXPECT_TRUE(second_root->GetBoundsInScreen().Contains(bounds)); 983a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) } 984a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 985a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch 986a02191e04bc25c4935f804f2c080ae28663d096dBen MurdochTEST_F(WindowSizerAshTest, TrustedPopupBehavior) { 987a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch scoped_ptr<TestingProfile> profile(new TestingProfile()); 988a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch Browser::CreateParams trusted_popup_create_params( 989a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch Browser::TYPE_POPUP, profile.get(), chrome::HOST_DESKTOP_TYPE_ASH); 990a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch trusted_popup_create_params.trusted_source = true; 991a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch 992a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch scoped_ptr<TestBrowserWindowAura> trusted_popup(CreateTestBrowserWindow( 993a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch CreateTestWindowInShellWithId(1), 994a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch gfx::Rect(16, 32, 640, 320), 995a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch trusted_popup_create_params)); 996a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // Trusted popup windows should follow the saved show state and ignore the 997a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // last show state. 998a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch EXPECT_EQ(ui::SHOW_STATE_DEFAULT, 999a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch GetWindowShowState(ui::SHOW_STATE_DEFAULT, 1000a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch ui::SHOW_STATE_NORMAL, 1001a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch BOTH, 1002a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch trusted_popup->browser(), 10035f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) p1280x1024, 10045f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) p1600x1200)); 10055f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // A popup that is sized to occupy the whole work area has default state. 10065f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) EXPECT_EQ(ui::SHOW_STATE_DEFAULT, 10075f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) GetWindowShowState(ui::SHOW_STATE_DEFAULT, 10085f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) ui::SHOW_STATE_NORMAL, 10095f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) BOTH, 10105f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) trusted_popup->browser(), 10115f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) p1600x1200, 1012a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch p1600x1200)); 1013a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch} 1014