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

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

Issue 8375012: Change panel overflow to not close any open panels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Commend updated. Created 9 years, 2 months 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
« no previous file with comments | « no previous file | chrome/browser/ui/panels/panel_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/string_number_conversions.h" 6 #include "base/string_number_conversions.h"
7 #include "chrome/browser/download/download_service.h" 7 #include "chrome/browser/download/download_service.h"
8 #include "chrome/browser/download/download_service_factory.h" 8 #include "chrome/browser/download/download_service_factory.h"
9 #include "chrome/browser/net/url_request_mock_util.h" 9 #include "chrome/browser/net/url_request_mock_util.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 web_app::GenerateApplicationNameFromExtensionId(extension1->id()), 73 web_app::GenerateApplicationNameFromExtensionId(extension1->id()),
74 gfx::Rect(0, 0, 250, 200)); 74 gfx::Rect(0, 0, 250, 200));
75 Panel* panel2 = CreatePanelWithBounds( 75 Panel* panel2 = CreatePanelWithBounds(
76 web_app::GenerateApplicationNameFromExtensionId(extension2->id()), 76 web_app::GenerateApplicationNameFromExtensionId(extension2->id()),
77 gfx::Rect(0, 0, 300, 200)); 77 gfx::Rect(0, 0, 300, 200));
78 Panel* panel3 = CreatePanelWithBounds( 78 Panel* panel3 = CreatePanelWithBounds(
79 web_app::GenerateApplicationNameFromExtensionId(extension1->id()), 79 web_app::GenerateApplicationNameFromExtensionId(extension1->id()),
80 gfx::Rect(0, 0, 200, 200)); 80 gfx::Rect(0, 0, 200, 200));
81 ASSERT_EQ(3, panel_manager->num_panels()); 81 ASSERT_EQ(3, panel_manager->num_panels());
82 82
83 // Test closing the leftmost panel that is from same extension. 83 // Open a panel that would overflow.
84 ui_test_utils::WindowedNotificationObserver signal(
85 chrome::NOTIFICATION_BROWSER_CLOSED,
86 content::Source<Browser>(panel2->browser()));
87 Panel* panel4 = CreatePanelWithBounds( 84 Panel* panel4 = CreatePanelWithBounds(
88 web_app::GenerateApplicationNameFromExtensionId(extension2->id()), 85 web_app::GenerateApplicationNameFromExtensionId(extension2->id()),
89 gfx::Rect(0, 0, 280, 200)); 86 gfx::Rect(0, 0, 280, 200));
90 signal.Wait(); 87 ASSERT_EQ(4, panel_manager->num_panels());
91 ASSERT_EQ(3, panel_manager->num_panels());
92 EXPECT_LT(panel4->GetBounds().right(), panel3->GetBounds().x()); 88 EXPECT_LT(panel4->GetBounds().right(), panel3->GetBounds().x());
93 EXPECT_LT(panel3->GetBounds().right(), panel1->GetBounds().x()); 89 EXPECT_GT(0, panel4->GetBounds().x());
94 90
95 // Test closing the leftmost panel. 91 // Open another panel that would overflow.
96 ui_test_utils::WindowedNotificationObserver signal2(
97 chrome::NOTIFICATION_BROWSER_CLOSED,
98 content::Source<Browser>(panel4->browser()));
99 Panel* panel5 = CreatePanelWithBounds( 92 Panel* panel5 = CreatePanelWithBounds(
100 web_app::GenerateApplicationNameFromExtensionId(extension3->id()), 93 web_app::GenerateApplicationNameFromExtensionId(extension3->id()),
101 gfx::Rect(0, 0, 300, 200)); 94 gfx::Rect(0, 0, 300, 200));
102 signal2.Wait(); 95 ASSERT_EQ(5, panel_manager->num_panels());
96 EXPECT_LT(panel5->GetBounds().right(), panel4->GetBounds().x());
97 EXPECT_GT(0, panel5->GetBounds().x());
98
99 // Close a visible panel. Expect an overflow panel to slide over.
100 CloseWindowAndWait(panel2->browser());
101 ASSERT_EQ(4, panel_manager->num_panels());
102 EXPECT_LT(panel4->GetBounds().right(), panel3->GetBounds().x());
103 EXPECT_LE(0, panel4->GetBounds().x());
104 EXPECT_GT(0, panel5->GetBounds().x());
105
106 // Close another visible panel. Remaining overflow panel should slide over
107 // but still not enough room to be fully visible.
108 CloseWindowAndWait(panel3->browser());
103 ASSERT_EQ(3, panel_manager->num_panels()); 109 ASSERT_EQ(3, panel_manager->num_panels());
104 EXPECT_LT(panel5->GetBounds().right(), panel3->GetBounds().x()); 110 EXPECT_LT(panel5->GetBounds().right(), panel4->GetBounds().x());
105 EXPECT_LT(panel3->GetBounds().right(), panel1->GetBounds().x()); 111 EXPECT_GT(0, panel5->GetBounds().x());
106 112
107 // Test closing 2 leftmost panels. 113 // Closing one more panel makes room for all panels to fit on screen.
108 ui_test_utils::WindowedNotificationObserver signal3( 114 CloseWindowAndWait(panel4->browser());
109 chrome::NOTIFICATION_BROWSER_CLOSED,
110 content::Source<Browser>(panel3->browser()));
111 ui_test_utils::WindowedNotificationObserver signal4(
112 chrome::NOTIFICATION_BROWSER_CLOSED,
113 content::Source<Browser>(panel5->browser()));
114 Panel* panel6 = CreatePanelWithBounds(
115 web_app::GenerateApplicationNameFromExtensionId(extension3->id()),
116 gfx::Rect(0, 0, 500, 200));
117 signal3.Wait();
118 signal4.Wait();
119 ASSERT_EQ(2, panel_manager->num_panels()); 115 ASSERT_EQ(2, panel_manager->num_panels());
120 EXPECT_LT(panel6->GetBounds().right(), panel1->GetBounds().x()); 116 EXPECT_LT(panel5->GetBounds().right(), panel1->GetBounds().x());
117 EXPECT_LE(0, panel5->GetBounds().x());
121 118
122 panel1->Close(); 119 panel1->Close();
123 panel6->Close(); 120 panel5->Close();
124 } 121 }
125 122
126 int horizontal_spacing() { 123 int horizontal_spacing() {
127 return PanelManager::horizontal_spacing(); 124 return PanelManager::horizontal_spacing();
128 } 125 }
129 126
130 // Helper function for debugging. 127 // Helper function for debugging.
131 void PrintAllPanelBounds() { 128 void PrintAllPanelBounds() {
132 const std::vector<Panel*>& panels = PanelManager::GetInstance()->panels(); 129 const std::vector<Panel*>& panels = PanelManager::GetInstance()->panels();
133 DLOG(WARNING) << "PanelBounds:"; 130 DLOG(WARNING) << "PanelBounds:";
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 EXPECT_EQ(1, tabbed_browser->tab_count()); 1343 EXPECT_EQ(1, tabbed_browser->tab_count());
1347 ASSERT_TRUE(tabbed_browser->window()->IsDownloadShelfVisible()); 1344 ASSERT_TRUE(tabbed_browser->window()->IsDownloadShelfVisible());
1348 tabbed_browser->CloseWindow(); 1345 tabbed_browser->CloseWindow();
1349 #endif 1346 #endif
1350 1347
1351 EXPECT_EQ(1, panel_browser->tab_count()); 1348 EXPECT_EQ(1, panel_browser->tab_count());
1352 ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible()); 1349 ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible());
1353 1350
1354 panel_browser->CloseWindow(); 1351 panel_browser->CloseWindow();
1355 } 1352 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/panels/panel_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698