Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/i18n/time_formatting.h" | 6 #include "base/i18n/time_formatting.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.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 if (location != Extension::EXTERNAL_POLICY_DOWNLOAD) { | 244 if (location != Extension::EXTERNAL_POLICY_DOWNLOAD) { |
| 245 expected_panel_menu_items[3].enabled = true; | 245 expected_panel_menu_items[3].enabled = true; |
| 246 expected_panel_menu_items[4].enabled = true; | 246 expected_panel_menu_items[4].enabled = true; |
| 247 } | 247 } |
| 248 ValidateSettingsMenuItems(frame_view->settings_menu_contents_.get(), | 248 ValidateSettingsMenuItems(frame_view->settings_menu_contents_.get(), |
| 249 arraysize(expected_panel_menu_items), | 249 arraysize(expected_panel_menu_items), |
| 250 expected_panel_menu_items); | 250 expected_panel_menu_items); |
| 251 | 251 |
| 252 browser_view->panel()->Close(); | 252 browser_view->panel()->Close(); |
| 253 } | 253 } |
| 254 | |
| 255 void TestMinimizeAndRestore() { | |
|
jennb
2011/06/27 23:18:02
Could you add a comment at the top of this class e
jianli
2011/06/29 01:28:12
Done.
| |
| 256 PanelBrowserView* browser_view = CreatePanelBrowserView("PanelTest"); | |
| 257 Panel* panel = browser_view->panel_.get(); | |
| 258 | |
| 259 EXPECT_EQ(PanelBrowserView::FULLY_RESTORED, browser_view->expand_state()); | |
| 260 int initial_height = panel->GetBounds().height(); | |
| 261 int titlebar_height = | |
| 262 browser_view->GetFrameView()->NonClientTopBorderHeight(); | |
| 263 | |
| 264 browser_view->MinimizePanel(); | |
| 265 EXPECT_EQ(PanelBrowserView::FULLY_MINIMIZED, browser_view->expand_state()); | |
| 266 EXPECT_LT(panel->GetBounds().height(), titlebar_height); | |
| 267 EXPECT_GT(panel->GetBounds().height(), 0); | |
| 268 | |
| 269 browser_view->RestorePanel(true); | |
| 270 EXPECT_EQ(PanelBrowserView::TITLEBAR_RESTORED, | |
| 271 browser_view->expand_state()); | |
| 272 EXPECT_EQ(titlebar_height, panel->GetBounds().height()); | |
| 273 | |
| 274 browser_view->MinimizePanel(); | |
| 275 EXPECT_EQ(PanelBrowserView::FULLY_MINIMIZED, browser_view->expand_state()); | |
| 276 EXPECT_LT(panel->GetBounds().height(), titlebar_height); | |
| 277 EXPECT_GT(panel->GetBounds().height(), 0); | |
| 278 | |
| 279 browser_view->RestorePanel(true); | |
| 280 EXPECT_EQ(PanelBrowserView::TITLEBAR_RESTORED, | |
| 281 browser_view->expand_state()); | |
| 282 EXPECT_EQ(titlebar_height, panel->GetBounds().height()); | |
| 283 | |
| 284 browser_view->RestorePanel(false); | |
| 285 EXPECT_EQ(PanelBrowserView::FULLY_RESTORED, browser_view->expand_state()); | |
| 286 EXPECT_EQ(initial_height, panel->GetBounds().height()); | |
| 287 | |
| 288 // No-op if we try to "restore" from full height to titlebar height. | |
| 289 browser_view->RestorePanel(true); | |
| 290 EXPECT_EQ(PanelBrowserView::FULLY_RESTORED, browser_view->expand_state()); | |
| 291 EXPECT_EQ(initial_height, panel->GetBounds().height()); | |
| 292 | |
| 293 browser_view->panel()->Close(); | |
| 294 } | |
| 254 }; | 295 }; |
| 255 | 296 |
| 256 // Panel is not supported for Linux view yet. | 297 // Panel is not supported for Linux view yet. |
| 257 #if !defined(OS_LINUX) || !defined(TOOLKIT_VIEWS) | 298 #if !defined(OS_LINUX) || !defined(TOOLKIT_VIEWS) |
| 258 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, CreatePanel) { | 299 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, CreatePanel) { |
| 259 PanelBrowserView* browser_view = CreatePanelBrowserView("PanelTest"); | 300 PanelBrowserView* browser_view = CreatePanelBrowserView("PanelTest"); |
| 260 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); | 301 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); |
| 261 | 302 |
| 262 // The bounds animation should not be triggered when the panel is up for the | 303 // The bounds animation should not be triggered when the panel is up for the |
| 263 // first time. | 304 // first time. |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 } | 583 } |
| 543 | 584 |
| 544 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, CreateSettingsMenu) { | 585 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, CreateSettingsMenu) { |
| 545 TestCreateSettingsMenuForExtension( | 586 TestCreateSettingsMenuForExtension( |
| 546 FILE_PATH_LITERAL("extension1"), Extension::EXTERNAL_POLICY_DOWNLOAD, | 587 FILE_PATH_LITERAL("extension1"), Extension::EXTERNAL_POLICY_DOWNLOAD, |
| 547 "", ""); | 588 "", ""); |
| 548 TestCreateSettingsMenuForExtension( | 589 TestCreateSettingsMenuForExtension( |
| 549 FILE_PATH_LITERAL("extension2"), Extension::INVALID, | 590 FILE_PATH_LITERAL("extension2"), Extension::INVALID, |
| 550 "http://home", "options.html"); | 591 "http://home", "options.html"); |
| 551 } | 592 } |
| 593 | |
| 594 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, MinimizeAndRestore) { | |
| 595 TestMinimizeAndRestore(); | |
| 596 } | |
| 552 #endif | 597 #endif |
| OLD | NEW |