| Index: chrome/browser/ui/panels/old_detached_panel_browsertest.cc
|
| diff --git a/chrome/browser/ui/panels/old_detached_panel_browsertest.cc b/chrome/browser/ui/panels/old_detached_panel_browsertest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..feec61f931f0d69e8289f7d45f63a2cc4632faea
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/panels/old_detached_panel_browsertest.cc
|
| @@ -0,0 +1,144 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "base/message_loop.h"
|
| +#include "chrome/browser/ui/panels/base_panel_browser_test.h"
|
| +#include "chrome/browser/ui/panels/detached_panel_strip.h"
|
| +#include "chrome/browser/ui/panels/native_panel.h"
|
| +#include "chrome/browser/ui/panels/panel.h"
|
| +#include "chrome/browser/ui/panels/panel_manager.h"
|
| +
|
| +class DetachedPanelBrowserTest : public BasePanelBrowserTest {
|
| +};
|
| +
|
| +IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, CheckDetachedPanelProperties) {
|
| + PanelManager* panel_manager = PanelManager::GetInstance();
|
| + DetachedPanelStrip* detached_strip = panel_manager->detached_strip();
|
| +
|
| + Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200));
|
| + scoped_ptr<NativePanelTesting> panel_testing(
|
| + NativePanelTesting::Create(panel->native_panel()));
|
| +
|
| + EXPECT_EQ(1, panel_manager->num_panels());
|
| + EXPECT_TRUE(detached_strip->HasPanel(panel));
|
| +
|
| + EXPECT_FALSE(panel->always_on_top());
|
| +
|
| + EXPECT_TRUE(panel_testing->IsButtonVisible(panel::CLOSE_BUTTON));
|
| + EXPECT_FALSE(panel_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
|
| + EXPECT_FALSE(panel_testing->IsButtonVisible(panel::RESTORE_BUTTON));
|
| +
|
| + EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse());
|
| +
|
| + Panel::AttentionMode expected_attention_mode =
|
| + static_cast<Panel::AttentionMode>(Panel::USE_PANEL_ATTENTION |
|
| + Panel::USE_SYSTEM_ATTENTION);
|
| + EXPECT_EQ(expected_attention_mode, panel->attention_mode());
|
| +
|
| + panel_manager->CloseAll();
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, DrawAttentionOnActive) {
|
| + // Create a detached panel that is initially active.
|
| + Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200));
|
| + scoped_ptr<NativePanelTesting> native_panel_testing(
|
| + NativePanelTesting::Create(panel->native_panel()));
|
| +
|
| + // Test that the attention should not be drawn if the detached panel is in
|
| + // focus.
|
| + EXPECT_TRUE(panel->IsActive());
|
| + EXPECT_FALSE(panel->IsDrawingAttention());
|
| + panel->FlashFrame(true);
|
| + EXPECT_FALSE(panel->IsDrawingAttention());
|
| + MessageLoop::current()->RunAllPending();
|
| + EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention());
|
| +
|
| + panel->Close();
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, DrawAttentionOnInactive) {
|
| + // Create an inactive detached panel.
|
| + Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200));
|
| + panel->Deactivate();
|
| + WaitForPanelActiveState(panel, SHOW_AS_INACTIVE);
|
| +
|
| + scoped_ptr<NativePanelTesting> native_panel_testing(
|
| + NativePanelTesting::Create(panel->native_panel()));
|
| +
|
| + // Test that the attention is drawn when the detached panel is not in focus.
|
| + EXPECT_FALSE(panel->IsActive());
|
| + EXPECT_FALSE(panel->IsDrawingAttention());
|
| + panel->FlashFrame(true);
|
| + EXPECT_TRUE(panel->IsDrawingAttention());
|
| + MessageLoop::current()->RunAllPending();
|
| + EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention());
|
| +
|
| + // Stop drawing attention.
|
| + panel->FlashFrame(false);
|
| + EXPECT_FALSE(panel->IsDrawingAttention());
|
| + MessageLoop::current()->RunAllPending();
|
| + EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention());
|
| +
|
| + panel->Close();
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, DrawAttentionResetOnActivate) {
|
| + // Create 2 panels so we end up with an inactive panel that can
|
| + // be made to draw attention.
|
| + Panel* panel1 = CreatePanel("test panel1");
|
| + Panel* panel2 = CreatePanel("test panel2");
|
| +
|
| + scoped_ptr<NativePanelTesting> native_panel_testing(
|
| + NativePanelTesting::Create(panel1->native_panel()));
|
| +
|
| + // Test that the attention is drawn when the detached panel is not in focus.
|
| + panel1->FlashFrame(true);
|
| + EXPECT_TRUE(panel1->IsDrawingAttention());
|
| + MessageLoop::current()->RunAllPending();
|
| + EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention());
|
| +
|
| + // Test that the attention is cleared when panel gets focus.
|
| + panel1->Activate();
|
| + WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE);
|
| + EXPECT_FALSE(panel1->IsDrawingAttention());
|
| + EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention());
|
| +
|
| + panel1->Close();
|
| + panel2->Close();
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, ClickTitlebar) {
|
| + PanelManager* panel_manager = PanelManager::GetInstance();
|
| +
|
| + Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200));
|
| + EXPECT_TRUE(panel->IsActive());
|
| + EXPECT_FALSE(panel->IsMinimized());
|
| +
|
| + // Clicking on an active detached panel's titlebar has no effect, regardless
|
| + // of modifier.
|
| + scoped_ptr<NativePanelTesting> test_panel(
|
| + NativePanelTesting::Create(panel->native_panel()));
|
| + test_panel->PressLeftMouseButtonTitlebar(panel->GetBounds().origin());
|
| + test_panel->ReleaseMouseButtonTitlebar();
|
| + EXPECT_TRUE(panel->IsActive());
|
| + EXPECT_FALSE(panel->IsMinimized());
|
| +
|
| + test_panel->PressLeftMouseButtonTitlebar(panel->GetBounds().origin(),
|
| + panel::APPLY_TO_ALL);
|
| + test_panel->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL);
|
| + EXPECT_TRUE(panel->IsActive());
|
| + EXPECT_FALSE(panel->IsMinimized());
|
| +
|
| + // Create a second panel to cause the first to become inactive.
|
| + CreateDetachedPanel("2", gfx::Rect(100, 200, 230, 345));
|
| + EXPECT_FALSE(panel->IsActive());
|
| +
|
| + // Clicking on an inactive detached panel's titlebar activates it.
|
| + test_panel->PressLeftMouseButtonTitlebar(panel->GetBounds().origin());
|
| + test_panel->ReleaseMouseButtonTitlebar();
|
| + WaitForPanelActiveState(panel, SHOW_AS_ACTIVE);
|
| + EXPECT_FALSE(panel->IsMinimized());
|
| +
|
| + panel_manager->CloseAll();
|
| +}
|
|
|