12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file. 42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ash/wm/panels/panel_layout_manager.h" 62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ash/ash_switches.h" 82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ash/root_window_controller.h" 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/screen_util.h" 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/shelf/shelf.h" 11f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "ash/shelf/shelf_button.h" 12c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "ash/shelf/shelf_layout_manager.h" 13f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "ash/shelf/shelf_model.h" 142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ash/shelf/shelf_types.h" 15f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "ash/shelf/shelf_util.h" 168bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ash/shelf/shelf_view.h" 172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ash/shelf/shelf_widget.h" 182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ash/shell.h" 192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ash/shell_window_ids.h" 202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ash/test/ash_test_base.h" 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/test/shelf_test_api.h" 228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ash/test/shelf_view_test_api.h" 232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ash/test/shell_test_api.h" 24a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "ash/test/test_shelf_delegate.h" 25f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "ash/wm/mru_window_tracker.h" 265c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include "ash/wm/window_state.h" 272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ash/wm/window_util.h" 282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/basictypes.h" 292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/command_line.h" 302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/compiler_specific.h" 31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/i18n/rtl.h" 322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/run_loop.h" 332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/aura/client/aura_constants.h" 342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/aura/test/test_windows.h" 352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/aura/window.h" 36a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/aura/window_event_dispatcher.h" 37868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ui/base/l10n/l10n_util.h" 380529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch#include "ui/events/event_utils.h" 395f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "ui/events/test/event_generator.h" 402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/views/widget/widget.h" 412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace ash { 432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)using aura::test::WindowIsAbove; 452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class PanelLayoutManagerTest : public test::AshTestBase { 472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public: 482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelLayoutManagerTest() {} 492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual ~PanelLayoutManagerTest() {} 502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void SetUp() OVERRIDE { 522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) test::AshTestBase::SetUp(); 53a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) ASSERT_TRUE(test::TestShelfDelegate::instance()); 542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 558bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) shelf_view_test_.reset(new test::ShelfViewTestAPI( 565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetShelfView(Shelf::ForPrimaryDisplay()))); 578bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) shelf_view_test_->SetAnimationDuration(1); 582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 607d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) aura::Window* CreateNormalWindow(const gfx::Rect& bounds) { 617d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) return CreateTestWindowInShellWithBounds(bounds); 622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 640529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch aura::Window* CreatePanelWindowWithDelegate(aura::WindowDelegate* delegate, 650529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch const gfx::Rect& bounds) { 662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) aura::Window* window = CreateTestWindowInShellWithDelegateAndType( 670529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch delegate, ui::wm::WINDOW_TYPE_PANEL, 0, bounds); 68a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) test::TestShelfDelegate* shelf_delegate = 69a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) test::TestShelfDelegate::instance(); 705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) shelf_delegate->AddShelfItem(window); 718bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return window; 732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 750529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch aura::Window* CreatePanelWindow(const gfx::Rect& bounds) { 760529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch return CreatePanelWindowWithDelegate(NULL, bounds); 770529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch } 780529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch 79c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) aura::Window* GetPanelContainer(aura::Window* panel) { 80c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return Shell::GetContainer(panel->GetRootWindow(), 81c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch kShellWindowId_PanelContainer); 822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) views::Widget* GetCalloutWidgetForPanel(aura::Window* panel) { 852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelLayoutManager* manager = 86c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) static_cast<PanelLayoutManager*>(GetPanelContainer(panel)-> 87c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) layout_manager()); 882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) DCHECK(manager); 892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelLayoutManager::PanelList::iterator found = std::find( 902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) manager->panel_windows_.begin(), manager->panel_windows_.end(), 912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel); 922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) DCHECK(found != manager->panel_windows_.end()); 932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) DCHECK(found->callout_widget); 942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return reinterpret_cast<views::Widget*>(found->callout_widget); 952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void PanelInScreen(aura::Window* panel) { 982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel_bounds = panel->GetBoundsInRootWindow(); 992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Point root_point = gfx::Point(panel_bounds.x(), panel_bounds.y()); 1005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Display display = ScreenUtil::FindDisplayContainingPoint(root_point); 1012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel_bounds_in_screen = panel->GetBoundsInScreen(); 1032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Point screen_bottom_right = gfx::Point( 1042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_bounds_in_screen.right(), 1052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_bounds_in_screen.bottom()); 1062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect display_bounds = display.bounds(); 1072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(screen_bottom_right.x() < display_bounds.width() && 1082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) screen_bottom_right.y() < display_bounds.height()); 1092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 1102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void PanelsNotOverlapping(aura::Window* panel1, aura::Window* panel2) { 1128bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Waits until all shelf view animations are done. 1138bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 1142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect window1_bounds = panel1->GetBoundsInRootWindow(); 1152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect window2_bounds = panel2->GetBoundsInRootWindow(); 1162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(window1_bounds.Intersects(window2_bounds)); 1182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 1192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 120f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) void IsPanelAboveLauncherIcon(const aura::Window* panel) { 1218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Waits until all shelf view animations are done. 1228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 1232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Shelf* shelf = RootWindowController::ForShelf(panel)->shelf()->shelf(); 1255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(panel); 126c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ASSERT_FALSE(icon_bounds.width() == 0 && icon_bounds.height() == 0); 1272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 128c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) gfx::Rect window_bounds = panel->GetBoundsInScreen(); 1293551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) ASSERT_LT(icon_bounds.width(), window_bounds.width()); 1303551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) ASSERT_LT(icon_bounds.height(), window_bounds.height()); 1315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Rect shelf_bounds = shelf->shelf_widget()->GetWindowBoundsInScreen(); 132c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ShelfAlignment alignment = GetAlignment(panel->GetRootWindow()); 1332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (IsHorizontal(alignment)) { 1352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // The horizontal bounds of the panel window should contain the bounds of 1365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // the shelf icon. 1372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_LE(window_bounds.x(), icon_bounds.x()); 1382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_GE(window_bounds.right(), icon_bounds.right()); 1392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } else { 1402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // The vertical bounds of the panel window should contain the bounds of 1415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // the shelf icon. 1422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_LE(window_bounds.y(), icon_bounds.y()); 1432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_GE(window_bounds.bottom(), icon_bounds.bottom()); 1442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 1452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) switch (alignment) { 1472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case SHELF_ALIGNMENT_BOTTOM: 1485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(shelf_bounds.y(), window_bounds.bottom()); 1492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) break; 1502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case SHELF_ALIGNMENT_LEFT: 1515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(shelf_bounds.right(), window_bounds.x()); 1522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) break; 1532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case SHELF_ALIGNMENT_RIGHT: 1545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(shelf_bounds.x(), window_bounds.right()); 1552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) break; 1562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case SHELF_ALIGNMENT_TOP: 1575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(shelf_bounds.bottom(), window_bounds.y()); 1582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) break; 1592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 1602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 1612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void IsCalloutAboveLauncherIcon(aura::Window* panel) { 1632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Flush the message loop, since callout updates use a delayed task. 1642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::RunLoop().RunUntilIdle(); 1652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) views::Widget* widget = GetCalloutWidgetForPanel(panel); 1662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Shelf* shelf = RootWindowController::ForShelf(panel)->shelf()->shelf(); 1685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(panel); 169c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ASSERT_FALSE(icon_bounds.IsEmpty()); 170c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 171c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) gfx::Rect panel_bounds = panel->GetBoundsInScreen(); 1722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect callout_bounds = widget->GetWindowBoundsInScreen(); 1732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_FALSE(icon_bounds.IsEmpty()); 1742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(widget->IsVisible()); 1762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 177c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ShelfAlignment alignment = GetAlignment(panel->GetRootWindow()); 1782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) switch (alignment) { 1792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case SHELF_ALIGNMENT_BOTTOM: 1802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel_bounds.bottom(), callout_bounds.y()); 1812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) break; 1822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case SHELF_ALIGNMENT_LEFT: 1832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel_bounds.x(), callout_bounds.right()); 1842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) break; 1852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case SHELF_ALIGNMENT_RIGHT: 1862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel_bounds.right(), callout_bounds.x()); 1872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) break; 1882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case SHELF_ALIGNMENT_TOP: 1892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel_bounds.y(), callout_bounds.bottom()); 1902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) break; 1912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 1922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (IsHorizontal(alignment)) { 1942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NEAR(icon_bounds.CenterPoint().x(), 1952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) widget->GetWindowBoundsInScreen().CenterPoint().x(), 1962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1); 1972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } else { 1982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NEAR(icon_bounds.CenterPoint().y(), 1992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) widget->GetWindowBoundsInScreen().CenterPoint().y(), 2002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1); 2012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 2022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 2032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool IsPanelCalloutVisible(aura::Window* panel) { 2052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) views::Widget* widget = GetCalloutWidgetForPanel(panel); 2062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return widget->IsVisible(); 2072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 2082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2098bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) test::ShelfViewTestAPI* shelf_view_test() { 2108bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return shelf_view_test_.get(); 2112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 2122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Clicks the shelf items on |shelf_view| that is associated with given 2145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // |window|. 2155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void ClickShelfItemForWindow(ShelfView* shelf_view, aura::Window* window) { 2168bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) test::ShelfViewTestAPI test_api(shelf_view); 2172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) test_api.SetAnimationDuration(1); 2182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) test_api.RunMessageLoopUntilAnimationsDone(); 219f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) ShelfModel* model = test::ShellTestApi(Shell::GetInstance()).shelf_model(); 2205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int index = model->ItemIndexByID(GetShelfIDForWindow(window)); 2212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds = test_api.GetButton(index)->GetBoundsInScreen(); 2222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2235f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) ui::test::EventGenerator& event_generator = GetEventGenerator(); 2242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) event_generator.MoveMouseTo(bounds.CenterPoint()); 2252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) event_generator.ClickLeftButton(); 2262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) test_api.RunMessageLoopUntilAnimationsDone(); 2282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 2292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void SetAlignment(aura::Window* root_window, ShelfAlignment alignment) { 2312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ash::Shell* shell = ash::Shell::GetInstance(); 232c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) shell->SetShelfAlignment(alignment, root_window); 2332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 2342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 235f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) ShelfAlignment GetAlignment(const aura::Window* root_window) { 2362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ash::Shell* shell = ash::Shell::GetInstance(); 237c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return shell->GetShelfAlignment(root_window); 238c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) } 239c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 240c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) void SetShelfAutoHideBehavior(aura::Window* window, 241c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ShelfAutoHideBehavior behavior) { 242c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ShelfLayoutManager* shelf = RootWindowController::ForWindow(window) 243c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ->shelf() 244c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ->shelf_layout_manager(); 245c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) shelf->SetAutoHideBehavior(behavior); 2465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ShelfView* shelf_view = GetShelfView(Shelf::ForWindow(window)); 2478bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) test::ShelfViewTestAPI test_api(shelf_view); 2487d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) test_api.RunMessageLoopUntilAnimationsDone(); 249c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) } 250c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 251c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) void SetShelfVisibilityState(aura::Window* window, 252c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ShelfVisibilityState visibility_state) { 253c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ShelfLayoutManager* shelf = RootWindowController::ForWindow(window) 254c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ->shelf() 255c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ->shelf_layout_manager(); 256c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) shelf->SetState(visibility_state); 2572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 2582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 259c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ShelfView* GetShelfView(Shelf* shelf) { 2605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return test::ShelfTestAPI(shelf).shelf_view(); 261d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) } 262d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 2632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private: 2648bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_; 2652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool IsHorizontal(ShelfAlignment alignment) { 2672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return alignment == SHELF_ALIGNMENT_BOTTOM || 2682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) alignment == SHELF_ALIGNMENT_TOP; 2692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 2702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(PanelLayoutManagerTest); 2722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}; 2732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 274868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class PanelLayoutManagerTextDirectionTest 275868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) : public PanelLayoutManagerTest, 276868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) public testing::WithParamInterface<bool> { 277868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) public: 278868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) PanelLayoutManagerTextDirectionTest() : is_rtl_(GetParam()) {} 279868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual ~PanelLayoutManagerTextDirectionTest() {} 280868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 281868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual void SetUp() OVERRIDE { 282868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) original_locale = l10n_util::GetApplicationLocale(std::string()); 283868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) if (is_rtl_) 284868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) base::i18n::SetICUDefaultLocale("he"); 285868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) PanelLayoutManagerTest::SetUp(); 286868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ASSERT_EQ(is_rtl_, base::i18n::IsRTL()); 287868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) } 288868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 289868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual void TearDown() OVERRIDE { 290868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) if (is_rtl_) 291868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) base::i18n::SetICUDefaultLocale(original_locale); 292868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) PanelLayoutManagerTest::TearDown(); 293868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) } 294868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 295868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) private: 296868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool is_rtl_; 297868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) std::string original_locale; 298868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 299868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(PanelLayoutManagerTextDirectionTest); 300868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}; 301868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 3025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Tests that a created panel window is above the shelf icon in LTR and RTL. 303868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)TEST_P(PanelLayoutManagerTextDirectionTest, AddOnePanel) { 3042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds(0, 0, 201, 201); 3052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> window(CreatePanelWindow(bounds)); 306c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); 307c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); 308868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(window.get())); 309c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 310c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 311c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Tests that a created panel window is successfully aligned over a hidden 3125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// shelf icon. 313c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)TEST_F(PanelLayoutManagerTest, PanelAlignsToHiddenLauncherIcon) { 314c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) gfx::Rect bounds(0, 0, 201, 201); 315c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SetShelfAutoHideBehavior(Shell::GetPrimaryRootWindow(), 316c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 3177d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) scoped_ptr<aura::Window> normal_window(CreateNormalWindow(bounds)); 318c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) scoped_ptr<aura::Window> window(CreatePanelWindow(bounds)); 319c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); 3202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); 3212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 3222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3237d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)TEST_F(PanelLayoutManagerTest, PanelAlignsToHiddenLauncherIconSecondDisplay) { 3247d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) if (!SupportsMultipleDisplays()) 3257d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) return; 3267d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 3275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Keep the displays wide so that shelves have enough space for shelves 3285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // buttons. 3297d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) UpdateDisplay("400x400,600x400"); 330f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 3317d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 3327d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) scoped_ptr<aura::Window> normal_window( 3337d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) CreateNormalWindow(gfx::Rect(450, 0, 100, 100))); 3347d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) scoped_ptr<aura::Window> panel(CreatePanelWindow(gfx::Rect(400, 0, 50, 50))); 3357d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) EXPECT_EQ(root_windows[1], panel->GetRootWindow()); 3367d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(panel.get())); 3377d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) gfx::Rect shelf_visible_position = panel->GetBoundsInScreen(); 3387d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 3397d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) SetShelfAutoHideBehavior(root_windows[1], 3407d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 3417d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // Expect the panel X position to remain the same after the shelf is hidden 3427d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // but the Y to move down. 3437d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(panel.get())); 3447d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) EXPECT_EQ(shelf_visible_position.x(), panel->GetBoundsInScreen().x()); 3457d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) EXPECT_GT(panel->GetBoundsInScreen().y(), shelf_visible_position.y()); 3467d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)} 3477d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 3482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Tests interactions between multiple panels 3492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(PanelLayoutManagerTest, MultiplePanelsAreAboveIcons) { 3502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect odd_bounds(0, 0, 201, 201); 3512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect even_bounds(0, 0, 200, 200); 3522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w1(CreatePanelWindow(odd_bounds)); 3542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get())); 3552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w2(CreatePanelWindow(even_bounds)); 3572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get())); 3582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); 3592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w3(CreatePanelWindow(odd_bounds)); 3612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get())); 3622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); 3632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w3.get())); 3642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 3652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(PanelLayoutManagerTest, MultiplePanelStacking) { 3672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds(0, 0, 201, 201); 3682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); 3692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); 3702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w3(CreatePanelWindow(bounds)); 3712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Default stacking order. 3732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(WindowIsAbove(w3.get(), w2.get())); 374a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); 375a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch 376a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch // Changing the active window should update the stacking order. 377a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch wm::ActivateWindow(w1.get()); 3788bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 379a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch EXPECT_TRUE(WindowIsAbove(w1.get(), w2.get())); 380a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); 381a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch 382a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch wm::ActivateWindow(w2.get()); 3838bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 384a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch EXPECT_TRUE(WindowIsAbove(w1.get(), w3.get())); 385a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); 386a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); 387a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch 388a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch wm::ActivateWindow(w3.get()); 389a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch EXPECT_TRUE(WindowIsAbove(w3.get(), w2.get())); 390a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); 391a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch} 392a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch 393a3f7b4e666c476898878fa745f637129375cd889Ben MurdochTEST_F(PanelLayoutManagerTest, MultiplePanelStackingVertical) { 3945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Set shelf to be aligned on the right. 395a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_RIGHT); 396a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch 397a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch // Size panels in such a way that ordering them by X coordinate would cause 398a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch // stacking order to be incorrect. Test that stacking order is based on Y. 399a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch scoped_ptr<aura::Window> w1(CreatePanelWindow(gfx::Rect(0, 0, 210, 201))); 400a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch scoped_ptr<aura::Window> w2(CreatePanelWindow(gfx::Rect(0, 0, 220, 201))); 401a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch scoped_ptr<aura::Window> w3(CreatePanelWindow(gfx::Rect(0, 0, 200, 201))); 402a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch 403a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch // Default stacking order. 404a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch EXPECT_TRUE(WindowIsAbove(w3.get(), w2.get())); 4052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); 4062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Changing the active window should update the stacking order. 4082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) wm::ActivateWindow(w1.get()); 4098bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 4102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(WindowIsAbove(w1.get(), w2.get())); 4112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); 4122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) wm::ActivateWindow(w2.get()); 4148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 4152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(WindowIsAbove(w1.get(), w3.get())); 4162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); 4172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); 4182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) wm::ActivateWindow(w3.get()); 4202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(WindowIsAbove(w3.get(), w2.get())); 4212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); 4222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 4232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(PanelLayoutManagerTest, MultiplePanelCallout) { 4252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds(0, 0, 200, 200); 4262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); 4272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); 4282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w3(CreatePanelWindow(bounds)); 4297d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) scoped_ptr<aura::Window> w4(CreateNormalWindow(gfx::Rect())); 4308bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 4312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(IsPanelCalloutVisible(w1.get())); 4322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(IsPanelCalloutVisible(w2.get())); 4332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(IsPanelCalloutVisible(w3.get())); 4342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) wm::ActivateWindow(w1.get()); 4352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(w1.get())); 4362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) wm::ActivateWindow(w2.get()); 4372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(w2.get())); 4382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) wm::ActivateWindow(w3.get()); 4392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(w3.get())); 4402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) wm::ActivateWindow(w4.get()); 4412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) wm::ActivateWindow(w3.get()); 4422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(w3.get())); 4432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) w3.reset(); 44458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(w2.get())); 4452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 4462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Tests removing panels. 4482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(PanelLayoutManagerTest, RemoveLeftPanel) { 4492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds(0, 0, 201, 201); 4502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); 4512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); 4522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w3(CreatePanelWindow(bounds)); 4532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // At this point, windows should be stacked with 1 < 2 < 3 4552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) wm::ActivateWindow(w1.get()); 4568bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 4572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Now, windows should be stacked 1 > 2 > 3 4582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) w1.reset(); 4592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); 4602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w3.get())); 4612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); 4622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 4632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(PanelLayoutManagerTest, RemoveMiddlePanel) { 4652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds(0, 0, 201, 201); 4662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); 4672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); 4682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w3(CreatePanelWindow(bounds)); 4692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // At this point, windows should be stacked with 1 < 2 < 3 4712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) wm::ActivateWindow(w2.get()); 4722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Windows should be stacked 1 < 2 > 3 4732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) w2.reset(); 4742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get())); 4752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w3.get())); 4762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(WindowIsAbove(w3.get(), w1.get())); 4772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 4782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(PanelLayoutManagerTest, RemoveRightPanel) { 4802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds(0, 0, 201, 201); 4812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); 4822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); 4832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w3(CreatePanelWindow(bounds)); 4842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // At this point, windows should be stacked with 1 < 2 < 3 4862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) wm::ActivateWindow(w3.get()); 4872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Order shouldn't change. 4882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) w3.reset(); 4892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get())); 4902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); 4912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); 4922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 4932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(PanelLayoutManagerTest, RemoveNonActivePanel) { 4952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds(0, 0, 201, 201); 4962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); 4972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); 4982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w3(CreatePanelWindow(bounds)); 4992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // At this point, windows should be stacked with 1 < 2 < 3 5012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) wm::ActivateWindow(w2.get()); 5022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Windows should be stacked 1 < 2 > 3 5032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) w1.reset(); 5042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); 5052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w3.get())); 5062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); 5072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 5082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(PanelLayoutManagerTest, SplitView) { 5102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds(0, 0, 90, 201); 5112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); 5122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); 5132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(PanelsNotOverlapping(w1.get(), w2.get())); 5152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 5162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(OS_WIN) 5182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 5192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define MAYBE_SplitViewOverlapWhenLarge DISABLED_SplitViewOverlapWhenLarge 5202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#else 5212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define MAYBE_SplitViewOverlapWhenLarge SplitViewOverlapWhenLarge 5222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif 5232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(PanelLayoutManagerTest, MAYBE_SplitViewOverlapWhenLarge) { 5252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds(0, 0, 600, 201); 5262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); 5272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); 5282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(PanelInScreen(w1.get())); 5302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_NO_FATAL_FAILURE(PanelInScreen(w2.get())); 5312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 5322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(PanelLayoutManagerTest, FanWindows) { 5342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds(0, 0, 201, 201); 5352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); 5362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); 5372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w3(CreatePanelWindow(bounds)); 5382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5398bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 5402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int window_x1 = w1->GetBoundsInRootWindow().CenterPoint().x(); 5412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int window_x2 = w2->GetBoundsInRootWindow().CenterPoint().x(); 5422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int window_x3 = w3->GetBoundsInRootWindow().CenterPoint().x(); 5435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Shelf* shelf = Shelf::ForPrimaryDisplay(); 5445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int icon_x1 = shelf->GetScreenBoundsOfItemIconForWindow(w1.get()).x(); 5455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int icon_x2 = shelf->GetScreenBoundsOfItemIconForWindow(w2.get()).x(); 5462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(window_x2 - window_x1, window_x3 - window_x2); 5472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int spacing = window_x2 - window_x1; 5482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_GT(spacing, icon_x2 - icon_x1); 5492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 5502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(PanelLayoutManagerTest, FanLargeWindow) { 5522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect small_bounds(0, 0, 201, 201); 5532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect large_bounds(0, 0, 501, 201); 5542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w1(CreatePanelWindow(small_bounds)); 5552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w2(CreatePanelWindow(large_bounds)); 5562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w3(CreatePanelWindow(small_bounds)); 5572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5588bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 5592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int window_x1 = w1->GetBoundsInRootWindow().CenterPoint().x(); 5602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int window_x2 = w2->GetBoundsInRootWindow().CenterPoint().x(); 5612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int window_x3 = w3->GetBoundsInRootWindow().CenterPoint().x(); 5622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // The distances may not be equidistant with a large panel but the panels 5632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // should be in the correct order with respect to their midpoints. 5642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_GT(window_x2, window_x1); 5652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_GT(window_x3, window_x2); 5662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 5672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(PanelLayoutManagerTest, MinimizeRestorePanel) { 5692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds(0, 0, 201, 201); 5702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> window(CreatePanelWindow(bounds)); 5712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Activate the window, ensure callout is visible. 5722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) wm::ActivateWindow(window.get()); 5732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) RunAllPendingInMessageLoop(); 5742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(IsPanelCalloutVisible(window.get())); 5752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Minimize the panel, callout should be hidden. 5765c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu wm::GetWindowState(window.get())->Minimize(); 5772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) RunAllPendingInMessageLoop(); 5782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(IsPanelCalloutVisible(window.get())); 5795c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu // Restore the panel; panel should not be activated by default but callout 5802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // should be visible. 5815c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu wm::GetWindowState(window.get())->Unminimize(); 5822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) RunAllPendingInMessageLoop(); 5832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(IsPanelCalloutVisible(window.get())); 5842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Activate the window, ensure callout is visible. 5852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) wm::ActivateWindow(window.get()); 5862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) RunAllPendingInMessageLoop(); 5872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(IsPanelCalloutVisible(window.get())); 5882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 5892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5907d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)TEST_F(PanelLayoutManagerTest, PanelMoveBetweenMultipleDisplays) { 5917d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) if (!SupportsMultipleDisplays()) 5927d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) return; 5932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Keep the displays wide so that shelves have enough space for launcher 5955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // buttons. 5962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) UpdateDisplay("600x400,600x400"); 597f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 5982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> p1_d1(CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); 6002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> p2_d1(CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); 6012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> p1_d2(CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); 6022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> p2_d2(CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); 6032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ShelfView* shelf_view_1st = GetShelfView(Shelf::ForPrimaryDisplay()); 6058bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) ShelfView* shelf_view_2nd = 6065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetShelfView(Shelf::ForWindow(root_windows[1])); 6072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); 6092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); 6102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); 6112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(root_windows[1], p2_d2->GetRootWindow()); 6122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 613c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch EXPECT_EQ(kShellWindowId_PanelContainer, p1_d1->parent()->id()); 614c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch EXPECT_EQ(kShellWindowId_PanelContainer, p2_d1->parent()->id()); 615c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch EXPECT_EQ(kShellWindowId_PanelContainer, p1_d2->parent()->id()); 616c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch EXPECT_EQ(kShellWindowId_PanelContainer, p2_d2->parent()->id()); 6172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Test a panel on 1st display. 6192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Clicking on the same display has no effect. 6205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ClickShelfItemForWindow(shelf_view_1st, p1_d1.get()); 6212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); 6222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); 6232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); 6242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); 6252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(root_windows[1]->GetBoundsInScreen().Contains( 6262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) p1_d1->GetBoundsInScreen())); 6272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Test if clicking on another display moves the panel to 6292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // that display. 6305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ClickShelfItemForWindow(shelf_view_2nd, p1_d1.get()); 6312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(root_windows[1], p1_d1->GetRootWindow()); 6322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); 6332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); 6342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(root_windows[1], p2_d2->GetRootWindow()); 6352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains( 6362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) p1_d1->GetBoundsInScreen())); 6372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Test a panel on 2nd display. 6392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Clicking on the same display has no effect. 6405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ClickShelfItemForWindow(shelf_view_2nd, p1_d2.get()); 6412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(root_windows[1], p1_d1->GetRootWindow()); 6422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); 6432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); 6442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(root_windows[1], p2_d2->GetRootWindow()); 6452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains( 6462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) p1_d2->GetBoundsInScreen())); 6472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Test if clicking on another display moves the panel to 6492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // that display. 6505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ClickShelfItemForWindow(shelf_view_1st, p1_d2.get()); 6512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(root_windows[1], p1_d1->GetRootWindow()); 6522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); 6532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(root_windows[0], p1_d2->GetRootWindow()); 6542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(root_windows[1], p2_d2->GetRootWindow()); 6552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(root_windows[0]->GetBoundsInScreen().Contains( 6562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) p1_d2->GetBoundsInScreen())); 6577dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch 6587dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch // Test if clicking on a previously moved window moves the 6597dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch // panel back to the original display. 6605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ClickShelfItemForWindow(shelf_view_1st, p1_d1.get()); 6617dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); 6627dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); 6637dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_EQ(root_windows[0], p1_d2->GetRootWindow()); 6647dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_EQ(root_windows[1], p2_d2->GetRootWindow()); 6657dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_TRUE(root_windows[0]->GetBoundsInScreen().Contains( 6667dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch p1_d1->GetBoundsInScreen())); 6672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 6682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6697d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)TEST_F(PanelLayoutManagerTest, PanelAttachPositionMultipleDisplays) { 6707d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) if (!SupportsMultipleDisplays()) 6717d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) return; 6727d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 6735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Keep the displays wide so that shelves have enough space for shelf buttons. 6745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Use differently sized displays so the shelf is in a different 675c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // position on second display. 676c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) UpdateDisplay("600x400,600x600"); 677f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 678c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 679c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) scoped_ptr<aura::Window> p1_d1(CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); 680c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) scoped_ptr<aura::Window> p1_d2(CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); 681c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 682c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); 683c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); 684c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 685c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) IsPanelAboveLauncherIcon(p1_d1.get()); 686c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) IsCalloutAboveLauncherIcon(p1_d1.get()); 687c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) IsPanelAboveLauncherIcon(p1_d2.get()); 688c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) IsCalloutAboveLauncherIcon(p1_d2.get()); 689c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 690c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 6917d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)TEST_F(PanelLayoutManagerTest, PanelAlignmentSecondDisplay) { 6927d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) if (!SupportsMultipleDisplays()) 6937d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) return; 6947d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 695c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) UpdateDisplay("600x400,600x400"); 696f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 697c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 698c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) scoped_ptr<aura::Window> p1_d2(CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); 699c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); 700c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 701c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) IsPanelAboveLauncherIcon(p1_d2.get()); 702c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) IsCalloutAboveLauncherIcon(p1_d2.get()); 703c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 704c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SetAlignment(root_windows[1], SHELF_ALIGNMENT_RIGHT); 705c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) IsPanelAboveLauncherIcon(p1_d2.get()); 706c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) IsCalloutAboveLauncherIcon(p1_d2.get()); 707c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SetAlignment(root_windows[1], SHELF_ALIGNMENT_LEFT); 708c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) IsPanelAboveLauncherIcon(p1_d2.get()); 709c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) IsCalloutAboveLauncherIcon(p1_d2.get()); 710c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SetAlignment(root_windows[1], SHELF_ALIGNMENT_TOP); 711c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) IsPanelAboveLauncherIcon(p1_d2.get()); 712c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) IsCalloutAboveLauncherIcon(p1_d2.get()); 713c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 714c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 7152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(PanelLayoutManagerTest, AlignmentLeft) { 7162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds(0, 0, 201, 201); 7172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w(CreatePanelWindow(bounds)); 718c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_LEFT); 7192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) IsPanelAboveLauncherIcon(w.get()); 7202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) IsCalloutAboveLauncherIcon(w.get()); 7212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 7222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(PanelLayoutManagerTest, AlignmentRight) { 7242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds(0, 0, 201, 201); 7252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w(CreatePanelWindow(bounds)); 726c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_RIGHT); 7272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) IsPanelAboveLauncherIcon(w.get()); 7282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) IsCalloutAboveLauncherIcon(w.get()); 7292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 7302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(PanelLayoutManagerTest, AlignmentTop) { 7322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds(0, 0, 201, 201); 7332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<aura::Window> w(CreatePanelWindow(bounds)); 734c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_TOP); 7352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) IsPanelAboveLauncherIcon(w.get()); 7362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) IsCalloutAboveLauncherIcon(w.get()); 7372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 7382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 739c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Tests that panels will hide and restore their state with the shelf visibility 740c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// state. This ensures that entering full-screen mode will hide your panels 741c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// until you leave it. 742c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)TEST_F(PanelLayoutManagerTest, PanelsHideAndRestoreWithShelf) { 743c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) gfx::Rect bounds(0, 0, 201, 201); 744c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 745c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); 746c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); 747c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) scoped_ptr<aura::Window> w3; 748c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Minimize w2. 7495c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu wm::GetWindowState(w2.get())->Minimize(); 750c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) RunAllPendingInMessageLoop(); 751c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_TRUE(w1->IsVisible()); 752c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_FALSE(w2->IsVisible()); 753c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 754c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SetShelfVisibilityState(Shell::GetPrimaryRootWindow(), SHELF_HIDDEN); 755c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) RunAllPendingInMessageLoop(); 756c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 757c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // w3 is created while in full-screen mode, should only become visible when 758c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // we exit fullscreen mode. 759c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) w3.reset(CreatePanelWindow(bounds)); 760c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 761c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_FALSE(w1->IsVisible()); 762c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_FALSE(w2->IsVisible()); 763c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_FALSE(w3->IsVisible()); 764c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 765f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // While in full-screen mode, the panel windows should still be in the 766f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // switchable window list - http://crbug.com/313919. 767f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) MruWindowTracker::WindowList switchable_window_list = 768f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList(); 769f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) EXPECT_EQ(3u, switchable_window_list.size()); 770f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) EXPECT_NE(switchable_window_list.end(), 771f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) std::find(switchable_window_list.begin(), switchable_window_list.end(), 772f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) w1.get())); 773f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) EXPECT_NE(switchable_window_list.end(), 774f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) std::find(switchable_window_list.begin(), switchable_window_list.end(), 775f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) w2.get())); 776f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) EXPECT_NE(switchable_window_list.end(), 777f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) std::find(switchable_window_list.begin(), switchable_window_list.end(), 778f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) w3.get())); 779f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 780c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SetShelfVisibilityState(Shell::GetPrimaryRootWindow(), SHELF_VISIBLE); 781c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) RunAllPendingInMessageLoop(); 782c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 783c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Windows should be restored to their prior state. 784c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_TRUE(w1->IsVisible()); 785c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_FALSE(w2->IsVisible()); 786c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_TRUE(w3->IsVisible()); 787c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 788c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 7890529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch// Verifies that touches along the attached edge of a panel do not 7900529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch// target the panel itself. 7910529e5d033099cbfc42635f6f6183833b09dff6eBen MurdochTEST_F(PanelLayoutManagerTest, TouchHitTestPanel) { 7920529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch aura::test::TestWindowDelegate delegate; 7930529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch scoped_ptr<aura::Window> w( 7940529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch CreatePanelWindowWithDelegate(&delegate, gfx::Rect(0, 0, 200, 200))); 7950529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch ui::EventTarget* root = w->GetRootWindow(); 7960529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch ui::EventTargeter* targeter = root->GetEventTargeter(); 7970529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch 7980529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch // Note that the constants used in the touch locations below are 7990529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch // arbitrarily-selected small numbers which will ensure the point is 8000529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch // within the default extended region surrounding the panel. This value 8010529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch // is calculated as 8020529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch // kResizeOutsideBoundsSize * kResizeOutsideBoundsScaleForTouch 8030529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch // in src/ash/root_window_controller.cc. 8040529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch 8050529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch // Hit test outside the right edge with a bottom-aligned shelf. 8060529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_BOTTOM); 8070529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch gfx::Rect bounds(w->bounds()); 8080529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch ui::TouchEvent touch(ui::ET_TOUCH_PRESSED, 8090529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch gfx::Point(bounds.right() + 3, bounds.y() + 2), 8100529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch 0, ui::EventTimeForNow()); 8110529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch ui::EventTarget* target = targeter->FindTargetForEvent(root, &touch); 8120529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch EXPECT_EQ(w.get(), target); 8130529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch 8140529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch // Hit test outside the bottom edge with a bottom-aligned shelf. 8150529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch touch.set_location(gfx::Point(bounds.x() + 6, bounds.bottom() + 5)); 8160529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch target = targeter->FindTargetForEvent(root, &touch); 8170529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch EXPECT_NE(w.get(), target); 8180529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch 8190529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch // Hit test outside the bottom edge with a right-aligned shelf. 8200529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_RIGHT); 8210529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch bounds = w->bounds(); 8220529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch touch.set_location(gfx::Point(bounds.x() + 6, bounds.bottom() + 5)); 8230529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch target = targeter->FindTargetForEvent(root, &touch); 8240529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch EXPECT_EQ(w.get(), target); 8250529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch 8260529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch // Hit test outside the right edge with a right-aligned shelf. 8270529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch touch.set_location(gfx::Point(bounds.right() + 3, bounds.y() + 2)); 8280529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch target = targeter->FindTargetForEvent(root, &touch); 8290529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch EXPECT_NE(w.get(), target); 8300529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch 8310529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch // Hit test outside the top edge with a left-aligned shelf. 8320529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_LEFT); 8330529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch bounds = w->bounds(); 8340529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch touch.set_location(gfx::Point(bounds.x() + 4, bounds.y() - 6)); 8350529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch target = targeter->FindTargetForEvent(root, &touch); 8360529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch EXPECT_EQ(w.get(), target); 8370529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch 8380529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch // Hit test outside the left edge with a left-aligned shelf. 8390529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); 8400529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch target = targeter->FindTargetForEvent(root, &touch); 8410529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch EXPECT_NE(w.get(), target); 8420529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch 8430529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch // Hit test outside the left edge with a top-aligned shelf. 8440529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_TOP); 8450529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch bounds = w->bounds(); 8460529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); 8470529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch target = targeter->FindTargetForEvent(root, &touch); 8480529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch EXPECT_EQ(w.get(), target); 8490529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch 8500529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch // Hit test outside the top edge with a top-aligned shelf. 8510529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch touch.set_location(gfx::Point(bounds.x() + 4, bounds.y() - 6)); 8520529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch target = targeter->FindTargetForEvent(root, &touch); 8530529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch EXPECT_NE(w.get(), target); 8540529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch} 8550529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch 856868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)INSTANTIATE_TEST_CASE_P(LtrRtl, PanelLayoutManagerTextDirectionTest, 857868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) testing::Bool()); 858868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 8592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} // namespace ash 860