| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/utf_string_conversions.h" | 6 #include "base/utf_string_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/browser_prefs.h" | 10 #include "chrome/browser/prefs/browser_prefs.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "chrome/browser/web_applications/web_app.h" | 29 #include "chrome/browser/web_applications/web_app.h" |
| 30 #include "chrome/common/chrome_notification_types.h" | 30 #include "chrome/common/chrome_notification_types.h" |
| 31 #include "chrome/common/extensions/extension_manifest_constants.h" | 31 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 32 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
| 33 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
| 34 #include "chrome/test/base/ui_test_utils.h" | 34 #include "chrome/test/base/ui_test_utils.h" |
| 35 #include "content/public/browser/download_manager.h" | 35 #include "content/public/browser/download_manager.h" |
| 36 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
| 37 #include "content/public/browser/web_contents.h" | 37 #include "content/public/browser/web_contents.h" |
| 38 #include "content/public/common/url_constants.h" | 38 #include "content/public/common/url_constants.h" |
| 39 #include "content/public/test/browser_test_utils.h" |
| 39 #include "content/test/net/url_request_mock_http_job.h" | 40 #include "content/test/net/url_request_mock_http_job.h" |
| 40 #include "net/base/net_util.h" | 41 #include "net/base/net_util.h" |
| 41 #include "testing/gtest/include/gtest/gtest.h" | 42 #include "testing/gtest/include/gtest/gtest.h" |
| 42 #include "ui/gfx/screen.h" | 43 #include "ui/gfx/screen.h" |
| 43 | 44 |
| 44 using content::BrowserContext; | 45 using content::BrowserContext; |
| 45 using content::BrowserThread; | 46 using content::BrowserThread; |
| 46 using content::DownloadItem; | 47 using content::DownloadItem; |
| 47 using content::DownloadManager; | 48 using content::DownloadManager; |
| 48 using content::WebContents; | 49 using content::WebContents; |
| (...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1373 SHOW_AS_ACTIVE); | 1374 SHOW_AS_ACTIVE); |
| 1374 params.url = ui_test_utils::GetTestUrl( | 1375 params.url = ui_test_utils::GetTestUrl( |
| 1375 FilePath(kTestDir), | 1376 FilePath(kTestDir), |
| 1376 FilePath(FILE_PATH_LITERAL("onbeforeunload.html"))); | 1377 FilePath(FILE_PATH_LITERAL("onbeforeunload.html"))); |
| 1377 Panel* panel = CreatePanelWithParams(params); | 1378 Panel* panel = CreatePanelWithParams(params); |
| 1378 EXPECT_EQ(1, panel_manager->num_panels()); | 1379 EXPECT_EQ(1, panel_manager->num_panels()); |
| 1379 WebContents* web_contents = panel->GetWebContents(); | 1380 WebContents* web_contents = panel->GetWebContents(); |
| 1380 | 1381 |
| 1381 // Close panel and respond to the onbeforeunload dialog with cancel. This is | 1382 // Close panel and respond to the onbeforeunload dialog with cancel. This is |
| 1382 // equivalent to clicking "Stay on this page" | 1383 // equivalent to clicking "Stay on this page" |
| 1383 scoped_ptr<ui_test_utils::TitleWatcher> title_watcher( | 1384 scoped_ptr<content::TitleWatcher> title_watcher( |
| 1384 new ui_test_utils::TitleWatcher(web_contents, title_first_close)); | 1385 new content::TitleWatcher(web_contents, title_first_close)); |
| 1385 panel->Close(); | 1386 panel->Close(); |
| 1386 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); | 1387 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
| 1387 alert->native_dialog()->CancelAppModalDialog(); | 1388 alert->native_dialog()->CancelAppModalDialog(); |
| 1388 EXPECT_EQ(title_first_close, title_watcher->WaitAndGetTitle()); | 1389 EXPECT_EQ(title_first_close, title_watcher->WaitAndGetTitle()); |
| 1389 EXPECT_EQ(1, panel_manager->num_panels()); | 1390 EXPECT_EQ(1, panel_manager->num_panels()); |
| 1390 | 1391 |
| 1391 // Close panel and respond to the onbeforeunload dialog with close. This is | 1392 // Close panel and respond to the onbeforeunload dialog with close. This is |
| 1392 // equivalent to clicking the OS close button on the dialog. | 1393 // equivalent to clicking the OS close button on the dialog. |
| 1393 title_watcher.reset( | 1394 title_watcher.reset( |
| 1394 new ui_test_utils::TitleWatcher(web_contents, title_second_close)); | 1395 new content::TitleWatcher(web_contents, title_second_close)); |
| 1395 panel->Close(); | 1396 panel->Close(); |
| 1396 alert = ui_test_utils::WaitForAppModalDialog(); | 1397 alert = ui_test_utils::WaitForAppModalDialog(); |
| 1397 alert->native_dialog()->CloseAppModalDialog(); | 1398 alert->native_dialog()->CloseAppModalDialog(); |
| 1398 EXPECT_EQ(title_second_close, title_watcher->WaitAndGetTitle()); | 1399 EXPECT_EQ(title_second_close, title_watcher->WaitAndGetTitle()); |
| 1399 EXPECT_EQ(1, panel_manager->num_panels()); | 1400 EXPECT_EQ(1, panel_manager->num_panels()); |
| 1400 | 1401 |
| 1401 // Close panel and respond to the onbeforeunload dialog with accept. This is | 1402 // Close panel and respond to the onbeforeunload dialog with accept. This is |
| 1402 // equivalent to clicking "Leave this page". | 1403 // equivalent to clicking "Leave this page". |
| 1403 content::WindowedNotificationObserver signal( | 1404 content::WindowedNotificationObserver signal( |
| 1404 chrome::NOTIFICATION_PANEL_CLOSED, | 1405 chrome::NOTIFICATION_PANEL_CLOSED, |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 EXPECT_GE(smaller_work_area_size.width(), panel->max_size().width()); | 1526 EXPECT_GE(smaller_work_area_size.width(), panel->max_size().width()); |
| 1526 EXPECT_EQ(smaller_work_area_size.height(), panel->max_size().height()); | 1527 EXPECT_EQ(smaller_work_area_size.height(), panel->max_size().height()); |
| 1527 EXPECT_GT(old_full_size.width(), panel->full_size().width()); | 1528 EXPECT_GT(old_full_size.width(), panel->full_size().width()); |
| 1528 EXPECT_GT(old_full_size.height(), panel->full_size().height()); | 1529 EXPECT_GT(old_full_size.height(), panel->full_size().height()); |
| 1529 EXPECT_GE(panel->max_size().width(), panel->full_size().width()); | 1530 EXPECT_GE(panel->max_size().width(), panel->full_size().width()); |
| 1530 EXPECT_GE(panel->max_size().height(), panel->full_size().height()); | 1531 EXPECT_GE(panel->max_size().height(), panel->full_size().height()); |
| 1531 EXPECT_EQ(smaller_work_area_size.height(), panel->full_size().height()); | 1532 EXPECT_EQ(smaller_work_area_size.height(), panel->full_size().height()); |
| 1532 | 1533 |
| 1533 panel->Close(); | 1534 panel->Close(); |
| 1534 } | 1535 } |
| OLD | NEW |