| 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/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" |
| (...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, AutoResize) { | 837 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, AutoResize) { |
| 838 PanelManager::GetInstance()->enable_auto_sizing(true); | 838 PanelManager::GetInstance()->enable_auto_sizing(true); |
| 839 | 839 |
| 840 // Create a test panel with tab contents loaded. | 840 // Create a test panel with tab contents loaded. |
| 841 CreatePanelParams params("PanelTest1", gfx::Rect(0, 0, 100, 100), | 841 CreatePanelParams params("PanelTest1", gfx::Rect(0, 0, 100, 100), |
| 842 SHOW_AS_ACTIVE); | 842 SHOW_AS_ACTIVE); |
| 843 params.url = GURL(chrome::kAboutBlankURL); | 843 params.url = GURL(chrome::kAboutBlankURL); |
| 844 Panel* panel = CreatePanelWithParams(params); | 844 Panel* panel = CreatePanelWithParams(params); |
| 845 | 845 |
| 846 // Load the test page. | 846 // Load the test page. |
| 847 const FilePath::CharType* kUpdateSizeTestFile = | 847 GURL url(ui_test_utils::GetTestUrl( |
| 848 FILE_PATH_LITERAL("update-preferred-size.html"); | 848 FilePath(kTestDir), |
| 849 ui_test_utils::NavigateToURL(panel->browser(), | 849 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); |
| 850 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), | 850 ui_test_utils::NavigateToURL(panel->browser(), url); |
| 851 FilePath(kUpdateSizeTestFile))); | 851 |
| 852 gfx::Rect initial_bounds = panel->GetBounds(); | 852 gfx::Rect initial_bounds = panel->GetBounds(); |
| 853 EXPECT_LE(100, initial_bounds.width()); | 853 EXPECT_LE(100, initial_bounds.width()); |
| 854 EXPECT_LE(100, initial_bounds.height()); | 854 EXPECT_LE(100, initial_bounds.height()); |
| 855 | 855 |
| 856 // Expand the test page. | 856 // Expand the test page. |
| 857 ui_test_utils::WindowedNotificationObserver enlarge( | 857 ui_test_utils::WindowedNotificationObserver enlarge( |
| 858 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, | 858 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, |
| 859 content::Source<Panel>(panel)); | 859 content::Source<Panel>(panel)); |
| 860 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( | 860 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( |
| 861 panel->browser()->GetSelectedTabContents()->render_view_host(), | 861 panel->browser()->GetSelectedTabContents()->render_view_host(), |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1397 | 1397 |
| 1398 // Verify that the panel that's left is the panel from the second extension. | 1398 // Verify that the panel that's left is the panel from the second extension. |
| 1399 EXPECT_EQ(panel_other, panel_manager->panels()[0]); | 1399 EXPECT_EQ(panel_other, panel_manager->panels()[0]); |
| 1400 panel_other->Close(); | 1400 panel_other->Close(); |
| 1401 } | 1401 } |
| 1402 | 1402 |
| 1403 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, OnBeforeUnloadOnClose) { | 1403 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, OnBeforeUnloadOnClose) { |
| 1404 PanelManager* panel_manager = PanelManager::GetInstance(); | 1404 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 1405 EXPECT_EQ(0, panel_manager->num_panels()); // No panels initially. | 1405 EXPECT_EQ(0, panel_manager->num_panels()); // No panels initially. |
| 1406 | 1406 |
| 1407 const char* on_before_unload_html_file = "onbeforeunload.html"; | |
| 1408 const string16 title_first_close = UTF8ToUTF16("TitleFirstClose"); | 1407 const string16 title_first_close = UTF8ToUTF16("TitleFirstClose"); |
| 1409 const string16 title_second_close = UTF8ToUTF16("TitleSecondClose"); | 1408 const string16 title_second_close = UTF8ToUTF16("TitleSecondClose"); |
| 1410 | 1409 |
| 1411 // Create a test panel with tab contents loaded. | 1410 // Create a test panel with tab contents loaded. |
| 1412 CreatePanelParams params("PanelTest1", gfx::Rect(0, 0, 300, 300), | 1411 CreatePanelParams params("PanelTest1", gfx::Rect(0, 0, 300, 300), |
| 1413 SHOW_AS_ACTIVE); | 1412 SHOW_AS_ACTIVE); |
| 1414 params.url = GURL(net::FilePathToFileURL( | 1413 params.url = ui_test_utils::GetTestUrl( |
| 1415 test_data_dir_.AppendASCII(on_before_unload_html_file))); | 1414 FilePath(kTestDir), |
| 1415 FilePath(FILE_PATH_LITERAL("onbeforeunload.html"))); |
| 1416 Panel* panel = CreatePanelWithParams(params); | 1416 Panel* panel = CreatePanelWithParams(params); |
| 1417 EXPECT_EQ(1, panel_manager->num_panels()); | 1417 EXPECT_EQ(1, panel_manager->num_panels()); |
| 1418 TabContents* tab_contents = panel->browser()->GetSelectedTabContents(); | 1418 TabContents* tab_contents = panel->browser()->GetSelectedTabContents(); |
| 1419 | 1419 |
| 1420 // Close panel and respond to the onbeforeunload dialog with cancel. This is | 1420 // Close panel and respond to the onbeforeunload dialog with cancel. This is |
| 1421 // equivalent to clicking "Stay on this page" | 1421 // equivalent to clicking "Stay on this page" |
| 1422 scoped_ptr<ui_test_utils::TitleWatcher> title_watcher( | 1422 scoped_ptr<ui_test_utils::TitleWatcher> title_watcher( |
| 1423 new ui_test_utils::TitleWatcher(tab_contents, title_first_close)); | 1423 new ui_test_utils::TitleWatcher(tab_contents, title_first_close)); |
| 1424 panel->Close(); | 1424 panel->Close(); |
| 1425 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); | 1425 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1447 alert->native_dialog()->AcceptAppModalDialog(); | 1447 alert->native_dialog()->AcceptAppModalDialog(); |
| 1448 browser_closed.Wait(); | 1448 browser_closed.Wait(); |
| 1449 EXPECT_EQ(0, panel_manager->num_panels()); | 1449 EXPECT_EQ(0, panel_manager->num_panels()); |
| 1450 } | 1450 } |
| 1451 | 1451 |
| 1452 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreateWithExistingContents) { | 1452 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreateWithExistingContents) { |
| 1453 PanelManager::GetInstance()->enable_auto_sizing(true); | 1453 PanelManager::GetInstance()->enable_auto_sizing(true); |
| 1454 | 1454 |
| 1455 // Load contents into regular tabbed browser. | 1455 // Load contents into regular tabbed browser. |
| 1456 GURL url(ui_test_utils::GetTestUrl( | 1456 GURL url(ui_test_utils::GetTestUrl( |
| 1457 FilePath(FilePath::kCurrentDirectory), | 1457 FilePath(kTestDir), |
| 1458 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); | 1458 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); |
| 1459 ui_test_utils::NavigateToURL(browser(), url); | 1459 ui_test_utils::NavigateToURL(browser(), url); |
| 1460 EXPECT_EQ(1, browser()->tab_count()); | 1460 EXPECT_EQ(1, browser()->tab_count()); |
| 1461 | 1461 |
| 1462 Profile* profile = browser()->profile(); | 1462 Profile* profile = browser()->profile(); |
| 1463 CreatePanelParams params("PanelTest1", gfx::Rect(0, 0, 100, 100), | 1463 CreatePanelParams params("PanelTest1", gfx::Rect(0, 0, 100, 100), |
| 1464 SHOW_AS_ACTIVE); | 1464 SHOW_AS_ACTIVE); |
| 1465 Panel* panel = CreatePanelWithParams(params); | 1465 Panel* panel = CreatePanelWithParams(params); |
| 1466 Browser* panel_browser = panel->browser(); | 1466 Browser* panel_browser = panel->browser(); |
| 1467 EXPECT_EQ(2U, BrowserList::size()); | 1467 EXPECT_EQ(2U, BrowserList::size()); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1832 // position when tall panel brings up its titlebar. | 1832 // position when tall panel brings up its titlebar. |
| 1833 CloseWindowAndWait(panel1->browser()); | 1833 CloseWindowAndWait(panel1->browser()); |
| 1834 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up, | 1834 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up, |
| 1835 GetBalloonBottomPosition(balloon)); | 1835 GetBalloonBottomPosition(balloon)); |
| 1836 | 1836 |
| 1837 // Closing the remaining tall panel should move the notification balloon back | 1837 // Closing the remaining tall panel should move the notification balloon back |
| 1838 // to its original position. | 1838 // to its original position. |
| 1839 CloseWindowAndWait(panel2->browser()); | 1839 CloseWindowAndWait(panel2->browser()); |
| 1840 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); | 1840 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); |
| 1841 } | 1841 } |
| OLD | NEW |