| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "chrome/browser/ui/panels/base_panel_browser_test.h" | 6 #include "chrome/browser/ui/panels/base_panel_browser_test.h" |
| 7 #include "chrome/browser/ui/panels/docked_panel_strip.h" | 7 #include "chrome/browser/ui/panels/docked_panel_strip.h" |
| 8 #include "chrome/browser/ui/panels/panel.h" | 8 #include "chrome/browser/ui/panels/panel.h" |
| 9 #include "chrome/browser/ui/panels/panel_manager.h" | 9 #include "chrome/browser/ui/panels/panel_manager.h" |
| 10 #include "chrome/browser/ui/panels/test_panel_strip_squeeze_observer.h" |
| 10 #include "chrome/common/chrome_notification_types.h" | 11 #include "chrome/common/chrome_notification_types.h" |
| 11 #include "content/public/browser/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
| 12 #include "content/public/test/test_utils.h" | 13 #include "content/public/test/test_utils.h" |
| 13 | 14 |
| 14 class DockedPanelBrowserTest : public BasePanelBrowserTest { | 15 class DockedPanelBrowserTest : public BasePanelBrowserTest { |
| 15 public: | 16 public: |
| 16 virtual void SetUpOnMainThread() OVERRIDE { | 17 virtual void SetUpOnMainThread() OVERRIDE { |
| 17 BasePanelBrowserTest::SetUpOnMainThread(); | 18 BasePanelBrowserTest::SetUpOnMainThread(); |
| 18 | 19 |
| 19 // All the tests here assume using mocked 800x600 screen area for the | 20 // All the tests here assume using mocked 800x600 screen area for the |
| 20 // primary monitor. Do the check now. | 21 // primary monitor. Do the check now. |
| 21 gfx::Rect primary_screen_area = PanelManager::GetInstance()-> | 22 gfx::Rect primary_screen_area = PanelManager::GetInstance()-> |
| 22 display_settings_provider()->GetPrimaryScreenArea(); | 23 display_settings_provider()->GetPrimaryScreenArea(); |
| 23 DCHECK(primary_screen_area.width() == 800); | 24 DCHECK(primary_screen_area.width() == 800); |
| 24 DCHECK(primary_screen_area.height() == 600); | 25 DCHECK(primary_screen_area.height() == 600); |
| 25 } | 26 } |
| 26 }; | 27 }; |
| 27 | 28 |
| 28 IN_PROC_BROWSER_TEST_F(DockedPanelBrowserTest, FLAKY_SqueezePanelsInDock) { | 29 IN_PROC_BROWSER_TEST_F(DockedPanelBrowserTest, SqueezePanelsInDock) { |
| 29 PanelManager* panel_manager = PanelManager::GetInstance(); | 30 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 30 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); | 31 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); |
| 31 | 32 |
| 32 // Create some docked panels. | 33 // Create some docked panels. |
| 33 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 100)); | 34 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 100)); |
| 34 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 200, 100)); | 35 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 200, 100)); |
| 35 Panel* panel3 = CreateDockedPanel("3", gfx::Rect(0, 0, 200, 100)); | 36 Panel* panel3 = CreateDockedPanel("3", gfx::Rect(0, 0, 200, 100)); |
| 36 ASSERT_EQ(3, docked_strip->num_panels()); | 37 ASSERT_EQ(3, docked_strip->num_panels()); |
| 37 | 38 |
| 38 // Check that nothing has been squeezed so far. | 39 // Check that nothing has been squeezed so far. |
| 39 EXPECT_EQ(panel1->GetBounds().width(), panel1->GetRestoredBounds().width()); | 40 EXPECT_EQ(panel1->GetBounds().width(), panel1->GetRestoredBounds().width()); |
| 40 EXPECT_EQ(panel2->GetBounds().width(), panel2->GetRestoredBounds().width()); | 41 EXPECT_EQ(panel2->GetBounds().width(), panel2->GetRestoredBounds().width()); |
| 41 EXPECT_EQ(panel3->GetBounds().width(), panel3->GetRestoredBounds().width()); | 42 EXPECT_EQ(panel3->GetBounds().width(), panel3->GetRestoredBounds().width()); |
| 42 | 43 |
| 43 // Create more panels so they start getting squeezed. | 44 // Create more panels so they start getting squeezed. |
| 44 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100)); | 45 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100)); |
| 45 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100)); | 46 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100)); |
| 46 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100)); | 47 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100)); |
| 47 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100)); | 48 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100)); |
| 48 | 49 |
| 49 // Wait for active states to settle. | 50 // Wait for active states to settle. |
| 50 WaitForPanelActiveState(panel7, SHOW_AS_ACTIVE); | 51 PanelStripSqueezeObserver panel7_settled(docked_strip, panel7); |
| 51 | 52 panel7_settled.Wait(); |
| 52 // Wait for the scheduled layout to run. | |
| 53 MessageLoopForUI::current()->RunAllPending(); | |
| 54 | 53 |
| 55 // The active panel should be at full width. | 54 // The active panel should be at full width. |
| 56 EXPECT_EQ(panel7->GetBounds().width(), panel7->GetRestoredBounds().width()); | 55 EXPECT_EQ(panel7->GetBounds().width(), panel7->GetRestoredBounds().width()); |
| 57 EXPECT_GT(panel7->GetBounds().x(), docked_strip->display_area().x()); | 56 EXPECT_GT(panel7->GetBounds().x(), docked_strip->display_area().x()); |
| 58 | 57 |
| 59 // The rest of them should be at reduced width. | 58 // The rest of them should be at reduced width. |
| 60 EXPECT_LT(panel1->GetBounds().width(), panel1->GetRestoredBounds().width()); | 59 EXPECT_LT(panel1->GetBounds().width(), panel1->GetRestoredBounds().width()); |
| 61 EXPECT_LT(panel2->GetBounds().width(), panel2->GetRestoredBounds().width()); | 60 EXPECT_LT(panel2->GetBounds().width(), panel2->GetRestoredBounds().width()); |
| 62 EXPECT_LT(panel3->GetBounds().width(), panel3->GetRestoredBounds().width()); | 61 EXPECT_LT(panel3->GetBounds().width(), panel3->GetRestoredBounds().width()); |
| 63 EXPECT_LT(panel4->GetBounds().width(), panel4->GetRestoredBounds().width()); | 62 EXPECT_LT(panel4->GetBounds().width(), panel4->GetRestoredBounds().width()); |
| 64 EXPECT_LT(panel5->GetBounds().width(), panel5->GetRestoredBounds().width()); | 63 EXPECT_LT(panel5->GetBounds().width(), panel5->GetRestoredBounds().width()); |
| 65 EXPECT_LT(panel6->GetBounds().width(), panel6->GetRestoredBounds().width()); | 64 EXPECT_LT(panel6->GetBounds().width(), panel6->GetRestoredBounds().width()); |
| 66 | 65 |
| 67 // Activate a different panel. | 66 // Activate a different panel. |
| 68 panel2->Activate(); | 67 panel2->Activate(); |
| 68 WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE); |
| 69 | 69 |
| 70 // Wait for active states to settle. | 70 // Wait for active states to settle. |
| 71 WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE); | 71 PanelStripSqueezeObserver panel2_settled(docked_strip, panel2); |
| 72 | 72 panel2_settled.Wait(); |
| 73 // Wait for the scheduled layout to run. | |
| 74 MessageLoopForUI::current()->RunAllPending(); | |
| 75 | 73 |
| 76 // The active panel should be at full width. | 74 // The active panel should be at full width. |
| 77 EXPECT_EQ(panel2->GetBounds().width(), panel2->GetRestoredBounds().width()); | 75 EXPECT_EQ(panel2->GetBounds().width(), panel2->GetRestoredBounds().width()); |
| 78 | 76 |
| 79 // The rest of them should be at reduced width. | 77 // The rest of them should be at reduced width. |
| 80 EXPECT_LT(panel1->GetBounds().width(), panel1->GetRestoredBounds().width()); | 78 EXPECT_LT(panel1->GetBounds().width(), panel1->GetRestoredBounds().width()); |
| 81 EXPECT_LT(panel3->GetBounds().width(), panel3->GetRestoredBounds().width()); | 79 EXPECT_LT(panel3->GetBounds().width(), panel3->GetRestoredBounds().width()); |
| 82 EXPECT_LT(panel4->GetBounds().width(), panel4->GetRestoredBounds().width()); | 80 EXPECT_LT(panel4->GetBounds().width(), panel4->GetRestoredBounds().width()); |
| 83 EXPECT_LT(panel5->GetBounds().width(), panel5->GetRestoredBounds().width()); | 81 EXPECT_LT(panel5->GetBounds().width(), panel5->GetRestoredBounds().width()); |
| 84 EXPECT_LT(panel6->GetBounds().width(), panel6->GetRestoredBounds().width()); | 82 EXPECT_LT(panel6->GetBounds().width(), panel6->GetRestoredBounds().width()); |
| 85 EXPECT_LT(panel7->GetBounds().width(), panel7->GetRestoredBounds().width()); | 83 EXPECT_LT(panel7->GetBounds().width(), panel7->GetRestoredBounds().width()); |
| 86 | 84 |
| 87 panel_manager->CloseAll(); | 85 panel_manager->CloseAll(); |
| 88 } | 86 } |
| 89 | 87 |
| 90 IN_PROC_BROWSER_TEST_F(DockedPanelBrowserTest, FLAKY_SqueezeAndThenSomeMore) { | 88 IN_PROC_BROWSER_TEST_F(DockedPanelBrowserTest, SqueezeAndThenSomeMore) { |
| 91 PanelManager* panel_manager = PanelManager::GetInstance(); | 89 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 90 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); |
| 92 | 91 |
| 93 // Create enough docked panels to get into squeezing. | 92 // Create enough docked panels to get into squeezing. |
| 94 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 100)); | 93 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 100)); |
| 95 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 200, 100)); | 94 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 200, 100)); |
| 96 Panel* panel3 = CreateDockedPanel("3", gfx::Rect(0, 0, 200, 100)); | 95 Panel* panel3 = CreateDockedPanel("3", gfx::Rect(0, 0, 200, 100)); |
| 97 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100)); | 96 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100)); |
| 98 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100)); | 97 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100)); |
| 99 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100)); | 98 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100)); |
| 100 | 99 |
| 101 // Wait for active states to settle. | 100 // Wait for active states to settle. |
| 102 WaitForPanelActiveState(panel6, SHOW_AS_ACTIVE); | 101 PanelStripSqueezeObserver panel6_settled(docked_strip, panel6); |
| 103 | 102 panel6_settled.Wait(); |
| 104 // Wait for the scheduled layout to run. | |
| 105 MessageLoopForUI::current()->RunAllPending(); | |
| 106 | 103 |
| 107 // Record current widths of some panels. | 104 // Record current widths of some panels. |
| 108 int panel_1_width_less_squeezed = panel1->GetBounds().width(); | 105 int panel_1_width_less_squeezed = panel1->GetBounds().width(); |
| 109 int panel_2_width_less_squeezed = panel2->GetBounds().width(); | 106 int panel_2_width_less_squeezed = panel2->GetBounds().width(); |
| 110 int panel_3_width_less_squeezed = panel3->GetBounds().width(); | 107 int panel_3_width_less_squeezed = panel3->GetBounds().width(); |
| 111 int panel_4_width_less_squeezed = panel4->GetBounds().width(); | 108 int panel_4_width_less_squeezed = panel4->GetBounds().width(); |
| 112 int panel_5_width_less_squeezed = panel5->GetBounds().width(); | 109 int panel_5_width_less_squeezed = panel5->GetBounds().width(); |
| 113 | 110 |
| 114 // These widths should be reduced. | 111 // These widths should be reduced. |
| 115 EXPECT_LT(panel_1_width_less_squeezed, panel1->GetRestoredBounds().width()); | 112 EXPECT_LT(panel_1_width_less_squeezed, panel1->GetRestoredBounds().width()); |
| 116 EXPECT_LT(panel_2_width_less_squeezed, panel2->GetRestoredBounds().width()); | 113 EXPECT_LT(panel_2_width_less_squeezed, panel2->GetRestoredBounds().width()); |
| 117 EXPECT_LT(panel_3_width_less_squeezed, panel3->GetRestoredBounds().width()); | 114 EXPECT_LT(panel_3_width_less_squeezed, panel3->GetRestoredBounds().width()); |
| 118 EXPECT_LT(panel_4_width_less_squeezed, panel4->GetRestoredBounds().width()); | 115 EXPECT_LT(panel_4_width_less_squeezed, panel4->GetRestoredBounds().width()); |
| 119 EXPECT_LT(panel_5_width_less_squeezed, panel5->GetRestoredBounds().width()); | 116 EXPECT_LT(panel_5_width_less_squeezed, panel5->GetRestoredBounds().width()); |
| 120 | 117 |
| 121 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100)); | 118 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100)); |
| 122 | 119 |
| 123 // Wait for active states to settle. | 120 // Wait for active states to settle. |
| 124 WaitForPanelActiveState(panel7, SHOW_AS_ACTIVE); | 121 PanelStripSqueezeObserver panel7_settled(docked_strip, panel7); |
| 125 | 122 panel7_settled.Wait(); |
| 126 // Wait for the scheduled layout to run. | |
| 127 MessageLoopForUI::current()->RunAllPending(); | |
| 128 | 123 |
| 129 // The active panel should be at full width. | 124 // The active panel should be at full width. |
| 130 EXPECT_EQ(panel7->GetBounds().width(), panel7->GetRestoredBounds().width()); | 125 EXPECT_EQ(panel7->GetBounds().width(), panel7->GetRestoredBounds().width()); |
| 131 | 126 |
| 132 // The panels should shrink in width. | 127 // The panels should shrink in width. |
| 133 EXPECT_LT(panel1->GetBounds().width(), panel_1_width_less_squeezed); | 128 EXPECT_LT(panel1->GetBounds().width(), panel_1_width_less_squeezed); |
| 134 EXPECT_LT(panel2->GetBounds().width(), panel_2_width_less_squeezed); | 129 EXPECT_LT(panel2->GetBounds().width(), panel_2_width_less_squeezed); |
| 135 EXPECT_LT(panel3->GetBounds().width(), panel_3_width_less_squeezed); | 130 EXPECT_LT(panel3->GetBounds().width(), panel_3_width_less_squeezed); |
| 136 EXPECT_LT(panel4->GetBounds().width(), panel_4_width_less_squeezed); | 131 EXPECT_LT(panel4->GetBounds().width(), panel_4_width_less_squeezed); |
| 137 EXPECT_LT(panel5->GetBounds().width(), panel_5_width_less_squeezed); | 132 EXPECT_LT(panel5->GetBounds().width(), panel_5_width_less_squeezed); |
| 138 | 133 |
| 139 panel_manager->CloseAll(); | 134 panel_manager->CloseAll(); |
| 140 } | 135 } |
| 141 | 136 |
| 142 IN_PROC_BROWSER_TEST_F(DockedPanelBrowserTest, FLAKY_MinimizeSqueezedActive) { | 137 IN_PROC_BROWSER_TEST_F(DockedPanelBrowserTest, MinimizeSqueezedActive) { |
| 143 PanelManager* panel_manager = PanelManager::GetInstance(); | 138 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 139 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); |
| 144 | 140 |
| 145 // Create enough docked panels to get into squeezing. | 141 // Create enough docked panels to get into squeezing. |
| 146 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 100)); | 142 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 100)); |
| 147 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 200, 100)); | 143 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 200, 100)); |
| 148 Panel* panel3 = CreateDockedPanel("3", gfx::Rect(0, 0, 200, 100)); | 144 Panel* panel3 = CreateDockedPanel("3", gfx::Rect(0, 0, 200, 100)); |
| 149 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100)); | 145 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100)); |
| 150 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100)); | 146 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100)); |
| 151 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100)); | 147 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100)); |
| 152 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100)); | 148 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100)); |
| 153 | 149 |
| 154 // Wait for active states to settle. | 150 // Wait for active states to settle. |
| 155 WaitForPanelActiveState(panel7, SHOW_AS_ACTIVE); | 151 PanelStripSqueezeObserver panel7_settled(docked_strip, panel7); |
| 156 | 152 panel7_settled.Wait(); |
| 157 // Wait for the scheduled layout to run. | |
| 158 MessageLoopForUI::current()->RunAllPending(); | |
| 159 | 153 |
| 160 // The active panel should be at full width. | 154 // The active panel should be at full width. |
| 161 EXPECT_EQ(panel7->GetBounds().width(), panel7->GetRestoredBounds().width()); | 155 EXPECT_EQ(panel7->GetBounds().width(), panel7->GetRestoredBounds().width()); |
| 162 | 156 |
| 163 // The rest of them should be at reduced width. | 157 // The rest of them should be at reduced width. |
| 164 EXPECT_LT(panel1->GetBounds().width(), panel1->GetRestoredBounds().width()); | 158 EXPECT_LT(panel1->GetBounds().width(), panel1->GetRestoredBounds().width()); |
| 165 EXPECT_LT(panel2->GetBounds().width(), panel2->GetRestoredBounds().width()); | 159 EXPECT_LT(panel2->GetBounds().width(), panel2->GetRestoredBounds().width()); |
| 166 EXPECT_LT(panel3->GetBounds().width(), panel3->GetRestoredBounds().width()); | 160 EXPECT_LT(panel3->GetBounds().width(), panel3->GetRestoredBounds().width()); |
| 167 EXPECT_LT(panel4->GetBounds().width(), panel4->GetRestoredBounds().width()); | 161 EXPECT_LT(panel4->GetBounds().width(), panel4->GetRestoredBounds().width()); |
| 168 EXPECT_LT(panel5->GetBounds().width(), panel5->GetRestoredBounds().width()); | 162 EXPECT_LT(panel5->GetBounds().width(), panel5->GetRestoredBounds().width()); |
| 169 EXPECT_LT(panel6->GetBounds().width(), panel6->GetRestoredBounds().width()); | 163 EXPECT_LT(panel6->GetBounds().width(), panel6->GetRestoredBounds().width()); |
| 170 | 164 |
| 171 // Record the width of an inactive panel and minimize it. | 165 // Record the width of an inactive panel and minimize it. |
| 172 int width_of_panel3_squeezed = panel3->GetBounds().width(); | 166 int width_of_panel3_squeezed = panel3->GetBounds().width(); |
| 173 panel3->Minimize(); | 167 panel3->Minimize(); |
| 174 | 168 |
| 175 // Wait for any possible events. | |
| 176 MessageLoopForUI::current()->RunAllPending(); | |
| 177 | |
| 178 // Check that this panel is still at the same width. | 169 // Check that this panel is still at the same width. |
| 179 EXPECT_EQ(width_of_panel3_squeezed, panel3->GetBounds().width()); | 170 EXPECT_EQ(width_of_panel3_squeezed, panel3->GetBounds().width()); |
| 180 | 171 |
| 181 // Minimize the active panel. It should become inactive and shrink in width. | 172 // Minimize the active panel. It should become inactive and shrink in width. |
| 182 content::WindowedNotificationObserver signal( | 173 content::WindowedNotificationObserver signal( |
| 183 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, | 174 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, |
| 184 content::NotificationService::AllSources()); | 175 content::NotificationService::AllSources()); |
| 185 panel7->Minimize(); | 176 panel7->Minimize(); |
| 186 | 177 |
| 187 // Wait for active states to settle. | 178 // Wait for active states to settle. |
| 188 WaitForPanelActiveState(panel7, SHOW_AS_INACTIVE); | 179 WaitForPanelActiveState(panel7, SHOW_AS_INACTIVE); |
| 189 | 180 |
| 190 // Wait for the scheduled layout to run. | 181 // Wait for the scheduled layout to run. |
| 191 signal.Wait(); | 182 signal.Wait(); |
| 192 | 183 |
| 193 // The minimized panel should now be at reduced width. | 184 // The minimized panel should now be at reduced width. |
| 194 EXPECT_LT(panel7->GetBounds().width(), panel7->GetRestoredBounds().width()); | 185 EXPECT_LT(panel7->GetBounds().width(), panel7->GetRestoredBounds().width()); |
| 195 | 186 |
| 196 panel_manager->CloseAll(); | 187 panel_manager->CloseAll(); |
| 197 } | 188 } |
| 198 | 189 |
| 199 IN_PROC_BROWSER_TEST_F(DockedPanelBrowserTest, FLAKY_CloseSqueezedPanels) { | 190 IN_PROC_BROWSER_TEST_F(DockedPanelBrowserTest, CloseSqueezedPanels) { |
| 200 PanelManager* panel_manager = PanelManager::GetInstance(); | 191 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 192 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); |
| 201 | 193 |
| 202 // Create enough docked panels to get into squeezing. | 194 // Create enough docked panels to get into squeezing. |
| 203 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 100)); | 195 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 100)); |
| 204 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 200, 100)); | 196 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 200, 100)); |
| 205 Panel* panel3 = CreateDockedPanel("3", gfx::Rect(0, 0, 200, 100)); | 197 Panel* panel3 = CreateDockedPanel("3", gfx::Rect(0, 0, 200, 100)); |
| 206 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100)); | 198 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100)); |
| 207 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100)); | 199 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100)); |
| 208 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100)); | 200 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100)); |
| 209 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100)); | 201 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100)); |
| 210 | 202 |
| 211 // Wait for active states to settle. | 203 // Wait for active states to settle. |
| 212 WaitForPanelActiveState(panel7, SHOW_AS_ACTIVE); | 204 PanelStripSqueezeObserver panel7_settled(docked_strip, panel7); |
| 213 | 205 panel7_settled.Wait(); |
| 214 // Wait for the scheduled layout to run. | |
| 215 MessageLoopForUI::current()->RunAllPending(); | |
| 216 | 206 |
| 217 // Record current widths of some panels. | 207 // Record current widths of some panels. |
| 218 int panel_1_orig_width = panel1->GetBounds().width(); | 208 int panel_1_orig_width = panel1->GetBounds().width(); |
| 219 int panel_2_orig_width = panel2->GetBounds().width(); | 209 int panel_2_orig_width = panel2->GetBounds().width(); |
| 220 int panel_3_orig_width = panel3->GetBounds().width(); | 210 int panel_3_orig_width = panel3->GetBounds().width(); |
| 221 int panel_4_orig_width = panel4->GetBounds().width(); | 211 int panel_4_orig_width = panel4->GetBounds().width(); |
| 222 int panel_5_orig_width = panel5->GetBounds().width(); | 212 int panel_5_orig_width = panel5->GetBounds().width(); |
| 223 int panel_6_orig_width = panel6->GetBounds().width(); | 213 int panel_6_orig_width = panel6->GetBounds().width(); |
| 224 int panel_7_orig_width = panel7->GetBounds().width(); | 214 int panel_7_orig_width = panel7->GetBounds().width(); |
| 225 | 215 |
| 226 // The active panel should be at full width. | 216 // The active panel should be at full width. |
| 227 EXPECT_EQ(panel_7_orig_width, panel7->GetRestoredBounds().width()); | 217 EXPECT_EQ(panel_7_orig_width, panel7->GetRestoredBounds().width()); |
| 228 | 218 |
| 229 // The rest of them should be at reduced width. | 219 // The rest of them should be at reduced width. |
| 230 EXPECT_LT(panel_1_orig_width, panel1->GetRestoredBounds().width()); | 220 EXPECT_LT(panel_1_orig_width, panel1->GetRestoredBounds().width()); |
| 231 EXPECT_LT(panel_2_orig_width, panel2->GetRestoredBounds().width()); | 221 EXPECT_LT(panel_2_orig_width, panel2->GetRestoredBounds().width()); |
| 232 EXPECT_LT(panel_3_orig_width, panel3->GetRestoredBounds().width()); | 222 EXPECT_LT(panel_3_orig_width, panel3->GetRestoredBounds().width()); |
| 233 EXPECT_LT(panel_4_orig_width, panel4->GetRestoredBounds().width()); | 223 EXPECT_LT(panel_4_orig_width, panel4->GetRestoredBounds().width()); |
| 234 EXPECT_LT(panel_5_orig_width, panel5->GetRestoredBounds().width()); | 224 EXPECT_LT(panel_5_orig_width, panel5->GetRestoredBounds().width()); |
| 235 EXPECT_LT(panel_6_orig_width, panel6->GetRestoredBounds().width()); | 225 EXPECT_LT(panel_6_orig_width, panel6->GetRestoredBounds().width()); |
| 236 | 226 |
| 237 // Close one panel. | 227 // Close one panel. |
| 228 content::WindowedNotificationObserver signal( |
| 229 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, |
| 230 content::NotificationService::AllSources()); |
| 238 CloseWindowAndWait(panel2); | 231 CloseWindowAndWait(panel2); |
| 239 | 232 signal.Wait(); |
| 240 // Wait for all processing to finish. | |
| 241 MessageLoopForUI::current()->RunAllPending(); | |
| 242 | 233 |
| 243 // The widths of the remaining panels should have increased. | 234 // The widths of the remaining panels should have increased. |
| 244 EXPECT_GT(panel1->GetBounds().width(), panel_1_orig_width); | 235 EXPECT_GT(panel1->GetBounds().width(), panel_1_orig_width); |
| 245 EXPECT_GT(panel3->GetBounds().width(), panel_3_orig_width); | 236 EXPECT_GT(panel3->GetBounds().width(), panel_3_orig_width); |
| 246 EXPECT_GT(panel4->GetBounds().width(), panel_4_orig_width); | 237 EXPECT_GT(panel4->GetBounds().width(), panel_4_orig_width); |
| 247 EXPECT_GT(panel5->GetBounds().width(), panel_5_orig_width); | 238 EXPECT_GT(panel5->GetBounds().width(), panel_5_orig_width); |
| 248 EXPECT_GT(panel6->GetBounds().width(), panel_6_orig_width); | 239 EXPECT_GT(panel6->GetBounds().width(), panel_6_orig_width); |
| 249 | 240 |
| 250 // The active panel should have stayed at full width. | 241 // The active panel should have stayed at full width. |
| 251 EXPECT_EQ(panel7->GetBounds().width(), panel_7_orig_width); | 242 EXPECT_EQ(panel7->GetBounds().width(), panel_7_orig_width); |
| 252 | 243 |
| 253 // Close several panels. | 244 // Close several panels. |
| 254 CloseWindowAndWait(panel3); | 245 CloseWindowAndWait(panel3); |
| 255 CloseWindowAndWait(panel5); | 246 CloseWindowAndWait(panel5); |
| 247 |
| 248 // Wait for strip update after last close. |
| 249 content::WindowedNotificationObserver signal2( |
| 250 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, |
| 251 content::NotificationService::AllSources()); |
| 256 CloseWindowAndWait(panel7); | 252 CloseWindowAndWait(panel7); |
| 257 | 253 signal2.Wait(); |
| 258 // Wait for all processing to finish. | |
| 259 MessageLoopForUI::current()->RunAllPending(); | |
| 260 | 254 |
| 261 // We should not have squeezing any more; all panels should be at full width. | 255 // We should not have squeezing any more; all panels should be at full width. |
| 262 EXPECT_EQ(panel1->GetBounds().width(), panel1->GetRestoredBounds().width()); | 256 EXPECT_EQ(panel1->GetBounds().width(), panel1->GetRestoredBounds().width()); |
| 263 EXPECT_EQ(panel4->GetBounds().width(), panel4->GetRestoredBounds().width()); | 257 EXPECT_EQ(panel4->GetBounds().width(), panel4->GetRestoredBounds().width()); |
| 264 EXPECT_EQ(panel6->GetBounds().width(), panel6->GetRestoredBounds().width()); | 258 EXPECT_EQ(panel6->GetBounds().width(), panel6->GetRestoredBounds().width()); |
| 265 | 259 |
| 266 panel_manager->CloseAll(); | 260 panel_manager->CloseAll(); |
| 267 } | 261 } |
| OLD | NEW |