| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 ASSERT_EQ(initial_tab, browser()->GetTabContentsAt(0)); | 408 ASSERT_EQ(initial_tab, browser()->GetTabContentsAt(0)); |
| 409 | 409 |
| 410 // Check that the appliaction browser has a single tab, and that tab contains | 410 // Check that the appliaction browser has a single tab, and that tab contains |
| 411 // the content that we app-ified. | 411 // the content that we app-ified. |
| 412 ASSERT_EQ(1, app_browser->tab_count()); | 412 ASSERT_EQ(1, app_browser->tab_count()); |
| 413 ASSERT_EQ(app_tab, app_browser->GetTabContentsAt(0)); | 413 ASSERT_EQ(app_tab, app_browser->GetTabContentsAt(0)); |
| 414 | 414 |
| 415 // Normal tabs should accept load drops. | 415 // Normal tabs should accept load drops. |
| 416 EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops); | 416 EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops); |
| 417 | 417 |
| 418 // The tab in an aopp window should not. | 418 // The tab in an app window should not. |
| 419 EXPECT_FALSE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops); | 419 EXPECT_FALSE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops); |
| 420 } | 420 } |
| 421 | 421 |
| 422 #endif // !defined(OS_MACOSX) | 422 #endif // !defined(OS_MACOSX) |
| 423 | 423 |
| 424 // Test RenderView correctly send back favicon url for web page that redirects | 424 // Test RenderView correctly send back favicon url for web page that redirects |
| 425 // to an anchor in javascript body.onload handler. | 425 // to an anchor in javascript body.onload handler. |
| 426 IN_PROC_BROWSER_TEST_F(BrowserTest, FaviconOfOnloadRedirectToAnchorPage) { | 426 IN_PROC_BROWSER_TEST_F(BrowserTest, FaviconOfOnloadRedirectToAnchorPage) { |
| 427 ASSERT_TRUE(test_server()->Start()); | 427 ASSERT_TRUE(test_server()->Start()); |
| 428 GURL url(test_server()->GetURL("files/onload_redirect_to_anchor.html")); | 428 GURL url(test_server()->GetURL("files/onload_redirect_to_anchor.html")); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 ExtensionService* service = browser()->profile()->GetExtensionService(); | 484 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 485 service->UninstallExtension(GetExtension()->id(), false); | 485 service->UninstallExtension(GetExtension()->id(), false); |
| 486 EXPECT_EQ(1, observer.closing_count()); | 486 EXPECT_EQ(1, observer.closing_count()); |
| 487 | 487 |
| 488 model->RemoveObserver(&observer); | 488 model->RemoveObserver(&observer); |
| 489 | 489 |
| 490 // There should only be one tab now. | 490 // There should only be one tab now. |
| 491 ASSERT_EQ(1, browser()->tab_count()); | 491 ASSERT_EQ(1, browser()->tab_count()); |
| 492 } | 492 } |
| 493 | 493 |
| 494 #if !defined(OS_MACOSX) |
| 495 // Open with --app-id=<id>, and see that an app window opens. |
| 496 IN_PROC_BROWSER_TEST_F(BrowserTest, AppIdSwitch) { |
| 497 ASSERT_TRUE(test_server()->Start()); |
| 498 |
| 499 // Load an app. |
| 500 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 501 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); |
| 502 const Extension* extension_app = GetExtension(); |
| 503 |
| 504 CommandLine command_line(CommandLine::NO_PROGRAM); |
| 505 command_line.AppendSwitchASCII(switches::kAppId, extension_app->id()); |
| 506 |
| 507 BrowserInit::LaunchWithProfile launch(FilePath(), command_line); |
| 508 ASSERT_TRUE(launch.OpenApplicationWindow(browser()->profile())); |
| 509 |
| 510 // Check that the new browser has an app name. |
| 511 // The launch should have created a new browser. |
| 512 ASSERT_EQ(2u, BrowserList::GetBrowserCount(browser()->profile())); |
| 513 |
| 514 // Find the new browser. |
| 515 Browser* new_browser = NULL; |
| 516 for (BrowserList::const_iterator i = BrowserList::begin(); |
| 517 i != BrowserList::end() && !new_browser; ++i) { |
| 518 if (*i != browser()) |
| 519 new_browser = *i; |
| 520 } |
| 521 ASSERT_TRUE(new_browser); |
| 522 ASSERT_TRUE(new_browser != browser()); |
| 523 |
| 524 // The browser's app_name should include the app's ID. |
| 525 ASSERT_NE( |
| 526 new_browser->app_name_.find(extension_app->id()), |
| 527 std::string::npos) << new_browser->app_name_; |
| 528 |
| 529 } |
| 530 #endif |
| 531 |
| 494 #if defined(OS_WIN) | 532 #if defined(OS_WIN) |
| 495 // http://crbug.com/46198. On XP/Vista, the failure rate is 5 ~ 6%. | 533 // http://crbug.com/46198. On XP/Vista, the failure rate is 5 ~ 6%. |
| 496 #define MAYBE_PageLanguageDetection FLAKY_PageLanguageDetection | 534 #define MAYBE_PageLanguageDetection FLAKY_PageLanguageDetection |
| 497 #else | 535 #else |
| 498 #define MAYBE_PageLanguageDetection PageLanguageDetection | 536 #define MAYBE_PageLanguageDetection PageLanguageDetection |
| 499 #endif | 537 #endif |
| 500 // Tests that the CLD (Compact Language Detection) works properly. | 538 // Tests that the CLD (Compact Language Detection) works properly. |
| 501 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageLanguageDetection) { | 539 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageLanguageDetection) { |
| 502 ASSERT_TRUE(test_server()->Start()); | 540 ASSERT_TRUE(test_server()->Start()); |
| 503 | 541 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 Browser* new_browser = NULL; | 681 Browser* new_browser = NULL; |
| 644 for (BrowserList::const_iterator i = BrowserList::begin(); | 682 for (BrowserList::const_iterator i = BrowserList::begin(); |
| 645 i != BrowserList::end() && !new_browser; ++i) { | 683 i != BrowserList::end() && !new_browser; ++i) { |
| 646 if (*i != browser()) | 684 if (*i != browser()) |
| 647 new_browser = *i; | 685 new_browser = *i; |
| 648 } | 686 } |
| 649 ASSERT_TRUE(new_browser); | 687 ASSERT_TRUE(new_browser); |
| 650 ASSERT_TRUE(new_browser != browser()); | 688 ASSERT_TRUE(new_browser != browser()); |
| 651 | 689 |
| 652 EXPECT_EQ(Browser::TYPE_APP, new_browser->type()); | 690 EXPECT_EQ(Browser::TYPE_APP, new_browser->type()); |
| 691 |
| 692 // The browser's app name should include the extension's id. |
| 693 std::string app_name = new_browser->app_name_; |
| 694 EXPECT_NE(app_name.find(extension_app->id()), std::string::npos) |
| 695 << "Name " << app_name << " should contain id "<< extension_app->id(); |
| 653 } | 696 } |
| 654 #endif // !defined(OS_MACOSX) | 697 #endif // !defined(OS_MACOSX) |
| 655 | 698 |
| 656 // TODO(ben): this test was never enabled. It has bit-rotted since being added. | 699 // TODO(ben): this test was never enabled. It has bit-rotted since being added. |
| 657 // It originally lived in browser_unittest.cc, but has been moved here to make | 700 // It originally lived in browser_unittest.cc, but has been moved here to make |
| 658 // room for real browser unit tests. | 701 // room for real browser unit tests. |
| 659 #if 0 | 702 #if 0 |
| 660 class BrowserTest2 : public InProcessBrowserTest { | 703 class BrowserTest2 : public InProcessBrowserTest { |
| 661 public: | 704 public: |
| 662 BrowserTest2() { | 705 BrowserTest2() { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 | 773 |
| 731 // The normal browser should now have four. | 774 // The normal browser should now have four. |
| 732 EXPECT_EQ(4, browser()->tab_count()); | 775 EXPECT_EQ(4, browser()->tab_count()); |
| 733 | 776 |
| 734 // Close the additional browsers. | 777 // Close the additional browsers. |
| 735 popup_browser->CloseAllTabs(); | 778 popup_browser->CloseAllTabs(); |
| 736 app_browser->CloseAllTabs(); | 779 app_browser->CloseAllTabs(); |
| 737 app_popup_browser->CloseAllTabs(); | 780 app_popup_browser->CloseAllTabs(); |
| 738 } | 781 } |
| 739 #endif | 782 #endif |
| OLD | NEW |