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

Side by Side Diff: chrome/browser/ui/panels/panel_overflow_browsertest.cc

Issue 8949035: Revert 115297 - Add overflow indicator count on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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"
12 #include "chrome/browser/ui/panels/panel_overflow_strip.h" 11 #include "chrome/browser/ui/panels/panel_overflow_strip.h"
13 #include "chrome/browser/ui/panels/panel_settings_menu_model.h" 12 #include "chrome/browser/ui/panels/panel_settings_menu_model.h"
14 #include "chrome/browser/ui/panels/panel_strip.h" 13 #include "chrome/browser/ui/panels/panel_strip.h"
15 #include "chrome/browser/ui/panels/test_panel_mouse_watcher.h" 14 #include "chrome/browser/ui/panels/test_panel_mouse_watcher.h"
16 #include "chrome/common/chrome_notification_types.h" 15 #include "chrome/common/chrome_notification_types.h"
17 #include "chrome/test/base/ui_test_utils.h" 16 #include "chrome/test/base/ui_test_utils.h"
18 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
19 18
20 namespace { 19 namespace {
21 20
22 // We override the default value for testing purpose. 21 // We override the default value for testing purpose.
23 const int kMaxVisibleOverflowPanelsForTesting = 3; 22 const int kMaxVisibleOverflowForTesting = 3;
24 const int kMaxVisibleOverflowPanelsOnHoverForTesting = 6;
25 23
26 // Encapsulates all the info we need to verify if a panel behaves as expected 24 // Encapsulates all the info we need to verify if a panel behaves as expected
27 // when we do the overflow testing. 25 // when we do the overflow testing.
28 struct PanelData { 26 struct PanelData {
29 Panel* panel; 27 Panel* panel;
30 Panel::ExpansionState expansion_state; 28 Panel::ExpansionState expansion_state;
31 bool visible; 29 bool visible;
32 bool active; 30 bool active;
33 31
34 explicit PanelData(Panel* panel) 32 explicit PanelData(Panel* panel)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 public: 79 public:
82 PanelOverflowBrowserTest() : BasePanelBrowserTest() { 80 PanelOverflowBrowserTest() : BasePanelBrowserTest() {
83 } 81 }
84 82
85 virtual ~PanelOverflowBrowserTest() { 83 virtual ~PanelOverflowBrowserTest() {
86 } 84 }
87 85
88 virtual void SetUpOnMainThread() OVERRIDE { 86 virtual void SetUpOnMainThread() OVERRIDE {
89 BasePanelBrowserTest::SetUpOnMainThread(); 87 BasePanelBrowserTest::SetUpOnMainThread();
90 88
91 PanelManager* panel_manager = PanelManager::GetInstance(); 89 PanelManager::GetInstance()->panel_overflow_strip()->
92 panel_manager->panel_overflow_strip()->set_max_visible_panels( 90 set_max_visible_panels(kMaxVisibleOverflowForTesting);
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);
99 91
100 // All the overflow tests assume 800x600 work area. Do the check now. 92 // All the overflow tests assume 800x600 work area. Do the check now.
101 DCHECK(PanelManager::GetInstance()->work_area().width() == 800); 93 DCHECK(PanelManager::GetInstance()->work_area().width() == 800);
102 } 94 }
103 95
104 protected: 96 protected:
105 static PanelDataList GetAllNormalPanelData() { 97 static PanelDataList GetAllNormalPanelData() {
106 PanelDataList panel_data_list; 98 PanelDataList panel_data_list;
107 PanelStrip::Panels panels = 99 PanelStrip::Panels panels =
108 PanelManager::GetInstance()->panel_strip()->panels(); 100 PanelManager::GetInstance()->panel_strip()->panels();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 #define MAYBE_CreateOverflowPanels CreateOverflowPanels 173 #define MAYBE_CreateOverflowPanels CreateOverflowPanels
182 #define MAYBE_CreateMoreOverflowPanels CreateMoreOverflowPanels 174 #define MAYBE_CreateMoreOverflowPanels CreateMoreOverflowPanels
183 // http://crbug.com/107230 175 // http://crbug.com/107230
184 #define MAYBE_CreatePanelOnDelayedOverflow CreatePanelOnDelayedOverflow 176 #define MAYBE_CreatePanelOnDelayedOverflow CreatePanelOnDelayedOverflow
185 #define MAYBE_CloseOverflowPanels CloseOverflowPanels 177 #define MAYBE_CloseOverflowPanels CloseOverflowPanels
186 #define MAYBE_CloseNormalPanels CloseNormalPanels 178 #define MAYBE_CloseNormalPanels CloseNormalPanels
187 #define MAYBE_CloseWithDelayedOverflow CloseWithDelayedOverflow 179 #define MAYBE_CloseWithDelayedOverflow CloseWithDelayedOverflow
188 #define MAYBE_ActivateOverflowPanels ActivateOverflowPanels 180 #define MAYBE_ActivateOverflowPanels ActivateOverflowPanels
189 #define MAYBE_HoverOverOverflowArea HoverOverOverflowArea 181 #define MAYBE_HoverOverOverflowArea HoverOverOverflowArea
190 #define MAYBE_ResizePanel ResizePanel 182 #define MAYBE_ResizePanel ResizePanel
191 #define MAYBE_OverflowIndicatorCount OverflowIndicatorCount
192 #define MAYBE_DrawOverflowAttention DrawOverflowAttention
193 #else 183 #else
194 #define MAYBE_CheckPanelProperties DISABLED_CheckPanelProperties 184 #define MAYBE_CheckPanelProperties DISABLED_CheckPanelProperties
195 #define MAYBE_UpdateDraggableStatus DISABLED_UpdateDraggableStatus 185 #define MAYBE_UpdateDraggableStatus DISABLED_UpdateDraggableStatus
196 #define MAYBE_CreateOverflowPanels DISABLED_CreateOverflowPanels 186 #define MAYBE_CreateOverflowPanels DISABLED_CreateOverflowPanels
197 #define MAYBE_CreateMoreOverflowPanels DISABLED_CreateMoreOverflowPanels 187 #define MAYBE_CreateMoreOverflowPanels DISABLED_CreateMoreOverflowPanels
198 #define MAYBE_CreatePanelOnDelayedOverflow DISABLED_CreatePanelOnDelayedOverflow 188 #define MAYBE_CreatePanelOnDelayedOverflow DISABLED_CreatePanelOnDelayedOverflow
199 #define MAYBE_CloseOverflowPanels DISABLED_CloseOverflowPanels 189 #define MAYBE_CloseOverflowPanels DISABLED_CloseOverflowPanels
200 #define MAYBE_CloseNormalPanels DISABLED_CloseNormalPanels 190 #define MAYBE_CloseNormalPanels DISABLED_CloseNormalPanels
201 #define MAYBE_CloseWithDelayedOverflow DISABLED_CloseWithDelayedOverflow 191 #define MAYBE_CloseWithDelayedOverflow DISABLED_CloseWithDelayedOverflow
202 #define MAYBE_ActivateOverflowPanels DISABLED_ActivateOverflowPanels 192 #define MAYBE_ActivateOverflowPanels DISABLED_ActivateOverflowPanels
203 #define MAYBE_HoverOverOverflowArea DISABLED_HoverOverOverflowArea 193 #define MAYBE_HoverOverOverflowArea DISABLED_HoverOverOverflowArea
204 #define MAYBE_ResizePanel DISABLED_ResizePanel 194 #define MAYBE_ResizePanel DISABLED_ResizePanel
205 #define MAYBE_OverflowIndicatorCount DISABLED_OverflowIndicatorCount
206 #define MAYBE_DrawOverflowAttention DISABLED_DrawOverflowAttention
207 #endif 195 #endif
208 196
209 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CheckPanelProperties) { 197 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CheckPanelProperties) {
210 // Create 3 panels that fit. 198 // Create 3 panels that fit.
211 Panel* panel1 = CreatePanelWithBounds("1", gfx::Rect(0, 0, 250, 200)); 199 Panel* panel1 = CreatePanelWithBounds("1", gfx::Rect(0, 0, 250, 200));
212 Panel* panel2 = CreatePanelWithBounds("2", gfx::Rect(0, 0, 300, 200)); 200 Panel* panel2 = CreatePanelWithBounds("2", gfx::Rect(0, 0, 300, 200));
213 Panel* panel3 = CreatePanelWithBounds("3", gfx::Rect(0, 0, 200, 200)); 201 Panel* panel3 = CreatePanelWithBounds("3", gfx::Rect(0, 0, 200, 200));
214 202
215 // Create an overflow panel without waiting for it to be moved to overflow. 203 // Create an overflow panel without waiting for it to be moved to overflow.
216 // Check its properties before and after it is moved to overflow. 204 // Check its properties before and after it is moved to overflow.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 EXPECT_TRUE(panel->draggable()); 239 EXPECT_TRUE(panel->draggable());
252 panel->Close(); 240 panel->Close();
253 } 241 }
254 242
255 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CreateOverflowPanels) { 243 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CreateOverflowPanels) {
256 PanelManager* panel_manager = PanelManager::GetInstance(); 244 PanelManager* panel_manager = PanelManager::GetInstance();
257 PanelStrip* panel_strip = panel_manager->panel_strip(); 245 PanelStrip* panel_strip = panel_manager->panel_strip();
258 PanelOverflowStrip* panel_overflow_strip = 246 PanelOverflowStrip* panel_overflow_strip =
259 panel_manager->panel_overflow_strip(); 247 panel_manager->panel_overflow_strip();
260 248
261 EXPECT_EQ(0, panel_manager->num_panels()); 249 const int panel_widths[] = {
262 EXPECT_EQ(0, panel_strip->num_panels()); 250 250, 260, 200, // normal
263 EXPECT_EQ(0, panel_overflow_strip->num_panels()); 251 255, 220 // overflow
264 EXPECT_FALSE(panel_overflow_strip->overflow_indicator()); 252 };
253 CreateOverflowPanels(3, 2, panel_widths);
265 254
266 // Create 3 normal panels. 255 std::vector<Panel*> panels = panel_manager->panels();
267 Panel* panel0 = CreatePanelWithBounds("Panel0", gfx::Rect(0, 0, 250, 200)); 256 ASSERT_EQ(5u, panels.size());
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());
297 EXPECT_EQ(3, panel_strip->num_panels()); 257 EXPECT_EQ(3, panel_strip->num_panels());
298 EXPECT_EQ(2, panel_overflow_strip->num_panels()); 258 EXPECT_EQ(2, panel_overflow_strip->num_panels());
299 EXPECT_FALSE(panel_overflow_strip->overflow_indicator()); 259 EXPECT_EQ(Panel::IN_OVERFLOW, panels[3]->expansion_state());
300 EXPECT_TRUE(IsPanelVisible(panel4)); 260 EXPECT_TRUE(IsPanelVisible(panels[3]));
261 EXPECT_EQ(Panel::IN_OVERFLOW, panels[4]->expansion_state());
262 EXPECT_TRUE(IsPanelVisible(panels[4]));
301 263
302 PanelManager::GetInstance()->RemoveAll(); 264 PanelManager::GetInstance()->RemoveAll();
303 } 265 }
304 266
305 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, 267 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest,
306 MAYBE_CreateMoreOverflowPanels) { 268 MAYBE_CreateMoreOverflowPanels) {
307 PanelManager* panel_manager = PanelManager::GetInstance(); 269 PanelManager* panel_manager = PanelManager::GetInstance();
308 PanelStrip* panel_strip = panel_manager->panel_strip(); 270 PanelStrip* panel_strip = panel_manager->panel_strip();
309 PanelOverflowStrip* panel_overflow_strip = 271 PanelOverflowStrip* panel_overflow_strip =
310 panel_manager->panel_overflow_strip(); 272 panel_manager->panel_overflow_strip();
311 273
312 const int panel_widths[] = { 274 const int panel_widths[] = {
313 250, 260, 200, // normal 275 250, 260, 200, // normal
314 255, 220, 210, // overflow 276 255, 220, 210, // overflow
315 220, 230 // overflow-on-overflow 277 220, 230 // overflow-on-overflow
316 }; 278 };
317 CreateOverflowPanels(3, 5, panel_widths); 279 CreateOverflowPanels(3, 5, panel_widths);
318 280
319 std::vector<Panel*> panels = panel_manager->panels(); 281 std::vector<Panel*> panels = panel_manager->panels();
320 ASSERT_EQ(8u, panels.size()); 282 ASSERT_EQ(8u, panels.size());
321 EXPECT_EQ(3, panel_strip->num_panels()); 283 EXPECT_EQ(3, panel_strip->num_panels());
322 EXPECT_EQ(5, panel_overflow_strip->num_panels()); 284 EXPECT_EQ(5, panel_overflow_strip->num_panels());
323 EXPECT_EQ(2, panel_overflow_strip->overflow_indicator()->GetCount());
324 EXPECT_EQ(Panel::IN_OVERFLOW, panels[3]->expansion_state()); 285 EXPECT_EQ(Panel::IN_OVERFLOW, panels[3]->expansion_state());
325 EXPECT_TRUE(IsPanelVisible(panels[3])); 286 EXPECT_TRUE(IsPanelVisible(panels[3]));
326 EXPECT_EQ(Panel::IN_OVERFLOW, panels[4]->expansion_state()); 287 EXPECT_EQ(Panel::IN_OVERFLOW, panels[4]->expansion_state());
327 EXPECT_TRUE(IsPanelVisible(panels[4])); 288 EXPECT_TRUE(IsPanelVisible(panels[4]));
328 EXPECT_EQ(Panel::IN_OVERFLOW, panels[5]->expansion_state()); 289 EXPECT_EQ(Panel::IN_OVERFLOW, panels[5]->expansion_state());
329 EXPECT_TRUE(IsPanelVisible(panels[5])); 290 EXPECT_TRUE(IsPanelVisible(panels[5]));
330 EXPECT_EQ(Panel::IN_OVERFLOW, panels[6]->expansion_state()); 291 EXPECT_EQ(Panel::IN_OVERFLOW, panels[6]->expansion_state());
331 EXPECT_FALSE(IsPanelVisible(panels[6])); 292 EXPECT_FALSE(IsPanelVisible(panels[6]));
332 EXPECT_EQ(Panel::IN_OVERFLOW, panels[7]->expansion_state()); 293 EXPECT_EQ(Panel::IN_OVERFLOW, panels[7]->expansion_state());
333 EXPECT_FALSE(IsPanelVisible(panels[7])); 294 EXPECT_FALSE(IsPanelVisible(panels[7]));
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 expected_overflow_list.Add(panels[3], Panel::IN_OVERFLOW, true, false); 716 expected_overflow_list.Add(panels[3], Panel::IN_OVERFLOW, true, false);
756 expected_overflow_list.Add(panels[2], Panel::IN_OVERFLOW, false, false); 717 expected_overflow_list.Add(panels[2], Panel::IN_OVERFLOW, false, false);
757 expected_overflow_list.Add(panels[5], Panel::IN_OVERFLOW, false, false); 718 expected_overflow_list.Add(panels[5], Panel::IN_OVERFLOW, false, false);
758 EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData()); 719 EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
759 720
760 PanelManager::GetInstance()->RemoveAll(); 721 PanelManager::GetInstance()->RemoveAll();
761 } 722 }
762 723
763 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_HoverOverOverflowArea) { 724 IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_HoverOverOverflowArea) {
764 PanelManager* panel_manager = PanelManager::GetInstance(); 725 PanelManager* panel_manager = PanelManager::GetInstance();
726 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher();
727 panel_manager->SetMouseWatcherForTesting(mouse_watcher);
765 PanelOverflowStrip* panel_overflow_strip = 728 PanelOverflowStrip* panel_overflow_strip =
766 panel_manager->panel_overflow_strip(); 729 panel_manager->panel_overflow_strip();
767 int iconified_width = panel_overflow_strip->current_display_width(); 730 int iconified_width = panel_overflow_strip->current_display_width();
768 731
769 // Create normal and overflow panels. 732 // Create normal and overflow panels.
770 // normal: P0, P1, P2 733 // normal: P0, P1, P2
771 // overflow: P3, P4, P5 734 // overflow: P3, P4, P5
772 // overflow-on-overflow: P6, P7 735 // overflow-on-overflow: P6, P7
773 const int panel_widths[] = { 736 const int panel_widths[] = {
774 250, 260, 200, // normal 737 250, 260, 200, // normal
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 const PanelOverflowStrip::Panels& overflow2 = overflow_strip->panels(); 917 const PanelOverflowStrip::Panels& overflow2 = overflow_strip->panels();
955 EXPECT_EQ(panel5, overflow2[0]); // strip order is preserved 918 EXPECT_EQ(panel5, overflow2[0]); // strip order is preserved
956 EXPECT_EQ(panel4, overflow2[1]); 919 EXPECT_EQ(panel4, overflow2[1]);
957 920
958 panel1->Close(); 921 panel1->Close();
959 panel2->Close(); 922 panel2->Close();
960 panel3->Close(); 923 panel3->Close();
961 panel4->Close(); 924 panel4->Close();
962 panel5->Close(); 925 panel5->Close();
963 } 926 }
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