Chromium Code Reviews| 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 af7f1682d1d717f4bdcd440b639d785168ef6b55..1e77b7bbf57023d6711808b7eb5cf1f3df95fc68 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 kMaxVisibleOnShrunkForTesting = 3; |
|
jennb
2011/12/19 22:24:50
"OnShrunk" and "OnExpanded" aren't as self-explana
jianli
2011/12/20 01:20:41
Done.
|
| +const int kMaxVisibleOnExpandedForTesting = 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_on_shrunk(kMaxVisibleOnShrunkForTesting); |
| + panel_manager->panel_overflow_strip()-> |
| + set_max_visible_panels_on_expanded(kMaxVisibleOnExpandedForTesting); |
| + |
| + 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); |
| @@ -176,6 +184,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_CreateOverflowPanels DISABLED_CreateOverflowPanels |
| #define MAYBE_CreateMoreOverflowPanels DISABLED_CreateMoreOverflowPanels |
| @@ -184,6 +194,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_CreateOverflowPanels) { |
| @@ -202,6 +214,7 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CreateOverflowPanels) { |
| ASSERT_EQ(5u, panels.size()); |
| EXPECT_EQ(3, panel_strip->num_panels()); |
| EXPECT_EQ(2, panel_overflow_strip->num_panels()); |
| + EXPECT_EQ(0, panel_overflow_strip->overflow_indicator()->GetCount()); |
|
jennb
2011/12/19 22:24:50
Do you have test coverage to check that if this co
jianli
2011/12/20 01:20:41
Done.
|
| EXPECT_EQ(Panel::IN_OVERFLOW, panels[3]->expansion_state()); |
| EXPECT_TRUE(IsPanelVisible(panels[3])); |
| EXPECT_EQ(Panel::IN_OVERFLOW, panels[4]->expansion_state()); |
| @@ -228,6 +241,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()); |
| @@ -612,8 +626,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(); |
| @@ -716,3 +728,179 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_HoverOverOverflowArea) { |
| panel_manager->RemoveAll(); |
| } |
| + |
| +IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_OverflowIndicatorCount) { |
|
jennb
2011/12/19 22:24:50
Need case for moving a big overflow panel into nor
jianli
2011/12/20 01:20:41
Done.
|
| + 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[] = { |
| + 240, 240, 240, // normal |
| + 240, 240, 240 // 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()); |
| + |
| + // Create 5 overflow-on-overflow panels. |
| + // normal: P0, P1, P2 |
| + // overflow: P3, P4, P5 |
| + // overflow-on-overflow: P6, P7, P8 |
| + // P9, P10 |
| + for (int i = 1; i <= 5; ++i) { |
| + CreatePanelParams params( |
| + MakePanelName(5 + i), |
|
jennb
2011/12/19 22:24:50
Should replace this 5 with size of panels vector.
jianli
2011/12/20 01:20:41
Done.
|
| + gfx::Rect(0, 0, 240, 200), |
| + SHOW_AS_INACTIVE); |
| + Panel* panel = CreatePanelWithParams(params); |
| + WaitForExpansionStateChanged(panel, Panel::IN_OVERFLOW); |
| + EXPECT_EQ(i, overflow_indicator->GetCount()); |
| + panels.push_back(panel); |
| + } |
| + |
| + // Expand the overflow area by moving mouse over it. |
| + // Expect the overflow indicator count gets updated. |
| + MoveMouseAndWaitForOverflowAnimationEnded(panels[3]->GetBounds().origin()); |
| + EXPECT_EQ(2, overflow_indicator->GetCount()); |
| + |
| + // Close an overflow panel. |
| + // Expect the overflow indicator count gets updated. |
| + CloseWindowAndWait(panels[3]->browser()); |
| + EXPECT_EQ(1, overflow_indicator->GetCount()); |
|
jennb
2011/12/19 22:24:50
Check that one of the overflow-on-overflow panels
jianli
2011/12/20 01:20:41
Done.
|
| + |
| + // Shrunk the overflow area by moving mouse over it. |
|
jennb
2011/12/19 22:24:50
Stop hovering the mouse over the overflow area.
jianli
2011/12/20 01:20:41
Done.
|
| + // Expect the overflow indicator count gets updated. |
| + MoveMouseAndWaitForOverflowAnimationEnded( |
| + gfx::Point(panels[4]->GetBounds().right() + 5, panels[4]->GetBounds().y())); |
| + EXPECT_EQ(4, overflow_indicator->GetCount()); |
|
jennb
2011/12/19 22:24:50
Verify overflow-of-overflow panels no longer visib
jianli
2011/12/20 01:20:41
Done.
|
| + |
| + // Close an overflow panel. |
| + // Expect the overflow indicator count gets updated. |
| + CloseWindowAndWait(panels[4]->browser()); |
| + EXPECT_EQ(3, overflow_indicator->GetCount()); |
| + |
| + panel_manager->RemoveAll(); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_DrawOverflowAttention) { |
| + PanelManager* panel_manager = PanelManager::GetInstance(); |
| + panel_manager->enable_auto_sizing(true); |
|
jennb
2011/12/19 22:24:50
This surprised me in a draw attention test. I actu
jianli
2011/12/20 01:20:41
Done.
|
| + 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 |
| + // overflow-on-overflow: P7, P8, P9, (P10, P11) |
| + const int panel_widths[] = { |
| + 100, 210, 210, 210, // normal |
| + 210, 210, 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. |
| + // Expect no impact to the overflow indicator. |
| + // normal: P0, P1, P2, P3 |
| + // overflow: P4, *P5, P6 |
| + // overflow-on-overflow: 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 |
| + // overflow-on-overflow: 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 |
| + // overflow-on-overflow: 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 anther overflow-on-overflow panel. |
| + // Expect the overflow indicator is still showing attention. |
| + // normal: P0, P1, P2, P5 |
| + // overflow: P3, P4, P6 |
| + // overflow-on-overflow: 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 |
| + // overflow-on-overflow: 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 anther overflow-on-overflow panel by activating |
|
jennb
2011/12/19 22:24:50
anther
jianli
2011/12/20 01:20:41
Done.
|
| + // it. Expect the overflow indicator is not showing attention. |
| + // normal: P0, P1, P2, P10 |
| + // overflow: P8, P5, P3 |
| + // overflow-on-overflow: 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 |
| + // overflow-on-overflow: P4, P6, P7, (P9, P11) |
| + EXPECT_FALSE(panels[3]->IsDrawingAttention()); |
| + panels[3]->FlashFrame(); |
| + EXPECT_TRUE(panels[3]->IsDrawingAttention()); |
| + EXPECT_FALSE(overflow_indicator->IsDrawingAttention()); |
| + |
| + // Enlarge a normal panel that would bump one normal panel to the overflow |
| + // area and the top overflow panel gets moved to overflow-on-overflow. |
| + // Expect the overflow indicator is showing attention. |
| + // normal: P0, P1, P2 |
| + // overflow: P10, P8, P5 |
| + // overflow-on-overflow: *P3, P4, P6, (P7, P9, P11) |
| + panel_manager->OnPreferredWindowSizeChanged(panels[0], gfx::Size(260, 200)); |
| + EXPECT_EQ(3, panel_strip->num_panels()); |
| + EXPECT_EQ(9, overflow_strip->num_panels()); |
| + 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, P2 |
| + // overflow: P10, P5, P3 |
| + // overflow-on-overflow: 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(); |
| +} |