This source file includes following definitions.
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/panels/base_panel_browser_test.h"
#include "chrome/browser/ui/panels/detached_panel_collection.h"
#include "chrome/browser/ui/panels/docked_panel_collection.h"
#include "chrome/browser/ui/panels/native_panel.h"
#include "chrome/browser/ui/panels/panel.h"
#include "chrome/browser/ui/panels/panel_manager.h"
#include "chrome/browser/ui/panels/stacked_panel_collection.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_utils.h"
class StackedPanelBrowserTest : public BasePanelBrowserTest {
};
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, CheckStackedPanelProperties) {
PanelManager* panel_manager = PanelManager::GetInstance();
StackedPanelCollection* stack = panel_manager->CreateStack();
gfx::Rect panel1_initial_bounds = gfx::Rect(100, 50, 200, 150);
Panel* panel1 = CreateStackedPanel("1", panel1_initial_bounds, stack);
gfx::Rect panel2_initial_bounds = gfx::Rect(0, 0, 150, 100);
Panel* panel2 = CreateStackedPanel("2", panel2_initial_bounds, stack);
gfx::Rect panel3_initial_bounds = gfx::Rect(0, 0, 120, 110);
Panel* panel3 = CreateStackedPanel("3", panel3_initial_bounds, stack);
scoped_ptr<NativePanelTesting> panel1_testing(
CreateNativePanelTesting(panel1));
scoped_ptr<NativePanelTesting> panel2_testing(
CreateNativePanelTesting(panel2));
scoped_ptr<NativePanelTesting> panel3_testing(
CreateNativePanelTesting(panel3));
ASSERT_EQ(0, panel_manager->docked_collection()->num_panels());
ASSERT_EQ(0, panel_manager->detached_collection()->num_panels());
ASSERT_EQ(1, panel_manager->num_stacks());
ASSERT_EQ(3, stack->num_panels());
EXPECT_EQ(stack, panel1->stack());
EXPECT_EQ(stack, panel2->stack());
EXPECT_EQ(stack, panel3->stack());
EXPECT_TRUE(panel1_testing->IsButtonVisible(panel::CLOSE_BUTTON));
EXPECT_TRUE(panel2_testing->IsButtonVisible(panel::CLOSE_BUTTON));
EXPECT_TRUE(panel3_testing->IsButtonVisible(panel::CLOSE_BUTTON));
if (PanelManager::CanUseSystemMinimize())
EXPECT_TRUE(panel1_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
else
EXPECT_FALSE(panel1_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
EXPECT_FALSE(panel2_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
EXPECT_FALSE(panel3_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
EXPECT_FALSE(panel1_testing->IsButtonVisible(panel::RESTORE_BUTTON));
EXPECT_FALSE(panel2_testing->IsButtonVisible(panel::RESTORE_BUTTON));
EXPECT_FALSE(panel3_testing->IsButtonVisible(panel::RESTORE_BUTTON));
gfx::Rect panel1_expected_bounds(panel1_initial_bounds);
EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds());
gfx::Rect panel2_expected_bounds(panel1_expected_bounds.x(),
panel1_expected_bounds.bottom(),
panel1_expected_bounds.width(),
panel2_initial_bounds.height());
EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds());
gfx::Rect panel3_expected_bounds(panel2_expected_bounds.x(),
panel2_expected_bounds.bottom(),
panel2_expected_bounds.width(),
panel3_initial_bounds.height());
EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds());
EXPECT_FALSE(panel1->IsAlwaysOnTop());
EXPECT_FALSE(panel2->IsAlwaysOnTop());
EXPECT_FALSE(panel3->IsAlwaysOnTop());
EXPECT_FALSE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
EXPECT_FALSE(panel3->IsMinimized());
EXPECT_EQ(panel::RESIZABLE_LEFT | panel::RESIZABLE_RIGHT |
panel::RESIZABLE_TOP | panel::RESIZABLE_TOP_LEFT |
panel::RESIZABLE_TOP_RIGHT | panel::RESIZABLE_BOTTOM,
panel1->CanResizeByMouse());
EXPECT_EQ(panel::RESIZABLE_LEFT | panel::RESIZABLE_RIGHT |
panel::RESIZABLE_BOTTOM,
panel2->CanResizeByMouse());
EXPECT_EQ(panel::RESIZABLE_LEFT | panel::RESIZABLE_RIGHT |
panel::RESIZABLE_BOTTOM | panel::RESIZABLE_BOTTOM_LEFT |
panel::RESIZABLE_BOTTOM_RIGHT,
panel3->CanResizeByMouse());
EXPECT_EQ(panel::TOP_ROUNDED, panel1_testing->GetWindowCornerStyle());
EXPECT_EQ(panel::NOT_ROUNDED, panel2_testing->GetWindowCornerStyle());
EXPECT_EQ(panel::BOTTOM_ROUNDED, panel3_testing->GetWindowCornerStyle());
Panel::AttentionMode expected_attention_mode =
static_cast<Panel::AttentionMode>(Panel::USE_PANEL_ATTENTION |
Panel::USE_SYSTEM_ATTENTION);
EXPECT_EQ(expected_attention_mode, panel1->attention_mode());
EXPECT_EQ(expected_attention_mode, panel2->attention_mode());
EXPECT_EQ(expected_attention_mode, panel3->attention_mode());
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest,
CheckMinimizedStackedPanelProperties) {
PanelManager* panel_manager = PanelManager::GetInstance();
StackedPanelCollection* stack = panel_manager->CreateStack();
gfx::Rect panel1_initial_bounds = gfx::Rect(100, 50, 200, 150);
Panel* panel1 = CreateStackedPanel("1", panel1_initial_bounds, stack);
gfx::Rect panel2_initial_bounds = gfx::Rect(0, 0, 150, 100);
Panel* panel2 = CreateStackedPanel("2", panel2_initial_bounds, stack);
gfx::Rect panel3_initial_bounds = gfx::Rect(0, 0, 120, 110);
Panel* panel3 = CreateStackedPanel("3", panel3_initial_bounds, stack);
scoped_ptr<NativePanelTesting> panel1_testing(
CreateNativePanelTesting(panel1));
scoped_ptr<NativePanelTesting> panel2_testing(
CreateNativePanelTesting(panel2));
scoped_ptr<NativePanelTesting> panel3_testing(
CreateNativePanelTesting(panel3));
panel1->Minimize();
WaitForBoundsAnimationFinished(panel1);
panel2->Minimize();
WaitForBoundsAnimationFinished(panel2);
panel3->Minimize();
WaitForBoundsAnimationFinished(panel3);
ASSERT_EQ(0, panel_manager->docked_collection()->num_panels());
ASSERT_EQ(0, panel_manager->detached_collection()->num_panels());
ASSERT_EQ(1, panel_manager->num_stacks());
ASSERT_EQ(3, stack->num_panels());
EXPECT_EQ(stack, panel1->stack());
EXPECT_EQ(stack, panel2->stack());
EXPECT_EQ(stack, panel3->stack());
EXPECT_TRUE(panel1_testing->IsButtonVisible(panel::CLOSE_BUTTON));
EXPECT_TRUE(panel2_testing->IsButtonVisible(panel::CLOSE_BUTTON));
EXPECT_TRUE(panel3_testing->IsButtonVisible(panel::CLOSE_BUTTON));
if (PanelManager::CanUseSystemMinimize())
EXPECT_TRUE(panel1_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
else
EXPECT_FALSE(panel1_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
EXPECT_FALSE(panel2_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
EXPECT_FALSE(panel3_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
EXPECT_FALSE(panel1_testing->IsButtonVisible(panel::RESTORE_BUTTON));
EXPECT_FALSE(panel2_testing->IsButtonVisible(panel::RESTORE_BUTTON));
EXPECT_FALSE(panel3_testing->IsButtonVisible(panel::RESTORE_BUTTON));
gfx::Rect panel1_expected_bounds(panel1_initial_bounds);
panel1_expected_bounds.set_height(panel1->TitleOnlyHeight());
EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds());
gfx::Rect panel2_expected_bounds(panel1_expected_bounds.x(),
panel1_expected_bounds.bottom(),
panel1_expected_bounds.width(),
panel2->TitleOnlyHeight());
EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds());
gfx::Rect panel3_expected_bounds(panel2_expected_bounds.x(),
panel2_expected_bounds.bottom(),
panel2_expected_bounds.width(),
panel3->TitleOnlyHeight());
EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds());
EXPECT_FALSE(panel1->IsAlwaysOnTop());
EXPECT_FALSE(panel2->IsAlwaysOnTop());
EXPECT_FALSE(panel3->IsAlwaysOnTop());
EXPECT_TRUE(panel1->IsMinimized());
EXPECT_TRUE(panel2->IsMinimized());
EXPECT_TRUE(panel3->IsMinimized());
EXPECT_EQ(panel::RESIZABLE_LEFT | panel::RESIZABLE_RIGHT,
panel1->CanResizeByMouse());
EXPECT_EQ(panel::RESIZABLE_LEFT | panel::RESIZABLE_RIGHT,
panel2->CanResizeByMouse());
EXPECT_EQ(panel::RESIZABLE_LEFT | panel::RESIZABLE_RIGHT,
panel3->CanResizeByMouse());
EXPECT_EQ(panel::TOP_ROUNDED, panel1_testing->GetWindowCornerStyle());
EXPECT_EQ(panel::NOT_ROUNDED, panel2_testing->GetWindowCornerStyle());
EXPECT_EQ(panel::BOTTOM_ROUNDED, panel3_testing->GetWindowCornerStyle());
Panel::AttentionMode expected_attention_mode =
static_cast<Panel::AttentionMode>(Panel::USE_PANEL_ATTENTION |
Panel::USE_SYSTEM_ATTENTION);
EXPECT_EQ(expected_attention_mode, panel1->attention_mode());
EXPECT_EQ(expected_attention_mode, panel2->attention_mode());
EXPECT_EQ(expected_attention_mode, panel3->attention_mode());
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, ClickTitlebar) {
PanelManager* panel_manager = PanelManager::GetInstance();
StackedPanelCollection* stack = panel_manager->CreateStack();
gfx::Rect panel1_initial_bounds = gfx::Rect(100, 50, 200, 150);
Panel* panel1 = CreateStackedPanel("1", panel1_initial_bounds, stack);
gfx::Rect panel2_initial_bounds = gfx::Rect(0, 0, 150, 100);
Panel* panel2 = CreateStackedPanel("2", panel2_initial_bounds, stack);
ASSERT_EQ(1, panel_manager->num_stacks());
scoped_ptr<NativePanelTesting> panel1_testing(
CreateNativePanelTesting(panel1));
scoped_ptr<NativePanelTesting> panel2_testing(
CreateNativePanelTesting(panel2));
gfx::Point panel1_origin = panel2->GetBounds().origin();
gfx::Point panel2_origin = panel2->GetBounds().origin();
EXPECT_FALSE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
gfx::Rect panel1_expected_bounds(panel1_initial_bounds);
EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds());
gfx::Rect panel2_expected_bounds(panel1_expected_bounds.x(),
panel1_expected_bounds.bottom(),
panel1_expected_bounds.width(),
panel2_initial_bounds.height());
EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds());
panel2_testing->PressLeftMouseButtonTitlebar(panel2_origin);
panel2_testing->ReleaseMouseButtonTitlebar();
WaitForBoundsAnimationFinished(panel2);
EXPECT_FALSE(panel1->IsMinimized());
EXPECT_TRUE(panel2->IsMinimized());
EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds());
panel2_expected_bounds.set_height(panel2->TitleOnlyHeight());
EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds());
panel2_testing->PressLeftMouseButtonTitlebar(panel2_origin);
panel2_testing->ReleaseMouseButtonTitlebar();
WaitForBoundsAnimationFinished(panel2);
EXPECT_FALSE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds());
panel2_expected_bounds.set_height(panel2_initial_bounds.height());
EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds());
panel2_testing->PressLeftMouseButtonTitlebar(panel2_origin,
panel::APPLY_TO_ALL);
panel2_testing->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL);
WaitForBoundsAnimationFinished(panel1);
WaitForBoundsAnimationFinished(panel2);
EXPECT_TRUE(panel1->IsMinimized());
EXPECT_TRUE(panel2->IsMinimized());
panel1_expected_bounds.set_height(panel1->TitleOnlyHeight());
EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds());
panel2_expected_bounds.set_y(panel1_expected_bounds.bottom());
panel2_expected_bounds.set_height(panel2->TitleOnlyHeight());
EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds());
panel1_testing->PressLeftMouseButtonTitlebar(panel1_origin,
panel::APPLY_TO_ALL);
panel1_testing->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL);
WaitForBoundsAnimationFinished(panel1);
WaitForBoundsAnimationFinished(panel2);
EXPECT_FALSE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
panel1_expected_bounds.set_height(panel1_initial_bounds.height());
EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds());
panel2_expected_bounds.set_y(panel1_expected_bounds.bottom());
panel2_expected_bounds.set_height(panel2_initial_bounds.height());
EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds());
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, CallMinimizeAndRestoreApi) {
PanelManager* panel_manager = PanelManager::GetInstance();
StackedPanelCollection* stack = panel_manager->CreateStack();
gfx::Rect panel1_initial_bounds = gfx::Rect(100, 50, 200, 150);
Panel* panel1 = CreateStackedPanel("1", panel1_initial_bounds, stack);
gfx::Rect panel2_initial_bounds = gfx::Rect(0, 0, 150, 100);
Panel* panel2 = CreateStackedPanel("2", panel2_initial_bounds, stack);
ASSERT_EQ(1, panel_manager->num_stacks());
EXPECT_FALSE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
gfx::Rect panel1_expected_bounds(panel1_initial_bounds);
EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds());
gfx::Rect panel2_expected_bounds(panel1_expected_bounds.x(),
panel1_expected_bounds.bottom(),
panel1_expected_bounds.width(),
panel2_initial_bounds.height());
EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds());
panel1->Minimize();
WaitForBoundsAnimationFinished(panel1);
EXPECT_TRUE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
panel1_expected_bounds.set_height(panel1->TitleOnlyHeight());
EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds());
panel2_expected_bounds.set_y(panel1_expected_bounds.bottom());
EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds());
panel1->Restore();
WaitForBoundsAnimationFinished(panel1);
EXPECT_FALSE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
panel1_expected_bounds.set_height(panel1_initial_bounds.height());
EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds());
panel2_expected_bounds.set_y(panel1_expected_bounds.bottom());
EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds());
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, ExpandToFitWithinScreen) {
PanelManager* panel_manager = PanelManager::GetInstance();
gfx::Rect work_area =
panel_manager->display_settings_provider()->GetPrimaryWorkArea();
StackedPanelCollection* stack = panel_manager->CreateStack();
Panel* panel1 = CreateStackedPanel("1", gfx::Rect(100, 90, 200, 150), stack);
Panel* panel2 = CreateStackedPanel("2", gfx::Rect(0, 0, 150, 100), stack);
Panel* panel3 = CreateStackedPanel("3", gfx::Rect(0, 0, 150, 120), stack);
Panel* panel4 = CreateStackedPanel("4", gfx::Rect(0, 0, 150, 100), stack);
ASSERT_EQ(4, stack->num_panels());
ASSERT_FALSE(panel1->IsMinimized());
ASSERT_FALSE(panel2->IsMinimized());
ASSERT_FALSE(panel3->IsMinimized());
ASSERT_FALSE(panel4->IsMinimized());
EXPECT_LE(panel4->GetBounds().bottom(), work_area.bottom());
int old_stack_top_position = panel1->GetBounds().y();
panel2->Minimize();
WaitForBoundsAnimationFinished(panel2);
ASSERT_FALSE(panel1->IsMinimized());
ASSERT_TRUE(panel2->IsMinimized());
ASSERT_FALSE(panel3->IsMinimized());
ASSERT_FALSE(panel4->IsMinimized());
gfx::Size panel2_full_size = panel2->full_size();
panel2_full_size.set_height(panel2_full_size.height() + 30);
panel2->set_full_size(panel2_full_size);
panel2->Restore();
WaitForBoundsAnimationFinished(panel2);
WaitForBoundsAnimationFinished(panel3);
WaitForBoundsAnimationFinished(panel4);
ASSERT_TRUE(panel1->IsMinimized());
ASSERT_FALSE(panel2->IsMinimized());
ASSERT_FALSE(panel3->IsMinimized());
ASSERT_FALSE(panel4->IsMinimized());
EXPECT_EQ(old_stack_top_position, panel1->GetBounds().y());
EXPECT_LE(panel4->GetBounds().bottom(), work_area.bottom());
EXPECT_EQ(panel2->GetBounds().height(), panel2_full_size.height());
gfx::Size panel1_full_size = panel1->full_size();
panel1_full_size.set_height(panel1_full_size.height() + 180);
panel1->set_full_size(panel1_full_size);
panel1->Restore();
WaitForBoundsAnimationFinished(panel1);
WaitForBoundsAnimationFinished(panel2);
WaitForBoundsAnimationFinished(panel3);
WaitForBoundsAnimationFinished(panel4);
ASSERT_FALSE(panel1->IsMinimized());
ASSERT_TRUE(panel2->IsMinimized());
ASSERT_TRUE(panel3->IsMinimized());
ASSERT_FALSE(panel4->IsMinimized());
EXPECT_LT(panel1->GetBounds().y(), old_stack_top_position);
EXPECT_GE(panel1->GetBounds().y(), work_area.y());
EXPECT_LE(panel4->GetBounds().bottom(), work_area.bottom());
EXPECT_EQ(panel1->GetBounds().height(), panel1_full_size.height());
old_stack_top_position = panel1->GetBounds().y();
panel3->Restore();
WaitForBoundsAnimationFinished(panel1);
WaitForBoundsAnimationFinished(panel2);
WaitForBoundsAnimationFinished(panel3);
WaitForBoundsAnimationFinished(panel4);
ASSERT_TRUE(panel1->IsMinimized());
ASSERT_TRUE(panel2->IsMinimized());
ASSERT_FALSE(panel3->IsMinimized());
ASSERT_FALSE(panel4->IsMinimized());
EXPECT_EQ(old_stack_top_position, panel1->GetBounds().y());
EXPECT_LE(panel4->GetBounds().bottom(), work_area.bottom());
panel2_full_size = panel2->full_size();
panel2_full_size.set_height(panel2_full_size.height() + 500);
panel2->set_full_size(panel2_full_size);
panel2->Restore();
WaitForBoundsAnimationFinished(panel1);
WaitForBoundsAnimationFinished(panel2);
WaitForBoundsAnimationFinished(panel3);
WaitForBoundsAnimationFinished(panel4);
EXPECT_TRUE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
EXPECT_TRUE(panel3->IsMinimized());
EXPECT_FALSE(panel4->IsMinimized());
EXPECT_EQ(panel1->GetBounds().y(), work_area.y());
EXPECT_EQ(panel4->GetBounds().bottom(), work_area.bottom());
EXPECT_LT(panel2->GetBounds().height(), panel2_full_size.height());
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, ExpandAllToFitWithinScreen) {
PanelManager* panel_manager = PanelManager::GetInstance();
gfx::Rect work_area =
panel_manager->display_settings_provider()->GetPrimaryWorkArea();
StackedPanelCollection* stack = panel_manager->CreateStack();
Panel* panel1 = CreateStackedPanel("1", gfx::Rect(100, 150, 200, 200), stack);
Panel* panel2 = CreateStackedPanel("2", gfx::Rect(0, 0, 150, 100), stack);
Panel* panel3 = CreateStackedPanel("3", gfx::Rect(0, 0, 150, 120), stack);
ASSERT_EQ(3, stack->num_panels());
scoped_ptr<NativePanelTesting> panel2_testing(
CreateNativePanelTesting(panel2));
panel2_testing->PressLeftMouseButtonTitlebar(panel2->GetBounds().origin(),
panel::APPLY_TO_ALL);
panel2_testing->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL);
WaitForBoundsAnimationFinished(panel1);
WaitForBoundsAnimationFinished(panel2);
WaitForBoundsAnimationFinished(panel3);
ASSERT_TRUE(panel1->IsMinimized());
ASSERT_TRUE(panel2->IsMinimized());
ASSERT_TRUE(panel3->IsMinimized());
gfx::Size panel2_full_size = panel2->full_size();
panel2_full_size.set_height(panel2_full_size.height() + 500);
panel2->set_full_size(panel2_full_size);
panel2_testing->PressLeftMouseButtonTitlebar(panel2->GetBounds().origin(),
panel::APPLY_TO_ALL);
panel2_testing->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL);
WaitForBoundsAnimationFinished(panel1);
WaitForBoundsAnimationFinished(panel2);
WaitForBoundsAnimationFinished(panel3);
EXPECT_TRUE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
EXPECT_TRUE(panel3->IsMinimized());
EXPECT_EQ(panel1->GetBounds().y(), work_area.y());
EXPECT_EQ(panel3->GetBounds().bottom(), work_area.bottom());
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, MinimizeButtonVisibility) {
PanelManager* panel_manager = PanelManager::GetInstance();
StackedPanelCollection* stack = panel_manager->CreateStack();
gfx::Rect panel1_initial_bounds = gfx::Rect(100, 50, 200, 150);
Panel* panel1 = CreateStackedPanel("1", panel1_initial_bounds, stack);
gfx::Rect panel2_initial_bounds = gfx::Rect(0, 0, 150, 100);
Panel* panel2 = CreateStackedPanel("2", panel2_initial_bounds, stack);
gfx::Rect panel3_initial_bounds = gfx::Rect(0, 0, 250, 120);
Panel* panel3 = CreateStackedPanel("3", panel3_initial_bounds, stack);
ASSERT_EQ(1, panel_manager->num_stacks());
ASSERT_EQ(3, stack->num_panels());
scoped_ptr<NativePanelTesting> panel1_testing(
CreateNativePanelTesting(panel1));
scoped_ptr<NativePanelTesting> panel2_testing(
CreateNativePanelTesting(panel2));
scoped_ptr<NativePanelTesting> panel3_testing(
CreateNativePanelTesting(panel3));
if (PanelManager::CanUseSystemMinimize())
EXPECT_TRUE(panel1_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
else
EXPECT_FALSE(panel1_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
EXPECT_FALSE(panel2_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
EXPECT_FALSE(panel3_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
gfx::Point mouse_location(panel2->GetBounds().origin());
panel2_testing->PressLeftMouseButtonTitlebar(mouse_location);
gfx::Vector2d drag_delta_to_unstack(120, 50);
panel2_testing->DragTitlebar(mouse_location + drag_delta_to_unstack);
panel2_testing->FinishDragTitlebar();
ASSERT_EQ(1, panel_manager->detached_collection()->num_panels());
ASSERT_EQ(1, panel_manager->num_stacks());
ASSERT_EQ(2, stack->num_panels());
if (PanelManager::CanUseSystemMinimize()) {
EXPECT_TRUE(panel1_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
EXPECT_TRUE(panel2_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
} else {
EXPECT_FALSE(panel1_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
EXPECT_FALSE(panel2_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
}
EXPECT_FALSE(panel3_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
gfx::Rect bounds1 = panel1->GetBounds();
gfx::Rect bounds2 = panel2->GetBounds();
mouse_location = bounds1.origin();
panel1_testing->PressLeftMouseButtonTitlebar(mouse_location);
gfx::Vector2d drag_delta_to_stack(bounds2.x() - bounds1.x(),
bounds2.y() - bounds1.bottom());
panel1_testing->DragTitlebar(mouse_location + drag_delta_to_stack);
panel1_testing->FinishDragTitlebar();
ASSERT_EQ(0, panel_manager->detached_collection()->num_panels());
ASSERT_EQ(1, panel_manager->num_stacks());
ASSERT_EQ(3, stack->num_panels());
if (PanelManager::CanUseSystemMinimize())
EXPECT_TRUE(panel1_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
else
EXPECT_FALSE(panel1_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
EXPECT_FALSE(panel2_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
EXPECT_FALSE(panel3_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, DISABLED_ClickMinimizeButton) {
PanelManager* panel_manager = PanelManager::GetInstance();
StackedPanelCollection* stack = panel_manager->CreateStack();
gfx::Rect panel1_initial_bounds = gfx::Rect(100, 50, 200, 150);
Panel* panel1 = CreateStackedPanel("1", panel1_initial_bounds, stack);
gfx::Rect panel2_initial_bounds = gfx::Rect(0, 0, 150, 100);
Panel* panel2 = CreateStackedPanel("2", panel2_initial_bounds, stack);
ASSERT_EQ(1, panel_manager->num_stacks());
scoped_ptr<NativePanelTesting> panel1_testing(
CreateNativePanelTesting(panel1));
EXPECT_FALSE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
panel1->OnMinimizeButtonClicked(panel::NO_MODIFIER);
EXPECT_FALSE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
EXPECT_TRUE(panel1_testing->VerifySystemMinimizeState());
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, UngroupMinimizedPanels) {
PanelManager* panel_manager = PanelManager::GetInstance();
StackedPanelCollection* stack = panel_manager->CreateStack();
gfx::Rect panel1_initial_bounds = gfx::Rect(100, 50, 200, 150);
Panel* panel1 = CreateStackedPanel("1", panel1_initial_bounds, stack);
gfx::Rect panel2_initial_bounds = gfx::Rect(0, 0, 150, 100);
Panel* panel2 = CreateStackedPanel("2", panel2_initial_bounds, stack);
gfx::Rect panel3_initial_bounds = gfx::Rect(0, 0, 250, 120);
Panel* panel3 = CreateStackedPanel("3", panel3_initial_bounds, stack);
ASSERT_EQ(1, panel_manager->num_stacks());
ASSERT_EQ(3, stack->num_panels());
scoped_ptr<NativePanelTesting> panel2_testing(
CreateNativePanelTesting(panel2));
scoped_ptr<NativePanelTesting> panel3_testing(
CreateNativePanelTesting(panel3));
panel1->Minimize();
WaitForBoundsAnimationFinished(panel1);
panel2->Minimize();
WaitForBoundsAnimationFinished(panel3);
panel3->Minimize();
WaitForBoundsAnimationFinished(panel3);
EXPECT_TRUE(panel1->IsMinimized());
EXPECT_TRUE(panel2->IsMinimized());
EXPECT_TRUE(panel3->IsMinimized());
gfx::Rect panel1_expected_bounds(panel1_initial_bounds);
panel1_expected_bounds.set_height(panel1->TitleOnlyHeight());
EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds());
gfx::Rect panel2_expected_bounds(panel1_expected_bounds.x(),
panel1_expected_bounds.bottom(),
panel1_expected_bounds.width(),
panel2->TitleOnlyHeight());
EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds());
gfx::Rect panel3_expected_bounds(panel2_expected_bounds.x(),
panel2_expected_bounds.bottom(),
panel2_expected_bounds.width(),
panel3->TitleOnlyHeight());
EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds());
gfx::Point mouse_location(panel2->GetBounds().origin());
panel2_testing->PressLeftMouseButtonTitlebar(mouse_location);
gfx::Vector2d drag_delta(120, 50);
panel2_testing->DragTitlebar(mouse_location + drag_delta);
panel2_testing->FinishDragTitlebar();
WaitForBoundsAnimationFinished(panel1);
ASSERT_EQ(1, panel_manager->detached_collection()->num_panels());
ASSERT_EQ(1, panel_manager->num_stacks());
ASSERT_EQ(2, stack->num_panels());
EXPECT_FALSE(panel1->IsMinimized());
EXPECT_TRUE(panel2->IsMinimized());
EXPECT_TRUE(panel3->IsMinimized());
panel1_expected_bounds.set_height(panel1_initial_bounds.height());
EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds());
panel2_expected_bounds.Offset(drag_delta);
EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds());
panel3_expected_bounds.Offset(drag_delta);
EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds());
mouse_location = panel3->GetBounds().origin();
panel3_testing->PressLeftMouseButtonTitlebar(mouse_location);
panel3_testing->DragTitlebar(mouse_location + drag_delta);
panel3_testing->FinishDragTitlebar();
WaitForBoundsAnimationFinished(panel2);
WaitForBoundsAnimationFinished(panel3);
ASSERT_EQ(3, panel_manager->detached_collection()->num_panels());
ASSERT_EQ(0, panel_manager->num_stacks());
EXPECT_FALSE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
EXPECT_FALSE(panel3->IsMinimized());
EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds());
panel2_expected_bounds.set_height(panel2_initial_bounds.height());
EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds());
panel3_expected_bounds.Offset(drag_delta);
panel3_expected_bounds.set_height(panel3_initial_bounds.height());
EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds());
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest,
AddNewPanelToStackWithMostPanels) {
PanelManager* panel_manager = PanelManager::GetInstance();
StackedPanelCollection* stack1 = panel_manager->CreateStack();
CreateStackedPanel("1", gfx::Rect(200, 50, 200, 150), stack1);
CreateStackedPanel("2", gfx::Rect(0, 0, 150, 100), stack1);
ASSERT_EQ(2, panel_manager->num_panels());
ASSERT_EQ(1, panel_manager->num_stacks());
ASSERT_EQ(2, stack1->num_panels());
StackedPanelCollection* stack2 = panel_manager->CreateStack();
CreateStackedPanel("3", gfx::Rect(100, 50, 200, 150), stack2);
CreateStackedPanel("4", gfx::Rect(0, 0, 150, 100), stack2);
CreateStackedPanel("5", gfx::Rect(0, 0, 250, 120), stack2);
ASSERT_EQ(5, panel_manager->num_panels());
ASSERT_EQ(2, panel_manager->num_stacks());
ASSERT_EQ(3, stack2->num_panels());
CreatePanelParams params("N", gfx::Rect(50, 50, 150, 100), SHOW_AS_ACTIVE);
params.create_mode = PanelManager::CREATE_AS_DETACHED;
Panel* new_panel = CreatePanelWithParams(params);
EXPECT_EQ(6, panel_manager->num_panels());
EXPECT_EQ(2, panel_manager->num_stacks());
EXPECT_EQ(2, stack1->num_panels());
EXPECT_EQ(4, stack2->num_panels());
EXPECT_TRUE(stack2->HasPanel(new_panel));
EXPECT_TRUE(new_panel == stack2->bottom_panel());
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest,
AddNewPanelToRightMostStack) {
PanelManager* panel_manager = PanelManager::GetInstance();
StackedPanelCollection* stack1 = panel_manager->CreateStack();
CreateStackedPanel("1", gfx::Rect(100, 50, 200, 150), stack1);
CreateStackedPanel("2", gfx::Rect(0, 0, 150, 100), stack1);
ASSERT_EQ(2, panel_manager->num_panels());
ASSERT_EQ(1, panel_manager->num_stacks());
ASSERT_EQ(2, stack1->num_panels());
StackedPanelCollection* stack2 = panel_manager->CreateStack();
CreateStackedPanel("3", gfx::Rect(200, 50, 200, 150), stack2);
CreateStackedPanel("4", gfx::Rect(0, 0, 150, 100), stack2);
ASSERT_EQ(4, panel_manager->num_panels());
ASSERT_EQ(2, panel_manager->num_stacks());
ASSERT_EQ(2, stack2->num_panels());
CreatePanelParams params("N", gfx::Rect(50, 50, 150, 100), SHOW_AS_ACTIVE);
params.create_mode = PanelManager::CREATE_AS_DETACHED;
Panel* new_panel = CreatePanelWithParams(params);
EXPECT_EQ(5, panel_manager->num_panels());
EXPECT_EQ(2, panel_manager->num_stacks());
EXPECT_EQ(2, stack1->num_panels());
EXPECT_EQ(3, stack2->num_panels());
EXPECT_TRUE(stack2->HasPanel(new_panel));
EXPECT_TRUE(new_panel == stack2->bottom_panel());
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest,
AddNewPanelToTopMostStack) {
PanelManager* panel_manager = PanelManager::GetInstance();
StackedPanelCollection* stack1 = panel_manager->CreateStack();
CreateStackedPanel("1", gfx::Rect(100, 90, 200, 150), stack1);
CreateStackedPanel("2", gfx::Rect(0, 0, 150, 100), stack1);
ASSERT_EQ(2, panel_manager->num_panels());
ASSERT_EQ(1, panel_manager->num_stacks());
ASSERT_EQ(2, stack1->num_panels());
StackedPanelCollection* stack2 = panel_manager->CreateStack();
CreateStackedPanel("3", gfx::Rect(100, 50, 200, 150), stack2);
CreateStackedPanel("4", gfx::Rect(0, 0, 150, 100), stack2);
ASSERT_EQ(4, panel_manager->num_panels());
ASSERT_EQ(2, panel_manager->num_stacks());
ASSERT_EQ(2, stack2->num_panels());
CreatePanelParams params("N", gfx::Rect(50, 50, 150, 100), SHOW_AS_ACTIVE);
params.create_mode = PanelManager::CREATE_AS_DETACHED;
Panel* new_panel = CreatePanelWithParams(params);
EXPECT_EQ(5, panel_manager->num_panels());
EXPECT_EQ(2, panel_manager->num_stacks());
EXPECT_EQ(2, stack1->num_panels());
EXPECT_EQ(3, stack2->num_panels());
EXPECT_TRUE(stack2->HasPanel(new_panel));
EXPECT_TRUE(new_panel == stack2->bottom_panel());
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest,
AddNewPanelToGroupWithRightMostDetachedPanel) {
PanelManager* panel_manager = PanelManager::GetInstance();
CreateDetachedPanel("1", gfx::Rect(200, 50, 250, 150));
Panel* panel2 = CreateDetachedPanel("2", gfx::Rect(250, 100, 150, 100));
ASSERT_EQ(2, panel_manager->num_panels());
ASSERT_EQ(0, panel_manager->num_stacks());
ASSERT_EQ(2, panel_manager->detached_collection()->num_panels());
CreatePanelParams params("N", gfx::Rect(50, 50, 150, 100), SHOW_AS_ACTIVE);
params.create_mode = PanelManager::CREATE_AS_DETACHED;
Panel* new_panel = CreatePanelWithParams(params);
EXPECT_EQ(3, panel_manager->num_panels());
EXPECT_EQ(1, panel_manager->detached_collection()->num_panels());
ASSERT_EQ(1, panel_manager->num_stacks());
StackedPanelCollection* stack = panel_manager->stacks().front();
EXPECT_EQ(2, stack->num_panels());
EXPECT_TRUE(panel2 == stack->top_panel());
EXPECT_TRUE(new_panel == stack->bottom_panel());
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest,
AddNewPanelToGroupWitTopMostDetachedPanel) {
PanelManager* panel_manager = PanelManager::GetInstance();
CreateDetachedPanel("1", gfx::Rect(200, 100, 100, 150));
Panel* panel2 = CreateDetachedPanel("2", gfx::Rect(200, 50, 100, 100));
ASSERT_EQ(2, panel_manager->num_panels());
ASSERT_EQ(0, panel_manager->num_stacks());
ASSERT_EQ(2, panel_manager->detached_collection()->num_panels());
CreatePanelParams params("N", gfx::Rect(50, 50, 150, 100), SHOW_AS_ACTIVE);
params.create_mode = PanelManager::CREATE_AS_DETACHED;
Panel* new_panel = CreatePanelWithParams(params);
EXPECT_EQ(3, panel_manager->num_panels());
EXPECT_EQ(1, panel_manager->detached_collection()->num_panels());
ASSERT_EQ(1, panel_manager->num_stacks());
StackedPanelCollection* stack = panel_manager->stacks().front();
EXPECT_EQ(2, stack->num_panels());
EXPECT_TRUE(panel2 == stack->top_panel());
EXPECT_TRUE(new_panel == stack->bottom_panel());
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest,
AddNewPanelToStackWithCollapseToFit) {
PanelManager* panel_manager = PanelManager::GetInstance();
StackedPanelCollection* stack = panel_manager->CreateStack();
Panel* panel1 = CreateStackedPanel("1", gfx::Rect(100, 50, 200, 140), stack);
Panel* panel2 = CreateStackedPanel("2", gfx::Rect(0, 0, 150, 150), stack);
Panel* panel3 = CreateStackedPanel("3", gfx::Rect(0, 0, 180, 120), stack);
Panel* panel4 = CreateStackedPanel("4", gfx::Rect(0, 0, 170, 110), stack);
ASSERT_EQ(4, panel_manager->num_panels());
ASSERT_EQ(1, panel_manager->num_stacks());
ASSERT_EQ(4, stack->num_panels());
EXPECT_FALSE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
EXPECT_FALSE(panel3->IsMinimized());
EXPECT_FALSE(panel4->IsMinimized());
CreatePanelParams params1("M", gfx::Rect(50, 50, 300, 110), SHOW_AS_ACTIVE);
params1.create_mode = PanelManager::CREATE_AS_DETACHED;
Panel* new_panel1 = CreatePanelWithParams(params1);
EXPECT_EQ(5, panel_manager->num_panels());
EXPECT_EQ(1, panel_manager->num_stacks());
EXPECT_EQ(5, stack->num_panels());
EXPECT_TRUE(new_panel1 == stack->bottom_panel());
EXPECT_TRUE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
EXPECT_FALSE(panel3->IsMinimized());
EXPECT_FALSE(panel4->IsMinimized());
EXPECT_FALSE(new_panel1->IsMinimized());
CreatePanelParams params2("N", gfx::Rect(50, 50, 300, 180), SHOW_AS_ACTIVE);
params2.create_mode = PanelManager::CREATE_AS_DETACHED;
Panel* new_panel2 = CreatePanelWithParams(params2);
EXPECT_EQ(6, panel_manager->num_panels());
EXPECT_EQ(1, panel_manager->num_stacks());
EXPECT_EQ(6, stack->num_panels());
EXPECT_TRUE(new_panel2 == stack->bottom_panel());
EXPECT_TRUE(panel1->IsMinimized());
EXPECT_TRUE(panel2->IsMinimized());
EXPECT_TRUE(panel3->IsMinimized());
EXPECT_FALSE(panel4->IsMinimized());
EXPECT_FALSE(new_panel1->IsMinimized());
EXPECT_FALSE(new_panel2->IsMinimized());
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest,
AddNewPanelToGroupWithDetachedPanelWithCollapseToFit) {
PanelManager* panel_manager = PanelManager::GetInstance();
Panel* panel1 =
CreateInactiveDetachedPanel("1", gfx::Rect(100, 310, 200, 200));
Panel* panel2 = CreateDetachedPanel("2", gfx::Rect(300, 300, 150, 200));
ASSERT_EQ(2, panel_manager->num_panels());
ASSERT_EQ(0, panel_manager->num_stacks());
ASSERT_EQ(2, panel_manager->detached_collection()->num_panels());
CreatePanelParams params("N", gfx::Rect(50, 50, 300, 220), SHOW_AS_ACTIVE);
params.create_mode = PanelManager::CREATE_AS_DETACHED;
Panel* new_panel = CreatePanelWithParams(params);
EXPECT_EQ(3, panel_manager->num_panels());
EXPECT_EQ(1, panel_manager->detached_collection()->num_panels());
ASSERT_EQ(1, panel_manager->num_stacks());
StackedPanelCollection* stack = panel_manager->stacks().front();
EXPECT_EQ(2, stack->num_panels());
EXPECT_TRUE(panel1 == stack->top_panel());
EXPECT_TRUE(new_panel == stack->bottom_panel());
EXPECT_TRUE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
EXPECT_FALSE(new_panel->IsMinimized());
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest,
AddNewPanelAsDetachedDueToNoPanelToGroupWith) {
PanelManager* panel_manager = PanelManager::GetInstance();
StackedPanelCollection* stack = panel_manager->CreateStack();
CreateStackedPanel("1", gfx::Rect(100, 350, 200, 100), stack);
CreateStackedPanel("2", gfx::Rect(0, 0, 150, 100), stack);
ASSERT_EQ(2, panel_manager->num_panels());
ASSERT_EQ(1, panel_manager->num_stacks());
ASSERT_EQ(2, stack->num_panels());
CreateDetachedPanel("3", gfx::Rect(300, 450, 200, 100));
CreateDetachedPanel("4", gfx::Rect(250, 150, 150, 200));
ASSERT_EQ(4, panel_manager->num_panels());
ASSERT_EQ(2, panel_manager->detached_collection()->num_panels());
ASSERT_EQ(1, panel_manager->num_stacks());
CreatePanelParams params("N", gfx::Rect(50, 50, 300, 300), SHOW_AS_ACTIVE);
params.create_mode = PanelManager::CREATE_AS_DETACHED;
Panel* new_panel = CreatePanelWithParams(params);
EXPECT_EQ(5, panel_manager->num_panels());
EXPECT_EQ(3, panel_manager->detached_collection()->num_panels());
EXPECT_EQ(1, panel_manager->num_stacks());
EXPECT_EQ(2, stack->num_panels());
EXPECT_TRUE(panel_manager->detached_collection()->HasPanel(new_panel));
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest,
AddNewPanelFromDifferentExtension) {
PanelManager* panel_manager = PanelManager::GetInstance();
base::DictionaryValue empty_value;
scoped_refptr<extensions::Extension> extension1 =
CreateExtension(FILE_PATH_LITERAL("TestExtension1"),
extensions::Manifest::INTERNAL, empty_value);
std::string extension1_app_name =
web_app::GenerateApplicationNameFromExtensionId(extension1->id());
scoped_refptr<extensions::Extension> extension2 =
CreateExtension(FILE_PATH_LITERAL("TestExtension2"),
extensions::Manifest::INTERNAL, empty_value);
std::string extension2_app_name =
web_app::GenerateApplicationNameFromExtensionId(extension2->id());
CreatePanelParams params1(
extension1_app_name, gfx::Rect(50, 50, 100, 100), SHOW_AS_ACTIVE);
params1.create_mode = PanelManager::CREATE_AS_DETACHED;
Panel* panel1 = CreatePanelWithParams(params1);
CreatePanelParams params2(
extension1_app_name, gfx::Rect(100, 100, 200, 100), SHOW_AS_ACTIVE);
params2.create_mode = PanelManager::CREATE_AS_DETACHED;
Panel* panel2 = CreatePanelWithParams(params2);
EXPECT_EQ(2, panel_manager->num_panels());
EXPECT_EQ(1, panel_manager->num_stacks());
StackedPanelCollection* stack1 = panel_manager->stacks().back();
EXPECT_TRUE(stack1->HasPanel(panel1));
EXPECT_TRUE(stack1->HasPanel(panel2));
CreatePanelParams params3(
extension2_app_name, gfx::Rect(350, 350, 100, 100), SHOW_AS_ACTIVE);
params3.create_mode = PanelManager::CREATE_AS_DETACHED;
Panel* panel3 = CreatePanelWithParams(params3);
CreatePanelParams params4(
extension2_app_name, gfx::Rect(100, 100, 200, 100), SHOW_AS_ACTIVE);
params4.create_mode = PanelManager::CREATE_AS_DETACHED;
Panel* panel4 = CreatePanelWithParams(params4);
EXPECT_EQ(4, panel_manager->num_panels());
EXPECT_EQ(2, panel_manager->num_stacks());
StackedPanelCollection* stack2 = panel_manager->stacks().back();
EXPECT_TRUE(stack2->HasPanel(panel3));
EXPECT_TRUE(stack2->HasPanel(panel4));
CreatePanelParams params5(
extension1_app_name, gfx::Rect(0, 0, 100, 100), SHOW_AS_ACTIVE);
params5.create_mode = PanelManager::CREATE_AS_DETACHED;
Panel* panel5 = CreatePanelWithParams(params5);
EXPECT_EQ(5, panel_manager->num_panels());
EXPECT_EQ(2, panel_manager->num_stacks());
EXPECT_TRUE(stack1->HasPanel(panel5));
CreatePanelParams params6(
extension2_app_name, gfx::Rect(0, 0, 100, 100), SHOW_AS_ACTIVE);
params6.create_mode = PanelManager::CREATE_AS_DETACHED;
Panel* panel6 = CreatePanelWithParams(params6);
EXPECT_EQ(6, panel_manager->num_panels());
EXPECT_EQ(2, panel_manager->num_stacks());
EXPECT_TRUE(stack2->HasPanel(panel6));
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest,
AddNewPanelFromDifferentProfile) {
PanelManager* panel_manager = PanelManager::GetInstance();
Profile* profile1 = browser()->profile();
scoped_ptr<TestingProfile> profile2(new TestingProfile());
CreatePanelParams params1(
"1", gfx::Rect(50, 50, 100, 100), SHOW_AS_ACTIVE);
params1.create_mode = PanelManager::CREATE_AS_DETACHED;
params1.profile = profile1;
Panel* panel1 = CreatePanelWithParams(params1);
CreatePanelParams params2(
"2", gfx::Rect(100, 100, 200, 100), SHOW_AS_ACTIVE);
params2.create_mode = PanelManager::CREATE_AS_DETACHED;
params2.profile = profile1;
Panel* panel2 = CreatePanelWithParams(params2);
EXPECT_EQ(2, panel_manager->num_panels());
EXPECT_EQ(1, panel_manager->num_stacks());
StackedPanelCollection* stack1 = panel_manager->stacks().back();
EXPECT_TRUE(stack1->HasPanel(panel1));
EXPECT_TRUE(stack1->HasPanel(panel2));
CreatePanelParams params3(
"3", gfx::Rect(350, 350, 100, 100), SHOW_AS_ACTIVE);
params3.create_mode = PanelManager::CREATE_AS_DETACHED;
params3.profile = profile2.get();
Panel* panel3 = CreatePanelWithParams(params3);
CreatePanelParams params4(
"4", gfx::Rect(100, 100, 200, 100), SHOW_AS_ACTIVE);
params4.create_mode = PanelManager::CREATE_AS_DETACHED;
params4.profile = profile2.get();
Panel* panel4 = CreatePanelWithParams(params4);
EXPECT_EQ(4, panel_manager->num_panels());
EXPECT_EQ(2, panel_manager->num_stacks());
StackedPanelCollection* stack2 = panel_manager->stacks().back();
EXPECT_TRUE(stack2->HasPanel(panel3));
EXPECT_TRUE(stack2->HasPanel(panel4));
CreatePanelParams params5(
"5", gfx::Rect(0, 0, 100, 100), SHOW_AS_ACTIVE);
params5.create_mode = PanelManager::CREATE_AS_DETACHED;
params5.profile = profile1;
Panel* panel5 = CreatePanelWithParams(params5);
EXPECT_EQ(5, panel_manager->num_panels());
EXPECT_EQ(2, panel_manager->num_stacks());
EXPECT_TRUE(stack1->HasPanel(panel5));
CreatePanelParams params6(
"6", gfx::Rect(0, 0, 100, 100), SHOW_AS_ACTIVE);
params6.create_mode = PanelManager::CREATE_AS_DETACHED;
params6.profile = profile2.get();
Panel* panel6 = CreatePanelWithParams(params6);
EXPECT_EQ(6, panel_manager->num_panels());
EXPECT_EQ(2, panel_manager->num_stacks());
EXPECT_TRUE(stack2->HasPanel(panel6));
CloseWindowAndWait(panel3);
CloseWindowAndWait(panel4);
CloseWindowAndWait(panel6);
panel_manager->CloseAll();
}
#if defined(TOOLKIT_GTK)
#define MAYBE_AddNewPanelNotWithSystemMinimizedDetachedPanel \
DISABLED_AddNewPanelNotWithSystemMinimizedDetachedPanel
#else
#define MAYBE_AddNewPanelNotWithSystemMinimizedDetachedPanel \
AddNewPanelNotWithSystemMinimizedDetachedPanel
#endif
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest,
MAYBE_AddNewPanelNotWithSystemMinimizedDetachedPanel) {
PanelManager* panel_manager = PanelManager::GetInstance();
Panel* panel1 = CreateDetachedPanel("1", gfx::Rect(200, 50, 250, 150));
EXPECT_EQ(1, panel_manager->num_panels());
EXPECT_EQ(0, panel_manager->num_stacks());
EXPECT_EQ(1, panel_manager->detached_collection()->num_panels());
EXPECT_EQ(PanelCollection::DETACHED, panel1->collection()->type());
panel1->OnMinimizeButtonClicked(panel::NO_MODIFIER);
CreatePanelParams params("N", gfx::Rect(50, 50, 150, 100), SHOW_AS_ACTIVE);
params.create_mode = PanelManager::CREATE_AS_DETACHED;
Panel* new_panel = CreatePanelWithParams(params);
EXPECT_EQ(2, panel_manager->num_panels());
EXPECT_EQ(2, panel_manager->detached_collection()->num_panels());
EXPECT_EQ(0, panel_manager->num_stacks());
EXPECT_EQ(PanelCollection::DETACHED, panel1->collection()->type());
EXPECT_EQ(PanelCollection::DETACHED, new_panel->collection()->type());
panel_manager->CloseAll();
}
#if defined(TOOLKIT_GTK)
#define MAYBE_AddNewPanelNotWithSystemMinimizedStack \
DISABLED_AddNewPanelNotWithSystemMinimizedStack
#else
#define MAYBE_AddNewPanelNotWithSystemMinimizedStack \
AddNewPanelNotWithSystemMinimizedStack
#endif
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest,
MAYBE_AddNewPanelNotWithSystemMinimizedStack) {
PanelManager* panel_manager = PanelManager::GetInstance();
StackedPanelCollection* stack = panel_manager->CreateStack();
Panel* panel1 = CreateStackedPanel("1", gfx::Rect(100, 90, 200, 150), stack);
Panel* panel2 = CreateStackedPanel("2", gfx::Rect(0, 0, 150, 100), stack);
EXPECT_EQ(2, panel_manager->num_panels());
EXPECT_EQ(0, panel_manager->detached_collection()->num_panels());
EXPECT_EQ(1, panel_manager->num_stacks());
EXPECT_EQ(2, stack->num_panels());
EXPECT_EQ(PanelCollection::STACKED, panel1->collection()->type());
EXPECT_EQ(PanelCollection::STACKED, panel2->collection()->type());
stack->OnMinimizeButtonClicked(panel1, panel::NO_MODIFIER);
CreatePanelParams params("N", gfx::Rect(50, 50, 150, 100), SHOW_AS_ACTIVE);
params.create_mode = PanelManager::CREATE_AS_DETACHED;
Panel* new_panel = CreatePanelWithParams(params);
EXPECT_EQ(3, panel_manager->num_panels());
EXPECT_EQ(1, panel_manager->detached_collection()->num_panels());
EXPECT_EQ(1, panel_manager->num_stacks());
EXPECT_EQ(2, stack->num_panels());
EXPECT_EQ(PanelCollection::STACKED, panel1->collection()->type());
EXPECT_EQ(PanelCollection::STACKED, panel2->collection()->type());
EXPECT_EQ(PanelCollection::DETACHED, new_panel->collection()->type());
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest, ClosePanels) {
PanelManager* panel_manager = PanelManager::GetInstance();
StackedPanelCollection* stack = panel_manager->CreateStack();
gfx::Rect panel1_initial_bounds = gfx::Rect(100, 50, 200, 150);
Panel* panel1 = CreateStackedPanel("1", panel1_initial_bounds, stack);
gfx::Rect panel2_initial_bounds = gfx::Rect(0, 0, 150, 100);
Panel* panel2 = CreateStackedPanel("2", panel2_initial_bounds, stack);
gfx::Rect panel3_initial_bounds = gfx::Rect(0, 0, 250, 120);
Panel* panel3 = CreateStackedPanel("3", panel3_initial_bounds, stack);
ASSERT_EQ(3, panel_manager->num_panels());
ASSERT_EQ(1, panel_manager->num_stacks());
ASSERT_EQ(3, stack->num_panels());
gfx::Rect panel1_expected_bounds(panel1_initial_bounds);
EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds());
gfx::Rect panel2_expected_bounds(panel1_expected_bounds.x(),
panel1_expected_bounds.bottom(),
panel1_expected_bounds.width(),
panel2_initial_bounds.height());
EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds());
gfx::Rect panel3_expected_bounds(panel2_expected_bounds.x(),
panel2_expected_bounds.bottom(),
panel2_expected_bounds.width(),
panel3_initial_bounds.height());
EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds());
CloseWindowAndWait(panel1);
WaitForBoundsAnimationFinished(panel2);
WaitForBoundsAnimationFinished(panel3);
ASSERT_EQ(2, panel_manager->num_panels());
ASSERT_EQ(1, panel_manager->num_stacks());
ASSERT_EQ(2, stack->num_panels());
EXPECT_EQ(PanelCollection::STACKED, panel2->collection()->type());
EXPECT_EQ(PanelCollection::STACKED, panel3->collection()->type());
panel2_expected_bounds.set_y(panel1_expected_bounds.y());
EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds());
panel3_expected_bounds.set_y(panel2_expected_bounds.bottom());
EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds());
CloseWindowAndWait(panel2);
WaitForBoundsAnimationFinished(panel3);
ASSERT_EQ(1, panel_manager->num_panels());
ASSERT_EQ(0, panel_manager->num_stacks());
EXPECT_EQ(PanelCollection::DETACHED, panel3->collection()->type());
panel3_expected_bounds.set_y(panel2_expected_bounds.y());
EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds());
panel_manager->CloseAll();
}
#if defined(TOOLKIT_GTK) || defined(OS_MACOSX)
#define MAYBE_FocusNextPanelOnPanelClose DISABLED_FocusNextPanelOnPanelClose
#else
#define MAYBE_FocusNextPanelOnPanelClose FocusNextPanelOnPanelClose
#endif
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest,
MAYBE_FocusNextPanelOnPanelClose) {
PanelManager* panel_manager = PanelManager::GetInstance();
StackedPanelCollection* stack = panel_manager->CreateStack();
Panel* panel1 = CreateStackedPanel("1", gfx::Rect(100, 50, 200, 200), stack);
Panel* panel2 = CreateStackedPanel("2", gfx::Rect(0, 0, 150, 100), stack);
Panel* panel3 = CreateStackedPanel("3", gfx::Rect(0, 0, 150, 120), stack);
ASSERT_EQ(3, stack->num_panels());
ASSERT_FALSE(panel1->IsActive());
ASSERT_FALSE(panel2->IsActive());
ASSERT_TRUE(panel3->IsActive());
CloseWindowAndWait(panel3);
EXPECT_FALSE(panel1->IsActive());
EXPECT_TRUE(panel2->IsActive());
CloseWindowAndWait(panel2);
EXPECT_TRUE(panel1->IsActive());
panel_manager->CloseAll();
}
#if defined(TOOLKIT_GTK) || defined(OS_MACOSX)
#define MAYBE_FocusNextUnminimizedPanelOnPanelClose \
DISABLED_FocusNextUnminimizedPanelOnPanelClose
#else
#define MAYBE_FocusNextUnminimizedPanelOnPanelClose \
FocusNextUnminimizedPanelOnPanelClose
#endif
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest,
MAYBE_FocusNextUnminimizedPanelOnPanelClose) {
PanelManager* panel_manager = PanelManager::GetInstance();
StackedPanelCollection* stack = panel_manager->CreateStack();
Panel* panel1 = CreateStackedPanel("1", gfx::Rect(100, 50, 200, 200), stack);
Panel* panel2 = CreateStackedPanel("2", gfx::Rect(0, 0, 150, 100), stack);
Panel* panel3 = CreateStackedPanel("3", gfx::Rect(0, 0, 150, 120), stack);
ASSERT_EQ(3, stack->num_panels());
ASSERT_FALSE(panel1->IsActive());
ASSERT_FALSE(panel2->IsActive());
ASSERT_TRUE(panel3->IsActive());
panel2->Minimize();
WaitForBoundsAnimationFinished(panel2);
CloseWindowAndWait(panel3);
EXPECT_TRUE(panel1->IsActive());
EXPECT_FALSE(panel2->IsActive());
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest,
ExpandCollapsedTopPanelOnBottomPanelClose) {
PanelManager* panel_manager = PanelManager::GetInstance();
StackedPanelCollection* stack = panel_manager->CreateStack();
gfx::Rect panel1_initial_bounds = gfx::Rect(100, 50, 200, 150);
Panel* panel1 = CreateStackedPanel("1", panel1_initial_bounds, stack);
gfx::Rect panel2_initial_bounds = gfx::Rect(0, 0, 150, 100);
Panel* panel2 = CreateStackedPanel("2", panel2_initial_bounds, stack);
ASSERT_EQ(2, panel_manager->num_panels());
ASSERT_EQ(1, panel_manager->num_stacks());
ASSERT_EQ(2, stack->num_panels());
int original_panel1_height = panel1->GetBounds().height();
panel1->Minimize();
WaitForBoundsAnimationFinished(panel2);
EXPECT_TRUE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
CloseWindowAndWait(panel2);
WaitForBoundsAnimationFinished(panel1);
EXPECT_EQ(1, panel_manager->num_panels());
EXPECT_EQ(0, panel_manager->num_stacks());
EXPECT_EQ(PanelCollection::DETACHED, panel1->collection()->type());
EXPECT_FALSE(panel1->IsMinimized());
EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state());
EXPECT_EQ(original_panel1_height, panel1->GetBounds().height());
panel_manager->CloseAll();
}
#if defined(OS_MACOSX)
#define MAYBE_FocusCollapsedStackedPanel DISABLED_FocusCollapsedStackedPanel
#else
#define MAYBE_FocusCollapsedStackedPanel FocusCollapsedStackedPanel
#endif
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest,
MAYBE_FocusCollapsedStackedPanel) {
PanelManager* panel_manager = PanelManager::GetInstance();
StackedPanelCollection* stack = panel_manager->CreateStack();
gfx::Rect panel1_initial_bounds = gfx::Rect(100, 50, 200, 150);
CreateStackedPanel("1", panel1_initial_bounds, stack);
gfx::Rect panel2_initial_bounds = gfx::Rect(0, 0, 150, 100);
Panel* panel2 = CreateStackedPanel("2", panel2_initial_bounds, stack);
ASSERT_EQ(2, panel_manager->num_panels());
ASSERT_EQ(1, panel_manager->num_stacks());
ASSERT_EQ(2, stack->num_panels());
panel2->Minimize();
WaitForBoundsAnimationFinished(panel2);
EXPECT_TRUE(panel2->IsMinimized());
EXPECT_FALSE(panel2->IsActive());
panel2->Activate();
WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE);
EXPECT_FALSE(panel2->IsMinimized());
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest,
UpdateStackedPanelsOnPrimaryDisplayChange) {
PanelManager* panel_manager = PanelManager::GetInstance();
StackedPanelCollection* stack = panel_manager->CreateStack();
Panel* panel1 = CreateStackedPanel("1", gfx::Rect(50, 50, 700, 100), stack);
Panel* panel2 = CreateStackedPanel("2", gfx::Rect(0, 0, 100, 100), stack);
Panel* panel3 = CreateStackedPanel("3", gfx::Rect(0, 0, 100, 100), stack);
Panel* panel4 = CreateStackedPanel("4", gfx::Rect(0, 0, 100, 100), stack);
Panel* panel5 = CreateStackedPanel("5", gfx::Rect(0, 0, 100, 100), stack);
ASSERT_EQ(5, panel_manager->num_panels());
ASSERT_EQ(1, panel_manager->num_stacks());
ASSERT_EQ(5, stack->num_panels());
int new_primary_area_width = 500;
gfx::Rect primary_display_area(0, 0, new_primary_area_width, 300);
gfx::Rect primary_work_area(0, 0, new_primary_area_width, 280);
mock_display_settings_provider()->SetPrimaryDisplay(
primary_display_area, primary_work_area);
WaitForBoundsAnimationFinished(panel1);
WaitForBoundsAnimationFinished(panel2);
WaitForBoundsAnimationFinished(panel3);
WaitForBoundsAnimationFinished(panel4);
WaitForBoundsAnimationFinished(panel5);
EXPECT_TRUE(panel1->IsMinimized());
EXPECT_TRUE(panel2->IsMinimized());
EXPECT_TRUE(panel3->IsMinimized());
EXPECT_TRUE(panel4->IsMinimized());
EXPECT_FALSE(panel5->IsMinimized());
gfx::Rect bounds1 = panel1->GetBounds();
EXPECT_EQ(primary_work_area.x(), bounds1.x());
EXPECT_LE(bounds1.x(), primary_work_area.right());
EXPECT_LE(primary_work_area.y(), bounds1.y());
EXPECT_EQ(new_primary_area_width, bounds1.width());
gfx::Rect bounds2 = panel2->GetBounds();
EXPECT_EQ(bounds1.x(), bounds2.x());
EXPECT_EQ(bounds1.width(), bounds2.width());
EXPECT_EQ(bounds1.bottom(), bounds2.y());
gfx::Rect bounds3 = panel3->GetBounds();
EXPECT_EQ(bounds2.x(), bounds3.x());
EXPECT_EQ(bounds2.width(), bounds3.width());
EXPECT_EQ(bounds2.bottom(), bounds3.y());
gfx::Rect bounds4 = panel4->GetBounds();
EXPECT_EQ(bounds3.x(), bounds4.x());
EXPECT_EQ(bounds3.width(), bounds4.width());
EXPECT_EQ(bounds3.bottom(), bounds4.y());
gfx::Rect bounds5 = panel5->GetBounds();
EXPECT_EQ(bounds4.x(), bounds5.x());
EXPECT_EQ(bounds4.width(), bounds5.width());
EXPECT_EQ(bounds4.bottom(), bounds5.y());
EXPECT_LE(bounds5.bottom(), primary_work_area.bottom());
panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest,
KeepShowingStackedPanelCreatedBeforeFullScreenMode) {
PanelManager* panel_manager = PanelManager::GetInstance();
StackedPanelCollection* stack = panel_manager->CreateStack();
Panel* panel1 = CreateStackedPanel("1", gfx::Rect(100, 50, 200, 150), stack);
Panel* panel2 = CreateStackedPanel("2", gfx::Rect(0, 0, 150, 100), stack);
scoped_ptr<NativePanelTesting> panel1_testing(
CreateNativePanelTesting(panel1));
scoped_ptr<NativePanelTesting> panel2_testing(
CreateNativePanelTesting(panel2));
EXPECT_TRUE(panel1_testing->IsWindowVisible());
EXPECT_TRUE(panel2_testing->IsWindowVisible());
mock_display_settings_provider()->EnableFullScreenMode(true);
EXPECT_TRUE(panel1_testing->IsWindowVisible());
EXPECT_TRUE(panel2_testing->IsWindowVisible());
mock_display_settings_provider()->EnableFullScreenMode(false);
EXPECT_TRUE(panel1_testing->IsWindowVisible());
EXPECT_TRUE(panel2_testing->IsWindowVisible());
panel_manager->CloseAll();
}