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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 #include "chrome/browser/ui/browser.h" 6 #include "chrome/browser/ui/browser.h"
7 #include "chrome/browser/ui/panels/base_panel_browser_test.h" 7 #include "chrome/browser/ui/panels/base_panel_browser_test.h"
8 #include "chrome/browser/ui/panels/native_panel.h" 8 #include "chrome/browser/ui/panels/native_panel.h"
9 #include "chrome/browser/ui/panels/panel.h" 9 #include "chrome/browser/ui/panels/panel.h"
10 #include "chrome/browser/ui/panels/panel_manager.h" 10 #include "chrome/browser/ui/panels/panel_manager.h"
11 #include "chrome/browser/ui/panels/panel_overflow_indicator.h"
11 #include "chrome/browser/ui/panels/panel_overflow_strip.h" 12 #include "chrome/browser/ui/panels/panel_overflow_strip.h"
12 #include "chrome/browser/ui/panels/panel_settings_menu_model.h" 13 #include "chrome/browser/ui/panels/panel_settings_menu_model.h"
13 #include "chrome/browser/ui/panels/panel_strip.h" 14 #include "chrome/browser/ui/panels/panel_strip.h"
14 #include "chrome/browser/ui/panels/test_panel_mouse_watcher.h" 15 #include "chrome/browser/ui/panels/test_panel_mouse_watcher.h"
15 #include "chrome/common/chrome_notification_types.h" 16 #include "chrome/common/chrome_notification_types.h"
16 #include "chrome/test/base/ui_test_utils.h" 17 #include "chrome/test/base/ui_test_utils.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 namespace { 20 namespace {
20 21
21 // We override the default value for testing purpose. 22 // We override the default value for testing purpose.
22 const int kMaxVisibleOverflowForTesting = 3; 23 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.
24 const int kMaxVisiblePanelsOnHoverForTesting = 6;
23 25
24 // Encapsulates all the info we need to verify if a panel behaves as expected 26 // Encapsulates all the info we need to verify if a panel behaves as expected
25 // when we do the overflow testing. 27 // when we do the overflow testing.
26 struct PanelData { 28 struct PanelData {
27 Panel* panel; 29 Panel* panel;
28 Panel::ExpansionState expansion_state; 30 Panel::ExpansionState expansion_state;
29 bool visible; 31 bool visible;
30 bool active; 32 bool active;
31 33
32 explicit PanelData(Panel* panel) 34 explicit PanelData(Panel* panel)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 public: 81 public:
80 PanelOverflowBrowserTest() : BasePanelBrowserTest() { 82 PanelOverflowBrowserTest() : BasePanelBrowserTest() {
81 } 83 }
82 84
83 virtual ~PanelOverflowBrowserTest() { 85 virtual ~PanelOverflowBrowserTest() {
84 } 86 }
85 87
86 virtual void SetUpOnMainThread() OVERRIDE { 88 virtual void SetUpOnMainThread() OVERRIDE {
87 BasePanelBrowserTest::SetUpOnMainThread(); 89 BasePanelBrowserTest::SetUpOnMainThread();
88 90
89 PanelManager::GetInstance()->panel_overflow_strip()-> 91 PanelManager* panel_manager = PanelManager::GetInstance();
90 set_max_visible_panels(kMaxVisibleOverflowForTesting); 92 panel_manager->panel_overflow_strip()->
93 set_max_visible_panels(kMaxVisiblePanelsForTesting);
94 panel_manager->panel_overflow_strip()->
95 set_max_visible_panels_on_hover(kMaxVisiblePanelsOnHoverForTesting);
96
97 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher();
98 panel_manager->SetMouseWatcherForTesting(mouse_watcher);
91 99
92 // All the overflow tests assume 800x600 work area. Do the check now. 100 // All the overflow tests assume 800x600 work area. Do the check now.
93 DCHECK(PanelManager::GetInstance()->work_area().width() == 800); 101 DCHECK(PanelManager::GetInstance()->work_area().width() == 800);
94 } 102 }
95 103
96 protected: 104 protected:
97 static PanelDataList GetAllNormalPanelData() { 105 static PanelDataList GetAllNormalPanelData() {
98 PanelDataList panel_data_list; 106 PanelDataList panel_data_list;
99 PanelStrip::Panels panels = 107 PanelStrip::Panels panels =
100 PanelManager::GetInstance()->panel_strip()->panels(); 108 PanelManager::GetInstance()->panel_strip()->panels();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 #define MAYBE_CheckPanelProperties CheckPanelProperties 179 #define MAYBE_CheckPanelProperties CheckPanelProperties
172 #define MAYBE_UpdateDraggableStatus UpdateDraggableStatus 180 #define MAYBE_UpdateDraggableStatus UpdateDraggableStatus
173 #define MAYBE_CreateOverflowPanels CreateOverflowPanels 181 #define MAYBE_CreateOverflowPanels CreateOverflowPanels
174 #define MAYBE_CreateMoreOverflowPanels CreateMoreOverflowPanels 182 #define MAYBE_CreateMoreOverflowPanels CreateMoreOverflowPanels
175 // http://crbug.com/107230 183 // http://crbug.com/107230
176 #define MAYBE_CreatePanelOnDelayedOverflow FAILS_CreatePanelOnDelayedOverflow 184 #define MAYBE_CreatePanelOnDelayedOverflow FAILS_CreatePanelOnDelayedOverflow
177 #define MAYBE_CloseOverflowPanels CloseOverflowPanels 185 #define MAYBE_CloseOverflowPanels CloseOverflowPanels
178 #define MAYBE_CloseNormalPanels CloseNormalPanels 186 #define MAYBE_CloseNormalPanels CloseNormalPanels
179 #define MAYBE_ActivateOverflowPanels ActivateOverflowPanels 187 #define MAYBE_ActivateOverflowPanels ActivateOverflowPanels
180 #define MAYBE_HoverOverOverflowArea HoverOverOverflowArea 188 #define MAYBE_HoverOverOverflowArea HoverOverOverflowArea
189 #define MAYBE_OverflowIndicatorCount OverflowIndicatorCount
190 #define MAYBE_DrawOverflowAttention DrawOverflowAttention
181 #else 191 #else
182 #define MAYBE_CheckPanelProperties DISABLED_CheckPanelProperties 192 #define MAYBE_CheckPanelProperties DISABLED_CheckPanelProperties
183 #define MAYBE_UpdateDraggableStatus DISABLED_UpdateDraggableStatus 193 #define MAYBE_UpdateDraggableStatus DISABLED_UpdateDraggableStatus
184 #define MAYBE_CreateOverflowPanels DISABLED_CreateOverflowPanels 194 #define MAYBE_CreateOverflowPanels DISABLED_CreateOverflowPanels
185 #define MAYBE_CreateMoreOverflowPanels DISABLED_CreateMoreOverflowPanels 195 #define MAYBE_CreateMoreOverflowPanels DISABLED_CreateMoreOverflowPanels
186 #define MAYBE_CreatePanelOnDelayedOverflow DISABLED_CreatePanelOnDelayedOverflow 196 #define MAYBE_CreatePanelOnDelayedOverflow DISABLED_CreatePanelOnDelayedOverflow
187 #define MAYBE_CloseOverflowPanels DISABLED_CloseOverflowPanels 197 #define MAYBE_CloseOverflowPanels DISABLED_CloseOverflowPanels
188 #define MAYBE_CloseNormalPanels DISABLED_CloseNormalPanels 198 #define MAYBE_CloseNormalPanels DISABLED_CloseNormalPanels
189 #define MAYBE_ActivateOverflowPanels DISABLED_ActivateOverflowPanels 199 #define MAYBE_ActivateOverflowPanels DISABLED_ActivateOverflowPanels
190 #define MAYBE_HoverOverOverflowArea DISABLED_HoverOverOverflowArea 200 #define MAYBE_HoverOverOverflowArea DISABLED_HoverOverOverflowArea
201 #define MAYBE_OverflowIndicatorCount DISABLED_OverflowIndicatorCount
202 #define MAYBE_DrawOverflowAttention DISABLED_DrawOverflowAttention
191 #endif 203 #endif
192 204
193 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CheckPanelProperties) { 205 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CheckPanelProperties) {
194 // Create 3 panels that fit. 206 // Create 3 panels that fit.
195 Panel* panel1 = CreatePanelWithBounds("1", gfx::Rect(0, 0, 250, 200)); 207 Panel* panel1 = CreatePanelWithBounds("1", gfx::Rect(0, 0, 250, 200));
196 Panel* panel2 = CreatePanelWithBounds("2", gfx::Rect(0, 0, 300, 200)); 208 Panel* panel2 = CreatePanelWithBounds("2", gfx::Rect(0, 0, 300, 200));
197 Panel* panel3 = CreatePanelWithBounds("3", gfx::Rect(0, 0, 200, 200)); 209 Panel* panel3 = CreatePanelWithBounds("3", gfx::Rect(0, 0, 200, 200));
198 210
199 // Create an overflow panel without waiting for it to be moved to overflow. 211 // Create an overflow panel without waiting for it to be moved to overflow.
200 // Check its properties before and after it is moved to overflow. 212 // Check its properties before and after it is moved to overflow.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 EXPECT_TRUE(panel->draggable()); 247 EXPECT_TRUE(panel->draggable());
236 panel->Close(); 248 panel->Close();
237 } 249 }
238 250
239 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CreateOverflowPanels) { 251 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CreateOverflowPanels) {
240 PanelManager* panel_manager = PanelManager::GetInstance(); 252 PanelManager* panel_manager = PanelManager::GetInstance();
241 PanelStrip* panel_strip = panel_manager->panel_strip(); 253 PanelStrip* panel_strip = panel_manager->panel_strip();
242 PanelOverflowStrip* panel_overflow_strip = 254 PanelOverflowStrip* panel_overflow_strip =
243 panel_manager->panel_overflow_strip(); 255 panel_manager->panel_overflow_strip();
244 256
245 const int panel_widths[] = { 257 EXPECT_EQ(0, panel_manager->num_panels());
246 250, 260, 200, // normal 258 EXPECT_EQ(0, panel_strip->num_panels());
247 255, 220 // overflow 259 EXPECT_EQ(0, panel_overflow_strip->num_panels());
248 }; 260 EXPECT_FALSE(panel_overflow_strip->overflow_indicator() &&
249 CreateOverflowPanels(3, 2, panel_widths); 261 panel_overflow_strip->overflow_indicator()->GetCount());
250 262
251 std::vector<Panel*> panels = panel_manager->panels(); 263 // Create 3 normal panels.
252 ASSERT_EQ(5u, panels.size()); 264 Panel* panel0 = CreatePanelWithBounds("Panel0", gfx::Rect(0, 0, 250, 200));
265 Panel* panel1 = CreatePanelWithBounds("Panel1", gfx::Rect(0, 0, 260, 200));
266 Panel* panel2 = CreatePanelWithBounds("Panel2", gfx::Rect(0, 0, 200, 200));
267
268 EXPECT_EQ(3, panel_manager->num_panels());
269 EXPECT_EQ(3, panel_strip->num_panels());
270 EXPECT_EQ(0, panel_overflow_strip->num_panels());
271 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.
272 panel_overflow_strip->overflow_indicator()->GetCount());
273 EXPECT_EQ(Panel::EXPANDED, panel0->expansion_state());
274 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state());
275 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state());
276
277 // Create 1 overflow panel.
278 CreatePanelParams params(
279 "Panel3", gfx::Rect(0, 0, 255, 200), SHOW_AS_INACTIVE);
280 Panel* panel3 = CreatePanelWithParams(params);
281
282 EXPECT_EQ(4, panel_manager->num_panels());
283 EXPECT_EQ(3, panel_strip->num_panels());
284 EXPECT_EQ(1, panel_overflow_strip->num_panels());
285 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.
286 EXPECT_EQ(Panel::IN_OVERFLOW, panel3->expansion_state());
287 EXPECT_TRUE(IsPanelVisible(panel3));
288
289 // Create 1 more overflow panel.
290 params.name = "Panel4";
291 Panel* panel4 = CreatePanelWithParams(params);
292
293 EXPECT_EQ(5, panel_manager->num_panels());
253 EXPECT_EQ(3, panel_strip->num_panels()); 294 EXPECT_EQ(3, panel_strip->num_panels());
254 EXPECT_EQ(2, panel_overflow_strip->num_panels()); 295 EXPECT_EQ(2, panel_overflow_strip->num_panels());
255 EXPECT_EQ(Panel::IN_OVERFLOW, panels[3]->expansion_state()); 296 EXPECT_EQ(0, panel_overflow_strip->overflow_indicator()->GetCount());
256 EXPECT_TRUE(IsPanelVisible(panels[3])); 297 EXPECT_EQ(Panel::IN_OVERFLOW, panel4->expansion_state());
257 EXPECT_EQ(Panel::IN_OVERFLOW, panels[4]->expansion_state()); 298 EXPECT_TRUE(IsPanelVisible(panel4));
258 EXPECT_TRUE(IsPanelVisible(panels[4]));
259 299
260 PanelManager::GetInstance()->RemoveAll(); 300 PanelManager::GetInstance()->RemoveAll();
261 } 301 }
262 302
263 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, 303 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest,
264 MAYBE_CreateMoreOverflowPanels) { 304 MAYBE_CreateMoreOverflowPanels) {
265 PanelManager* panel_manager = PanelManager::GetInstance(); 305 PanelManager* panel_manager = PanelManager::GetInstance();
266 PanelStrip* panel_strip = panel_manager->panel_strip(); 306 PanelStrip* panel_strip = panel_manager->panel_strip();
267 PanelOverflowStrip* panel_overflow_strip = 307 PanelOverflowStrip* panel_overflow_strip =
268 panel_manager->panel_overflow_strip(); 308 panel_manager->panel_overflow_strip();
269 309
270 const int panel_widths[] = { 310 const int panel_widths[] = {
271 250, 260, 200, // normal 311 250, 260, 200, // normal
272 255, 220, 210, // overflow 312 255, 220, 210, // overflow
273 220, 230 // overflow-on-overflow 313 220, 230 // overflow-on-overflow
274 }; 314 };
275 CreateOverflowPanels(3, 5, panel_widths); 315 CreateOverflowPanels(3, 5, panel_widths);
276 316
277 std::vector<Panel*> panels = panel_manager->panels(); 317 std::vector<Panel*> panels = panel_manager->panels();
278 ASSERT_EQ(8u, panels.size()); 318 ASSERT_EQ(8u, panels.size());
279 EXPECT_EQ(3, panel_strip->num_panels()); 319 EXPECT_EQ(3, panel_strip->num_panels());
280 EXPECT_EQ(5, panel_overflow_strip->num_panels()); 320 EXPECT_EQ(5, panel_overflow_strip->num_panels());
321 EXPECT_EQ(2, panel_overflow_strip->overflow_indicator()->GetCount());
281 EXPECT_EQ(Panel::IN_OVERFLOW, panels[3]->expansion_state()); 322 EXPECT_EQ(Panel::IN_OVERFLOW, panels[3]->expansion_state());
282 EXPECT_TRUE(IsPanelVisible(panels[3])); 323 EXPECT_TRUE(IsPanelVisible(panels[3]));
283 EXPECT_EQ(Panel::IN_OVERFLOW, panels[4]->expansion_state()); 324 EXPECT_EQ(Panel::IN_OVERFLOW, panels[4]->expansion_state());
284 EXPECT_TRUE(IsPanelVisible(panels[4])); 325 EXPECT_TRUE(IsPanelVisible(panels[4]));
285 EXPECT_EQ(Panel::IN_OVERFLOW, panels[5]->expansion_state()); 326 EXPECT_EQ(Panel::IN_OVERFLOW, panels[5]->expansion_state());
286 EXPECT_TRUE(IsPanelVisible(panels[5])); 327 EXPECT_TRUE(IsPanelVisible(panels[5]));
287 EXPECT_EQ(Panel::IN_OVERFLOW, panels[6]->expansion_state()); 328 EXPECT_EQ(Panel::IN_OVERFLOW, panels[6]->expansion_state());
288 EXPECT_FALSE(IsPanelVisible(panels[6])); 329 EXPECT_FALSE(IsPanelVisible(panels[6]));
289 EXPECT_EQ(Panel::IN_OVERFLOW, panels[7]->expansion_state()); 330 EXPECT_EQ(Panel::IN_OVERFLOW, panels[7]->expansion_state());
290 EXPECT_FALSE(IsPanelVisible(panels[7])); 331 EXPECT_FALSE(IsPanelVisible(panels[7]));
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 expected_overflow_list.Add(panels[3], Panel::IN_OVERFLOW, true, false); 696 expected_overflow_list.Add(panels[3], Panel::IN_OVERFLOW, true, false);
656 expected_overflow_list.Add(panels[2], Panel::IN_OVERFLOW, false, false); 697 expected_overflow_list.Add(panels[2], Panel::IN_OVERFLOW, false, false);
657 expected_overflow_list.Add(panels[5], Panel::IN_OVERFLOW, false, false); 698 expected_overflow_list.Add(panels[5], Panel::IN_OVERFLOW, false, false);
658 EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData()); 699 EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
659 700
660 PanelManager::GetInstance()->RemoveAll(); 701 PanelManager::GetInstance()->RemoveAll();
661 } 702 }
662 703
663 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_HoverOverOverflowArea) { 704 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_HoverOverOverflowArea) {
664 PanelManager* panel_manager = PanelManager::GetInstance(); 705 PanelManager* panel_manager = PanelManager::GetInstance();
665 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher();
666 panel_manager->SetMouseWatcherForTesting(mouse_watcher);
667 PanelOverflowStrip* panel_overflow_strip = 706 PanelOverflowStrip* panel_overflow_strip =
668 panel_manager->panel_overflow_strip(); 707 panel_manager->panel_overflow_strip();
669 int iconified_width = panel_overflow_strip->current_display_width(); 708 int iconified_width = panel_overflow_strip->current_display_width();
670 709
671 // Create normal and overflow panels. 710 // Create normal and overflow panels.
672 // normal: P0, P1, P2 711 // normal: P0, P1, P2
673 // overflow: P3, P4, P5 712 // overflow: P3, P4, P5
674 // overflow-on-overflow: P6, P7 713 // overflow-on-overflow: P6, P7
675 const int panel_widths[] = { 714 const int panel_widths[] = {
676 250, 260, 200, // normal 715 250, 260, 200, // normal
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 panels[7]->GetBounds().x(), panels[7]->GetBounds().y() - 1)); 798 panels[7]->GetBounds().x(), panels[7]->GetBounds().y() - 1));
760 EXPECT_EQ(iconified_width, panel_overflow_strip->current_display_width()); 799 EXPECT_EQ(iconified_width, panel_overflow_strip->current_display_width());
761 EXPECT_EQ(iconified_width, panels[3]->GetBounds().width()); 800 EXPECT_EQ(iconified_width, panels[3]->GetBounds().width());
762 EXPECT_EQ(iconified_width, panels[4]->GetBounds().width()); 801 EXPECT_EQ(iconified_width, panels[4]->GetBounds().width());
763 EXPECT_EQ(iconified_width, panels[5]->GetBounds().width()); 802 EXPECT_EQ(iconified_width, panels[5]->GetBounds().width());
764 EXPECT_EQ(0, panels[6]->GetBounds().width()); 803 EXPECT_EQ(0, panels[6]->GetBounds().width());
765 EXPECT_EQ(0, panels[7]->GetBounds().width()); 804 EXPECT_EQ(0, panels[7]->GetBounds().width());
766 805
767 panel_manager->RemoveAll(); 806 panel_manager->RemoveAll();
768 } 807 }
808
809 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_OverflowIndicatorCount) {
810 PanelManager* panel_manager = PanelManager::GetInstance();
811 PanelOverflowStrip* panel_overflow_strip =
812 panel_manager->panel_overflow_strip();
813
814 // Create normal and overflow panels.
815 // normal: P0, P1, P2
816 // overflow: P3, P4, P5
817 const int panel_widths[] = {
818 250, 250, 210, // normal
819 250, 250, 260 // overflow
820 };
821 std::vector<Panel*> panels = CreateOverflowPanels(3, 3, panel_widths);
822 EXPECT_EQ(3, panel_overflow_strip->num_panels());
823 PanelOverflowIndicator* overflow_indicator =
824 panel_overflow_strip->overflow_indicator();
825 EXPECT_EQ(0, overflow_indicator->GetCount());
jennb 2011/12/20 02:08:23 Expect no indicator.
jianli 2011/12/20 22:08:10 Done.
826
827 // Create 5 overflow-on-overflow panels.
828 // normal: P0, P1, P2
829 // overflow: P3, P4, P5, (P6, P7, P8, P9, P10)
830 // The panels enclosed in parentheses are hidden.
831 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.
832 for (int i = 0; i < 5; ++i) {
833 CreatePanelParams params(
834 MakePanelName(num_existing_panels + i),
835 gfx::Rect(0, 0, 250, 200),
836 SHOW_AS_INACTIVE);
837 Panel* panel = CreatePanelWithParams(params);
838 WaitForExpansionStateChanged(panel, Panel::IN_OVERFLOW);
839 EXPECT_EQ(i + 1, overflow_indicator->GetCount());
840 panels.push_back(panel);
841 }
842
843 // Expand the overflow area by moving mouse over it.
844 // Expect the overflow indicator count gets updated.
845 // normal: P0, P1, P2
846 // overflow: P3, P4, P5, P6, P7, P8, (P9, P10)
847 MoveMouseAndWaitForOverflowAnimationEnded(panels[3]->GetBounds().origin());
848 EXPECT_TRUE(IsPanelVisible(panels[6]));
849 EXPECT_TRUE(IsPanelVisible(panels[7]));
850 EXPECT_TRUE(IsPanelVisible(panels[8]));
851 EXPECT_FALSE(IsPanelVisible(panels[9]));
852 EXPECT_FALSE(IsPanelVisible(panels[10]));
853 EXPECT_EQ(2, overflow_indicator->GetCount());
854
855 // Close an overflow panel that makes one overflow-on-overflow panel become
856 // visible. Expect the overflow indicator count gets decreased by 1.
857 // normal: P0, P1, P2
858 // overflow: P4, P5, P6, P7, P8, P9, (P10)
859 CloseWindowAndWait(panels[3]->browser());
860 EXPECT_TRUE(IsPanelVisible(panels[6]));
861 EXPECT_TRUE(IsPanelVisible(panels[7]));
862 EXPECT_TRUE(IsPanelVisible(panels[8]));
863 EXPECT_TRUE(IsPanelVisible(panels[9]));
864 EXPECT_FALSE(IsPanelVisible(panels[10]));
865 EXPECT_EQ(1, overflow_indicator->GetCount());
866
867 // 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.
868 // area. Expect the overflow indicator count gets updated.
869 // normal: P0, P1, P2
870 // overflow: P4, P5, P6, (P7, P8, P9, P10)
871 MoveMouseAndWaitForOverflowAnimationEnded(gfx::Point(
872 panels[4]->GetBounds().right() + 5, panels[4]->GetBounds().y()));
873 EXPECT_TRUE(IsPanelVisible(panels[6]));
874 EXPECT_FALSE(IsPanelVisible(panels[7]));
875 EXPECT_FALSE(IsPanelVisible(panels[8]));
876 EXPECT_FALSE(IsPanelVisible(panels[9]));
877 EXPECT_FALSE(IsPanelVisible(panels[10]));
878 EXPECT_EQ(4, overflow_indicator->GetCount());
879
880 // Close an overflow panel.
881 // Expect the overflow indicator count gets decreased by 1.
882 // normal: P0, P1, P2
883 // overflow: P5, P6, P7, (P8, P9, P10)
884 CloseWindowAndWait(panels[4]->browser());
885 EXPECT_TRUE(IsPanelVisible(panels[6]));
886 EXPECT_TRUE(IsPanelVisible(panels[7]));
887 EXPECT_FALSE(IsPanelVisible(panels[8]));
888 EXPECT_FALSE(IsPanelVisible(panels[9]));
889 EXPECT_FALSE(IsPanelVisible(panels[10]));
890 EXPECT_EQ(3, overflow_indicator->GetCount());
891
892 // Activating a big overflow panel will cause 2 normal panels to move to the
893 // 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.
894 // overflow-on-overflow.
895 // Expect the overflow indicator count gets increased by 1.
896 // normal: P0, P5
897 // overflow: P1, P2, P6, (P7, P8, P9, P10)
898 panels[5]->Activate();
899 WaitForPanelActiveState(panels[5], SHOW_AS_ACTIVE);
900 WaitForExpansionStateChanged(panels[5], Panel::EXPANDED);
901 EXPECT_TRUE(IsPanelVisible(panels[6]));
902 EXPECT_FALSE(IsPanelVisible(panels[7]));
903 EXPECT_FALSE(IsPanelVisible(panels[8]));
904 EXPECT_FALSE(IsPanelVisible(panels[9]));
905 EXPECT_FALSE(IsPanelVisible(panels[10]));
906 EXPECT_EQ(4, overflow_indicator->GetCount());
907
908 panel_manager->RemoveAll();
909 }
910
911 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_DrawOverflowAttention) {
jennb 2011/12/20 02:08:23 Very thorough coverage of many scenarios!
912 PanelManager* panel_manager = PanelManager::GetInstance();
913 PanelStrip* panel_strip = panel_manager->panel_strip();
914 PanelOverflowStrip* overflow_strip = panel_manager->panel_overflow_strip();
915
916 // Create normal and overflow panels.
917 // normal: P0, P1, P2, P3
918 // overflow: P4, P5, P6, (P7, P8, P9, P10, P11)
919 // The panels enclosed in parentheses are hidden.
920 const int panel_widths[] = {
921 100, 210, 210, 210, // normal
922 210, 260, 210, // overflow
923 210, 210, 210, // overflow-on-overflow on shrunk
924 210, 210 // overflow-on-overflow on expanded
925 };
926 std::vector<Panel*> panels = CreateOverflowPanels(4, 8, panel_widths);
927 EXPECT_EQ(4, panel_strip->num_panels());
928 EXPECT_EQ(8, overflow_strip->num_panels());
929 PanelOverflowIndicator* overflow_indicator =
930 overflow_strip->overflow_indicator();
931
932 // 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.
933 // Expect no impact to the overflow indicator.
934 // normal: P0, P1, P2, P3
935 // overflow: P4, *P5, P6, (P7, P8, P9, P10, P11)
936 EXPECT_FALSE(panels[5]->IsDrawingAttention());
937 panels[5]->FlashFrame();
938 EXPECT_TRUE(panels[5]->IsDrawingAttention());
939 EXPECT_FALSE(overflow_indicator->IsDrawingAttention());
940
941 // Activating this overflow panel will clear its attention.
942 // Expect no impact to the overflow indicator.
943 // normal: P0, P1, P2, P5
944 // overflow: P3, P4, P6, (P7, P8, P9, P10, P11)
945 panels[5]->Activate();
946 WaitForPanelActiveState(panels[5], SHOW_AS_ACTIVE);
947 EXPECT_FALSE(panels[5]->IsDrawingAttention());
948 EXPECT_FALSE(overflow_indicator->IsDrawingAttention());
949
950 // Draw attention for an overflow-on-overflow panel.
951 // Expect the overflow indicator is showing attention.
952 // normal: P0, P1, P2, P5
953 // overflow: P3, P4, P6, (P7, *P8, P9, P10, P11)
954 EXPECT_FALSE(panels[8]->IsDrawingAttention());
955 panels[8]->FlashFrame();
956 EXPECT_TRUE(panels[8]->IsDrawingAttention());
957 EXPECT_TRUE(overflow_indicator->IsDrawingAttention());
958
959 // Draw attention for another overflow-on-overflow panel.
960 // Expect the overflow indicator is still showing attention.
961 // normal: P0, P1, P2, P5
962 // overflow: P3, P4, P6, (P7, *P8, P9, *P10, P11)
963 EXPECT_FALSE(panels[10]->IsDrawingAttention());
964 panels[10]->FlashFrame();
965 EXPECT_TRUE(panels[10]->IsDrawingAttention());
966 EXPECT_TRUE(overflow_indicator->IsDrawingAttention());
967
968 // Stop drawing attention for an overflow-on-overflow panel by activating it.
969 // Expect the overflow indicator is still showing attention.
970 // normal: P0, P1, P2, P8
971 // overflow: P5, P3, P4, (P6, P7, P9, *P10, P11)
972 panels[8]->Activate();
973 WaitForPanelActiveState(panels[8], SHOW_AS_ACTIVE);
974 EXPECT_FALSE(panels[8]->IsDrawingAttention());
975 EXPECT_TRUE(overflow_indicator->IsDrawingAttention());
976
977 // Stop drawing attention for another overflow-on-overflow panel by activating
978 // it. Expect the overflow indicator is not showing attention.
979 // normal: P0, P1, P2, P10
980 // overflow: P8, P5, P3, (P4, P6, P7, P9, P11)
981 panels[10]->Activate();
982 WaitForPanelActiveState(panels[10], SHOW_AS_ACTIVE);
983 EXPECT_FALSE(panels[10]->IsDrawingAttention());
984 EXPECT_FALSE(overflow_indicator->IsDrawingAttention());
985
986 // Draw attention for the top overflow panel.
987 // Expect no impact to the overflow indicator.
988 // normal: P0, P1, P2, P10
989 // overflow: P8, P5, *P3, (P4, P6, P7, P9, P11)
990 EXPECT_TRUE(IsPanelVisible(panels[3]));
991 EXPECT_FALSE(panels[3]->IsDrawingAttention());
992 panels[3]->FlashFrame();
993 EXPECT_TRUE(panels[3]->IsDrawingAttention());
994 EXPECT_FALSE(overflow_indicator->IsDrawingAttention());
995
996 // Activating a big overflow panel will cause 2 normal panels to move to the
997 // overflow area and also get the top visible overflow panel bumped to the
998 // overflow-on-overflow.
999 // Expect the overflow indicator is showing attention.
1000 // normal: P0, P1, P5
1001 // overflow: P2, P10, P8, (*P3, P4, P6, P7, P9, P11)
1002 panels[5]->Activate();
1003 WaitForPanelActiveState(panels[5], SHOW_AS_ACTIVE);
1004 WaitForExpansionStateChanged(panels[5], Panel::EXPANDED);
1005 EXPECT_EQ(3, panel_strip->num_panels());
1006 EXPECT_EQ(9, overflow_strip->num_panels());
1007 EXPECT_FALSE(IsPanelVisible(panels[3]));
1008 EXPECT_TRUE(panels[3]->IsDrawingAttention());
1009 EXPECT_TRUE(overflow_indicator->IsDrawingAttention());
1010
1011 // Close an overflow panel that would move the first oveflow-on-overflow panel
1012 // to become visible. Expect the overflow indicator is not showing attention.
1013 // normal: P0, P1, P5
1014 // overflow: P2, P10, P3, (P4, P6, P7, P9, P11)
1015 CloseWindowAndWait(panels[8]->browser());
1016 EXPECT_EQ(3, panel_strip->num_panels());
1017 EXPECT_EQ(8, overflow_strip->num_panels());
1018 EXPECT_TRUE(panels[3]->IsDrawingAttention());
1019 EXPECT_FALSE(overflow_indicator->IsDrawingAttention());
1020
1021 panel_manager->RemoveAll();
1022 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698