Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(461)

Unified Diff: chrome/browser/ui/panels/panel_overflow_browsertest.cc

Issue 8953040: Add overflow indicator count on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix per feedback Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/panels/panel_overflow_browsertest.cc
diff --git a/chrome/browser/ui/panels/panel_overflow_browsertest.cc b/chrome/browser/ui/panels/panel_overflow_browsertest.cc
index 3c5416c32c64f34c071a82c293a05c08548c0bf1..c39c2a0979f543d73289d2ab342af7a7b55ff016 100644
--- a/chrome/browser/ui/panels/panel_overflow_browsertest.cc
+++ b/chrome/browser/ui/panels/panel_overflow_browsertest.cc
@@ -8,6 +8,7 @@
#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/panel_overflow_indicator.h"
#include "chrome/browser/ui/panels/panel_overflow_strip.h"
#include "chrome/browser/ui/panels/panel_settings_menu_model.h"
#include "chrome/browser/ui/panels/panel_strip.h"
@@ -18,8 +19,9 @@
namespace {
-// We override the default value for testing purpose.
-const int kMaxVisibleOverflowForTesting = 3;
+// We override the default value for testing purpose.
+const int kMaxVisiblePanelsForTesting = 3;
jennb 2011/12/20 02:08:23 Prefer to have overflow in the name of these 2 as
jianli 2011/12/20 22:08:10 Done.
+const int kMaxVisiblePanelsOnHoverForTesting = 6;
// Encapsulates all the info we need to verify if a panel behaves as expected
// when we do the overflow testing.
@@ -86,8 +88,14 @@ class PanelOverflowBrowserTest : public BasePanelBrowserTest {
virtual void SetUpOnMainThread() OVERRIDE {
BasePanelBrowserTest::SetUpOnMainThread();
- PanelManager::GetInstance()->panel_overflow_strip()->
- set_max_visible_panels(kMaxVisibleOverflowForTesting);
+ PanelManager* panel_manager = PanelManager::GetInstance();
+ panel_manager->panel_overflow_strip()->
+ set_max_visible_panels(kMaxVisiblePanelsForTesting);
+ panel_manager->panel_overflow_strip()->
+ set_max_visible_panels_on_hover(kMaxVisiblePanelsOnHoverForTesting);
+
+ PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher();
+ panel_manager->SetMouseWatcherForTesting(mouse_watcher);
// All the overflow tests assume 800x600 work area. Do the check now.
DCHECK(PanelManager::GetInstance()->work_area().width() == 800);
@@ -178,6 +186,8 @@ class PanelOverflowBrowserTest : public BasePanelBrowserTest {
#define MAYBE_CloseNormalPanels CloseNormalPanels
#define MAYBE_ActivateOverflowPanels ActivateOverflowPanels
#define MAYBE_HoverOverOverflowArea HoverOverOverflowArea
+#define MAYBE_OverflowIndicatorCount OverflowIndicatorCount
+#define MAYBE_DrawOverflowAttention DrawOverflowAttention
#else
#define MAYBE_CheckPanelProperties DISABLED_CheckPanelProperties
#define MAYBE_UpdateDraggableStatus DISABLED_UpdateDraggableStatus
@@ -188,6 +198,8 @@ class PanelOverflowBrowserTest : public BasePanelBrowserTest {
#define MAYBE_CloseNormalPanels DISABLED_CloseNormalPanels
#define MAYBE_ActivateOverflowPanels DISABLED_ActivateOverflowPanels
#define MAYBE_HoverOverOverflowArea DISABLED_HoverOverOverflowArea
+#define MAYBE_OverflowIndicatorCount DISABLED_OverflowIndicatorCount
+#define MAYBE_DrawOverflowAttention DISABLED_DrawOverflowAttention
#endif
IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CheckPanelProperties) {
@@ -242,20 +254,48 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CreateOverflowPanels) {
PanelOverflowStrip* panel_overflow_strip =
panel_manager->panel_overflow_strip();
- const int panel_widths[] = {
- 250, 260, 200, // normal
- 255, 220 // overflow
- };
- CreateOverflowPanels(3, 2, panel_widths);
+ EXPECT_EQ(0, panel_manager->num_panels());
+ EXPECT_EQ(0, panel_strip->num_panels());
+ EXPECT_EQ(0, panel_overflow_strip->num_panels());
+ EXPECT_FALSE(panel_overflow_strip->overflow_indicator() &&
+ panel_overflow_strip->overflow_indicator()->GetCount());
- std::vector<Panel*> panels = panel_manager->panels();
- ASSERT_EQ(5u, panels.size());
+ // Create 3 normal panels.
+ Panel* panel0 = CreatePanelWithBounds("Panel0", gfx::Rect(0, 0, 250, 200));
+ Panel* panel1 = CreatePanelWithBounds("Panel1", gfx::Rect(0, 0, 260, 200));
+ Panel* panel2 = CreatePanelWithBounds("Panel2", gfx::Rect(0, 0, 200, 200));
+
+ EXPECT_EQ(3, panel_manager->num_panels());
+ EXPECT_EQ(3, panel_strip->num_panels());
+ EXPECT_EQ(0, panel_overflow_strip->num_panels());
+ EXPECT_FALSE(panel_overflow_strip->overflow_indicator() &&
jennb 2011/12/20 02:08:23 Don't need the GetCount() check. Just verify that
jianli 2011/12/20 22:08:10 Done.
+ panel_overflow_strip->overflow_indicator()->GetCount());
+ EXPECT_EQ(Panel::EXPANDED, panel0->expansion_state());
+ EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state());
+ EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state());
+
+ // Create 1 overflow panel.
+ CreatePanelParams params(
+ "Panel3", gfx::Rect(0, 0, 255, 200), SHOW_AS_INACTIVE);
+ Panel* panel3 = CreatePanelWithParams(params);
+
+ EXPECT_EQ(4, panel_manager->num_panels());
+ EXPECT_EQ(3, panel_strip->num_panels());
+ EXPECT_EQ(1, panel_overflow_strip->num_panels());
+ EXPECT_EQ(0, panel_overflow_strip->overflow_indicator()->GetCount());
jennb 2011/12/20 02:08:23 Should still be no indicator as you don't need it
jianli 2011/12/20 22:08:10 Done.
+ EXPECT_EQ(Panel::IN_OVERFLOW, panel3->expansion_state());
+ EXPECT_TRUE(IsPanelVisible(panel3));
+
+ // Create 1 more overflow panel.
+ params.name = "Panel4";
+ Panel* panel4 = CreatePanelWithParams(params);
+
+ EXPECT_EQ(5, panel_manager->num_panels());
EXPECT_EQ(3, panel_strip->num_panels());
EXPECT_EQ(2, panel_overflow_strip->num_panels());
- EXPECT_EQ(Panel::IN_OVERFLOW, panels[3]->expansion_state());
- EXPECT_TRUE(IsPanelVisible(panels[3]));
- EXPECT_EQ(Panel::IN_OVERFLOW, panels[4]->expansion_state());
- EXPECT_TRUE(IsPanelVisible(panels[4]));
+ EXPECT_EQ(0, panel_overflow_strip->overflow_indicator()->GetCount());
+ EXPECT_EQ(Panel::IN_OVERFLOW, panel4->expansion_state());
+ EXPECT_TRUE(IsPanelVisible(panel4));
PanelManager::GetInstance()->RemoveAll();
}
@@ -278,6 +318,7 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest,
ASSERT_EQ(8u, panels.size());
EXPECT_EQ(3, panel_strip->num_panels());
EXPECT_EQ(5, panel_overflow_strip->num_panels());
+ EXPECT_EQ(2, panel_overflow_strip->overflow_indicator()->GetCount());
EXPECT_EQ(Panel::IN_OVERFLOW, panels[3]->expansion_state());
EXPECT_TRUE(IsPanelVisible(panels[3]));
EXPECT_EQ(Panel::IN_OVERFLOW, panels[4]->expansion_state());
@@ -662,8 +703,6 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_ActivateOverflowPanels) {
IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_HoverOverOverflowArea) {
PanelManager* panel_manager = PanelManager::GetInstance();
- PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher();
- panel_manager->SetMouseWatcherForTesting(mouse_watcher);
PanelOverflowStrip* panel_overflow_strip =
panel_manager->panel_overflow_strip();
int iconified_width = panel_overflow_strip->current_display_width();
@@ -766,3 +805,218 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_HoverOverOverflowArea) {
panel_manager->RemoveAll();
}
+
+IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_OverflowIndicatorCount) {
+ PanelManager* panel_manager = PanelManager::GetInstance();
+ PanelOverflowStrip* panel_overflow_strip =
+ panel_manager->panel_overflow_strip();
+
+ // Create normal and overflow panels.
+ // normal: P0, P1, P2
+ // overflow: P3, P4, P5
+ const int panel_widths[] = {
+ 250, 250, 210, // normal
+ 250, 250, 260 // overflow
+ };
+ std::vector<Panel*> panels = CreateOverflowPanels(3, 3, panel_widths);
+ EXPECT_EQ(3, panel_overflow_strip->num_panels());
+ PanelOverflowIndicator* overflow_indicator =
+ panel_overflow_strip->overflow_indicator();
+ EXPECT_EQ(0, overflow_indicator->GetCount());
jennb 2011/12/20 02:08:23 Expect no indicator.
jianli 2011/12/20 22:08:10 Done.
+
+ // Create 5 overflow-on-overflow panels.
+ // normal: P0, P1, P2
+ // overflow: P3, P4, P5, (P6, P7, P8, P9, P10)
+ // The panels enclosed in parentheses are hidden.
+ int num_existing_panels = static_cast<int>(panels.size());
jennb 2011/12/20 02:08:23 panel_manager->num_panels() ? then you won't have
jianli 2011/12/20 22:08:10 Done.
+ for (int i = 0; i < 5; ++i) {
+ CreatePanelParams params(
+ MakePanelName(num_existing_panels + i),
+ gfx::Rect(0, 0, 250, 200),
+ SHOW_AS_INACTIVE);
+ Panel* panel = CreatePanelWithParams(params);
+ WaitForExpansionStateChanged(panel, Panel::IN_OVERFLOW);
+ EXPECT_EQ(i + 1, overflow_indicator->GetCount());
+ panels.push_back(panel);
+ }
+
+ // Expand the overflow area by moving mouse over it.
+ // Expect the overflow indicator count gets updated.
+ // normal: P0, P1, P2
+ // overflow: P3, P4, P5, P6, P7, P8, (P9, P10)
+ MoveMouseAndWaitForOverflowAnimationEnded(panels[3]->GetBounds().origin());
+ EXPECT_TRUE(IsPanelVisible(panels[6]));
+ EXPECT_TRUE(IsPanelVisible(panels[7]));
+ EXPECT_TRUE(IsPanelVisible(panels[8]));
+ EXPECT_FALSE(IsPanelVisible(panels[9]));
+ EXPECT_FALSE(IsPanelVisible(panels[10]));
+ EXPECT_EQ(2, overflow_indicator->GetCount());
+
+ // Close an overflow panel that makes one overflow-on-overflow panel become
+ // visible. Expect the overflow indicator count gets decreased by 1.
+ // normal: P0, P1, P2
+ // overflow: P4, P5, P6, P7, P8, P9, (P10)
+ CloseWindowAndWait(panels[3]->browser());
+ EXPECT_TRUE(IsPanelVisible(panels[6]));
+ EXPECT_TRUE(IsPanelVisible(panels[7]));
+ EXPECT_TRUE(IsPanelVisible(panels[8]));
+ EXPECT_TRUE(IsPanelVisible(panels[9]));
+ EXPECT_FALSE(IsPanelVisible(panels[10]));
+ EXPECT_EQ(1, overflow_indicator->GetCount());
+
+ // Shrunk the overflow area by stopping hovering the mouse over the overflow
jennb 2011/12/20 02:08:23 Shrink
jianli 2011/12/20 22:08:10 Done.
+ // area. Expect the overflow indicator count gets updated.
+ // normal: P0, P1, P2
+ // overflow: P4, P5, P6, (P7, P8, P9, P10)
+ MoveMouseAndWaitForOverflowAnimationEnded(gfx::Point(
+ panels[4]->GetBounds().right() + 5, panels[4]->GetBounds().y()));
+ EXPECT_TRUE(IsPanelVisible(panels[6]));
+ EXPECT_FALSE(IsPanelVisible(panels[7]));
+ EXPECT_FALSE(IsPanelVisible(panels[8]));
+ EXPECT_FALSE(IsPanelVisible(panels[9]));
+ EXPECT_FALSE(IsPanelVisible(panels[10]));
+ EXPECT_EQ(4, overflow_indicator->GetCount());
+
+ // Close an overflow panel.
+ // Expect the overflow indicator count gets decreased by 1.
+ // normal: P0, P1, P2
+ // overflow: P5, P6, P7, (P8, P9, P10)
+ CloseWindowAndWait(panels[4]->browser());
+ EXPECT_TRUE(IsPanelVisible(panels[6]));
+ EXPECT_TRUE(IsPanelVisible(panels[7]));
+ EXPECT_FALSE(IsPanelVisible(panels[8]));
+ EXPECT_FALSE(IsPanelVisible(panels[9]));
+ EXPECT_FALSE(IsPanelVisible(panels[10]));
+ EXPECT_EQ(3, overflow_indicator->GetCount());
+
+ // Activating a big overflow panel will cause 2 normal panels to move to the
+ // oevrflow area and also get the top visivle overflow panel bumped to the
jennb 2011/12/20 02:08:23 visivle
jianli 2011/12/20 22:08:10 Done.
+ // overflow-on-overflow.
+ // Expect the overflow indicator count gets increased by 1.
+ // normal: P0, P5
+ // overflow: P1, P2, P6, (P7, P8, P9, P10)
+ panels[5]->Activate();
+ WaitForPanelActiveState(panels[5], SHOW_AS_ACTIVE);
+ WaitForExpansionStateChanged(panels[5], Panel::EXPANDED);
+ EXPECT_TRUE(IsPanelVisible(panels[6]));
+ EXPECT_FALSE(IsPanelVisible(panels[7]));
+ EXPECT_FALSE(IsPanelVisible(panels[8]));
+ EXPECT_FALSE(IsPanelVisible(panels[9]));
+ EXPECT_FALSE(IsPanelVisible(panels[10]));
+ EXPECT_EQ(4, overflow_indicator->GetCount());
+
+ panel_manager->RemoveAll();
+}
+
+IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_DrawOverflowAttention) {
jennb 2011/12/20 02:08:23 Very thorough coverage of many scenarios!
+ PanelManager* panel_manager = PanelManager::GetInstance();
+ PanelStrip* panel_strip = panel_manager->panel_strip();
+ PanelOverflowStrip* overflow_strip = panel_manager->panel_overflow_strip();
+
+ // Create normal and overflow panels.
+ // normal: P0, P1, P2, P3
+ // overflow: P4, P5, P6, (P7, P8, P9, P10, P11)
+ // The panels enclosed in parentheses are hidden.
+ const int panel_widths[] = {
+ 100, 210, 210, 210, // normal
+ 210, 260, 210, // overflow
+ 210, 210, 210, // overflow-on-overflow on shrunk
+ 210, 210 // overflow-on-overflow on expanded
+ };
+ std::vector<Panel*> panels = CreateOverflowPanels(4, 8, panel_widths);
+ EXPECT_EQ(4, panel_strip->num_panels());
+ EXPECT_EQ(8, overflow_strip->num_panels());
+ PanelOverflowIndicator* overflow_indicator =
+ overflow_strip->overflow_indicator();
+
+ // Draw attention for an overflow panel.
jennb 2011/12/20 02:08:23 a visible overflow panel
jianli 2011/12/20 22:08:10 Done.
+ // Expect no impact to the overflow indicator.
+ // normal: P0, P1, P2, P3
+ // overflow: P4, *P5, P6, (P7, P8, P9, P10, P11)
+ EXPECT_FALSE(panels[5]->IsDrawingAttention());
+ panels[5]->FlashFrame();
+ EXPECT_TRUE(panels[5]->IsDrawingAttention());
+ EXPECT_FALSE(overflow_indicator->IsDrawingAttention());
+
+ // Activating this overflow panel will clear its attention.
+ // Expect no impact to the overflow indicator.
+ // normal: P0, P1, P2, P5
+ // overflow: P3, P4, P6, (P7, P8, P9, P10, P11)
+ panels[5]->Activate();
+ WaitForPanelActiveState(panels[5], SHOW_AS_ACTIVE);
+ EXPECT_FALSE(panels[5]->IsDrawingAttention());
+ EXPECT_FALSE(overflow_indicator->IsDrawingAttention());
+
+ // Draw attention for an overflow-on-overflow panel.
+ // Expect the overflow indicator is showing attention.
+ // normal: P0, P1, P2, P5
+ // overflow: P3, P4, P6, (P7, *P8, P9, P10, P11)
+ EXPECT_FALSE(panels[8]->IsDrawingAttention());
+ panels[8]->FlashFrame();
+ EXPECT_TRUE(panels[8]->IsDrawingAttention());
+ EXPECT_TRUE(overflow_indicator->IsDrawingAttention());
+
+ // Draw attention for another overflow-on-overflow panel.
+ // Expect the overflow indicator is still showing attention.
+ // normal: P0, P1, P2, P5
+ // overflow: P3, P4, P6, (P7, *P8, P9, *P10, P11)
+ EXPECT_FALSE(panels[10]->IsDrawingAttention());
+ panels[10]->FlashFrame();
+ EXPECT_TRUE(panels[10]->IsDrawingAttention());
+ EXPECT_TRUE(overflow_indicator->IsDrawingAttention());
+
+ // Stop drawing attention for an overflow-on-overflow panel by activating it.
+ // Expect the overflow indicator is still showing attention.
+ // normal: P0, P1, P2, P8
+ // overflow: P5, P3, P4, (P6, P7, P9, *P10, P11)
+ panels[8]->Activate();
+ WaitForPanelActiveState(panels[8], SHOW_AS_ACTIVE);
+ EXPECT_FALSE(panels[8]->IsDrawingAttention());
+ EXPECT_TRUE(overflow_indicator->IsDrawingAttention());
+
+ // Stop drawing attention for another overflow-on-overflow panel by activating
+ // it. Expect the overflow indicator is not showing attention.
+ // normal: P0, P1, P2, P10
+ // overflow: P8, P5, P3, (P4, P6, P7, P9, P11)
+ panels[10]->Activate();
+ WaitForPanelActiveState(panels[10], SHOW_AS_ACTIVE);
+ EXPECT_FALSE(panels[10]->IsDrawingAttention());
+ EXPECT_FALSE(overflow_indicator->IsDrawingAttention());
+
+ // Draw attention for the top overflow panel.
+ // Expect no impact to the overflow indicator.
+ // normal: P0, P1, P2, P10
+ // overflow: P8, P5, *P3, (P4, P6, P7, P9, P11)
+ EXPECT_TRUE(IsPanelVisible(panels[3]));
+ EXPECT_FALSE(panels[3]->IsDrawingAttention());
+ panels[3]->FlashFrame();
+ EXPECT_TRUE(panels[3]->IsDrawingAttention());
+ EXPECT_FALSE(overflow_indicator->IsDrawingAttention());
+
+ // Activating a big overflow panel will cause 2 normal panels to move to the
+ // overflow area and also get the top visible overflow panel bumped to the
+ // overflow-on-overflow.
+ // Expect the overflow indicator is showing attention.
+ // normal: P0, P1, P5
+ // overflow: P2, P10, P8, (*P3, P4, P6, P7, P9, P11)
+ panels[5]->Activate();
+ WaitForPanelActiveState(panels[5], SHOW_AS_ACTIVE);
+ WaitForExpansionStateChanged(panels[5], Panel::EXPANDED);
+ EXPECT_EQ(3, panel_strip->num_panels());
+ EXPECT_EQ(9, overflow_strip->num_panels());
+ EXPECT_FALSE(IsPanelVisible(panels[3]));
+ EXPECT_TRUE(panels[3]->IsDrawingAttention());
+ EXPECT_TRUE(overflow_indicator->IsDrawingAttention());
+
+ // Close an overflow panel that would move the first oveflow-on-overflow panel
+ // to become visible. Expect the overflow indicator is not showing attention.
+ // normal: P0, P1, P5
+ // overflow: P2, P10, P3, (P4, P6, P7, P9, P11)
+ CloseWindowAndWait(panels[8]->browser());
+ EXPECT_EQ(3, panel_strip->num_panels());
+ EXPECT_EQ(8, overflow_strip->num_panels());
+ EXPECT_TRUE(panels[3]->IsDrawingAttention());
+ EXPECT_FALSE(overflow_indicator->IsDrawingAttention());
+
+ panel_manager->RemoveAll();
+}

Powered by Google App Engine
This is Rietveld 408576698