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) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/wm/workspace/workspace_layout_manager.h" 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#include <string> 8f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 98bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ash/display/display_layout.h" 108bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ash/display/display_manager.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/root_window_controller.h" 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/screen_util.h" 135c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include "ash/session/session_state_delegate.h" 142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ash/shelf/shelf_layout_manager.h" 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/shell.h" 16a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "ash/shell_observer.h" 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/shell_window_ids.h" 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/test/ash_test_base.h" 19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ash/wm/maximize_mode/workspace_backdrop_delegate.h" 2068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)#include "ash/wm/window_state.h" 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/wm/window_util.h" 22a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ash/wm/wm_event.h" 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/wm/workspace/workspace_window_resizer.h" 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/basictypes.h" 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/compiler_specific.h" 262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/aura/client/aura_constants.h" 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/aura/test/test_windows.h" 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/aura/window.h" 29a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/aura/window_event_dispatcher.h" 3046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#include "ui/base/ime/dummy_text_input_client.h" 3146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#include "ui/base/ime/input_method.h" 32f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#include "ui/base/ime/text_input_focus_manager.h" 33f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#include "ui/base/ui_base_switches_util.h" 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/base/ui_base_types.h" 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/insets.h" 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/gfx/screen.h" 37ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch#include "ui/views/widget/widget.h" 38ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch#include "ui/views/widget/widget_delegate.h" 39a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/wm/core/window_util.h" 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace ash { 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace { 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 44ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdochclass MaximizeDelegateView : public views::WidgetDelegateView { 45ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch public: 46f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) explicit MaximizeDelegateView(const gfx::Rect& initial_bounds) 47ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch : initial_bounds_(initial_bounds) { 48ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch } 49ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch virtual ~MaximizeDelegateView() {} 50ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 51ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch virtual bool GetSavedWindowPlacement( 520f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) const views::Widget* widget, 53ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch gfx::Rect* bounds, 54ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch ui::WindowShowState* show_state) const OVERRIDE { 55ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch *bounds = initial_bounds_; 56ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch *show_state = ui::SHOW_STATE_MAXIMIZED; 57ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch return true; 58ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch } 59ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 60ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch private: 61ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch const gfx::Rect initial_bounds_; 62ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 63ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch DISALLOW_COPY_AND_ASSIGN(MaximizeDelegateView); 64ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch}; 65ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 66a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class TestShellObserver : public ShellObserver { 67a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) public: 68a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) TestShellObserver() : call_count_(0), 69a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) is_fullscreen_(false) { 70a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) Shell::GetInstance()->AddShellObserver(this); 71a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) } 72a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 73a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual ~TestShellObserver() { 74a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) Shell::GetInstance()->RemoveShellObserver(this); 75a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) } 76a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 77a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual void OnFullscreenStateChanged(bool is_fullscreen, 78a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) aura::Window* root_window) OVERRIDE { 79a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) call_count_++; 80a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) is_fullscreen_ = is_fullscreen; 81a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) } 82a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 83a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) int call_count() const { 84a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) return call_count_; 85a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) } 86a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 87a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) bool is_fullscreen() const { 88a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) return is_fullscreen_; 89a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) } 90a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 91a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) private: 92a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) int call_count_; 93a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) bool is_fullscreen_; 94a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 95a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(TestShellObserver); 96a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)}; 97a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 98ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch} // namespace 99ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 1002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)typedef test::AshTestBase WorkspaceLayoutManagerTest; 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Verifies that a window containing a restore coordinate will be restored to 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// to the size prior to minimize, keeping the restore rectangle in tact (if 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// there is one). 1057d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) { 1062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> window( 1072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4))); 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect bounds(10, 15, 25, 35); 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window->SetBounds(bounds); 11068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) 11168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) wm::WindowState* window_state = wm::GetWindowState(window.get()); 11268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) 113c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // This will not be used for un-minimizing window. 11468043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100)); 11568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->Minimize(); 11668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->Restore(); 11768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) EXPECT_EQ("0,0 100x100", window_state->GetRestoreBoundsInScreen().ToString()); 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ("10,15 25x35", window.get()->bounds().ToString()); 119c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 1207d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) if (!SupportsMultipleDisplays()) 1217d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) return; 1227d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 123c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) UpdateDisplay("400x300,500x400"); 124c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), 1255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ScreenUtil::GetSecondaryDisplay()); 126c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_EQ(Shell::GetAllRootWindows()[1], window->GetRootWindow()); 12768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->Minimize(); 128c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // This will not be used for un-minimizing window. 12968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100)); 13068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->Restore(); 131c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_EQ("600,0 100x100", window->GetBoundsInScreen().ToString()); 132c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 133c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Make sure the unminimized window moves inside the display when 134c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // 2nd display is disconnected. 13568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->Minimize(); 136c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) UpdateDisplay("400x300"); 13768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->Restore(); 138c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_EQ(Shell::GetPrimaryRootWindow(), window->GetRootWindow()); 139c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_TRUE( 140c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds())); 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1438bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)TEST_F(WorkspaceLayoutManagerTest, KeepMinimumVisibilityInDisplays) { 1448bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) if (!SupportsMultipleDisplays()) 1458bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return; 1468bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1478bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) UpdateDisplay("300x400,400x500"); 148f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1498bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DisplayLayout layout(DisplayLayout::TOP, 0); 1518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) Shell::GetInstance()->display_manager()-> 1528bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) SetLayoutForCurrentDisplays(layout); 1538bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) EXPECT_EQ("0,-500 400x500", root_windows[1]->GetBoundsInScreen().ToString()); 1548bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1558bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) scoped_ptr<aura::Window> window1( 1568bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) CreateTestWindowInShellWithBounds(gfx::Rect(10, -400, 200, 200))); 1578bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) EXPECT_EQ("10,-400 200x200", window1->GetBoundsInScreen().ToString()); 1588bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1598bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Make sure the caption is visible. 1608bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) scoped_ptr<aura::Window> window2( 1618bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) CreateTestWindowInShellWithBounds(gfx::Rect(10, -600, 200, 200))); 1628bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) EXPECT_EQ("10,-500 200x200", window2->GetBoundsInScreen().ToString()); 1638bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 1648bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 165bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben MurdochTEST_F(WorkspaceLayoutManagerTest, KeepRestoredWindowInDisplay) { 166bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch if (!SupportsHostWindowResize()) 167bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch return; 168bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch scoped_ptr<aura::Window> window( 169bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40))); 17068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) wm::WindowState* window_state = wm::GetWindowState(window.get()); 17168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) 172bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch // Maximized -> Normal transition. 17368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->Maximize(); 17468043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->SetRestoreBoundsInScreen(gfx::Rect(-100, -100, 30, 40)); 17568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->Restore(); 176bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch EXPECT_TRUE( 177bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds())); 1788bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Y bounds should not be negative. 1798bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) EXPECT_EQ("-20,0 30x40", window->bounds().ToString()); 180bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch 181bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch // Minimized -> Normal transition. 182bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch window->SetBounds(gfx::Rect(-100, -100, 30, 40)); 18368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->Minimize(); 184bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch EXPECT_FALSE( 185bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds())); 186bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch EXPECT_EQ("-100,-100 30x40", window->bounds().ToString()); 187bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch window->Show(); 188bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch EXPECT_TRUE( 189bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds())); 1908bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Y bounds should not be negative. 1918bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) EXPECT_EQ("-20,0 30x40", window->bounds().ToString()); 192bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch 193bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch // Fullscreen -> Normal transition. 194bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch window->SetBounds(gfx::Rect(0, 0, 30, 40)); // reset bounds. 195bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch ASSERT_EQ("0,0 30x40", window->bounds().ToString()); 196bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 197bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch EXPECT_EQ(window->bounds(), window->GetRootWindow()->bounds()); 19868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->SetRestoreBoundsInScreen(gfx::Rect(-100, -100, 30, 40)); 19968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->Restore(); 200bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch EXPECT_TRUE( 201bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds())); 2028bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Y bounds should not be negative. 2038bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) EXPECT_EQ("-20,0 30x40", window->bounds().ToString()); 204bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch} 205bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch 206ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben MurdochTEST_F(WorkspaceLayoutManagerTest, MaximizeInDisplayToBeRestored) { 207ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch if (!SupportsMultipleDisplays()) 208ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch return; 209ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch UpdateDisplay("300x400,400x500"); 210ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 211f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 212ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 213ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch scoped_ptr<aura::Window> window( 214ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40))); 215ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch EXPECT_EQ(root_windows[0], window->GetRootWindow()); 216ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 21768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) wm::WindowState* window_state = wm::GetWindowState(window.get()); 21868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->SetRestoreBoundsInScreen(gfx::Rect(400, 0, 30, 40)); 219ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch // Maximize the window in 2nd display as the restore bounds 220ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch // is inside 2nd display. 22168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->Maximize(); 222ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch EXPECT_EQ(root_windows[1], window->GetRootWindow()); 22358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) EXPECT_EQ("300,0 400x453", window->GetBoundsInScreen().ToString()); 224ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 22568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->Restore(); 226ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch EXPECT_EQ(root_windows[1], window->GetRootWindow()); 227ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch EXPECT_EQ("400,0 30x40", window->GetBoundsInScreen().ToString()); 228ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 229ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch // If the restore bounds intersects with the current display, 230ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch // don't move. 23168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->SetRestoreBoundsInScreen(gfx::Rect(280, 0, 30, 40)); 23268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->Maximize(); 233ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch EXPECT_EQ(root_windows[1], window->GetRootWindow()); 23458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) EXPECT_EQ("300,0 400x453", window->GetBoundsInScreen().ToString()); 235ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 23668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->Restore(); 237ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch EXPECT_EQ(root_windows[1], window->GetRootWindow()); 238ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch EXPECT_EQ("280,0 30x40", window->GetBoundsInScreen().ToString()); 239ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 240ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch // Restoring widget state. 241ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch scoped_ptr<views::Widget> w1(new views::Widget); 242ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch views::Widget::InitParams params; 243ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 244ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch params.delegate = new MaximizeDelegateView(gfx::Rect(400, 0, 30, 40)); 245ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch params.context = root_windows[0]; 246ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch w1->Init(params); 247ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch w1->Show(); 248ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch EXPECT_TRUE(w1->IsMaximized()); 249ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow()); 25058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) EXPECT_EQ("300,0 400x453", w1->GetWindowBoundsInScreen().ToString()); 251ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch w1->Restore(); 252ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow()); 253ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch EXPECT_EQ("400,0 30x40", w1->GetWindowBoundsInScreen().ToString()); 254ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch} 255ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 256ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben MurdochTEST_F(WorkspaceLayoutManagerTest, FullscreenInDisplayToBeRestored) { 257ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch if (!SupportsMultipleDisplays()) 258ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch return; 259ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch UpdateDisplay("300x400,400x500"); 260ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 261f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 262ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 263ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch scoped_ptr<aura::Window> window( 264ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40))); 265ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch EXPECT_EQ(root_windows[0], window->GetRootWindow()); 266ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 26768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) wm::WindowState* window_state = wm::GetWindowState(window.get()); 26868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->SetRestoreBoundsInScreen(gfx::Rect(400, 0, 30, 40)); 269ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch // Maximize the window in 2nd display as the restore bounds 270ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch // is inside 2nd display. 271ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch window->SetProperty(aura::client::kShowStateKey, 272ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch ui::SHOW_STATE_FULLSCREEN); 273ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch EXPECT_EQ(root_windows[1], window->GetRootWindow()); 274ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch EXPECT_EQ("300,0 400x500", window->GetBoundsInScreen().ToString()); 275ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 27668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->Restore(); 277ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch EXPECT_EQ(root_windows[1], window->GetRootWindow()); 278ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch EXPECT_EQ("400,0 30x40", window->GetBoundsInScreen().ToString()); 279ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 280ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch // If the restore bounds intersects with the current display, 281ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch // don't move. 28268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->SetRestoreBoundsInScreen(gfx::Rect(280, 0, 30, 40)); 283ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch window->SetProperty(aura::client::kShowStateKey, 284ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch ui::SHOW_STATE_FULLSCREEN); 285ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch EXPECT_EQ(root_windows[1], window->GetRootWindow()); 286ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch EXPECT_EQ("300,0 400x500", window->GetBoundsInScreen().ToString()); 287ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 28868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->Restore(); 289ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch EXPECT_EQ(root_windows[1], window->GetRootWindow()); 290ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch EXPECT_EQ("280,0 30x40", window->GetBoundsInScreen().ToString()); 291ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch} 292ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// WindowObserver implementation used by DontClobberRestoreBoundsWindowObserver. 2944e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// This code mirrors what BrowserFrameAsh does. In particular when this code 2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// sees the window was maximized it changes the bounds of a secondary 2965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// window. The secondary window mirrors the status window. 2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class DontClobberRestoreBoundsWindowObserver : public aura::WindowObserver { 2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DontClobberRestoreBoundsWindowObserver() : window_(NULL) {} 3005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void set_window(aura::Window* window) { window_ = window; } 3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnWindowPropertyChanged(aura::Window* window, 3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const void* key, 3052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) intptr_t old) OVERRIDE { 3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!window_) 3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return; 3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 30968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) if (wm::GetWindowState(window)->IsMaximized()) { 3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) aura::Window* w = window_; 3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window_ = NULL; 3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect shelf_bounds(Shell::GetPrimaryRootWindowController()-> 3142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetShelfLayoutManager()->GetIdealBounds()); 3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Rect& window_bounds(w->bounds()); 3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) w->SetBounds(gfx::Rect(window_bounds.x(), shelf_bounds.y() - 1, 3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window_bounds.width(), window_bounds.height())); 3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) aura::Window* window_; 3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(DontClobberRestoreBoundsWindowObserver); 3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Creates a window, maximized the window and from within the maximized 3285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// notification sets the bounds of a window to overlap the shelf. Verifies this 3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// doesn't effect the restore bounds. 3305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerTest, DontClobberRestoreBounds) { 3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DontClobberRestoreBoundsWindowObserver window_observer; 3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<aura::Window> window(new aura::Window(NULL)); 3335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->SetType(ui::wm::WINDOW_TYPE_NORMAL); 3345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->Init(aura::WINDOW_LAYER_TEXTURED); 3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window->SetBounds(gfx::Rect(10, 20, 30, 40)); 3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // NOTE: for this test to exercise the failure the observer needs to be added 3374e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // before the parent set. This mimics what BrowserFrameAsh does. 3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window->AddObserver(&window_observer); 3391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) ParentWindowInPrimaryRootWindow(window.get()); 3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window->Show(); 34168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) 34268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) wm::WindowState* window_state = wm::GetWindowState(window.get()); 34368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->Activate(); 3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> window2( 3462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 30, 40))); 347a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ::wm::AddTransientChild(window.get(), window2.get()); 3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window2->Show(); 3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window_observer.set_window(window2.get()); 35168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->Maximize(); 35268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) EXPECT_EQ("10,20 30x40", 35368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->GetRestoreBoundsInScreen().ToString()); 3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window->RemoveObserver(&window_observer); 3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Verifies when a window is maximized all descendant windows have a size. 3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerTest, ChildBoundsResetOnMaximize) { 3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<aura::Window> window( 3602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateTestWindowInShellWithBounds(gfx::Rect(10, 20, 30, 40))); 3615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window->Show(); 36268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) wm::WindowState* window_state = wm::GetWindowState(window.get()); 36368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->Activate(); 3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<aura::Window> child_window( 3655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) aura::test::CreateTestWindowWithBounds(gfx::Rect(5, 6, 7, 8), 3665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window.get())); 3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) child_window->Show(); 36868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) window_state->Maximize(); 3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ("5,6 7x8", child_window->bounds().ToString()); 3705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 372a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Verifies a window created with maximized state has the maximized 373a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// bounds. 374a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerTest, MaximizeWithEmptySize) { 375a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) scoped_ptr<aura::Window> window( 376a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::test::CreateTestWindowWithBounds(gfx::Rect(0, 0, 0, 0), 377a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) NULL)); 378a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) wm::GetWindowState(window.get())->Maximize(); 379a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::Window* default_container = Shell::GetContainer( 380c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch Shell::GetPrimaryRootWindow(), kShellWindowId_DefaultContainer); 381a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) default_container->AddChild(window.get()); 382a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) window->Show(); 383a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) gfx::Rect work_area( 384a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) Shell::GetScreen()->GetPrimaryDisplay().work_area()); 385a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_EQ(work_area.ToString(), window->GetBoundsInScreen().ToString()); 386a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 387a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 3885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerTest, WindowShouldBeOnScreenWhenAdded) { 3895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Normal window bounds shouldn't be changed. 3905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_bounds(100, 100, 200, 200); 3912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> window( 3922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateTestWindowInShellWithBounds(window_bounds)); 3935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(window_bounds, window->bounds()); 3945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If the window is out of the workspace, it would be moved on screen. 3965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect root_window_bounds = 397bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch Shell::GetInstance()->GetPrimaryRootWindow()->bounds(); 3985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window_bounds.Offset(root_window_bounds.width(), root_window_bounds.height()); 3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASSERT_FALSE(window_bounds.Intersects(root_window_bounds)); 4002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> out_window( 4012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateTestWindowInShellWithBounds(window_bounds)); 4025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(window_bounds.size(), out_window->bounds().size()); 4032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds = out_window->bounds(); 4042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bounds.Intersect(root_window_bounds); 405bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch 406bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch // 30% of the window edge must be visible. 407bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch EXPECT_GT(bounds.width(), out_window->bounds().width() * 0.29); 408bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch EXPECT_GT(bounds.height(), out_window->bounds().height() * 0.29); 409bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch 4103551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) aura::Window* parent = out_window->parent(); 4113551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) parent->RemoveChild(out_window.get()); 4123551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) out_window->SetBounds(gfx::Rect(-200, -200, 200, 200)); 4133551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // UserHasChangedWindowPositionOrSize flag shouldn't turn off this behavior. 41468043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) wm::GetWindowState(window.get())->set_bounds_changed_by_user(true); 4153551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) parent->AddChild(out_window.get()); 4163551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) EXPECT_GT(bounds.width(), out_window->bounds().width() * 0.29); 4173551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) EXPECT_GT(bounds.height(), out_window->bounds().height() * 0.29); 4183551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 419bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch // Make sure we always make more than 1/3 of the window edge visible even 420bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch // if the initial bounds intersects with display. 421bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch window_bounds.SetRect(-150, -150, 200, 200); 422bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch bounds = window_bounds; 423bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch bounds.Intersect(root_window_bounds); 424bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch 425bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch // Make sure that the initial bounds' visible area is less than 26% 426bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch // so that the auto adjustment logic kicks in. 427bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch ASSERT_LT(bounds.width(), out_window->bounds().width() * 0.26); 428bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch ASSERT_LT(bounds.height(), out_window->bounds().height() * 0.26); 429bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch ASSERT_TRUE(window_bounds.Intersects(root_window_bounds)); 430bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch 431bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch scoped_ptr<aura::Window> partially_out_window( 432bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch CreateTestWindowInShellWithBounds(window_bounds)); 433bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch EXPECT_EQ(window_bounds.size(), partially_out_window->bounds().size()); 434bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch bounds = partially_out_window->bounds(); 435bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch bounds.Intersect(root_window_bounds); 436bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch EXPECT_GT(bounds.width(), out_window->bounds().width() * 0.29); 437bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch EXPECT_GT(bounds.height(), out_window->bounds().height() * 0.29); 438bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch 439bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch // Make sure the window whose 30% width/height is bigger than display 440bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch // will be placed correctly. 441bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch window_bounds.SetRect(-1900, -1900, 3000, 3000); 442bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch scoped_ptr<aura::Window> window_bigger_than_display( 443bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch CreateTestWindowInShellWithBounds(window_bounds)); 444bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch EXPECT_GE(root_window_bounds.width(), 445bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch window_bigger_than_display->bounds().width()); 446bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch EXPECT_GE(root_window_bounds.height(), 447bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch window_bigger_than_display->bounds().height()); 448bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch 449bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch bounds = window_bigger_than_display->bounds(); 450bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch bounds.Intersect(root_window_bounds); 451bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch EXPECT_GT(bounds.width(), out_window->bounds().width() * 0.29); 452bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch EXPECT_GT(bounds.height(), out_window->bounds().height() * 0.29); 4535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Verifies the size of a window is enforced to be smaller than the work area. 4565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerTest, SizeToWorkArea) { 4575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Normal window bounds shouldn't be changed. 4585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Size work_area( 4592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Shell::GetScreen()->GetPrimaryDisplay().work_area().size()); 4605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Rect window_bounds( 4615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 100, 101, work_area.width() + 1, work_area.height() + 2); 4622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> window( 4632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateTestWindowInShellWithBounds(window_bounds)); 4645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), 4655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window->bounds().ToString()); 4665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Directly setting the bounds triggers a slightly different code path. Verify 4685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // that too. 4695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window->SetBounds(window_bounds); 4705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), 4715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) window->bounds().ToString()); 4725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 474a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerTest, NotifyFullscreenChanges) { 475a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) TestShellObserver observer; 476a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) scoped_ptr<aura::Window> window1( 477a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40))); 478a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) scoped_ptr<aura::Window> window2( 479a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40))); 480a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) wm::WindowState* window_state1 = wm::GetWindowState(window1.get()); 481a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) wm::WindowState* window_state2 = wm::GetWindowState(window2.get()); 482a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) window_state2->Activate(); 483a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 484a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const wm::WMEvent toggle_fullscreen_event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 485a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) window_state2->OnWMEvent(&toggle_fullscreen_event); 486a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) EXPECT_EQ(1, observer.call_count()); 487a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) EXPECT_TRUE(observer.is_fullscreen()); 488a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 489a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // When window1 moves to the front the fullscreen state should change. 490a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) window_state1->Activate(); 491a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) EXPECT_EQ(2, observer.call_count()); 492a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) EXPECT_FALSE(observer.is_fullscreen()); 493a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 494a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // It should change back if window2 becomes active again. 495a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) window_state2->Activate(); 496a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) EXPECT_EQ(3, observer.call_count()); 497a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) EXPECT_TRUE(observer.is_fullscreen()); 498a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 499a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) window_state2->OnWMEvent(&toggle_fullscreen_event); 500a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) EXPECT_EQ(4, observer.call_count()); 501a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) EXPECT_FALSE(observer.is_fullscreen()); 502a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 503a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) window_state2->OnWMEvent(&toggle_fullscreen_event); 504a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) EXPECT_EQ(5, observer.call_count()); 505a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) EXPECT_TRUE(observer.is_fullscreen()); 506a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 507a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Closing the window should change the fullscreen state. 508a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) window2.reset(); 509a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) EXPECT_EQ(6, observer.call_count()); 510a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) EXPECT_FALSE(observer.is_fullscreen()); 511a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 512a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 5135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Following tests were originally written for BaseLayoutManager. 5145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 5155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace { 5165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 5175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class WorkspaceLayoutManagerSoloTest : public test::AshTestBase { 5185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public: 5195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) WorkspaceLayoutManagerSoloTest() {} 5205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual ~WorkspaceLayoutManagerSoloTest() {} 5215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 5225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void SetUp() OVERRIDE { 5235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) test::AshTestBase::SetUp(); 5245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UpdateDisplay("800x600"); 5255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) aura::Window* default_container = Shell::GetContainer( 526c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch Shell::GetPrimaryRootWindow(), kShellWindowId_DefaultContainer); 527c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch default_container->SetLayoutManager( 528c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch new WorkspaceLayoutManager(Shell::GetPrimaryRootWindow())); 5295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 5305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 5315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) aura::Window* CreateTestWindow(const gfx::Rect& bounds) { 5325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return CreateTestWindowInShellWithBounds(bounds); 5335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 5345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 5355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private: 5365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerSoloTest); 5375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 5385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 5395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace 5405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 5415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Tests normal->maximize->normal. 5425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerSoloTest, Maximize) { 5435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Rect bounds(100, 100, 200, 200); 5445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); 5455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 5465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Maximized window fills the work area, not the whole display. 5475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ( 5485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), 5495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->bounds().ToString()); 5505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 5515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); 5525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 5535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 5545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Tests normal->minimize->normal. 5555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerSoloTest, Minimize) { 5565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Rect bounds(100, 100, 200, 200); 5575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); 5585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); 5595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Note: Currently minimize doesn't do anything except set the state. 5605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // See crbug.com/104571. 5615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); 5625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 5635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); 5645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 5655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 5665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// A WindowDelegate which sets the focus when the window 5675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// becomes visible. 5685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class FocusDelegate : public aura::test::TestWindowDelegate { 5695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public: 5705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FocusDelegate() 5715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) : window_(NULL), 5725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) show_state_(ui::SHOW_STATE_END) { 5735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 5745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual ~FocusDelegate() {} 5755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 5765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void set_window(aura::Window* window) { window_ = window; } 5775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 5785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // aura::test::TestWindowDelegate overrides: 5795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE { 5805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (window_) { 5815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (visible) 5825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window_->Focus(); 5835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) show_state_ = window_->GetProperty(aura::client::kShowStateKey); 5845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 5855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 5865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 5875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::WindowShowState GetShowStateAndReset() { 5885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::WindowShowState ret = show_state_; 5895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) show_state_ = ui::SHOW_STATE_END; 5905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return ret; 5915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 5925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 5935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private: 5945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) aura::Window* window_; 5955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::WindowShowState show_state_; 5965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 5975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(FocusDelegate); 5985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 5995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 6005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Make sure that the window's show state is correct in 6015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// |WindowDelegate::OnWindowTargetVisibilityChanged|, and setting 6025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// focus in this callback doesn't cause DCHECK error. See 6035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// crbug.com/168383. 6045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerSoloTest, FocusDuringUnminimize) { 6055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FocusDelegate delegate; 6065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( 6075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) &delegate, 0, gfx::Rect(100, 100, 100, 100))); 6085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) delegate.set_window(window.get()); 6095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); 6105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(window->IsVisible()); 6115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(ui::SHOW_STATE_MINIMIZED, delegate.GetShowStateAndReset()); 6125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->Show(); 6135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(window->IsVisible()); 6145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(ui::SHOW_STATE_NORMAL, delegate.GetShowStateAndReset()); 6155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 6165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 6175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Tests maximized window size during root window resize. 6185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerSoloTest, MaximizeRootWindowResize) { 6195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Rect bounds(100, 100, 200, 200); 6205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); 6215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 6225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Rect initial_work_area_bounds = 6235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()); 6245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(initial_work_area_bounds.ToString(), window->bounds().ToString()); 6255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Enlarge the root window. We should still match the work area size. 6265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UpdateDisplay("900x700"); 6275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ( 6285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), 6295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->bounds().ToString()); 6305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_NE( 6315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) initial_work_area_bounds.ToString(), 6325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString()); 6335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 6345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 6355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Tests normal->fullscreen->normal. 6365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerSoloTest, Fullscreen) { 6375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Rect bounds(100, 100, 200, 200); 6385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); 6395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 6405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Fullscreen window fills the whole display. 6415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( 6425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window.get()).bounds().ToString(), 6435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->bounds().ToString()); 6445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 6455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); 6465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 6475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 6485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Tests fullscreen window size during root window resize. 6495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerSoloTest, FullscreenRootWindowResize) { 6505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Rect bounds(100, 100, 200, 200); 6515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); 6525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Fullscreen window fills the whole display. 6535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 6545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( 6555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window.get()).bounds().ToString(), 6565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->bounds().ToString()); 6575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Enlarge the root window. We should still match the display size. 6585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UpdateDisplay("800x600"); 6595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( 6605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window.get()).bounds().ToString(), 6615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->bounds().ToString()); 6625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 6635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 6645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Tests that when the screen gets smaller the windows aren't bigger than 6655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// the screen. 6665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerSoloTest, RootWindowResizeShrinksWindows) { 6675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<aura::Window> window( 6685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CreateTestWindow(gfx::Rect(10, 20, 500, 400))); 6695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( 6705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window.get()).work_area(); 6715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Invariant: Window is smaller than work area. 6725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_LE(window->bounds().width(), work_area.width()); 6735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_LE(window->bounds().height(), work_area.height()); 6745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 6755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Make the root window narrower than our window. 6765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UpdateDisplay("300x400"); 6775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) work_area = Shell::GetScreen()->GetDisplayNearestWindow( 6785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window.get()).work_area(); 6795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_LE(window->bounds().width(), work_area.width()); 6805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_LE(window->bounds().height(), work_area.height()); 6815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 6825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Make the root window shorter than our window. 6835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UpdateDisplay("300x200"); 6845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) work_area = Shell::GetScreen()->GetDisplayNearestWindow( 6855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window.get()).work_area(); 6865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_LE(window->bounds().width(), work_area.width()); 6875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_LE(window->bounds().height(), work_area.height()); 6885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 6895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Enlarging the root window does not change the window bounds. 6905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Rect old_bounds = window->bounds(); 6915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UpdateDisplay("800x600"); 6925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(old_bounds.width(), window->bounds().width()); 6935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(old_bounds.height(), window->bounds().height()); 6945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 6955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 6965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Verifies maximizing sets the restore bounds, and restoring 6975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// restores the bounds. 6985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerSoloTest, MaximizeSetsRestoreBounds) { 6995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(10, 20, 30, 40))); 7005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) wm::WindowState* window_state = wm::GetWindowState(window.get()); 7015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 7025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Maximize it, which will keep the previous restore bounds. 7035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 7045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ("10,20 30x40", window_state->GetRestoreBoundsInParent().ToString()); 7055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 7065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Restore it, which should restore bounds and reset restore bounds. 7075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 7085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ("10,20 30x40", window->bounds().ToString()); 7095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(window_state->HasRestoreBounds()); 7105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 7115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 7125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Verifies maximizing keeps the restore bounds if set. 7135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerSoloTest, MaximizeResetsRestoreBounds) { 7145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); 7155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 7165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) wm::WindowState* window_state = wm::GetWindowState(window.get()); 7175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window_state->SetRestoreBoundsInParent(gfx::Rect(10, 11, 12, 13)); 7185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 7195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Maximize it, which will keep the previous restore bounds. 7205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 7215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ("10,11 12x13", window_state->GetRestoreBoundsInParent().ToString()); 7225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 7235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 7245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Verifies that the restore bounds do not get reset when restoring to a 7255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// maximzied state from a minimized state. 7265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerSoloTest, 7275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) BoundsAfterRestoringToMaximizeFromMinimize) { 7285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); 7295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Rect bounds(10, 15, 25, 35); 7305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->SetBounds(bounds); 7315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 7325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) wm::WindowState* window_state = wm::GetWindowState(window.get()); 7335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Maximize it, which should reset restore bounds. 7345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window_state->Maximize(); 7355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(bounds.ToString(), 7365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window_state->GetRestoreBoundsInParent().ToString()); 7375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Minimize the window. The restore bounds should not change. 7385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window_state->Minimize(); 7395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(bounds.ToString(), 7405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window_state->GetRestoreBoundsInParent().ToString()); 7415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 7425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Show the window again. The window should be maximized, and the restore 7435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // bounds should not change. 7445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->Show(); 7455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(bounds.ToString(), 7465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window_state->GetRestoreBoundsInParent().ToString()); 7475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(window_state->IsMaximized()); 7485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 7495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window_state->Restore(); 7505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); 7515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 7525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 7535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Verify if the window is not resized during screen lock. See: crbug.com/173127 7545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerSoloTest, NotResizeWhenScreenIsLocked) { 7555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetCanLockScreen(true); 7565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); 7575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // window with AlwaysOnTop will be managed by BaseLayoutManager. 7585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->SetProperty(aura::client::kAlwaysOnTopKey, true); 7595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->Show(); 7605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 761c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ShelfLayoutManager* shelf = ShelfLayoutManager::ForShelf(window.get()); 7625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 7635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 7645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->SetBounds(ScreenUtil::GetMaximizedWindowBoundsInParent(window.get())); 7655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Rect window_bounds = window->bounds(); 7665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ( 7675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), 7685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window_bounds.ToString()); 7695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 7705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Shell::GetInstance()->session_state_delegate()->LockScreen(); 7715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) shelf->UpdateVisibilityState(); 7725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_NE( 7735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), 7745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window_bounds.ToString()); 7755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 7765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Shell::GetInstance()->session_state_delegate()->UnlockScreen(); 7775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) shelf->UpdateVisibilityState(); 7785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString()); 7795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 7805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 781a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Following tests are written to test the backdrop functionality. 782a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 783a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace { 784a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 785a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class WorkspaceLayoutManagerBackdropTest : public test::AshTestBase { 786a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) public: 787a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) WorkspaceLayoutManagerBackdropTest() {} 788a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual ~WorkspaceLayoutManagerBackdropTest() {} 789a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 790a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual void SetUp() OVERRIDE { 791a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) test::AshTestBase::SetUp(); 792a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) UpdateDisplay("800x600"); 793c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch default_container_ = Shell::GetContainer(Shell::GetPrimaryRootWindow(), 794c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch kShellWindowId_DefaultContainer); 795a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 796a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 797a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::Window* CreateTestWindow(const gfx::Rect& bounds) { 798a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::Window* window = CreateTestWindowInShellWithBounds(bounds); 799a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return window; 800a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 801a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 802a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Turn the top window back drop on / off. 803a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) void ShowTopWindowBackdrop(bool show) { 804c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch scoped_ptr<ash::WorkspaceLayoutManagerDelegate> backdrop; 805a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (show) { 806c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch backdrop.reset(new ash::WorkspaceBackdropDelegate(default_container_)); 807a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 808c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch (static_cast<WorkspaceLayoutManager*>(default_container_->layout_manager())) 809c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ->SetMaximizeBackdropDelegate(backdrop.Pass()); 810a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Closing and / or opening can be a delayed operation. 811a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::MessageLoop::current()->RunUntilIdle(); 812a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 813a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 814a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Return the default container. 815a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::Window* default_container() { return default_container_; } 816a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 817a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Return the order of windows (top most first) as they are in the default 818a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // container. If the window is visible it will be a big letter, otherwise a 819a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // small one. The backdrop will be an X and unknown windows will be shown as 820a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // '!'. 821a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) std::string GetWindowOrderAsString(aura::Window* backdrop, 822a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::Window* wa, 823a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::Window* wb, 824a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::Window* wc) { 825a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) std::string result; 826a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) for (int i = static_cast<int>(default_container()->children().size()) - 1; 827a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) i >= 0; 828a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) --i) { 829a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (!result.empty()) 830a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) result += ","; 831a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (default_container()->children()[i] == wa) 832a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) result += default_container()->children()[i]->IsVisible() ? "A" : "a"; 833a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) else if (default_container()->children()[i] == wb) 834a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) result += default_container()->children()[i]->IsVisible() ? "B" : "b"; 835a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) else if (default_container()->children()[i] == wc) 836a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) result += default_container()->children()[i]->IsVisible() ? "C" : "c"; 837a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) else if (default_container()->children()[i] == backdrop) 838a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) result += default_container()->children()[i]->IsVisible() ? "X" : "x"; 839a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) else 840a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) result += "!"; 841a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 842a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return result; 843a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 844a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 845a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) private: 846a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // The default container. 847a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::Window* default_container_; 848a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 849a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerBackdropTest); 850a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}; 851a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 852a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} // namespace 853a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 854a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Check that creating the BackDrop without destroying it does not lead into 855a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// a crash. 856a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerBackdropTest, BackdropCrashTest) { 857a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTopWindowBackdrop(true); 858a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 859a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 860a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Verify basic assumptions about the backdrop. 861a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerBackdropTest, BasicBackdropTests) { 862a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Create a backdrop and see that there is one window (the backdrop) and 863a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // that the size is the same as the default container as well as that it is 864a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // not visible. 865a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTopWindowBackdrop(true); 866a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_EQ(1U, default_container()->children().size()); 867a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_FALSE(default_container()->children()[0]->IsVisible()); 868a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 869a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) { 870a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Add a window and make sure that the backdrop is the second child. 871a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); 872a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) window->Show(); 873a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_EQ(2U, default_container()->children().size()); 874a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_TRUE(default_container()->children()[0]->IsVisible()); 875a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_TRUE(default_container()->children()[1]->IsVisible()); 876a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_EQ(window.get(), default_container()->children()[1]); 877a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_EQ(default_container()->bounds().ToString(), 878a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) default_container()->children()[0]->bounds().ToString()); 879a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 880a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 881a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // With the window gone the backdrop should be invisible again. 882a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_EQ(1U, default_container()->children().size()); 883a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_FALSE(default_container()->children()[0]->IsVisible()); 884a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 885a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Destroying the Backdrop should empty the container. 886a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTopWindowBackdrop(false); 887a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_EQ(0U, default_container()->children().size()); 888a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 889a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 890a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Verify that the backdrop gets properly created and placed. 891a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerBackdropTest, VerifyBackdropAndItsStacking) { 892a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) scoped_ptr<aura::Window> window1(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); 893a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) window1->Show(); 894a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 895a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Get the default container and check that only a single window is in there. 896a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_EQ(1U, default_container()->children().size()); 897a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_EQ(window1.get(), default_container()->children()[0]); 898a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_EQ("A", GetWindowOrderAsString(NULL, window1.get(), NULL, NULL)); 899a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 900a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Create 2 more windows and check that they are also in the container. 901a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) scoped_ptr<aura::Window> window2(CreateTestWindow(gfx::Rect(10, 2, 3, 4))); 902a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) scoped_ptr<aura::Window> window3(CreateTestWindow(gfx::Rect(20, 2, 3, 4))); 903a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) window2->Show(); 904a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) window3->Show(); 905a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 906a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::Window* backdrop = NULL; 907a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_EQ("C,B,A", 908a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GetWindowOrderAsString(backdrop, window1.get(), window2.get(), 909a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) window3.get())); 910a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 911a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Turn on the backdrop mode and check that the window shows up where it 912a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // should be (second highest number). 913a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTopWindowBackdrop(true); 914a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) backdrop = default_container()->children()[2]; 915a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_EQ("C,X,B,A", 916a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GetWindowOrderAsString(backdrop, window1.get(), window2.get(), 917a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) window3.get())); 918a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 919a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Switch the order of windows and check that it still remains in that 920a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // location. 921a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) default_container()->StackChildAtTop(window2.get()); 922a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_EQ("B,X,C,A", 923a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GetWindowOrderAsString(backdrop, window1.get(), window2.get(), 924a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) window3.get())); 925a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 926a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Make the top window invisible and check. 927a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) window2.get()->Hide(); 928a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_EQ("b,C,X,A", 929a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GetWindowOrderAsString(backdrop, window1.get(), window2.get(), 930a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) window3.get())); 931a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Then delete window after window and see that everything is in order. 932a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) window1.reset(); 933a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_EQ("b,C,X", 934a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GetWindowOrderAsString(backdrop, window1.get(), window2.get(), 935a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) window3.get())); 936a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) window3.reset(); 937a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_EQ("b,x", 938a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GetWindowOrderAsString(backdrop, window1.get(), window2.get(), 939a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) window3.get())); 940a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTopWindowBackdrop(false); 941a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_EQ("b", 942a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GetWindowOrderAsString(NULL, window1.get(), window2.get(), 943a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) window3.get())); 944a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 945a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 946f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// Tests that when hidding the shelf, that the backdrop resizes to fill the 947f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// entire workspace area. 948f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)TEST_F(WorkspaceLayoutManagerBackdropTest, ShelfVisibilityChangesBounds) { 949f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) ShelfLayoutManager* shelf_layout_manager = 950f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); 951f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) ShowTopWindowBackdrop(true); 952f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) RunAllPendingInMessageLoop(); 953f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 954f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) ASSERT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); 955f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) gfx::Rect initial_bounds = default_container()->children()[0]->bounds(); 956f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); 957f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) shelf_layout_manager->UpdateVisibilityState(); 958f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 959f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // When the shelf is re-shown WorkspaceLayoutManager shrinks all children 960f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // including the backdrop. 961f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 962f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) shelf_layout_manager->UpdateVisibilityState(); 963f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) gfx::Rect reduced_bounds = default_container()->children()[0]->bounds(); 964f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) EXPECT_LT(reduced_bounds.height(), initial_bounds.height()); 965f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 966f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); 967f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) shelf_layout_manager->UpdateVisibilityState(); 968f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 969f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) EXPECT_GT(default_container()->children()[0]->bounds().height(), 970f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) reduced_bounds.height()); 971f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)} 972f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 97346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)class WorkspaceLayoutManagerKeyboardTest : public test::AshTestBase { 97446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) public: 97546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) WorkspaceLayoutManagerKeyboardTest() {} 97646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) virtual ~WorkspaceLayoutManagerKeyboardTest() {} 97746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 97846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) virtual void SetUp() OVERRIDE { 97946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) test::AshTestBase::SetUp(); 98046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) UpdateDisplay("800x600"); 98146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) aura::Window* default_container = Shell::GetContainer( 98246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) Shell::GetPrimaryRootWindow(), kShellWindowId_DefaultContainer); 98346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) layout_manager_ = new WorkspaceLayoutManager(Shell::GetPrimaryRootWindow()); 98446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) default_container->SetLayoutManager(layout_manager_); 98546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) } 98646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 98746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) aura::Window* CreateTestWindow(const gfx::Rect& bounds) { 98846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) return CreateTestWindowInShellWithBounds(bounds); 98946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) } 99046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 99146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) void ShowKeyboard() { 99246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) restore_work_area_insets_ = Shell::GetScreen()->GetPrimaryDisplay(). 99346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) GetWorkAreaInsets(); 99446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) Shell::GetInstance()->SetDisplayWorkAreaInsets( 99546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) Shell::GetPrimaryRootWindow(), 99646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) gfx::Insets(0, 0, keyboard_bounds_.height(), 0)); 99746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_); 99846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) } 99946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 100046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) void HideKeyboard() { 100146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) Shell::GetInstance()->SetDisplayWorkAreaInsets( 100246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) Shell::GetPrimaryRootWindow(), 100346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) restore_work_area_insets_); 100446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) layout_manager_->OnKeyboardBoundsChanging(gfx::Rect()); 100546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) } 100646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 100746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) void SetKeyboardBounds(const gfx::Rect& bounds) { 100846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) keyboard_bounds_ = bounds; 100946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) } 101046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 101146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) private: 101246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) gfx::Insets restore_work_area_insets_; 101346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) gfx::Rect keyboard_bounds_; 1014f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) WorkspaceLayoutManager* layout_manager_; 101546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 101646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest); 101746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)}; 101846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 101946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)class FakeTextInputClient : public ui::DummyTextInputClient { 102046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) public: 1021f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) explicit FakeTextInputClient(gfx::NativeWindow window) : window_(window) {} 102246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) virtual ~FakeTextInputClient() {} 102346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 102446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) virtual gfx::NativeWindow GetAttachedWindow() const OVERRIDE { 102546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) return window_; 102646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) } 102746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 102846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) private: 102946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) gfx::NativeWindow window_; 103046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 103146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(FakeTextInputClient); 103246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)}; 103346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 103446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) { 103546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) gfx::Rect work_area( 103646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) Shell::GetScreen()->GetPrimaryDisplay().work_area()); 103746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) gfx::Rect keyboard_bounds(work_area.x(), 103846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) work_area.y() + work_area.height() / 2, 103946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) work_area.width(), 104046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) work_area.height() / 2); 104146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 104246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) SetKeyboardBounds(keyboard_bounds); 104346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) scoped_ptr<aura::Window> window( 104446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) CreateTestWindowInShellWithBounds(work_area)); 104546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 104646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) aura::Window* root_window = ash::Shell::GetInstance()->GetPrimaryRootWindow(); 104746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) FakeTextInputClient text_input_client(window.get()); 104846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) ui::InputMethod* input_method = 104946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) root_window->GetProperty(aura::client::kRootWindowInputMethodKey); 1050f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) if (switches::IsTextInputFocusManagerEnabled()) { 1051f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) ui::TextInputFocusManager::GetInstance()->FocusTextInputClient( 1052f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) &text_input_client); 1053f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) } else { 1054f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) input_method->SetFocusedTextInputClient(&text_input_client); 1055f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) } 105646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 105746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) int available_height = 105846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) Shell::GetScreen()->GetPrimaryDisplay().bounds().height() - 105946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) keyboard_bounds.height(); 106046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 106146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) EXPECT_EQ(gfx::Rect(work_area).ToString(), 106246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) window->bounds().ToString()); 106346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) ShowKeyboard(); 106446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) EXPECT_EQ(gfx::Rect(work_area.origin(), 106546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) gfx::Size(work_area.width(), available_height)).ToString(), 106646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) window->bounds().ToString()); 106746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) HideKeyboard(); 106846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 106946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) window->SetBounds(gfx::Rect(50, 50, 100, 500)); 107046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) EXPECT_EQ("50,50 100x500", window->bounds().ToString()); 107146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) ShowKeyboard(); 107246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(), 107346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) window->bounds().ToString()); 107446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) HideKeyboard(); 1075f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) if (switches::IsTextInputFocusManagerEnabled()) { 1076f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) ui::TextInputFocusManager::GetInstance()->BlurTextInputClient( 1077f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) &text_input_client); 1078f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) } else { 1079f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) input_method->SetFocusedTextInputClient(NULL); 1080f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) } 108146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)} 108246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 10835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace ash 1084