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

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

Issue 8566034: Align expanded panel to the bottom of screen edge when there is an auto-hiding taskbar (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test. Created 9 years, 1 month 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.cc » ('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/i18n/time_formatting.h" 5 #include "base/i18n/time_formatting.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "chrome/browser/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser_window.h" 9 #include "chrome/browser/ui/browser_window.h"
10 #include "chrome/browser/ui/panels/base_panel_browser_test.h" 10 #include "chrome/browser/ui/panels/base_panel_browser_test.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 content::Source<Browser>(panel->browser())); 168 content::Source<Browser>(panel->browser()));
169 panel->Close(); 169 panel->Close();
170 signal.Wait(); 170 signal.Wait();
171 } 171 }
172 172
173 // We put all the testing logic in this class instead of the test so that 173 // We put all the testing logic in this class instead of the test so that
174 // we do not need to declare each new test as a friend of PanelBrowserView 174 // we do not need to declare each new test as a friend of PanelBrowserView
175 // for the purpose of accessing its private members. 175 // for the purpose of accessing its private members.
176 void TestMinimizeAndRestore(bool enable_auto_hiding) { 176 void TestMinimizeAndRestore(bool enable_auto_hiding) {
177 PanelManager* panel_manager = PanelManager::GetInstance(); 177 PanelManager* panel_manager = PanelManager::GetInstance();
178 int expected_bottom_on_minimized = testing_work_area().height(); 178 int expected_bottom_on_expanded = testing_work_area().height();
179 int expected_bottom_on_unminimized = expected_bottom_on_minimized; 179 int expected_bottom_on_title_only = expected_bottom_on_expanded;
180 int expected_bottom_on_minimized = expected_bottom_on_expanded;
180 181
181 // Turn on auto-hiding if requested. 182 // Turn on auto-hiding if requested.
182 static const int bottom_thickness = 40; 183 static const int bottom_thickness = 40;
183 mock_auto_hiding_desktop_bar()->EnableAutoHiding( 184 mock_auto_hiding_desktop_bar()->EnableAutoHiding(
184 AutoHidingDesktopBar::ALIGN_BOTTOM, 185 AutoHidingDesktopBar::ALIGN_BOTTOM,
185 enable_auto_hiding, 186 enable_auto_hiding,
186 bottom_thickness); 187 bottom_thickness);
187 if (enable_auto_hiding) 188 if (enable_auto_hiding)
188 expected_bottom_on_unminimized -= bottom_thickness; 189 expected_bottom_on_title_only -= bottom_thickness;
189 190
190 // Create and test one panel first. 191 // Create and test one panel first.
191 Panel* panel1 = CreatePanel("PanelTest1"); 192 Panel* panel1 = CreatePanel("PanelTest1");
192 PanelBrowserView* browser_view1 = GetBrowserView(panel1); 193 PanelBrowserView* browser_view1 = GetBrowserView(panel1);
193 PanelBrowserFrameView* frame_view1 = browser_view1->GetFrameView(); 194 PanelBrowserFrameView* frame_view1 = browser_view1->GetFrameView();
194 195
195 // Test minimizing/restoring an individual panel. 196 // Test minimizing/restoring an individual panel.
196 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state()); 197 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state());
197 EXPECT_EQ(0, panel_manager->minimized_panel_count()); 198 EXPECT_EQ(0, panel_manager->minimized_panel_count());
198 int initial_height = panel1->GetBounds().height(); 199 int initial_height = panel1->GetBounds().height();
199 int titlebar_height = frame_view1->NonClientTopBorderHeight(); 200 int titlebar_height = frame_view1->NonClientTopBorderHeight();
200 201
201 panel1->SetExpansionState(Panel::MINIMIZED); 202 panel1->SetExpansionState(Panel::MINIMIZED);
202 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); 203 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state());
203 EXPECT_LT(panel1->GetBounds().height(), titlebar_height); 204 EXPECT_LT(panel1->GetBounds().height(), titlebar_height);
204 EXPECT_GT(panel1->GetBounds().height(), 0); 205 EXPECT_GT(panel1->GetBounds().height(), 0);
205 EXPECT_EQ(expected_bottom_on_minimized, panel1->GetBounds().bottom()); 206 EXPECT_EQ(expected_bottom_on_minimized, panel1->GetBounds().bottom());
206 EXPECT_EQ(1, panel_manager->minimized_panel_count()); 207 EXPECT_EQ(1, panel_manager->minimized_panel_count());
207 WaitTillBoundsAnimationFinished(panel1); 208 WaitTillBoundsAnimationFinished(panel1);
208 EXPECT_FALSE(panel1->IsActive()); 209 EXPECT_FALSE(panel1->IsActive());
209 210
210 panel1->SetExpansionState(Panel::TITLE_ONLY); 211 panel1->SetExpansionState(Panel::TITLE_ONLY);
211 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); 212 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state());
212 EXPECT_EQ(titlebar_height, panel1->GetBounds().height()); 213 EXPECT_EQ(titlebar_height, panel1->GetBounds().height());
213 EXPECT_EQ(expected_bottom_on_unminimized, panel1->GetBounds().bottom()); 214 EXPECT_EQ(expected_bottom_on_title_only, panel1->GetBounds().bottom());
214 EXPECT_EQ(1, panel_manager->minimized_panel_count()); 215 EXPECT_EQ(1, panel_manager->minimized_panel_count());
215 WaitTillBoundsAnimationFinished(panel1); 216 WaitTillBoundsAnimationFinished(panel1);
216 EXPECT_TRUE(frame_view1->close_button_->IsVisible()); 217 EXPECT_TRUE(frame_view1->close_button_->IsVisible());
217 EXPECT_TRUE(frame_view1->title_icon_->IsVisible()); 218 EXPECT_TRUE(frame_view1->title_icon_->IsVisible());
218 EXPECT_TRUE(frame_view1->title_label_->IsVisible()); 219 EXPECT_TRUE(frame_view1->title_label_->IsVisible());
219 220
220 panel1->SetExpansionState(Panel::EXPANDED); 221 panel1->SetExpansionState(Panel::EXPANDED);
221 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state()); 222 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state());
222 EXPECT_EQ(initial_height, panel1->GetBounds().height()); 223 EXPECT_EQ(initial_height, panel1->GetBounds().height());
223 EXPECT_EQ(expected_bottom_on_unminimized, panel1->GetBounds().bottom()); 224 EXPECT_EQ(expected_bottom_on_expanded, panel1->GetBounds().bottom());
224 EXPECT_EQ(0, panel_manager->minimized_panel_count()); 225 EXPECT_EQ(0, panel_manager->minimized_panel_count());
225 WaitTillBoundsAnimationFinished(panel1); 226 WaitTillBoundsAnimationFinished(panel1);
226 EXPECT_TRUE(frame_view1->close_button_->IsVisible()); 227 EXPECT_TRUE(frame_view1->close_button_->IsVisible());
227 EXPECT_TRUE(frame_view1->title_icon_->IsVisible()); 228 EXPECT_TRUE(frame_view1->title_icon_->IsVisible());
228 EXPECT_TRUE(frame_view1->title_label_->IsVisible()); 229 EXPECT_TRUE(frame_view1->title_label_->IsVisible());
229 230
230 panel1->SetExpansionState(Panel::MINIMIZED); 231 panel1->SetExpansionState(Panel::MINIMIZED);
231 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); 232 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state());
232 EXPECT_LT(panel1->GetBounds().height(), titlebar_height); 233 EXPECT_LT(panel1->GetBounds().height(), titlebar_height);
233 EXPECT_GT(panel1->GetBounds().height(), 0); 234 EXPECT_GT(panel1->GetBounds().height(), 0);
234 EXPECT_EQ(expected_bottom_on_minimized, panel1->GetBounds().bottom()); 235 EXPECT_EQ(expected_bottom_on_minimized, panel1->GetBounds().bottom());
235 EXPECT_EQ(1, panel_manager->minimized_panel_count()); 236 EXPECT_EQ(1, panel_manager->minimized_panel_count());
236 237
237 panel1->SetExpansionState(Panel::TITLE_ONLY); 238 panel1->SetExpansionState(Panel::TITLE_ONLY);
238 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); 239 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state());
239 EXPECT_EQ(titlebar_height, panel1->GetBounds().height()); 240 EXPECT_EQ(titlebar_height, panel1->GetBounds().height());
240 EXPECT_EQ(expected_bottom_on_unminimized, panel1->GetBounds().bottom()); 241 EXPECT_EQ(expected_bottom_on_title_only, panel1->GetBounds().bottom());
241 EXPECT_EQ(1, panel_manager->minimized_panel_count()); 242 EXPECT_EQ(1, panel_manager->minimized_panel_count());
242 243
243 // Create 2 more panels for more testing. 244 // Create 2 more panels for more testing.
244 Panel* panel2 = CreatePanel("PanelTest2"); 245 Panel* panel2 = CreatePanel("PanelTest2");
245 Panel* panel3 = CreatePanel("PanelTest3"); 246 Panel* panel3 = CreatePanel("PanelTest3");
246 247
247 // Test bringing up or down the title-bar of all minimized panels. 248 // Test bringing up or down the title-bar of all minimized panels.
248 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); 249 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state());
249 panel3->SetExpansionState(Panel::MINIMIZED); 250 panel3->SetExpansionState(Panel::MINIMIZED);
250 EXPECT_EQ(Panel::MINIMIZED, panel3->expansion_state()); 251 EXPECT_EQ(Panel::MINIMIZED, panel3->expansion_state());
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 int right_bar_thickness = 30; 367 int right_bar_thickness = 30;
367 mock_auto_hiding_desktop_bar()->EnableAutoHiding( 368 mock_auto_hiding_desktop_bar()->EnableAutoHiding(
368 AutoHidingDesktopBar::ALIGN_BOTTOM, true, bottom_bar_thickness); 369 AutoHidingDesktopBar::ALIGN_BOTTOM, true, bottom_bar_thickness);
369 mock_auto_hiding_desktop_bar()->EnableAutoHiding( 370 mock_auto_hiding_desktop_bar()->EnableAutoHiding(
370 AutoHidingDesktopBar::ALIGN_RIGHT, true, right_bar_thickness); 371 AutoHidingDesktopBar::ALIGN_RIGHT, true, right_bar_thickness);
371 EXPECT_EQ( 372 EXPECT_EQ(
372 initial_starting_right_position - manager->StartingRightPosition(), 373 initial_starting_right_position - manager->StartingRightPosition(),
373 right_bar_thickness); 374 right_bar_thickness);
374 375
375 Panel* panel = CreatePanel("PanelTest"); 376 Panel* panel = CreatePanel("PanelTest");
377 panel->SetExpansionState(Panel::TITLE_ONLY);
378 WaitTillBoundsAnimationFinished(panel);
379
376 EXPECT_EQ(testing_work_area().height() - bottom_bar_thickness, 380 EXPECT_EQ(testing_work_area().height() - bottom_bar_thickness,
377 panel->GetBounds().bottom()); 381 panel->GetBounds().bottom());
378 EXPECT_GT(testing_work_area().right() - right_bar_thickness, 382 EXPECT_GT(testing_work_area().right() - right_bar_thickness,
379 panel->GetBounds().right()); 383 panel->GetBounds().right());
380 384
381 initial_starting_right_position = manager->StartingRightPosition(); 385 initial_starting_right_position = manager->StartingRightPosition();
382 int bottom_bar_thickness_delta = 10; 386 int bottom_bar_thickness_delta = 10;
383 bottom_bar_thickness += bottom_bar_thickness_delta; 387 bottom_bar_thickness += bottom_bar_thickness_delta;
384 int right_bar_thickness_delta = 15; 388 int right_bar_thickness_delta = 15;
385 right_bar_thickness += right_bar_thickness_delta; 389 right_bar_thickness += right_bar_thickness_delta;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 // TODO(jianli): Investigate why this fails on win trunk build. 612 // TODO(jianli): Investigate why this fails on win trunk build.
609 // http://crbug.com/102734 613 // http://crbug.com/102734
610 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, DISABLED_DrawAttention) { 614 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, DISABLED_DrawAttention) {
611 TestDrawAttention(); 615 TestDrawAttention();
612 } 616 }
613 617
614 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, ChangeAutoHideTaskBarThickness) { 618 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, ChangeAutoHideTaskBarThickness) {
615 TestChangeAutoHideTaskBarThickness(); 619 TestChangeAutoHideTaskBarThickness();
616 } 620 }
617 #endif 621 #endif
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/panels/panel_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698