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

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

Issue 8776035: Add PanelOverflowStrip to handle panel overflow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Prepare for final landing 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/string_number_conversions.h" 6 #include "base/string_number_conversions.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/download/download_service.h" 9 #include "chrome/browser/download/download_service.h"
10 #include "chrome/browser/download/download_service_factory.h" 10 #include "chrome/browser/download/download_service_factory.h"
11 #include "chrome/browser/net/url_request_mock_util.h" 11 #include "chrome/browser/net/url_request_mock_util.h"
12 #include "chrome/browser/notifications/balloon_collection_impl.h" 12 #include "chrome/browser/notifications/balloon_collection_impl.h"
13 #include "chrome/browser/notifications/desktop_notification_service.h" 13 #include "chrome/browser/notifications/desktop_notification_service.h"
14 #include "chrome/browser/notifications/notification.h" 14 #include "chrome/browser/notifications/notification.h"
15 #include "chrome/browser/notifications/notification_ui_manager.h" 15 #include "chrome/browser/notifications/notification_ui_manager.h"
16 #include "chrome/browser/prefs/browser_prefs.h" 16 #include "chrome/browser/prefs/browser_prefs.h"
17 #include "chrome/browser/prefs/pref_service.h" 17 #include "chrome/browser/prefs/pref_service.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/tabs/tab_strip_model.h" 19 #include "chrome/browser/tabs/tab_strip_model.h"
20 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" 20 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h"
21 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" 21 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h"
22 #include "chrome/browser/ui/browser_list.h" 22 #include "chrome/browser/ui/browser_list.h"
23 #include "chrome/browser/ui/browser_window.h" 23 #include "chrome/browser/ui/browser_window.h"
24 #include "chrome/browser/ui/find_bar/find_bar.h" 24 #include "chrome/browser/ui/find_bar/find_bar.h"
25 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 25 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
26 #include "chrome/browser/ui/panels/base_panel_browser_test.h" 26 #include "chrome/browser/ui/panels/base_panel_browser_test.h"
27 #include "chrome/browser/ui/panels/native_panel.h" 27 #include "chrome/browser/ui/panels/native_panel.h"
28 #include "chrome/browser/ui/panels/panel.h" 28 #include "chrome/browser/ui/panels/panel.h"
29 #include "chrome/browser/ui/panels/panel_manager.h" 29 #include "chrome/browser/ui/panels/panel_manager.h"
30 #include "chrome/browser/ui/panels/panel_overflow_strip.h"
30 #include "chrome/browser/ui/panels/panel_settings_menu_model.h" 31 #include "chrome/browser/ui/panels/panel_settings_menu_model.h"
32 #include "chrome/browser/ui/panels/panel_strip.h"
31 #include "chrome/browser/ui/panels/test_panel_mouse_watcher.h" 33 #include "chrome/browser/ui/panels/test_panel_mouse_watcher.h"
32 #include "chrome/browser/web_applications/web_app.h" 34 #include "chrome/browser/web_applications/web_app.h"
33 #include "chrome/common/chrome_notification_types.h" 35 #include "chrome/common/chrome_notification_types.h"
34 #include "chrome/common/pref_names.h" 36 #include "chrome/common/pref_names.h"
35 #include "chrome/common/url_constants.h" 37 #include "chrome/common/url_constants.h"
36 #include "chrome/test/base/ui_test_utils.h" 38 #include "chrome/test/base/ui_test_utils.h"
37 #include "content/browser/download/download_manager.h" 39 #include "content/browser/download/download_manager.h"
38 #include "content/browser/net/url_request_mock_http_job.h" 40 #include "content/browser/net/url_request_mock_http_job.h"
39 #include "content/browser/tab_contents/tab_contents.h" 41 #include "content/browser/tab_contents/tab_contents.h"
40 #include "content/public/browser/notification_service.h" 42 #include "content/public/browser/notification_service.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 const gfx::Point& position) { 76 const gfx::Point& position) {
75 ui_test_utils::WindowedNotificationObserver signal( 77 ui_test_utils::WindowedNotificationObserver signal(
76 chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE, 78 chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE,
77 content::Source<Panel>(panel)); 79 content::Source<Panel>(panel));
78 MoveMouse(position); 80 MoveMouse(position);
79 signal.Wait(); 81 signal.Wait();
80 } 82 }
81 83
82 void TestCreatePanelOnOverflow() { 84 void TestCreatePanelOnOverflow() {
83 PanelManager* panel_manager = PanelManager::GetInstance(); 85 PanelManager* panel_manager = PanelManager::GetInstance();
86 PanelStrip* panel_strip = panel_manager->panel_strip();
87 PanelOverflowStrip* panel_overflow_strip =
88 panel_manager->panel_overflow_strip();
84 EXPECT_EQ(0, panel_manager->num_panels()); // No panels initially. 89 EXPECT_EQ(0, panel_manager->num_panels()); // No panels initially.
85 90
86 // Create testing extensions. 91 // Create testing extensions.
87 DictionaryValue empty_value; 92 DictionaryValue empty_value;
88 scoped_refptr<Extension> extension1 = 93 scoped_refptr<Extension> extension1 =
89 CreateExtension(FILE_PATH_LITERAL("extension1"), 94 CreateExtension(FILE_PATH_LITERAL("extension1"),
90 Extension::INVALID, empty_value); 95 Extension::INVALID, empty_value);
91 scoped_refptr<Extension> extension2 = 96 scoped_refptr<Extension> extension2 =
92 CreateExtension(FILE_PATH_LITERAL("extension2"), 97 CreateExtension(FILE_PATH_LITERAL("extension2"),
93 Extension::INVALID, empty_value); 98 Extension::INVALID, empty_value);
94 scoped_refptr<Extension> extension3 = 99 scoped_refptr<Extension> extension3 =
95 CreateExtension(FILE_PATH_LITERAL("extension3"), 100 CreateExtension(FILE_PATH_LITERAL("extension3"),
96 Extension::INVALID, empty_value); 101 Extension::INVALID, empty_value);
97 102
98 // First, create 3 panels. 103 // First, create 3 panels.
99 Panel* panel1 = CreatePanelWithBounds( 104 Panel* panel1 = CreatePanelWithBounds(
100 web_app::GenerateApplicationNameFromExtensionId(extension1->id()), 105 web_app::GenerateApplicationNameFromExtensionId(extension1->id()),
101 gfx::Rect(0, 0, 250, 200)); 106 gfx::Rect(0, 0, 250, 200));
102 Panel* panel2 = CreatePanelWithBounds( 107 Panel* panel2 = CreatePanelWithBounds(
103 web_app::GenerateApplicationNameFromExtensionId(extension2->id()), 108 web_app::GenerateApplicationNameFromExtensionId(extension2->id()),
104 gfx::Rect(0, 0, 300, 200)); 109 gfx::Rect(0, 0, 300, 200));
105 Panel* panel3 = CreatePanelWithBounds( 110 Panel* panel3 = CreatePanelWithBounds(
106 web_app::GenerateApplicationNameFromExtensionId(extension1->id()), 111 web_app::GenerateApplicationNameFromExtensionId(extension1->id()),
107 gfx::Rect(0, 0, 200, 200)); 112 gfx::Rect(0, 0, 200, 200));
108 ASSERT_EQ(3, panel_manager->num_panels()); 113 ASSERT_EQ(3, panel_manager->num_panels());
114 EXPECT_EQ(3, panel_strip->num_panels());
115 EXPECT_EQ(0, panel_overflow_strip->num_panels());
109 116
110 // Open a panel that would overflow. 117 // Open a panel that would overflow.
111 Panel* panel4 = CreatePanelWithBounds( 118 Panel* panel4 = CreatePanelWithBounds(
112 web_app::GenerateApplicationNameFromExtensionId(extension2->id()), 119 web_app::GenerateApplicationNameFromExtensionId(extension2->id()),
113 gfx::Rect(0, 0, 280, 200)); 120 gfx::Rect(0, 0, 280, 200));
114 ASSERT_EQ(4, panel_manager->num_panels()); 121 ASSERT_EQ(4, panel_manager->num_panels());
115 EXPECT_LT(panel4->GetBounds().right(), panel3->GetBounds().x()); 122 EXPECT_EQ(3, panel_strip->num_panels());
116 EXPECT_GT(0, panel4->GetBounds().x()); 123 EXPECT_EQ(1, panel_overflow_strip->num_panels());
124 EXPECT_EQ(Panel::IN_OVERFLOW, panel4->expansion_state());
117 125
118 // Open another panel that would overflow. 126 // Open another panel that would overflow.
119 Panel* panel5 = CreatePanelWithBounds( 127 Panel* panel5 = CreatePanelWithBounds(
120 web_app::GenerateApplicationNameFromExtensionId(extension3->id()), 128 web_app::GenerateApplicationNameFromExtensionId(extension3->id()),
121 gfx::Rect(0, 0, 300, 200)); 129 gfx::Rect(0, 0, 300, 200));
122 ASSERT_EQ(5, panel_manager->num_panels()); 130 ASSERT_EQ(5, panel_manager->num_panels());
123 EXPECT_LT(panel5->GetBounds().right(), panel4->GetBounds().x()); 131 EXPECT_EQ(3, panel_strip->num_panels());
124 EXPECT_GT(0, panel5->GetBounds().x()); 132 EXPECT_EQ(2, panel_overflow_strip->num_panels());
133 EXPECT_EQ(Panel::IN_OVERFLOW, panel4->expansion_state());
134 EXPECT_EQ(Panel::IN_OVERFLOW, panel5->expansion_state());
125 135
126 // Close a visible panel. Expect an overflow panel to slide over. 136 // Close a visible panel. Expect an overflow panel to move over.
127 CloseWindowAndWait(panel2->browser()); 137 CloseWindowAndWait(panel2->browser());
128 ASSERT_EQ(4, panel_manager->num_panels()); 138 ASSERT_EQ(4, panel_manager->num_panels());
129 EXPECT_LT(panel4->GetBounds().right(), panel3->GetBounds().x()); 139 EXPECT_EQ(3, panel_strip->num_panels());
130 EXPECT_LE(0, panel4->GetBounds().x()); 140 EXPECT_EQ(1, panel_overflow_strip->num_panels());
131 EXPECT_GT(0, panel5->GetBounds().x()); 141 EXPECT_NE(Panel::IN_OVERFLOW, panel4->expansion_state());
142 EXPECT_EQ(Panel::IN_OVERFLOW, panel5->expansion_state());
132 143
133 // Close another visible panel. Remaining overflow panel should slide over 144 // Close another visible panel. Remaining overflow panel cannot move over
134 // but still not enough room to be fully visible. 145 // due to not enough room.
135 CloseWindowAndWait(panel3->browser()); 146 CloseWindowAndWait(panel3->browser());
136 ASSERT_EQ(3, panel_manager->num_panels()); 147 ASSERT_EQ(3, panel_manager->num_panels());
137 EXPECT_LT(panel5->GetBounds().right(), panel4->GetBounds().x()); 148 EXPECT_EQ(2, panel_strip->num_panels());
138 EXPECT_GT(0, panel5->GetBounds().x()); 149 EXPECT_EQ(1, panel_overflow_strip->num_panels());
150 EXPECT_EQ(Panel::IN_OVERFLOW, panel5->expansion_state());
139 151
140 // Closing one more panel makes room for all panels to fit on screen. 152 // Closing one more panel makes room for all panels to fit on screen.
141 CloseWindowAndWait(panel4->browser()); 153 CloseWindowAndWait(panel4->browser());
142 ASSERT_EQ(2, panel_manager->num_panels()); 154 ASSERT_EQ(2, panel_manager->num_panels());
143 EXPECT_LT(panel5->GetBounds().right(), panel1->GetBounds().x()); 155 EXPECT_EQ(2, panel_strip->num_panels());
144 EXPECT_LE(0, panel5->GetBounds().x()); 156 EXPECT_EQ(0, panel_overflow_strip->num_panels());
157 EXPECT_NE(Panel::IN_OVERFLOW, panel5->expansion_state());
145 158
146 panel1->Close(); 159 panel1->Close();
147 panel5->Close(); 160 panel5->Close();
148 } 161 }
149 162
150 int horizontal_spacing() { 163 int horizontal_spacing() {
151 return PanelManager::horizontal_spacing(); 164 return PanelManager::horizontal_spacing();
152 } 165 }
153 166
154 // Helper function for debugging. 167 // Helper function for debugging.
(...skipping 1783 matching lines...) Expand 10 before | Expand all | Expand 10 after
1938 // position when tall panel brings up its titlebar. 1951 // position when tall panel brings up its titlebar.
1939 CloseWindowAndWait(panel1->browser()); 1952 CloseWindowAndWait(panel1->browser());
1940 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up, 1953 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up,
1941 GetBalloonBottomPosition(balloon)); 1954 GetBalloonBottomPosition(balloon));
1942 1955
1943 // Closing the remaining tall panel should move the notification balloon back 1956 // Closing the remaining tall panel should move the notification balloon back
1944 // to its original position. 1957 // to its original position.
1945 CloseWindowAndWait(panel2->browser()); 1958 CloseWindowAndWait(panel2->browser());
1946 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); 1959 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon));
1947 } 1960 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_view_browsertest.cc ('k') | chrome/browser/ui/panels/panel_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698