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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 // menu is showing. | 562 // menu is showing. |
563 IN_PROC_BROWSER_TEST_F(BrowserTest, CloseWithAppMenuOpen) { | 563 IN_PROC_BROWSER_TEST_F(BrowserTest, CloseWithAppMenuOpen) { |
564 if (browser_defaults::kBrowserAliveWithNoWindows) | 564 if (browser_defaults::kBrowserAliveWithNoWindows) |
565 return; | 565 return; |
566 | 566 |
567 // We need a message loop running for menus on windows. | 567 // We need a message loop running for menus on windows. |
568 MessageLoop::current()->PostTask(FROM_HERE, | 568 MessageLoop::current()->PostTask(FROM_HERE, |
569 new RunCloseWithAppMenuTask(browser())); | 569 new RunCloseWithAppMenuTask(browser())); |
570 } | 570 } |
571 | 571 |
| 572 #if !defined(OS_MACOSX) |
| 573 IN_PROC_BROWSER_TEST_F(BrowserTest, OpenAppWindowLikeNtp) { |
| 574 ASSERT_TRUE(test_server()->Start()); |
| 575 |
| 576 // Load an app |
| 577 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 578 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); |
| 579 const Extension* extension_app = GetExtension(); |
| 580 |
| 581 // Launch it in a window, as AppLauncherHandler::HandleLaunchApp() would. |
| 582 TabContents* app_window = Browser::OpenApplication( |
| 583 browser()->profile(), extension_app, extension_misc::LAUNCH_WINDOW, NULL); |
| 584 ASSERT_TRUE(app_window); |
| 585 |
| 586 // Apps launched in a window from the NTP do not have extension_app set in |
| 587 // tab contents. |
| 588 EXPECT_FALSE(app_window->extension_app()); |
| 589 EXPECT_EQ(extension_app->GetFullLaunchURL(), app_window->GetURL()); |
| 590 |
| 591 // The launch should have created a new browser. |
| 592 ASSERT_EQ(2u, BrowserList::GetBrowserCount(browser()->profile())); |
| 593 |
| 594 // Find the new browser. |
| 595 Browser* new_browser = NULL; |
| 596 for (BrowserList::const_iterator i = BrowserList::begin(); |
| 597 i != BrowserList::end() && !new_browser; ++i) { |
| 598 if (*i != browser()) |
| 599 new_browser = *i; |
| 600 } |
| 601 ASSERT_TRUE(new_browser); |
| 602 ASSERT_TRUE(new_browser != browser()); |
| 603 |
| 604 EXPECT_EQ(Browser::TYPE_APP, new_browser->type()); |
| 605 } |
| 606 #endif // !defined(OS_MACOSX) |
| 607 |
572 // TODO(ben): this test was never enabled. It has bit-rotted since being added. | 608 // TODO(ben): this test was never enabled. It has bit-rotted since being added. |
573 // It originally lived in browser_unittest.cc, but has been moved here to make | 609 // It originally lived in browser_unittest.cc, but has been moved here to make |
574 // room for real browser unit tests. | 610 // room for real browser unit tests. |
575 #if 0 | 611 #if 0 |
576 class BrowserTest2 : public InProcessBrowserTest { | 612 class BrowserTest2 : public InProcessBrowserTest { |
577 public: | 613 public: |
578 BrowserTest2() { | 614 BrowserTest2() { |
579 host_resolver_proc_ = new net::RuleBasedHostResolverProc(NULL); | 615 host_resolver_proc_ = new net::RuleBasedHostResolverProc(NULL); |
580 // Avoid making external DNS lookups. In this test we don't need this | 616 // Avoid making external DNS lookups. In this test we don't need this |
581 // to succeed. | 617 // to succeed. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 | 682 |
647 // The normal browser should now have four. | 683 // The normal browser should now have four. |
648 EXPECT_EQ(4, browser()->tab_count()); | 684 EXPECT_EQ(4, browser()->tab_count()); |
649 | 685 |
650 // Close the additional browsers. | 686 // Close the additional browsers. |
651 popup_browser->CloseAllTabs(); | 687 popup_browser->CloseAllTabs(); |
652 app_browser->CloseAllTabs(); | 688 app_browser->CloseAllTabs(); |
653 app_popup_browser->CloseAllTabs(); | 689 app_popup_browser->CloseAllTabs(); |
654 } | 690 } |
655 #endif | 691 #endif |
OLD | NEW |