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 "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/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/ui/browser_list.h" | 12 #include "chrome/browser/ui/browser_list.h" |
13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
14 #include "chrome/browser/ui/find_bar/find_bar.h" | 14 #include "chrome/browser/ui/find_bar/find_bar.h" |
15 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 15 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
16 #include "chrome/browser/ui/panels/base_panel_browser_test.h" | 16 #include "chrome/browser/ui/panels/base_panel_browser_test.h" |
17 #include "chrome/browser/ui/panels/native_panel.h" | 17 #include "chrome/browser/ui/panels/native_panel.h" |
18 #include "chrome/browser/ui/panels/panel.h" | 18 #include "chrome/browser/ui/panels/panel.h" |
19 #include "chrome/browser/ui/panels/panel_manager.h" | 19 #include "chrome/browser/ui/panels/panel_manager.h" |
20 #include "chrome/browser/ui/panels/panel_settings_menu_model.h" | 20 #include "chrome/browser/ui/panels/panel_settings_menu_model.h" |
21 #include "chrome/browser/web_applications/web_app.h" | 21 #include "chrome/browser/web_applications/web_app.h" |
22 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
23 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
24 #include "chrome/common/url_constants.h" | |
24 #include "chrome/test/base/ui_test_utils.h" | 25 #include "chrome/test/base/ui_test_utils.h" |
25 #include "content/browser/download/download_manager.h" | 26 #include "content/browser/download/download_manager.h" |
26 #include "content/browser/net/url_request_mock_http_job.h" | 27 #include "content/browser/net/url_request_mock_http_job.h" |
27 #include "content/browser/tab_contents/tab_contents.h" | 28 #include "content/browser/tab_contents/tab_contents.h" |
29 #include "content/public/browser/notification_service.h" | |
28 #include "content/public/common/url_constants.h" | 30 #include "content/public/common/url_constants.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
30 | 32 |
31 class PanelBrowserTest : public BasePanelBrowserTest { | 33 class PanelBrowserTest : public BasePanelBrowserTest { |
32 public: | 34 public: |
33 PanelBrowserTest() : BasePanelBrowserTest() { | 35 PanelBrowserTest() : BasePanelBrowserTest() { |
34 } | 36 } |
35 | 37 |
36 protected: | 38 protected: |
37 void CloseWindowAndWait(Browser* browser) { | 39 void CloseWindowAndWait(Browser* browser) { |
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1306 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); | 1308 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); |
1307 | 1309 |
1308 // Another check for the same. | 1310 // Another check for the same. |
1309 EXPECT_FALSE(panel1->IsActive()); | 1311 EXPECT_FALSE(panel1->IsActive()); |
1310 EXPECT_FALSE(panel2->IsActive()); | 1312 EXPECT_FALSE(panel2->IsActive()); |
1311 | 1313 |
1312 panel1->Close(); | 1314 panel1->Close(); |
1313 panel2->Close(); | 1315 panel2->Close(); |
1314 } | 1316 } |
1315 | 1317 |
1318 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, | |
1319 NonExtensionDomainPanelsCloseOnUninstall) { | |
1320 // Create a test extension. | |
1321 DictionaryValue empty_value; | |
1322 scoped_refptr<Extension> extension = | |
1323 CreateExtension(FILE_PATH_LITERAL("TestExtension"), | |
1324 Extension::INVALID, empty_value); | |
1325 std::string extension_app_name = | |
1326 web_app::GenerateApplicationNameFromExtensionId(extension->id()); | |
1327 | |
1328 PanelManager* panel_manager = PanelManager::GetInstance(); | |
1329 EXPECT_EQ(0, panel_manager->num_panels()); | |
1330 | |
1331 // Create a panel with the extension as host. | |
1332 CreatePanelParams params(extension_app_name, gfx::Rect(), SHOW_AS_INACTIVE); | |
1333 std::string extension_domain_url(chrome::kExtensionScheme); | |
1334 extension_domain_url += "://"; | |
1335 extension_domain_url += extension->id(); | |
1336 extension_domain_url += "/hello.html"; | |
1337 params.url = GURL(extension_domain_url); | |
1338 CreatePanelWithParams(params); | |
1339 EXPECT_EQ(1, panel_manager->num_panels()); | |
1340 | |
1341 // Create a panel with a non-extension host. | |
1342 CreatePanelParams params1(extension_app_name, gfx::Rect(), SHOW_AS_INACTIVE); | |
1343 params1.url = GURL(chrome::kAboutBlankURL); | |
1344 CreatePanelWithParams(params1); | |
1345 EXPECT_EQ(2, panel_manager->num_panels()); | |
1346 | |
1347 // Create another extension and a panel from that extension. | |
1348 scoped_refptr<Extension> extension_other = | |
1349 CreateExtension(FILE_PATH_LITERAL("TestExtensionOther"), | |
1350 Extension::INVALID, empty_value); | |
1351 std::string extension_app_name_other = | |
1352 web_app::GenerateApplicationNameFromExtensionId(extension_other->id()); | |
1353 Panel* panel_other = CreatePanel(extension_app_name_other); | |
1354 | |
1355 // Send unload notification on the first extension and wait for count of | |
1356 // panels to go down to 1. | |
1357 UnloadedExtensionInfo details(extension, | |
1358 extension_misc::UNLOAD_REASON_UNINSTALL); | |
1359 content::NotificationService::current()->Notify( | |
1360 chrome::NOTIFICATION_EXTENSION_UNLOADED, | |
1361 content::Source<Profile>(browser()->profile()), | |
1362 content::Details<UnloadedExtensionInfo>(&details)); | |
1363 while (panel_manager->num_panels() != 1) | |
1364 MessageLoopForUI::current()->RunAllPending(); | |
Paweł Hajdan Jr.
2011/10/25 09:01:38
NOOOOOO! Don't do that please, it's known to be ba
prasadt
2011/10/25 17:29:28
Spooky response for something that seems to be don
| |
1365 | |
1366 // Verify that the panel that's left is the panel from the second extension. | |
1367 EXPECT_EQ(panel_other, panel_manager->panels()[0]); | |
1368 panel_other->Close(); | |
1369 } | |
1370 | |
1316 class PanelDownloadTest : public PanelBrowserTest { | 1371 class PanelDownloadTest : public PanelBrowserTest { |
1317 public: | 1372 public: |
1318 PanelDownloadTest() : PanelBrowserTest() { } | 1373 PanelDownloadTest() : PanelBrowserTest() { } |
1319 | 1374 |
1320 // Creates a temporary directory for downloads that is auto-deleted | 1375 // Creates a temporary directory for downloads that is auto-deleted |
1321 // on destruction. | 1376 // on destruction. |
1322 bool CreateDownloadDirectory(Profile* profile) { | 1377 bool CreateDownloadDirectory(Profile* profile) { |
1323 bool created = downloads_directory_.CreateUniqueTempDir(); | 1378 bool created = downloads_directory_.CreateUniqueTempDir(); |
1324 if (!created) | 1379 if (!created) |
1325 return false; | 1380 return false; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1480 EXPECT_EQ(1, tabbed_browser->tab_count()); | 1535 EXPECT_EQ(1, tabbed_browser->tab_count()); |
1481 ASSERT_TRUE(tabbed_browser->window()->IsDownloadShelfVisible()); | 1536 ASSERT_TRUE(tabbed_browser->window()->IsDownloadShelfVisible()); |
1482 tabbed_browser->CloseWindow(); | 1537 tabbed_browser->CloseWindow(); |
1483 #endif | 1538 #endif |
1484 | 1539 |
1485 EXPECT_EQ(1, panel_browser->tab_count()); | 1540 EXPECT_EQ(1, panel_browser->tab_count()); |
1486 ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible()); | 1541 ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible()); |
1487 | 1542 |
1488 panel_browser->CloseWindow(); | 1543 panel_browser->CloseWindow(); |
1489 } | 1544 } |
OLD | NEW |