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

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 trybot 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 kMaxVisibleOverflowPanelsForTesting = 3;
24 const int kMaxVisibleOverflowPanelsOnHoverForTesting = 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()->set_max_visible_panels(
93 kMaxVisibleOverflowPanelsForTesting);
94 panel_manager->panel_overflow_strip()->set_max_visible_panels_on_hover(
95 kMaxVisibleOverflowPanelsOnHoverForTesting);
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 CreatePanelOnDelayedOverflow 184 #define MAYBE_CreatePanelOnDelayedOverflow CreatePanelOnDelayedOverflow
177 #define MAYBE_CloseOverflowPanels CloseOverflowPanels 185 #define MAYBE_CloseOverflowPanels CloseOverflowPanels
178 #define MAYBE_CloseNormalPanels CloseNormalPanels 186 #define MAYBE_CloseNormalPanels CloseNormalPanels
179 #define MAYBE_CloseWithDelayedOverflow CloseWithDelayedOverflow 187 #define MAYBE_CloseWithDelayedOverflow CloseWithDelayedOverflow
180 #define MAYBE_ActivateOverflowPanels ActivateOverflowPanels 188 #define MAYBE_ActivateOverflowPanels ActivateOverflowPanels
181 #define MAYBE_HoverOverOverflowArea HoverOverOverflowArea 189 #define MAYBE_HoverOverOverflowArea HoverOverOverflowArea
182 #define MAYBE_ResizePanel ResizePanel 190 #define MAYBE_ResizePanel ResizePanel
191 #define MAYBE_OverflowIndicatorCount OverflowIndicatorCount
192 #define MAYBE_DrawOverflowAttention DrawOverflowAttention
183 #else 193 #else
184 #define MAYBE_CheckPanelProperties DISABLED_CheckPanelProperties 194 #define MAYBE_CheckPanelProperties DISABLED_CheckPanelProperties
185 #define MAYBE_UpdateDraggableStatus DISABLED_UpdateDraggableStatus 195 #define MAYBE_UpdateDraggableStatus DISABLED_UpdateDraggableStatus
186 #define MAYBE_CreateOverflowPanels DISABLED_CreateOverflowPanels 196 #define MAYBE_CreateOverflowPanels DISABLED_CreateOverflowPanels
187 #define MAYBE_CreateMoreOverflowPanels DISABLED_CreateMoreOverflowPanels 197 #define MAYBE_CreateMoreOverflowPanels DISABLED_CreateMoreOverflowPanels
188 #define MAYBE_CreatePanelOnDelayedOverflow DISABLED_CreatePanelOnDelayedOverflow 198 #define MAYBE_CreatePanelOnDelayedOverflow DISABLED_CreatePanelOnDelayedOverflow
189 #define MAYBE_CloseOverflowPanels DISABLED_CloseOverflowPanels 199 #define MAYBE_CloseOverflowPanels DISABLED_CloseOverflowPanels
190 #define MAYBE_CloseNormalPanels DISABLED_CloseNormalPanels 200 #define MAYBE_CloseNormalPanels DISABLED_CloseNormalPanels
191 #define MAYBE_CloseWithDelayedOverflow DISABLED_CloseWithDelayedOverflow 201 #define MAYBE_CloseWithDelayedOverflow DISABLED_CloseWithDelayedOverflow
192 #define MAYBE_ActivateOverflowPanels DISABLED_ActivateOverflowPanels 202 #define MAYBE_ActivateOverflowPanels DISABLED_ActivateOverflowPanels
193 #define MAYBE_HoverOverOverflowArea DISABLED_HoverOverOverflowArea 203 #define MAYBE_HoverOverOverflowArea DISABLED_HoverOverOverflowArea
194 #define MAYBE_ResizePanel DISABLED_ResizePanel 204 #define MAYBE_ResizePanel DISABLED_ResizePanel
205 #define MAYBE_OverflowIndicatorCount DISABLED_OverflowIndicatorCount
206 #define MAYBE_DrawOverflowAttention DISABLED_DrawOverflowAttention
195 #endif 207 #endif
196 208
197 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CheckPanelProperties) { 209 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CheckPanelProperties) {
198 // Create 3 panels that fit. 210 // Create 3 panels that fit.
199 Panel* panel1 = CreatePanelWithBounds("1", gfx::Rect(0, 0, 250, 200)); 211 Panel* panel1 = CreatePanelWithBounds("1", gfx::Rect(0, 0, 250, 200));
200 Panel* panel2 = CreatePanelWithBounds("2", gfx::Rect(0, 0, 300, 200)); 212 Panel* panel2 = CreatePanelWithBounds("2", gfx::Rect(0, 0, 300, 200));
201 Panel* panel3 = CreatePanelWithBounds("3", gfx::Rect(0, 0, 200, 200)); 213 Panel* panel3 = CreatePanelWithBounds("3", gfx::Rect(0, 0, 200, 200));
202 214
203 // Create an overflow panel without waiting for it to be moved to overflow. 215 // Create an overflow panel without waiting for it to be moved to overflow.
204 // Check its properties before and after it is moved to overflow. 216 // Check its properties before and after it is moved to overflow.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 EXPECT_TRUE(panel->draggable()); 251 EXPECT_TRUE(panel->draggable());
240 panel->Close(); 252 panel->Close();
241 } 253 }
242 254
243 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CreateOverflowPanels) { 255 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CreateOverflowPanels) {
244 PanelManager* panel_manager = PanelManager::GetInstance(); 256 PanelManager* panel_manager = PanelManager::GetInstance();
245 PanelStrip* panel_strip = panel_manager->panel_strip(); 257 PanelStrip* panel_strip = panel_manager->panel_strip();
246 PanelOverflowStrip* panel_overflow_strip = 258 PanelOverflowStrip* panel_overflow_strip =
247 panel_manager->panel_overflow_strip(); 259 panel_manager->panel_overflow_strip();
248 260
249 const int panel_widths[] = { 261 EXPECT_EQ(0, panel_manager->num_panels());
250 250, 260, 200, // normal 262 EXPECT_EQ(0, panel_strip->num_panels());
251 255, 220 // overflow 263 EXPECT_EQ(0, panel_overflow_strip->num_panels());
252 }; 264 EXPECT_FALSE(panel_overflow_strip->overflow_indicator());
253 CreateOverflowPanels(3, 2, panel_widths);
254 265
255 std::vector<Panel*> panels = panel_manager->panels(); 266 // Create 3 normal panels.
256 ASSERT_EQ(5u, panels.size()); 267 Panel* panel0 = CreatePanelWithBounds("Panel0", gfx::Rect(0, 0, 250, 200));
268 Panel* panel1 = CreatePanelWithBounds("Panel1", gfx::Rect(0, 0, 260, 200));
269 Panel* panel2 = CreatePanelWithBounds("Panel2", gfx::Rect(0, 0, 200, 200));
270
271 EXPECT_EQ(3, panel_manager->num_panels());
272 EXPECT_EQ(3, panel_strip->num_panels());
273 EXPECT_EQ(0, panel_overflow_strip->num_panels());
274 EXPECT_FALSE(panel_overflow_strip->overflow_indicator());
275 EXPECT_EQ(Panel::EXPANDED, panel0->expansion_state());
276 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state());
277 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state());
278
279 // Create 1 overflow panel.
280 CreatePanelParams params(
281 "Panel3", gfx::Rect(0, 0, 255, 200), SHOW_AS_INACTIVE);
282 Panel* panel3 = CreatePanelWithParams(params);
283 WaitForExpansionStateChanged(panel3, Panel::IN_OVERFLOW);
284
285 EXPECT_EQ(4, panel_manager->num_panels());
286 EXPECT_EQ(3, panel_strip->num_panels());
287 EXPECT_EQ(1, panel_overflow_strip->num_panels());
288 EXPECT_FALSE(panel_overflow_strip->overflow_indicator());
289 EXPECT_TRUE(IsPanelVisible(panel3));
290
291 // Create 1 more overflow panel.
292 params.name = "Panel4";
293 Panel* panel4 = CreatePanelWithParams(params);
294 WaitForExpansionStateChanged(panel4, Panel::IN_OVERFLOW);
295
296 EXPECT_EQ(5, panel_manager->num_panels());
257 EXPECT_EQ(3, panel_strip->num_panels()); 297 EXPECT_EQ(3, panel_strip->num_panels());
258 EXPECT_EQ(2, panel_overflow_strip->num_panels()); 298 EXPECT_EQ(2, panel_overflow_strip->num_panels());
259 EXPECT_EQ(Panel::IN_OVERFLOW, panels[3]->expansion_state()); 299 EXPECT_FALSE(panel_overflow_strip->overflow_indicator());
260 EXPECT_TRUE(IsPanelVisible(panels[3])); 300 EXPECT_TRUE(IsPanelVisible(panel4));
261 EXPECT_EQ(Panel::IN_OVERFLOW, panels[4]->expansion_state());
262 EXPECT_TRUE(IsPanelVisible(panels[4]));
263 301
264 PanelManager::GetInstance()->RemoveAll(); 302 PanelManager::GetInstance()->RemoveAll();
265 } 303 }
266 304
267 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, 305 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest,
268 MAYBE_CreateMoreOverflowPanels) { 306 MAYBE_CreateMoreOverflowPanels) {
269 PanelManager* panel_manager = PanelManager::GetInstance(); 307 PanelManager* panel_manager = PanelManager::GetInstance();
270 PanelStrip* panel_strip = panel_manager->panel_strip(); 308 PanelStrip* panel_strip = panel_manager->panel_strip();
271 PanelOverflowStrip* panel_overflow_strip = 309 PanelOverflowStrip* panel_overflow_strip =
272 panel_manager->panel_overflow_strip(); 310 panel_manager->panel_overflow_strip();
273 311
274 const int panel_widths[] = { 312 const int panel_widths[] = {
275 250, 260, 200, // normal 313 250, 260, 200, // normal
276 255, 220, 210, // overflow 314 255, 220, 210, // overflow
277 220, 230 // overflow-on-overflow 315 220, 230 // overflow-on-overflow
278 }; 316 };
279 CreateOverflowPanels(3, 5, panel_widths); 317 CreateOverflowPanels(3, 5, panel_widths);
280 318
281 std::vector<Panel*> panels = panel_manager->panels(); 319 std::vector<Panel*> panels = panel_manager->panels();
282 ASSERT_EQ(8u, panels.size()); 320 ASSERT_EQ(8u, panels.size());
283 EXPECT_EQ(3, panel_strip->num_panels()); 321 EXPECT_EQ(3, panel_strip->num_panels());
284 EXPECT_EQ(5, panel_overflow_strip->num_panels()); 322 EXPECT_EQ(5, panel_overflow_strip->num_panels());
323 EXPECT_EQ(2, panel_overflow_strip->overflow_indicator()->GetCount());
285 EXPECT_EQ(Panel::IN_OVERFLOW, panels[3]->expansion_state()); 324 EXPECT_EQ(Panel::IN_OVERFLOW, panels[3]->expansion_state());
286 EXPECT_TRUE(IsPanelVisible(panels[3])); 325 EXPECT_TRUE(IsPanelVisible(panels[3]));
287 EXPECT_EQ(Panel::IN_OVERFLOW, panels[4]->expansion_state()); 326 EXPECT_EQ(Panel::IN_OVERFLOW, panels[4]->expansion_state());
288 EXPECT_TRUE(IsPanelVisible(panels[4])); 327 EXPECT_TRUE(IsPanelVisible(panels[4]));
289 EXPECT_EQ(Panel::IN_OVERFLOW, panels[5]->expansion_state()); 328 EXPECT_EQ(Panel::IN_OVERFLOW, panels[5]->expansion_state());
290 EXPECT_TRUE(IsPanelVisible(panels[5])); 329 EXPECT_TRUE(IsPanelVisible(panels[5]));
291 EXPECT_EQ(Panel::IN_OVERFLOW, panels[6]->expansion_state()); 330 EXPECT_EQ(Panel::IN_OVERFLOW, panels[6]->expansion_state());
292 EXPECT_FALSE(IsPanelVisible(panels[6])); 331 EXPECT_FALSE(IsPanelVisible(panels[6]));
293 EXPECT_EQ(Panel::IN_OVERFLOW, panels[7]->expansion_state()); 332 EXPECT_EQ(Panel::IN_OVERFLOW, panels[7]->expansion_state());
294 EXPECT_FALSE(IsPanelVisible(panels[7])); 333 EXPECT_FALSE(IsPanelVisible(panels[7]));
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 expected_overflow_list.Add(panels[3], Panel::IN_OVERFLOW, true, false); 755 expected_overflow_list.Add(panels[3], Panel::IN_OVERFLOW, true, false);
717 expected_overflow_list.Add(panels[2], Panel::IN_OVERFLOW, false, false); 756 expected_overflow_list.Add(panels[2], Panel::IN_OVERFLOW, false, false);
718 expected_overflow_list.Add(panels[5], Panel::IN_OVERFLOW, false, false); 757 expected_overflow_list.Add(panels[5], Panel::IN_OVERFLOW, false, false);
719 EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData()); 758 EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
720 759
721 PanelManager::GetInstance()->RemoveAll(); 760 PanelManager::GetInstance()->RemoveAll();
722 } 761 }
723 762
724 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_HoverOverOverflowArea) { 763 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_HoverOverOverflowArea) {
725 PanelManager* panel_manager = PanelManager::GetInstance(); 764 PanelManager* panel_manager = PanelManager::GetInstance();
726 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher();
727 panel_manager->SetMouseWatcherForTesting(mouse_watcher);
728 PanelOverflowStrip* panel_overflow_strip = 765 PanelOverflowStrip* panel_overflow_strip =
729 panel_manager->panel_overflow_strip(); 766 panel_manager->panel_overflow_strip();
730 int iconified_width = panel_overflow_strip->current_display_width(); 767 int iconified_width = panel_overflow_strip->current_display_width();
731 768
732 // Create normal and overflow panels. 769 // Create normal and overflow panels.
733 // normal: P0, P1, P2 770 // normal: P0, P1, P2
734 // overflow: P3, P4, P5 771 // overflow: P3, P4, P5
735 // overflow-on-overflow: P6, P7 772 // overflow-on-overflow: P6, P7
736 const int panel_widths[] = { 773 const int panel_widths[] = {
737 250, 260, 200, // normal 774 250, 260, 200, // normal
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 const PanelOverflowStrip::Panels& overflow2 = overflow_strip->panels(); 954 const PanelOverflowStrip::Panels& overflow2 = overflow_strip->panels();
918 EXPECT_EQ(panel5, overflow2[0]); // strip order is preserved 955 EXPECT_EQ(panel5, overflow2[0]); // strip order is preserved
919 EXPECT_EQ(panel4, overflow2[1]); 956 EXPECT_EQ(panel4, overflow2[1]);
920 957
921 panel1->Close(); 958 panel1->Close();
922 panel2->Close(); 959 panel2->Close();
923 panel3->Close(); 960 panel3->Close();
924 panel4->Close(); 961 panel4->Close();
925 panel5->Close(); 962 panel5->Close();
926 } 963 }
964
965 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_OverflowIndicatorCount) {
966 PanelManager* panel_manager = PanelManager::GetInstance();
967 PanelOverflowStrip* overflow_strip = panel_manager->panel_overflow_strip();
968
969 // Create normal and overflow panels.
970 // normal: P0, P1, P2
971 // overflow: P3, P4, P5
972 const int panel_widths[] = {
973 250, 250, 210, // normal
974 250, 250, 260 // overflow
975 };
976 std::vector<Panel*> panels = CreateOverflowPanels(3, 3, panel_widths);
977 EXPECT_EQ(3, overflow_strip->num_panels());
978 EXPECT_FALSE(overflow_strip->overflow_indicator());
979
980 // Create 5 overflow-on-overflow panels.
981 // normal: P0, P1, P2
982 // overflow: P3, P4, P5, (P6, P7, P8, P9, P10)
983 // The panels enclosed in parentheses are hidden.
984 int num_existing_panels = panel_manager->num_panels();
985 for (int i = 0; i < 5; ++i) {
986 CreatePanelParams params(
987 MakePanelName(num_existing_panels + i),
988 gfx::Rect(0, 0, 250, 200),
989 SHOW_AS_INACTIVE);
990 Panel* panel = CreatePanelWithParams(params);
991 WaitForExpansionStateChanged(panel, Panel::IN_OVERFLOW);
992 EXPECT_EQ(i + 1, overflow_strip->overflow_indicator()->GetCount());
993 panels.push_back(panel);
994 }
995
996 // Expand the overflow area by moving mouse over it.
997 // Expect the overflow indicator count gets updated.
998 // normal: P0, P1, P2
999 // overflow: P3, P4, P5, P6, P7, P8, (P9, P10)
1000 MoveMouseAndWaitForOverflowAnimationEnded(panels[3]->GetBounds().origin());
1001 EXPECT_TRUE(IsPanelVisible(panels[6]));
1002 EXPECT_TRUE(IsPanelVisible(panels[7]));
1003 EXPECT_TRUE(IsPanelVisible(panels[8]));
1004 EXPECT_FALSE(IsPanelVisible(panels[9]));
1005 EXPECT_FALSE(IsPanelVisible(panels[10]));
1006 EXPECT_EQ(2, overflow_strip->overflow_indicator()->GetCount());
1007
1008 // Close an overflow panel that makes one overflow-on-overflow panel become
1009 // visible. Expect the overflow indicator count gets decreased by 1.
1010 // normal: P0, P1, P2
1011 // overflow: P4, P5, P6, P7, P8, P9, (P10)
1012 CloseWindowAndWait(panels[3]->browser());
1013 EXPECT_TRUE(IsPanelVisible(panels[6]));
1014 EXPECT_TRUE(IsPanelVisible(panels[7]));
1015 EXPECT_TRUE(IsPanelVisible(panels[8]));
1016 EXPECT_TRUE(IsPanelVisible(panels[9]));
1017 EXPECT_FALSE(IsPanelVisible(panels[10]));
1018 EXPECT_EQ(1, overflow_strip->overflow_indicator()->GetCount());
1019
1020 // Shrink the overflow area by stopping hovering the mouse over the overflow
1021 // area. Expect the overflow indicator count gets updated.
1022 // normal: P0, P1, P2
1023 // overflow: P4, P5, P6, (P7, P8, P9, P10)
1024 MoveMouseAndWaitForOverflowAnimationEnded(gfx::Point(
1025 panels[4]->GetBounds().right() + 5, panels[4]->GetBounds().y()));
1026 EXPECT_TRUE(IsPanelVisible(panels[6]));
1027 EXPECT_FALSE(IsPanelVisible(panels[7]));
1028 EXPECT_FALSE(IsPanelVisible(panels[8]));
1029 EXPECT_FALSE(IsPanelVisible(panels[9]));
1030 EXPECT_FALSE(IsPanelVisible(panels[10]));
1031 EXPECT_EQ(4, overflow_strip->overflow_indicator()->GetCount());
1032
1033 // Close an overflow panel.
1034 // Expect the overflow indicator count gets decreased by 1.
1035 // normal: P0, P1, P2
1036 // overflow: P5, P6, P7, (P8, P9, P10)
1037 CloseWindowAndWait(panels[4]->browser());
1038 EXPECT_TRUE(IsPanelVisible(panels[6]));
1039 EXPECT_TRUE(IsPanelVisible(panels[7]));
1040 EXPECT_FALSE(IsPanelVisible(panels[8]));
1041 EXPECT_FALSE(IsPanelVisible(panels[9]));
1042 EXPECT_FALSE(IsPanelVisible(panels[10]));
1043 EXPECT_EQ(3, overflow_strip->overflow_indicator()->GetCount());
1044
1045 // Activating a big overflow panel will cause 2 normal panels to move to the
1046 // oevrflow area and also get the top visible overflow panel bumped to the
1047 // overflow-on-overflow.
1048 // Expect the overflow indicator count gets increased by 1.
1049 // normal: P0, P5
1050 // overflow: P1, P2, P6, (P7, P8, P9, P10)
1051 panels[5]->Activate();
1052 WaitForPanelActiveState(panels[5], SHOW_AS_ACTIVE);
1053 WaitForExpansionStateChanged(panels[5], Panel::EXPANDED);
1054 EXPECT_TRUE(IsPanelVisible(panels[6]));
1055 EXPECT_FALSE(IsPanelVisible(panels[7]));
1056 EXPECT_FALSE(IsPanelVisible(panels[8]));
1057 EXPECT_FALSE(IsPanelVisible(panels[9]));
1058 EXPECT_FALSE(IsPanelVisible(panels[10]));
1059 EXPECT_EQ(4, overflow_strip->overflow_indicator()->GetCount());
1060
1061 panel_manager->RemoveAll();
1062 }
1063
1064 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_DrawOverflowAttention) {
1065 PanelManager* panel_manager = PanelManager::GetInstance();
1066 PanelStrip* panel_strip = panel_manager->panel_strip();
1067 PanelOverflowStrip* overflow_strip = panel_manager->panel_overflow_strip();
1068
1069 // Create normal and overflow panels.
1070 // normal: P0, P1, P2, P3
1071 // overflow: P4, P5, P6, (P7, P8, P9, P10, P11)
1072 // The panels enclosed in parentheses are hidden.
1073 const int panel_widths[] = {
1074 100, 210, 210, 210, // normal
1075 210, 260, 210, // overflow
1076 210, 210, 210, // overflow-on-overflow on shrunk
1077 210, 210 // overflow-on-overflow on expanded
1078 };
1079 std::vector<Panel*> panels = CreateOverflowPanels(4, 8, panel_widths);
1080 EXPECT_EQ(4, panel_strip->num_panels());
1081 EXPECT_EQ(8, overflow_strip->num_panels());
1082 PanelOverflowIndicator* overflow_indicator =
1083 overflow_strip->overflow_indicator();
1084
1085 // Draw attention for a visible overflow panel.
1086 // Expect no impact to the overflow indicator.
1087 // normal: P0, P1, P2, P3
1088 // overflow: P4, *P5, P6, (P7, P8, P9, P10, P11)
1089 EXPECT_FALSE(panels[5]->IsDrawingAttention());
1090 panels[5]->FlashFrame();
1091 EXPECT_TRUE(panels[5]->IsDrawingAttention());
1092 EXPECT_FALSE(overflow_indicator->IsDrawingAttention());
1093
1094 // Activating this overflow panel will clear its attention.
1095 // Expect no impact to the overflow indicator.
1096 // normal: P0, P1, P2, P5
1097 // overflow: P3, P4, P6, (P7, P8, P9, P10, P11)
1098 panels[5]->Activate();
1099 WaitForPanelActiveState(panels[5], SHOW_AS_ACTIVE);
1100 EXPECT_FALSE(panels[5]->IsDrawingAttention());
1101 EXPECT_FALSE(overflow_indicator->IsDrawingAttention());
1102
1103 // Draw attention for an overflow-on-overflow panel.
1104 // Expect the overflow indicator is showing attention.
1105 // normal: P0, P1, P2, P5
1106 // overflow: P3, P4, P6, (P7, *P8, P9, P10, P11)
1107 EXPECT_FALSE(panels[8]->IsDrawingAttention());
1108 panels[8]->FlashFrame();
1109 EXPECT_TRUE(panels[8]->IsDrawingAttention());
1110 EXPECT_TRUE(overflow_indicator->IsDrawingAttention());
1111
1112 // Draw attention for another overflow-on-overflow panel.
1113 // Expect the overflow indicator is still showing attention.
1114 // normal: P0, P1, P2, P5
1115 // overflow: P3, P4, P6, (P7, *P8, P9, *P10, P11)
1116 EXPECT_FALSE(panels[10]->IsDrawingAttention());
1117 panels[10]->FlashFrame();
1118 EXPECT_TRUE(panels[10]->IsDrawingAttention());
1119 EXPECT_TRUE(overflow_indicator->IsDrawingAttention());
1120
1121 // Stop drawing attention for an overflow-on-overflow panel by activating it.
1122 // Expect the overflow indicator is still showing attention.
1123 // normal: P0, P1, P2, P8
1124 // overflow: P5, P3, P4, (P6, P7, P9, *P10, P11)
1125 panels[8]->Activate();
1126 WaitForPanelActiveState(panels[8], SHOW_AS_ACTIVE);
1127 EXPECT_FALSE(panels[8]->IsDrawingAttention());
1128 EXPECT_TRUE(overflow_indicator->IsDrawingAttention());
1129
1130 // Stop drawing attention for another overflow-on-overflow panel by activating
1131 // it. Expect the overflow indicator is not showing attention.
1132 // normal: P0, P1, P2, P10
1133 // overflow: P8, P5, P3, (P4, P6, P7, P9, P11)
1134 panels[10]->Activate();
1135 WaitForPanelActiveState(panels[10], SHOW_AS_ACTIVE);
1136 EXPECT_FALSE(panels[10]->IsDrawingAttention());
1137 EXPECT_FALSE(overflow_indicator->IsDrawingAttention());
1138
1139 // Draw attention for the top overflow panel.
1140 // Expect no impact to the overflow indicator.
1141 // normal: P0, P1, P2, P10
1142 // overflow: P8, P5, *P3, (P4, P6, P7, P9, P11)
1143 EXPECT_TRUE(IsPanelVisible(panels[3]));
1144 EXPECT_FALSE(panels[3]->IsDrawingAttention());
1145 panels[3]->FlashFrame();
1146 EXPECT_TRUE(panels[3]->IsDrawingAttention());
1147 EXPECT_FALSE(overflow_indicator->IsDrawingAttention());
1148
1149 // Activating a big overflow panel will cause 2 normal panels to move to the
1150 // overflow area and also get the top visible overflow panel bumped to the
1151 // overflow-on-overflow.
1152 // Expect the overflow indicator is showing attention.
1153 // normal: P0, P1, P5
1154 // overflow: P2, P10, P8, (*P3, P4, P6, P7, P9, P11)
1155 panels[5]->Activate();
1156 WaitForPanelActiveState(panels[5], SHOW_AS_ACTIVE);
1157 WaitForExpansionStateChanged(panels[5], Panel::EXPANDED);
1158 EXPECT_EQ(3, panel_strip->num_panels());
1159 EXPECT_EQ(9, overflow_strip->num_panels());
1160 EXPECT_FALSE(IsPanelVisible(panels[3]));
1161 EXPECT_TRUE(panels[3]->IsDrawingAttention());
1162 EXPECT_TRUE(overflow_indicator->IsDrawingAttention());
1163
1164 // Close an overflow panel that would move the first oveflow-on-overflow panel
1165 // to become visible. Expect the overflow indicator is not showing attention.
1166 // normal: P0, P1, P5
1167 // overflow: P2, P10, P3, (P4, P6, P7, P9, P11)
1168 CloseWindowAndWait(panels[8]->browser());
1169 EXPECT_EQ(3, panel_strip->num_panels());
1170 EXPECT_EQ(8, overflow_strip->num_panels());
1171 EXPECT_TRUE(panels[3]->IsDrawingAttention());
1172 EXPECT_FALSE(overflow_indicator->IsDrawingAttention());
1173
1174 panel_manager->RemoveAll();
1175 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_manager.cc ('k') | chrome/browser/ui/panels/panel_overflow_indicator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698