12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2013 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 "chrome/browser/ui/browser.h" 62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/panels/base_panel_browser_test.h" 72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/panels/detached_panel_collection.h" 82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/panels/docked_panel_collection.h" 92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/panels/native_panel.h" 102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/panels/panel.h" 112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/panels/panel_manager.h" 122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/panels/stacked_panel_collection.h" 132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/web_applications/web_app.h" 142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/test/base/testing_profile.h" 152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/public/test/test_utils.h" 162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class StackedPanelBrowserTest : public BasePanelBrowserTest { 182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}; 192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, CheckStackedPanelProperties) { 212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 2 stacked panels. 242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack = panel_manager->CreateStack(); 252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel1_initial_bounds = gfx::Rect(100, 50, 200, 150); 262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel1 = CreateStackedPanel("1", panel1_initial_bounds, stack); 272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel2_initial_bounds = gfx::Rect(0, 0, 150, 100); 282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel2 = CreateStackedPanel("2", panel2_initial_bounds, stack); 292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel3_initial_bounds = gfx::Rect(0, 0, 120, 110); 302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel3 = CreateStackedPanel("3", panel3_initial_bounds, stack); 312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<NativePanelTesting> panel1_testing( 332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateNativePanelTesting(panel1)); 342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<NativePanelTesting> panel2_testing( 352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateNativePanelTesting(panel2)); 362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<NativePanelTesting> panel3_testing( 372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateNativePanelTesting(panel3)); 382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Check that all 3 panels are in a stack. 402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(0, panel_manager->docked_collection()->num_panels()); 412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(0, panel_manager->detached_collection()->num_panels()); 422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(3, stack->num_panels()); 442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(stack, panel1->stack()); 452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(stack, panel2->stack()); 462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(stack, panel3->stack()); 472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Check buttons. 492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel1_testing->IsButtonVisible(panel::CLOSE_BUTTON)); 502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel2_testing->IsButtonVisible(panel::CLOSE_BUTTON)); 512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel3_testing->IsButtonVisible(panel::CLOSE_BUTTON)); 522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 53a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (PanelManager::CanUseSystemMinimize()) 54a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_TRUE(panel1_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); 55a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) else 56a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_FALSE(panel1_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); 572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); 582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel3_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); 592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel1_testing->IsButtonVisible(panel::RESTORE_BUTTON)); 612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2_testing->IsButtonVisible(panel::RESTORE_BUTTON)); 622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel3_testing->IsButtonVisible(panel::RESTORE_BUTTON)); 632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Check bounds. 652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel1_expected_bounds(panel1_initial_bounds); 662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds()); 672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel2_expected_bounds(panel1_expected_bounds.x(), 682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_expected_bounds.bottom(), 692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_expected_bounds.width(), 702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_initial_bounds.height()); 712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds()); 722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel3_expected_bounds(panel2_expected_bounds.x(), 732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_expected_bounds.bottom(), 742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_expected_bounds.width(), 752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel3_initial_bounds.height()); 762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds()); 772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Check other properties. 792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel1->IsAlwaysOnTop()); 802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2->IsAlwaysOnTop()); 812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel3->IsAlwaysOnTop()); 822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel1->IsMinimized()); 842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2->IsMinimized()); 852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel3->IsMinimized()); 862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel::RESIZABLE_LEFT | panel::RESIZABLE_RIGHT | 882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel::RESIZABLE_TOP | panel::RESIZABLE_TOP_LEFT | 892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel::RESIZABLE_TOP_RIGHT | panel::RESIZABLE_BOTTOM, 902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1->CanResizeByMouse()); 912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel::RESIZABLE_LEFT | panel::RESIZABLE_RIGHT | 922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel::RESIZABLE_BOTTOM, 932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2->CanResizeByMouse()); 942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel::RESIZABLE_LEFT | panel::RESIZABLE_RIGHT | 952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel::RESIZABLE_BOTTOM | panel::RESIZABLE_BOTTOM_LEFT | 962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel::RESIZABLE_BOTTOM_RIGHT, 972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel3->CanResizeByMouse()); 982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel::TOP_ROUNDED, panel1_testing->GetWindowCornerStyle()); 1002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel::NOT_ROUNDED, panel2_testing->GetWindowCornerStyle()); 1012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel::BOTTOM_ROUNDED, panel3_testing->GetWindowCornerStyle()); 1022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel::AttentionMode expected_attention_mode = 1042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) static_cast<Panel::AttentionMode>(Panel::USE_PANEL_ATTENTION | 1052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel::USE_SYSTEM_ATTENTION); 1062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(expected_attention_mode, panel1->attention_mode()); 1072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(expected_attention_mode, panel2->attention_mode()); 1082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(expected_attention_mode, panel3->attention_mode()); 1092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, 1142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CheckMinimizedStackedPanelProperties) { 1152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 1162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 2 stacked panels. 1182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack = panel_manager->CreateStack(); 1192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel1_initial_bounds = gfx::Rect(100, 50, 200, 150); 1202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel1 = CreateStackedPanel("1", panel1_initial_bounds, stack); 1212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel2_initial_bounds = gfx::Rect(0, 0, 150, 100); 1222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel2 = CreateStackedPanel("2", panel2_initial_bounds, stack); 1232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel3_initial_bounds = gfx::Rect(0, 0, 120, 110); 1242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel3 = CreateStackedPanel("3", panel3_initial_bounds, stack); 1252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<NativePanelTesting> panel1_testing( 1272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateNativePanelTesting(panel1)); 1282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<NativePanelTesting> panel2_testing( 1292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateNativePanelTesting(panel2)); 1302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<NativePanelTesting> panel3_testing( 1312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateNativePanelTesting(panel3)); 1322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Minimize these 2 panels. 1342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1->Minimize(); 1352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel1); 1362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2->Minimize(); 1372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel2); 1382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel3->Minimize(); 1392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel3); 1402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Check that all 2 panels are in a stack. 1422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(0, panel_manager->docked_collection()->num_panels()); 1432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(0, panel_manager->detached_collection()->num_panels()); 1442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 1452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(3, stack->num_panels()); 1462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(stack, panel1->stack()); 1472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(stack, panel2->stack()); 1482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(stack, panel3->stack()); 1492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Check buttons. 1512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel1_testing->IsButtonVisible(panel::CLOSE_BUTTON)); 1522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel2_testing->IsButtonVisible(panel::CLOSE_BUTTON)); 1532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel3_testing->IsButtonVisible(panel::CLOSE_BUTTON)); 1542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 155a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (PanelManager::CanUseSystemMinimize()) 156a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_TRUE(panel1_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); 157a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) else 158a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_FALSE(panel1_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); 1592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); 1602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel3_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); 1612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel1_testing->IsButtonVisible(panel::RESTORE_BUTTON)); 1632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2_testing->IsButtonVisible(panel::RESTORE_BUTTON)); 1642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel3_testing->IsButtonVisible(panel::RESTORE_BUTTON)); 1652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Check bounds. 1672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel1_expected_bounds(panel1_initial_bounds); 1682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_expected_bounds.set_height(panel1->TitleOnlyHeight()); 1692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds()); 1702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel2_expected_bounds(panel1_expected_bounds.x(), 1712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_expected_bounds.bottom(), 1722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_expected_bounds.width(), 1732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2->TitleOnlyHeight()); 1742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds()); 1752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel3_expected_bounds(panel2_expected_bounds.x(), 1762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_expected_bounds.bottom(), 1772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_expected_bounds.width(), 1782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel3->TitleOnlyHeight()); 1792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds()); 1802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Check other properties. 1822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel1->IsAlwaysOnTop()); 1832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2->IsAlwaysOnTop()); 1842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel3->IsAlwaysOnTop()); 1852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel1->IsMinimized()); 1872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel2->IsMinimized()); 1882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel3->IsMinimized()); 1892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel::RESIZABLE_LEFT | panel::RESIZABLE_RIGHT, 1912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1->CanResizeByMouse()); 1922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel::RESIZABLE_LEFT | panel::RESIZABLE_RIGHT, 1932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2->CanResizeByMouse()); 1942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel::RESIZABLE_LEFT | panel::RESIZABLE_RIGHT, 1952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel3->CanResizeByMouse()); 1962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel::TOP_ROUNDED, panel1_testing->GetWindowCornerStyle()); 1982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel::NOT_ROUNDED, panel2_testing->GetWindowCornerStyle()); 1992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel::BOTTOM_ROUNDED, panel3_testing->GetWindowCornerStyle()); 2002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel::AttentionMode expected_attention_mode = 2022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) static_cast<Panel::AttentionMode>(Panel::USE_PANEL_ATTENTION | 2032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel::USE_SYSTEM_ATTENTION); 2042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(expected_attention_mode, panel1->attention_mode()); 2052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(expected_attention_mode, panel2->attention_mode()); 2062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(expected_attention_mode, panel3->attention_mode()); 2072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 2092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 2102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, ClickTitlebar) { 2122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 2132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 2 stacked panels. 2152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack = panel_manager->CreateStack(); 2162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel1_initial_bounds = gfx::Rect(100, 50, 200, 150); 2172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel1 = CreateStackedPanel("1", panel1_initial_bounds, stack); 2182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel2_initial_bounds = gfx::Rect(0, 0, 150, 100); 2192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel2 = CreateStackedPanel("2", panel2_initial_bounds, stack); 2202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 2212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<NativePanelTesting> panel1_testing( 2232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateNativePanelTesting(panel1)); 2242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<NativePanelTesting> panel2_testing( 2252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateNativePanelTesting(panel2)); 2262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Point panel1_origin = panel2->GetBounds().origin(); 2282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Point panel2_origin = panel2->GetBounds().origin(); 2292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel1->IsMinimized()); 2312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2->IsMinimized()); 2322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel1_expected_bounds(panel1_initial_bounds); 2342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds()); 2352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel2_expected_bounds(panel1_expected_bounds.x(), 2362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_expected_bounds.bottom(), 2372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_expected_bounds.width(), 2382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_initial_bounds.height()); 2392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds()); 2402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Clicking on P2's titlebar to collapse it. 2422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_testing->PressLeftMouseButtonTitlebar(panel2_origin); 2432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_testing->ReleaseMouseButtonTitlebar(); 2442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel2); 2452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel1->IsMinimized()); 2462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel2->IsMinimized()); 2472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds()); 2482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_expected_bounds.set_height(panel2->TitleOnlyHeight()); 2492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds()); 2502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Clicking on P2's titlebar to expand it. 2522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_testing->PressLeftMouseButtonTitlebar(panel2_origin); 2532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_testing->ReleaseMouseButtonTitlebar(); 2542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel2); 2552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel1->IsMinimized()); 2562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2->IsMinimized()); 2572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds()); 2582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_expected_bounds.set_height(panel2_initial_bounds.height()); 2592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds()); 2602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Clicking on P2's titlebar with APPLY_TO_ALL modifier to collapse all 2622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // panels. 2632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_testing->PressLeftMouseButtonTitlebar(panel2_origin, 2642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel::APPLY_TO_ALL); 2652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_testing->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); 2662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel1); 2672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel2); 2682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel1->IsMinimized()); 2692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel2->IsMinimized()); 2702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_expected_bounds.set_height(panel1->TitleOnlyHeight()); 2712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds()); 2722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_expected_bounds.set_y(panel1_expected_bounds.bottom()); 2732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_expected_bounds.set_height(panel2->TitleOnlyHeight()); 2742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds()); 2752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Clicking on P1's titlebar with APPLY_TO_ALL modifier to expand all 2772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // panels. 2782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_testing->PressLeftMouseButtonTitlebar(panel1_origin, 2792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel::APPLY_TO_ALL); 2802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_testing->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); 2812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel1); 2822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel2); 2832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel1->IsMinimized()); 2842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2->IsMinimized()); 2852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_expected_bounds.set_height(panel1_initial_bounds.height()); 2862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds()); 2872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_expected_bounds.set_y(panel1_expected_bounds.bottom()); 2882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_expected_bounds.set_height(panel2_initial_bounds.height()); 2892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds()); 2902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 2922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 2932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, CallMinimizeAndRestoreApi) { 2952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 2962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 2 stacked panels. 2982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack = panel_manager->CreateStack(); 2992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel1_initial_bounds = gfx::Rect(100, 50, 200, 150); 3002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel1 = CreateStackedPanel("1", panel1_initial_bounds, stack); 3012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel2_initial_bounds = gfx::Rect(0, 0, 150, 100); 3022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel2 = CreateStackedPanel("2", panel2_initial_bounds, stack); 3032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 3042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel1->IsMinimized()); 3062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2->IsMinimized()); 3072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel1_expected_bounds(panel1_initial_bounds); 3092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds()); 3102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel2_expected_bounds(panel1_expected_bounds.x(), 3112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_expected_bounds.bottom(), 3122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_expected_bounds.width(), 3132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_initial_bounds.height()); 3142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds()); 3152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Collapsing P1 by calling its Minimize API. 3172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1->Minimize(); 3182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel1); 3192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel1->IsMinimized()); 3202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2->IsMinimized()); 3212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_expected_bounds.set_height(panel1->TitleOnlyHeight()); 3222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds()); 3232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_expected_bounds.set_y(panel1_expected_bounds.bottom()); 3242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds()); 3252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Expanding P1 by calling its Restore API. 3272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1->Restore(); 3282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel1); 3292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel1->IsMinimized()); 3302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2->IsMinimized()); 3312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_expected_bounds.set_height(panel1_initial_bounds.height()); 3322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds()); 3332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_expected_bounds.set_y(panel1_expected_bounds.bottom()); 3342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds()); 3352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 3372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 3382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, ExpandToFitWithinScreen) { 3402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 3412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect work_area = 3422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->display_settings_provider()->GetPrimaryWorkArea(); 3432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 344a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Create 4 stacked panels. P4 is the active panel. 3452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack = panel_manager->CreateStack(); 346a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) Panel* panel1 = CreateStackedPanel("1", gfx::Rect(100, 90, 200, 150), stack); 3472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel2 = CreateStackedPanel("2", gfx::Rect(0, 0, 150, 100), stack); 3482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel3 = CreateStackedPanel("3", gfx::Rect(0, 0, 150, 120), stack); 349a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) Panel* panel4 = CreateStackedPanel("4", gfx::Rect(0, 0, 150, 100), stack); 350a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ASSERT_EQ(4, stack->num_panels()); 351a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ASSERT_FALSE(panel1->IsMinimized()); 352a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ASSERT_FALSE(panel2->IsMinimized()); 353a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ASSERT_FALSE(panel3->IsMinimized()); 354a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ASSERT_FALSE(panel4->IsMinimized()); 355a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_LE(panel4->GetBounds().bottom(), work_area.bottom()); 356a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) int old_stack_top_position = panel1->GetBounds().y(); 3572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Collapse P2. 3592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2->Minimize(); 3602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel2); 3612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_FALSE(panel1->IsMinimized()); 3622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_TRUE(panel2->IsMinimized()); 3632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_FALSE(panel3->IsMinimized()); 364a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ASSERT_FALSE(panel4->IsMinimized()); 365a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 366a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Grow P2's restored height. 367a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gfx::Size panel2_full_size = panel2->full_size(); 368a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) panel2_full_size.set_height(panel2_full_size.height() + 30); 369a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) panel2->set_full_size(panel2_full_size); 3702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Expand P2. Expect that the least recently active panel P1 is minimized in 3722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // order to make space for P2. 3732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2->Restore(); 3742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel2); 3752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel3); 376a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) WaitForBoundsAnimationFinished(panel4); 3772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_TRUE(panel1->IsMinimized()); 3782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_FALSE(panel2->IsMinimized()); 3792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_FALSE(panel3->IsMinimized()); 380a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ASSERT_FALSE(panel4->IsMinimized()); 381a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_EQ(old_stack_top_position, panel1->GetBounds().y()); 382a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_LE(panel4->GetBounds().bottom(), work_area.bottom()); 383a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_EQ(panel2->GetBounds().height(), panel2_full_size.height()); 3842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Grow P1's restored height. 3862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Size panel1_full_size = panel1->full_size(); 387a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) panel1_full_size.set_height(panel1_full_size.height() + 180); 3882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1->set_full_size(panel1_full_size); 3892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Expand P1. Expect that both P2 and P3 are collapsed and the stack moves 3912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // up in order to make space for P1. 3922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1->Restore(); 3932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel1); 3942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel2); 3952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel3); 396a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) WaitForBoundsAnimationFinished(panel4); 3972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_FALSE(panel1->IsMinimized()); 3982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_TRUE(panel2->IsMinimized()); 3992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_TRUE(panel3->IsMinimized()); 400a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ASSERT_FALSE(panel4->IsMinimized()); 401a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_LT(panel1->GetBounds().y(), old_stack_top_position); 4022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_GE(panel1->GetBounds().y(), work_area.y()); 403a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_LE(panel4->GetBounds().bottom(), work_area.bottom()); 4042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel1->GetBounds().height(), panel1_full_size.height()); 405a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) old_stack_top_position = panel1->GetBounds().y(); 4062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Expand P3. Expect that P1 get collapsed in order to make space for P3. 4082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel3->Restore(); 4092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel1); 4102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel2); 4112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel3); 412a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) WaitForBoundsAnimationFinished(panel4); 4132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_TRUE(panel1->IsMinimized()); 4142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_TRUE(panel2->IsMinimized()); 4152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_FALSE(panel3->IsMinimized()); 416a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ASSERT_FALSE(panel4->IsMinimized()); 417a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_EQ(old_stack_top_position, panel1->GetBounds().y()); 418a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_LE(panel4->GetBounds().bottom(), work_area.bottom()); 4192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Grow P2's restored height by a very large value such that the stack with 4212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // P2 in full height will not fit within the screen. 422a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) panel2_full_size = panel2->full_size(); 4232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_full_size.set_height(panel2_full_size.height() + 500); 4242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2->set_full_size(panel2_full_size); 4252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Expand P2. Expect: 4272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // 1) Both P1 and P3 are collapsed 4282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // 2) The stack moves up to the top of the screen 4292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // 3) P2's restored height is reduced 4302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2->Restore(); 4312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel1); 4322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel2); 4332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel3); 434a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) WaitForBoundsAnimationFinished(panel4); 4352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel1->IsMinimized()); 4362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2->IsMinimized()); 4372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel3->IsMinimized()); 438a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_FALSE(panel4->IsMinimized()); 4392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel1->GetBounds().y(), work_area.y()); 440a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_EQ(panel4->GetBounds().bottom(), work_area.bottom()); 4412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_LT(panel2->GetBounds().height(), panel2_full_size.height()); 4422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 4442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 4452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4467dbb3d5cf0c15f500944d211057644d6a2f37371Ben MurdochIN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, ExpandAllToFitWithinScreen) { 4472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 4482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect work_area = 4492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->display_settings_provider()->GetPrimaryWorkArea(); 4502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 3 stacked panels. 4522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack = panel_manager->CreateStack(); 4532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel1 = CreateStackedPanel("1", gfx::Rect(100, 150, 200, 200), stack); 4542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel2 = CreateStackedPanel("2", gfx::Rect(0, 0, 150, 100), stack); 4552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel3 = CreateStackedPanel("3", gfx::Rect(0, 0, 150, 120), stack); 4562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(3, stack->num_panels()); 4572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<NativePanelTesting> panel2_testing( 4592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateNativePanelTesting(panel2)); 4602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Collapse all panels by clicking on P2's titlebar with APPLY_TO_ALL 4622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // modifier. 4632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_testing->PressLeftMouseButtonTitlebar(panel2->GetBounds().origin(), 4642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel::APPLY_TO_ALL); 4652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_testing->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); 4662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel1); 4672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel2); 4682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel3); 4692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_TRUE(panel1->IsMinimized()); 4702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_TRUE(panel2->IsMinimized()); 4712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_TRUE(panel3->IsMinimized()); 4722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Grow P2's restored height by a very large value. 4742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Size panel2_full_size = panel2->full_size(); 4752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_full_size.set_height(panel2_full_size.height() + 500); 4762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2->set_full_size(panel2_full_size); 4772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Expand all panels by clicking on P2's titlebar with APPLY_TO_ALL 4792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // modifier again. Expect only P2 is expanded due to no available space for 4802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // P1 and P3. 4812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_testing->PressLeftMouseButtonTitlebar(panel2->GetBounds().origin(), 4822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel::APPLY_TO_ALL); 4832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_testing->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); 4842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel1); 4852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel2); 4862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel3); 4872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel1->IsMinimized()); 4882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2->IsMinimized()); 4892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel3->IsMinimized()); 4902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel1->GetBounds().y(), work_area.y()); 4912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel3->GetBounds().bottom(), work_area.bottom()); 4922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 4942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 4952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, MinimizeButtonVisibility) { 4972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 4982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 3 stacked panels. 5002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack = panel_manager->CreateStack(); 5012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel1_initial_bounds = gfx::Rect(100, 50, 200, 150); 5022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel1 = CreateStackedPanel("1", panel1_initial_bounds, stack); 5032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel2_initial_bounds = gfx::Rect(0, 0, 150, 100); 5042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel2 = CreateStackedPanel("2", panel2_initial_bounds, stack); 5052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel3_initial_bounds = gfx::Rect(0, 0, 250, 120); 5062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel3 = CreateStackedPanel("3", panel3_initial_bounds, stack); 5072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 5082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(3, stack->num_panels()); 5092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<NativePanelTesting> panel1_testing( 5112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateNativePanelTesting(panel1)); 5122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<NativePanelTesting> panel2_testing( 5132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateNativePanelTesting(panel2)); 5142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<NativePanelTesting> panel3_testing( 5152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateNativePanelTesting(panel3)); 5162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Only P1 shows minimize button. 518a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (PanelManager::CanUseSystemMinimize()) 519a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_TRUE(panel1_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); 520a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) else 521a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_FALSE(panel1_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); 5222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); 5232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel3_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); 5242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Drag P2 away to unstack from P1. 5262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Expect only P2, top panel of the stack consisting P2 and P3, shows minimize 5272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // button. 5282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Point mouse_location(panel2->GetBounds().origin()); 5292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_testing->PressLeftMouseButtonTitlebar(mouse_location); 5302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Vector2d drag_delta_to_unstack(120, 50); 5312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_testing->DragTitlebar(mouse_location + drag_delta_to_unstack); 5322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_testing->FinishDragTitlebar(); 5332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->detached_collection()->num_panels()); 5342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 5352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, stack->num_panels()); 5362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 537a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (PanelManager::CanUseSystemMinimize()) { 538a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_TRUE(panel1_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); 539a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_TRUE(panel2_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); 540a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } else { 541a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_FALSE(panel1_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); 542a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_FALSE(panel2_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); 543a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 5442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel3_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); 5452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Drag P1 to stack to the top edge of P2. 5472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Expect only P1, top panel of the stack consisting P1, P2 and P3, shows 5482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // minimize button. 5492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds1 = panel1->GetBounds(); 5502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds2 = panel2->GetBounds(); 5512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) mouse_location = bounds1.origin(); 5522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_testing->PressLeftMouseButtonTitlebar(mouse_location); 5532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Vector2d drag_delta_to_stack(bounds2.x() - bounds1.x(), 5542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bounds2.y() - bounds1.bottom()); 5552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_testing->DragTitlebar(mouse_location + drag_delta_to_stack); 5562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_testing->FinishDragTitlebar(); 5572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(0, panel_manager->detached_collection()->num_panels()); 5582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 5592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(3, stack->num_panels()); 5602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 561a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (PanelManager::CanUseSystemMinimize()) 562a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_TRUE(panel1_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); 563a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) else 564a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_FALSE(panel1_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); 5652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); 5662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel3_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); 5672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 5692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 5702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, DISABLED_ClickMinimizeButton) { 5722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 5732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 2 stacked panels. 5752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack = panel_manager->CreateStack(); 5762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel1_initial_bounds = gfx::Rect(100, 50, 200, 150); 5772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel1 = CreateStackedPanel("1", panel1_initial_bounds, stack); 5782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel2_initial_bounds = gfx::Rect(0, 0, 150, 100); 5792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel2 = CreateStackedPanel("2", panel2_initial_bounds, stack); 5802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 5812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<NativePanelTesting> panel1_testing( 5832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateNativePanelTesting(panel1)); 5842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel1->IsMinimized()); 5862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2->IsMinimized()); 5872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Collapsing P1 by calling its Minimize API. 5892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1->OnMinimizeButtonClicked(panel::NO_MODIFIER); 5902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel1->IsMinimized()); 5912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2->IsMinimized()); 5922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel1_testing->VerifySystemMinimizeState()); 5932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 5952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 5962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, UngroupMinimizedPanels) { 5982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 5992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 3 stacked panels. 6012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack = panel_manager->CreateStack(); 6022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel1_initial_bounds = gfx::Rect(100, 50, 200, 150); 6032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel1 = CreateStackedPanel("1", panel1_initial_bounds, stack); 6042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel2_initial_bounds = gfx::Rect(0, 0, 150, 100); 6052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel2 = CreateStackedPanel("2", panel2_initial_bounds, stack); 6062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel3_initial_bounds = gfx::Rect(0, 0, 250, 120); 6072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel3 = CreateStackedPanel("3", panel3_initial_bounds, stack); 6082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 6092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(3, stack->num_panels()); 6102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<NativePanelTesting> panel2_testing( 6122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateNativePanelTesting(panel2)); 6132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<NativePanelTesting> panel3_testing( 6142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateNativePanelTesting(panel3)); 6152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Minimize these 3 panels. 6172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1->Minimize(); 6182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel1); 6192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2->Minimize(); 6202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel3); 6212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel3->Minimize(); 6222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel3); 6232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel1->IsMinimized()); 6252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel2->IsMinimized()); 6262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel3->IsMinimized()); 6272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel1_expected_bounds(panel1_initial_bounds); 6292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_expected_bounds.set_height(panel1->TitleOnlyHeight()); 6302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds()); 6312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel2_expected_bounds(panel1_expected_bounds.x(), 6322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_expected_bounds.bottom(), 6332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_expected_bounds.width(), 6342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2->TitleOnlyHeight()); 6352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds()); 6362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel3_expected_bounds(panel2_expected_bounds.x(), 6372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_expected_bounds.bottom(), 6382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_expected_bounds.width(), 6392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel3->TitleOnlyHeight()); 6402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds()); 6412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Drag P2 away to unstack from P1. 6432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Expect P2 and P3 are still stacked and minimized while P1 becomes detached 6442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // and expanded. The minimize button of P2 should become visible now. 6452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Point mouse_location(panel2->GetBounds().origin()); 6462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_testing->PressLeftMouseButtonTitlebar(mouse_location); 6472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Vector2d drag_delta(120, 50); 6482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_testing->DragTitlebar(mouse_location + drag_delta); 6492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_testing->FinishDragTitlebar(); 6502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel1); 6512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->detached_collection()->num_panels()); 6522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 6532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, stack->num_panels()); 6542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel1->IsMinimized()); 6562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel2->IsMinimized()); 6572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel3->IsMinimized()); 6582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_expected_bounds.set_height(panel1_initial_bounds.height()); 6602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds()); 6612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_expected_bounds.Offset(drag_delta); 6622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds()); 6632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel3_expected_bounds.Offset(drag_delta); 6642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds()); 6652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Drag P3 away to unstack from P2. 6672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Expect both panels become detached and expanded. 6682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) mouse_location = panel3->GetBounds().origin(); 6692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel3_testing->PressLeftMouseButtonTitlebar(mouse_location); 6702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel3_testing->DragTitlebar(mouse_location + drag_delta); 6712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel3_testing->FinishDragTitlebar(); 6722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel2); 6732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel3); 6742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(3, panel_manager->detached_collection()->num_panels()); 6752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(0, panel_manager->num_stacks()); 6762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel1->IsMinimized()); 6782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2->IsMinimized()); 6792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel3->IsMinimized()); 6802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds()); 6822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_expected_bounds.set_height(panel2_initial_bounds.height()); 6832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds()); 6842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel3_expected_bounds.Offset(drag_delta); 6852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel3_expected_bounds.set_height(panel3_initial_bounds.height()); 6862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds()); 6872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 6892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 6902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, 6922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) AddNewPanelToStackWithMostPanels) { 6932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 6942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create one stack with 2 panels. 6962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack1 = panel_manager->CreateStack(); 697c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CreateStackedPanel("1", gfx::Rect(200, 50, 200, 150), stack1); 698c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CreateStackedPanel("2", gfx::Rect(0, 0, 150, 100), stack1); 6992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, panel_manager->num_panels()); 7002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 7012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, stack1->num_panels()); 7022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create another stack with 3 panels. 7042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack2 = panel_manager->CreateStack(); 705c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CreateStackedPanel("3", gfx::Rect(100, 50, 200, 150), stack2); 706c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CreateStackedPanel("4", gfx::Rect(0, 0, 150, 100), stack2); 707c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CreateStackedPanel("5", gfx::Rect(0, 0, 250, 120), stack2); 7082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(5, panel_manager->num_panels()); 7092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, panel_manager->num_stacks()); 7102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(3, stack2->num_panels()); 7112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create new panel. Expect that it will append to stack2 since it has most 7132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // panels. 714a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CreatePanelParams params("N", gfx::Rect(50, 50, 150, 100), SHOW_AS_ACTIVE); 7152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params.create_mode = PanelManager::CREATE_AS_DETACHED; 7162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* new_panel = CreatePanelWithParams(params); 7172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(6, panel_manager->num_panels()); 7182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, panel_manager->num_stacks()); 7192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, stack1->num_panels()); 7202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(4, stack2->num_panels()); 7212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(stack2->HasPanel(new_panel)); 7222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(new_panel == stack2->bottom_panel()); 7232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 7252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 7262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, 7282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) AddNewPanelToRightMostStack) { 7292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 7302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create one stack with 2 panels. 7322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack1 = panel_manager->CreateStack(); 733c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CreateStackedPanel("1", gfx::Rect(100, 50, 200, 150), stack1); 734c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CreateStackedPanel("2", gfx::Rect(0, 0, 150, 100), stack1); 7352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, panel_manager->num_panels()); 7362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 7372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, stack1->num_panels()); 7382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create another stack with 2 panels. 7402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack2 = panel_manager->CreateStack(); 741c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CreateStackedPanel("3", gfx::Rect(200, 50, 200, 150), stack2); 742c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CreateStackedPanel("4", gfx::Rect(0, 0, 150, 100), stack2); 7432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(4, panel_manager->num_panels()); 7442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, panel_manager->num_stacks()); 7452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, stack2->num_panels()); 7462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create new panel. Both stack1 and stack2 have same number of panels. Since 7482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // stack2 is right-most, new panel will be added to it. 749a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CreatePanelParams params("N", gfx::Rect(50, 50, 150, 100), SHOW_AS_ACTIVE); 7502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params.create_mode = PanelManager::CREATE_AS_DETACHED; 7512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* new_panel = CreatePanelWithParams(params); 7522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(5, panel_manager->num_panels()); 7532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, panel_manager->num_stacks()); 7542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, stack1->num_panels()); 7552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(3, stack2->num_panels()); 7562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(stack2->HasPanel(new_panel)); 7572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(new_panel == stack2->bottom_panel()); 7582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 7602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 7612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, 7632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) AddNewPanelToTopMostStack) { 7642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 7652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create one stack with 2 panels. 7672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack1 = panel_manager->CreateStack(); 768c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CreateStackedPanel("1", gfx::Rect(100, 90, 200, 150), stack1); 769c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CreateStackedPanel("2", gfx::Rect(0, 0, 150, 100), stack1); 7702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, panel_manager->num_panels()); 7712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 7722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, stack1->num_panels()); 7732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create another stack with 2 panels. 7752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack2 = panel_manager->CreateStack(); 776c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CreateStackedPanel("3", gfx::Rect(100, 50, 200, 150), stack2); 777c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CreateStackedPanel("4", gfx::Rect(0, 0, 150, 100), stack2); 7782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(4, panel_manager->num_panels()); 7792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, panel_manager->num_stacks()); 7802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, stack2->num_panels()); 7812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create new panel. Both stack1 and stack2 have same number of panels and 7832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // same right position. Since stack2 is top-most, new panel will be added to 7842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // it. 785a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CreatePanelParams params("N", gfx::Rect(50, 50, 150, 100), SHOW_AS_ACTIVE); 7862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params.create_mode = PanelManager::CREATE_AS_DETACHED; 7872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* new_panel = CreatePanelWithParams(params); 7882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(5, panel_manager->num_panels()); 7892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, panel_manager->num_stacks()); 7902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, stack1->num_panels()); 7912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(3, stack2->num_panels()); 7922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(stack2->HasPanel(new_panel)); 7932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(new_panel == stack2->bottom_panel()); 7942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 7962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 7972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, 7992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) AddNewPanelToGroupWithRightMostDetachedPanel) { 8002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 8012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 8022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 2 detached panels. 803c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CreateDetachedPanel("1", gfx::Rect(200, 50, 250, 150)); 8042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel2 = CreateDetachedPanel("2", gfx::Rect(250, 100, 150, 100)); 8052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, panel_manager->num_panels()); 8062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(0, panel_manager->num_stacks()); 8072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, panel_manager->detached_collection()->num_panels()); 8082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 8092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create new panel. Expect that new panel will stack to the bottom of panel2 8102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // since it is right-most. 811a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CreatePanelParams params("N", gfx::Rect(50, 50, 150, 100), SHOW_AS_ACTIVE); 8122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params.create_mode = PanelManager::CREATE_AS_DETACHED; 8132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* new_panel = CreatePanelWithParams(params); 8142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(3, panel_manager->num_panels()); 8152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(1, panel_manager->detached_collection()->num_panels()); 8162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 8172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack = panel_manager->stacks().front(); 8182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, stack->num_panels()); 8192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel2 == stack->top_panel()); 8202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(new_panel == stack->bottom_panel()); 8212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 8222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 8232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 8242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 8252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, 8262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) AddNewPanelToGroupWitTopMostDetachedPanel) { 8272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 8282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 8292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 2 detached panels. 830c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CreateDetachedPanel("1", gfx::Rect(200, 100, 100, 150)); 8312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel2 = CreateDetachedPanel("2", gfx::Rect(200, 50, 100, 100)); 8322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, panel_manager->num_panels()); 8332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(0, panel_manager->num_stacks()); 8342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, panel_manager->detached_collection()->num_panels()); 8352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 8362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create new panel. Expect that new panel will stack to the bottom of panel2 8372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // since it is top-most. 838a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CreatePanelParams params("N", gfx::Rect(50, 50, 150, 100), SHOW_AS_ACTIVE); 8392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params.create_mode = PanelManager::CREATE_AS_DETACHED; 8402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* new_panel = CreatePanelWithParams(params); 8412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(3, panel_manager->num_panels()); 8422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(1, panel_manager->detached_collection()->num_panels()); 8432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 8442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack = panel_manager->stacks().front(); 8452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, stack->num_panels()); 8462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel2 == stack->top_panel()); 8472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(new_panel == stack->bottom_panel()); 8482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 8492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 8502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 8512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 8522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, 8532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) AddNewPanelToStackWithCollapseToFit) { 8542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 8552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 856a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Create one stack with 4 panels. 857a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // The panels from most recent active to least recent active are: 858a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // P4 P3 P2 P1 8592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack = panel_manager->CreateStack(); 860a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) Panel* panel1 = CreateStackedPanel("1", gfx::Rect(100, 50, 200, 140), stack); 8612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel2 = CreateStackedPanel("2", gfx::Rect(0, 0, 150, 150), stack); 8622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel3 = CreateStackedPanel("3", gfx::Rect(0, 0, 180, 120), stack); 863a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) Panel* panel4 = CreateStackedPanel("4", gfx::Rect(0, 0, 170, 110), stack); 8642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(4, panel_manager->num_panels()); 8652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 8662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(4, stack->num_panels()); 8672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel1->IsMinimized()); 8682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2->IsMinimized()); 8692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel3->IsMinimized()); 8702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel4->IsMinimized()); 8712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 872a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Create a panel. Expect the least recent active panel P1 gets minimized such 8732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // that there is enough space for new panel to append to the stack. 874a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // The panels from most recent active to least recent active are: 875a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // PM P4 P3 P2 P1* 876a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CreatePanelParams params1("M", gfx::Rect(50, 50, 300, 110), SHOW_AS_ACTIVE); 8772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params1.create_mode = PanelManager::CREATE_AS_DETACHED; 8782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* new_panel1 = CreatePanelWithParams(params1); 8792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(5, panel_manager->num_panels()); 8802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(1, panel_manager->num_stacks()); 8812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(5, stack->num_panels()); 8822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(new_panel1 == stack->bottom_panel()); 883a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_TRUE(panel1->IsMinimized()); 884a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_FALSE(panel2->IsMinimized()); 8852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel3->IsMinimized()); 8862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel4->IsMinimized()); 8872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(new_panel1->IsMinimized()); 8882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 889a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Create another panel. Expect P2 and P3 are minimized such that there is 890a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // enough space for new panel to append to the stack. 891a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CreatePanelParams params2("N", gfx::Rect(50, 50, 300, 180), SHOW_AS_ACTIVE); 8922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params2.create_mode = PanelManager::CREATE_AS_DETACHED; 8932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* new_panel2 = CreatePanelWithParams(params2); 8942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(6, panel_manager->num_panels()); 8952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(1, panel_manager->num_stacks()); 8962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(6, stack->num_panels()); 8972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(new_panel2 == stack->bottom_panel()); 898a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_TRUE(panel1->IsMinimized()); 8992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel2->IsMinimized()); 9002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel3->IsMinimized()); 901a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_FALSE(panel4->IsMinimized()); 9022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(new_panel1->IsMinimized()); 9032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(new_panel2->IsMinimized()); 9042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 9052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 9062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 9072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 9082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, 909eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch AddNewPanelToGroupWithDetachedPanelWithCollapseToFit) { 9102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 9112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 9122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 2 detached panels. 913a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Since P2 is active, it will not get collapsed when the new panel to stack 914a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // with needs the space. 915eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch Panel* panel1 = 916eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch CreateInactiveDetachedPanel("1", gfx::Rect(100, 310, 200, 200)); 917a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) Panel* panel2 = CreateDetachedPanel("2", gfx::Rect(300, 300, 150, 200)); 9182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, panel_manager->num_panels()); 9192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(0, panel_manager->num_stacks()); 9202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, panel_manager->detached_collection()->num_panels()); 9212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 922a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Create new panel. Expect panel1 is minimized such that there is enough 923a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // space for new panel to append to panel1. 924a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CreatePanelParams params("N", gfx::Rect(50, 50, 300, 220), SHOW_AS_ACTIVE); 9252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params.create_mode = PanelManager::CREATE_AS_DETACHED; 9262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* new_panel = CreatePanelWithParams(params); 9272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(3, panel_manager->num_panels()); 9282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(1, panel_manager->detached_collection()->num_panels()); 9292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 9302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack = panel_manager->stacks().front(); 9312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, stack->num_panels()); 932a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_TRUE(panel1 == stack->top_panel()); 9332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(new_panel == stack->bottom_panel()); 934a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_TRUE(panel1->IsMinimized()); 935a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EXPECT_FALSE(panel2->IsMinimized()); 9362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(new_panel->IsMinimized()); 9372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 9382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 9392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 9402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 9412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, 9422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) AddNewPanelAsDetachedDueToNoPanelToGroupWith) { 9432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 9442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 9452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create one stack with 2 panels. 9462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack = panel_manager->CreateStack(); 947c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CreateStackedPanel("1", gfx::Rect(100, 350, 200, 100), stack); 948c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CreateStackedPanel("2", gfx::Rect(0, 0, 150, 100), stack); 9492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, panel_manager->num_panels()); 9502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 9512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, stack->num_panels()); 9522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 9532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 2 detached panels. 954c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CreateDetachedPanel("3", gfx::Rect(300, 450, 200, 100)); 955c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CreateDetachedPanel("4", gfx::Rect(250, 150, 150, 200)); 9562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(4, panel_manager->num_panels()); 9572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, panel_manager->detached_collection()->num_panels()); 9582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 9592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 9602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create new panel. Expect that new panel has to be created as detached due 9612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // to that there is not enough space from any stack or detached panel. 962a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CreatePanelParams params("N", gfx::Rect(50, 50, 300, 300), SHOW_AS_ACTIVE); 9632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params.create_mode = PanelManager::CREATE_AS_DETACHED; 9642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* new_panel = CreatePanelWithParams(params); 9652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(5, panel_manager->num_panels()); 9662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(3, panel_manager->detached_collection()->num_panels()); 9672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(1, panel_manager->num_stacks()); 9682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, stack->num_panels()); 9692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel_manager->detached_collection()->HasPanel(new_panel)); 9702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 9712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 9722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 9732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 9742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, 9752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) AddNewPanelFromDifferentExtension) { 9762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 9772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 9782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 2 test extensions. 9795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::DictionaryValue empty_value; 9802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_refptr<extensions::Extension> extension1 = 9812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateExtension(FILE_PATH_LITERAL("TestExtension1"), 98290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) extensions::Manifest::INTERNAL, empty_value); 9832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) std::string extension1_app_name = 9842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) web_app::GenerateApplicationNameFromExtensionId(extension1->id()); 9852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_refptr<extensions::Extension> extension2 = 9862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreateExtension(FILE_PATH_LITERAL("TestExtension2"), 98790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) extensions::Manifest::INTERNAL, empty_value); 9882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) std::string extension2_app_name = 9892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) web_app::GenerateApplicationNameFromExtensionId(extension2->id()); 9902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 9912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 2 panels from extension1. Expect that these 2 panels stack together. 9922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreatePanelParams params1( 993a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) extension1_app_name, gfx::Rect(50, 50, 100, 100), SHOW_AS_ACTIVE); 9942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params1.create_mode = PanelManager::CREATE_AS_DETACHED; 9952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel1 = CreatePanelWithParams(params1); 9962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreatePanelParams params2( 997a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) extension1_app_name, gfx::Rect(100, 100, 200, 100), SHOW_AS_ACTIVE); 9982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params2.create_mode = PanelManager::CREATE_AS_DETACHED; 9992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel2 = CreatePanelWithParams(params2); 10002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, panel_manager->num_panels()); 10012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(1, panel_manager->num_stacks()); 10022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack1 = panel_manager->stacks().back(); 10032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(stack1->HasPanel(panel1)); 10042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(stack1->HasPanel(panel2)); 10052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 10062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 2 panels from extension2. Expect that these 2 panels form a separate 10072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // stack. 10082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreatePanelParams params3( 1009a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) extension2_app_name, gfx::Rect(350, 350, 100, 100), SHOW_AS_ACTIVE); 10102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params3.create_mode = PanelManager::CREATE_AS_DETACHED; 10112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel3 = CreatePanelWithParams(params3); 10122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreatePanelParams params4( 1013a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) extension2_app_name, gfx::Rect(100, 100, 200, 100), SHOW_AS_ACTIVE); 10142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params4.create_mode = PanelManager::CREATE_AS_DETACHED; 10152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel4 = CreatePanelWithParams(params4); 10162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(4, panel_manager->num_panels()); 10172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, panel_manager->num_stacks()); 10182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack2 = panel_manager->stacks().back(); 10192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(stack2->HasPanel(panel3)); 10202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(stack2->HasPanel(panel4)); 10212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 10222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create one more panel from extension1. Expect that new panel should join 10232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // with the stack of panel1 and panel2. 10242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreatePanelParams params5( 1025a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) extension1_app_name, gfx::Rect(0, 0, 100, 100), SHOW_AS_ACTIVE); 10262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params5.create_mode = PanelManager::CREATE_AS_DETACHED; 10272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel5 = CreatePanelWithParams(params5); 10282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(5, panel_manager->num_panels()); 10292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, panel_manager->num_stacks()); 10302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(stack1->HasPanel(panel5)); 10312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 10322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create one more panel from extension2. Expect that new panel should join 10332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // with the stack of panel3 and panel4. 10342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreatePanelParams params6( 1035a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) extension2_app_name, gfx::Rect(0, 0, 100, 100), SHOW_AS_ACTIVE); 10362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params6.create_mode = PanelManager::CREATE_AS_DETACHED; 10372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel6 = CreatePanelWithParams(params6); 10382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(6, panel_manager->num_panels()); 10392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, panel_manager->num_stacks()); 10402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(stack2->HasPanel(panel6)); 10412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 10422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 10432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 10442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 10452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, 10462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) AddNewPanelFromDifferentProfile) { 10472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 10482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 10492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create a new profile. 10502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Profile* profile1 = browser()->profile(); 10512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<TestingProfile> profile2(new TestingProfile()); 10522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 10532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 2 panels from profile1. Expect that these 2 panels stack together. 10542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreatePanelParams params1( 1055a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) "1", gfx::Rect(50, 50, 100, 100), SHOW_AS_ACTIVE); 10562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params1.create_mode = PanelManager::CREATE_AS_DETACHED; 10572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params1.profile = profile1; 10582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel1 = CreatePanelWithParams(params1); 10592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreatePanelParams params2( 1060a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) "2", gfx::Rect(100, 100, 200, 100), SHOW_AS_ACTIVE); 10612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params2.create_mode = PanelManager::CREATE_AS_DETACHED; 10622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params2.profile = profile1; 10632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel2 = CreatePanelWithParams(params2); 10642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, panel_manager->num_panels()); 10652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(1, panel_manager->num_stacks()); 10662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack1 = panel_manager->stacks().back(); 10672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(stack1->HasPanel(panel1)); 10682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(stack1->HasPanel(panel2)); 10692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 10702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 2 panels from profile2. Expect that these 2 panels form a separate 10712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // stack. 10722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreatePanelParams params3( 1073a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) "3", gfx::Rect(350, 350, 100, 100), SHOW_AS_ACTIVE); 10742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params3.create_mode = PanelManager::CREATE_AS_DETACHED; 10752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params3.profile = profile2.get(); 10762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel3 = CreatePanelWithParams(params3); 10772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreatePanelParams params4( 1078a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) "4", gfx::Rect(100, 100, 200, 100), SHOW_AS_ACTIVE); 10792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params4.create_mode = PanelManager::CREATE_AS_DETACHED; 10802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params4.profile = profile2.get(); 10812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel4 = CreatePanelWithParams(params4); 10822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(4, panel_manager->num_panels()); 10832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, panel_manager->num_stacks()); 10842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack2 = panel_manager->stacks().back(); 10852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(stack2->HasPanel(panel3)); 10862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(stack2->HasPanel(panel4)); 10872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 10882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create one more panel from profile1. Expect that new panel should join 10892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // with the stack of panel1 and panel2. 10902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreatePanelParams params5( 1091a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) "5", gfx::Rect(0, 0, 100, 100), SHOW_AS_ACTIVE); 10922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params5.create_mode = PanelManager::CREATE_AS_DETACHED; 10932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params5.profile = profile1; 10942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel5 = CreatePanelWithParams(params5); 10952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(5, panel_manager->num_panels()); 10962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, panel_manager->num_stacks()); 10972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(stack1->HasPanel(panel5)); 10982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 10992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create one more panel from profile2. Expect that new panel should join 11002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // with the stack of panel3 and panel4. 11012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CreatePanelParams params6( 1102a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) "6", gfx::Rect(0, 0, 100, 100), SHOW_AS_ACTIVE); 11032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params6.create_mode = PanelManager::CREATE_AS_DETACHED; 11042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params6.profile = profile2.get(); 11052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel6 = CreatePanelWithParams(params6); 11062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(6, panel_manager->num_panels()); 11072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, panel_manager->num_stacks()); 11082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(stack2->HasPanel(panel6)); 11092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 11102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Wait until all panels created from profile2 get fully closed since profile2 11112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // is going out of scope at the exit of this function. 11122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CloseWindowAndWait(panel3); 11132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CloseWindowAndWait(panel4); 11142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CloseWindowAndWait(panel6); 11152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 11162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 11172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 11182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 11192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, 1120f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) AddNewPanelNotWithSystemMinimizedDetachedPanel) { 11212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 11222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 11232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 1 detached panel. 11242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel1 = CreateDetachedPanel("1", gfx::Rect(200, 50, 250, 150)); 11252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(1, panel_manager->num_panels()); 11262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(0, panel_manager->num_stacks()); 11272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(1, panel_manager->detached_collection()->num_panels()); 11282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(PanelCollection::DETACHED, panel1->collection()->type()); 11292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 11302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Minimize the detached panel by system. 11312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1->OnMinimizeButtonClicked(panel::NO_MODIFIER); 11322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 11332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create new panel. Expect that new panel will open as a separate detached 11342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // panel, instead of being grouped with the system-minimized detached panel. 1135a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CreatePanelParams params("N", gfx::Rect(50, 50, 150, 100), SHOW_AS_ACTIVE); 11362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params.create_mode = PanelManager::CREATE_AS_DETACHED; 11372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* new_panel = CreatePanelWithParams(params); 11382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, panel_manager->num_panels()); 11392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, panel_manager->detached_collection()->num_panels()); 11402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(0, panel_manager->num_stacks()); 11412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(PanelCollection::DETACHED, panel1->collection()->type()); 11422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(PanelCollection::DETACHED, new_panel->collection()->type()); 11432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 11442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 11452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 11462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 11472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, 1148f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) AddNewPanelNotWithSystemMinimizedStack) { 11492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 11502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 11512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create one stack with 2 panels. 11522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack = panel_manager->CreateStack(); 11532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel1 = CreateStackedPanel("1", gfx::Rect(100, 90, 200, 150), stack); 11542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel2 = CreateStackedPanel("2", gfx::Rect(0, 0, 150, 100), stack); 11552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, panel_manager->num_panels()); 11562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(0, panel_manager->detached_collection()->num_panels()); 11572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(1, panel_manager->num_stacks()); 11582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, stack->num_panels()); 11592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(PanelCollection::STACKED, panel1->collection()->type()); 11602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(PanelCollection::STACKED, panel2->collection()->type()); 11612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 11622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Minimize the stack by system. 11632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) stack->OnMinimizeButtonClicked(panel1, panel::NO_MODIFIER); 11642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 11652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create new panel. Expect that new panel will open as a separate detached 11662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // panel, instead of appending to the system-minimized stack. 1167a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CreatePanelParams params("N", gfx::Rect(50, 50, 150, 100), SHOW_AS_ACTIVE); 11682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) params.create_mode = PanelManager::CREATE_AS_DETACHED; 11692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* new_panel = CreatePanelWithParams(params); 11702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(3, panel_manager->num_panels()); 11712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(1, panel_manager->detached_collection()->num_panels()); 11722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(1, panel_manager->num_stacks()); 11732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(2, stack->num_panels()); 11742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(PanelCollection::STACKED, panel1->collection()->type()); 11752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(PanelCollection::STACKED, panel2->collection()->type()); 11762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(PanelCollection::DETACHED, new_panel->collection()->type()); 11772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 11782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 11792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 11802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 11812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, ClosePanels) { 11822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 11832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 11842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 3 stacked panels. 11852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack = panel_manager->CreateStack(); 11862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel1_initial_bounds = gfx::Rect(100, 50, 200, 150); 11872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel1 = CreateStackedPanel("1", panel1_initial_bounds, stack); 11882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel2_initial_bounds = gfx::Rect(0, 0, 150, 100); 11892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel2 = CreateStackedPanel("2", panel2_initial_bounds, stack); 11902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel3_initial_bounds = gfx::Rect(0, 0, 250, 120); 11912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel3 = CreateStackedPanel("3", panel3_initial_bounds, stack); 11922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(3, panel_manager->num_panels()); 11932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 11942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(3, stack->num_panels()); 11952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 11962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel1_expected_bounds(panel1_initial_bounds); 11972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds()); 11982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel2_expected_bounds(panel1_expected_bounds.x(), 11992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_expected_bounds.bottom(), 12002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1_expected_bounds.width(), 12012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_initial_bounds.height()); 12022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds()); 12032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel3_expected_bounds(panel2_expected_bounds.x(), 12042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_expected_bounds.bottom(), 12052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_expected_bounds.width(), 12062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel3_initial_bounds.height()); 12072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds()); 12082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 12092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Close P1. Expect that P2 and P3 should move up. 12102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CloseWindowAndWait(panel1); 12112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel2); 12122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel3); 12132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, panel_manager->num_panels()); 12142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 12152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, stack->num_panels()); 12162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(PanelCollection::STACKED, panel2->collection()->type()); 12172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(PanelCollection::STACKED, panel3->collection()->type()); 12182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 12192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2_expected_bounds.set_y(panel1_expected_bounds.y()); 12202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds()); 12212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel3_expected_bounds.set_y(panel2_expected_bounds.bottom()); 12222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds()); 12232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 12242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Close P2. Expect that P3 should become detached and move up. 12252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CloseWindowAndWait(panel2); 12262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel3); 12272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_panels()); 12282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(0, panel_manager->num_stacks()); 12292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(PanelCollection::DETACHED, panel3->collection()->type()); 12302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 12312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel3_expected_bounds.set_y(panel2_expected_bounds.y()); 12322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds()); 12332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 12342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 12352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 12362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1237a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// Skip the test since active state might not be fully supported for some window 1238a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// managers. 1239f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#if defined(OS_MACOSX) 1240a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#define MAYBE_FocusNextPanelOnPanelClose DISABLED_FocusNextPanelOnPanelClose 1241a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#else 1242a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#define MAYBE_FocusNextPanelOnPanelClose FocusNextPanelOnPanelClose 1243a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#endif 1244a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, 1245a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) MAYBE_FocusNextPanelOnPanelClose) { 12462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 12472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 12482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 3 stacked panels. 12492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack = panel_manager->CreateStack(); 12503551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) Panel* panel1 = CreateStackedPanel("1", gfx::Rect(100, 50, 200, 200), stack); 12512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel2 = CreateStackedPanel("2", gfx::Rect(0, 0, 150, 100), stack); 12522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel3 = CreateStackedPanel("3", gfx::Rect(0, 0, 150, 120), stack); 12532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(3, stack->num_panels()); 12542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_FALSE(panel1->IsActive()); 12552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_FALSE(panel2->IsActive()); 12562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_TRUE(panel3->IsActive()); 12572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 12582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Close P3. Expect P2 should become active. 12592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CloseWindowAndWait(panel3); 12602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel1->IsActive()); 12612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel2->IsActive()); 12622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 12632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Close P2. Expect P1 should become active. 12642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CloseWindowAndWait(panel2); 12652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel1->IsActive()); 12662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 12672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 12682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 12692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 12703551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)// Skip the test since active state might not be fully supported for some window 12713551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)// managers. 1272f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#if defined(OS_MACOSX) 12733551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#define MAYBE_FocusNextUnminimizedPanelOnPanelClose \ 12743551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) DISABLED_FocusNextUnminimizedPanelOnPanelClose 12753551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#else 12763551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#define MAYBE_FocusNextUnminimizedPanelOnPanelClose \ 12773551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) FocusNextUnminimizedPanelOnPanelClose 12783551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#endif 12793551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, 12803551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) MAYBE_FocusNextUnminimizedPanelOnPanelClose) { 12813551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 12823551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 12833551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // Create 3 stacked panels. 12843551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) StackedPanelCollection* stack = panel_manager->CreateStack(); 12853551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) Panel* panel1 = CreateStackedPanel("1", gfx::Rect(100, 50, 200, 200), stack); 12863551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) Panel* panel2 = CreateStackedPanel("2", gfx::Rect(0, 0, 150, 100), stack); 12873551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) Panel* panel3 = CreateStackedPanel("3", gfx::Rect(0, 0, 150, 120), stack); 12883551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) ASSERT_EQ(3, stack->num_panels()); 12893551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) ASSERT_FALSE(panel1->IsActive()); 12903551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) ASSERT_FALSE(panel2->IsActive()); 12913551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) ASSERT_TRUE(panel3->IsActive()); 12923551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 12933551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // Minimize P2. 12943551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) panel2->Minimize(); 12953551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) WaitForBoundsAnimationFinished(panel2); 12963551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 12973551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // Close P3. Expect P1, not P2, should become active. 12983551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) CloseWindowAndWait(panel3); 12993551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) EXPECT_TRUE(panel1->IsActive()); 13003551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) EXPECT_FALSE(panel2->IsActive()); 13013551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 13023551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) panel_manager->CloseAll(); 13033551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)} 13043551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 13052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, 13062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ExpandCollapsedTopPanelOnBottomPanelClose) { 13072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 13082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 13092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 2 stacked panels. 13102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack = panel_manager->CreateStack(); 13112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel1_initial_bounds = gfx::Rect(100, 50, 200, 150); 13122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel1 = CreateStackedPanel("1", panel1_initial_bounds, stack); 13132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel2_initial_bounds = gfx::Rect(0, 0, 150, 100); 13142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel2 = CreateStackedPanel("2", panel2_initial_bounds, stack); 13152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, panel_manager->num_panels()); 13162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 13172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, stack->num_panels()); 13182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 13192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Collapse top panel. 13203551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) int original_panel1_height = panel1->GetBounds().height(); 13212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel1->Minimize(); 13222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel2); 13232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel1->IsMinimized()); 13242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2->IsMinimized()); 13252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 13262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Close bottom panel. Expect that top panel should become detached and 13272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // expanded. 13282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CloseWindowAndWait(panel2); 13292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel1); 13302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(1, panel_manager->num_panels()); 13312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(0, panel_manager->num_stacks()); 13322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(PanelCollection::DETACHED, panel1->collection()->type()); 13332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel1->IsMinimized()); 13342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state()); 13353551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) EXPECT_EQ(original_panel1_height, panel1->GetBounds().height()); 13362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 13372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 13382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 13392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1340c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// The activation waiting logic does not work well on MacOSX. Disabled for now. 1341c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#if defined(OS_MACOSX) 1342c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#define MAYBE_FocusCollapsedStackedPanel DISABLED_FocusCollapsedStackedPanel 1343c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#else 1344c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#define MAYBE_FocusCollapsedStackedPanel FocusCollapsedStackedPanel 1345c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#endif 1346c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, 1347c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) MAYBE_FocusCollapsedStackedPanel) { 13482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 13492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 13502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create 2 stacked panels. 13512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack = panel_manager->CreateStack(); 13522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel1_initial_bounds = gfx::Rect(100, 50, 200, 150); 1353c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CreateStackedPanel("1", panel1_initial_bounds, stack); 13542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect panel2_initial_bounds = gfx::Rect(0, 0, 150, 100); 13552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel2 = CreateStackedPanel("2", panel2_initial_bounds, stack); 13562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, panel_manager->num_panels()); 13572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 13582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(2, stack->num_panels()); 13592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 13602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Collapse a panel. 13612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2->Minimize(); 13622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForBoundsAnimationFinished(panel2); 13632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel2->IsMinimized()); 13642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2->IsActive()); 13652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 13662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Focus the panel. Expect the panel is expanded. 13672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel2->Activate(); 13682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE); 13692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel2->IsMinimized()); 13702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 13712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 13722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 13732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 13742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, 13752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) UpdateStackedPanelsOnPrimaryDisplayChange) { 13762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 13772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 13782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Create one stack with 5 panels. 13792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StackedPanelCollection* stack = panel_manager->CreateStack(); 13802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel1 = CreateStackedPanel("1", gfx::Rect(50, 50, 700, 100), stack); 13812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel2 = CreateStackedPanel("2", gfx::Rect(0, 0, 100, 100), stack); 13822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel3 = CreateStackedPanel("3", gfx::Rect(0, 0, 100, 100), stack); 13832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel4 = CreateStackedPanel("4", gfx::Rect(0, 0, 100, 100), stack); 13842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Panel* panel5 = CreateStackedPanel("5", gfx::Rect(0, 0, 100, 100), stack); 13852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(5, panel_manager->num_panels()); 13862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(1, panel_manager->num_stacks()); 13872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_EQ(5, stack->num_panels()); 13882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 13892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Make the primary display smaller. 13902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Expect that all panels except P5 should be collapsed and their bounds 13912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // should be updated. 1392c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) int new_primary_area_width = 500; 1393c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) gfx::Rect primary_display_area(0, 0, new_primary_area_width, 300); 1394c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) gfx::Rect primary_work_area(0, 0, new_primary_area_width, 280); 13952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) mock_display_settings_provider()->SetPrimaryDisplay( 13962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) primary_display_area, primary_work_area); 1397c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) WaitForBoundsAnimationFinished(panel1); 1398c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) WaitForBoundsAnimationFinished(panel2); 1399c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) WaitForBoundsAnimationFinished(panel3); 1400c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) WaitForBoundsAnimationFinished(panel4); 1401c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) WaitForBoundsAnimationFinished(panel5); 14022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 14032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel1->IsMinimized()); 14042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel2->IsMinimized()); 14052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel3->IsMinimized()); 14062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(panel4->IsMinimized()); 14072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(panel5->IsMinimized()); 14082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 14092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds1 = panel1->GetBounds(); 1410c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_EQ(primary_work_area.x(), bounds1.x()); 14112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_LE(bounds1.x(), primary_work_area.right()); 14122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_LE(primary_work_area.y(), bounds1.y()); 1413c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_EQ(new_primary_area_width, bounds1.width()); 14142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 14152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds2 = panel2->GetBounds(); 14162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(bounds1.x(), bounds2.x()); 14172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(bounds1.width(), bounds2.width()); 14182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(bounds1.bottom(), bounds2.y()); 14192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 14202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds3 = panel3->GetBounds(); 14212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(bounds2.x(), bounds3.x()); 14222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(bounds2.width(), bounds3.width()); 14232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(bounds2.bottom(), bounds3.y()); 14242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 14252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds4 = panel4->GetBounds(); 14262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(bounds3.x(), bounds4.x()); 14272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(bounds3.width(), bounds4.width()); 14282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(bounds3.bottom(), bounds4.y()); 14292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 14302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect bounds5 = panel5->GetBounds(); 14312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(bounds4.x(), bounds5.x()); 14322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(bounds4.width(), bounds5.width()); 14332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(bounds4.bottom(), bounds5.y()); 14342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_LE(bounds5.bottom(), primary_work_area.bottom()); 14352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 14362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) panel_manager->CloseAll(); 14372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 143868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) 143968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, 144068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) KeepShowingStackedPanelCreatedBeforeFullScreenMode) { 144168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) PanelManager* panel_manager = PanelManager::GetInstance(); 144268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) 144368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) // Create 2 stacked panels. 144468043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) StackedPanelCollection* stack = panel_manager->CreateStack(); 144568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) Panel* panel1 = CreateStackedPanel("1", gfx::Rect(100, 50, 200, 150), stack); 144668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) Panel* panel2 = CreateStackedPanel("2", gfx::Rect(0, 0, 150, 100), stack); 144768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) scoped_ptr<NativePanelTesting> panel1_testing( 144868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) CreateNativePanelTesting(panel1)); 144968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) scoped_ptr<NativePanelTesting> panel2_testing( 145068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) CreateNativePanelTesting(panel2)); 145168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) 145268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) // Panels should be visible at first. 145368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) EXPECT_TRUE(panel1_testing->IsWindowVisible()); 145468043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) EXPECT_TRUE(panel2_testing->IsWindowVisible()); 145568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) 1456f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // Panels' visibility should not be affected when entering full-screen mode. 145768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) mock_display_settings_provider()->EnableFullScreenMode(true); 145868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) EXPECT_TRUE(panel1_testing->IsWindowVisible()); 145968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) EXPECT_TRUE(panel2_testing->IsWindowVisible()); 146068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) 146168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) // Panels' visibility should not be affected when leaving full-screen mode. 146268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) mock_display_settings_provider()->EnableFullScreenMode(false); 146368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) EXPECT_TRUE(panel1_testing->IsWindowVisible()); 146468043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) EXPECT_TRUE(panel2_testing->IsWindowVisible()); 146568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) 146668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) panel_manager->CloseAll(); 146768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)} 1468