Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 | 197 |
| 198 // Used by CloseWithAppMenuOpen. Invokes CloseWindow on the supplied browser. | 198 // Used by CloseWithAppMenuOpen. Invokes CloseWindow on the supplied browser. |
| 199 void CloseWindowCallback(Browser* browser) { | 199 void CloseWindowCallback(Browser* browser) { |
| 200 chrome::CloseWindow(browser); | 200 chrome::CloseWindow(browser); |
| 201 } | 201 } |
| 202 | 202 |
| 203 // Used by CloseWithAppMenuOpen. Posts a CloseWindowCallback and shows the app | 203 // Used by CloseWithAppMenuOpen. Posts a CloseWindowCallback and shows the app |
| 204 // menu. | 204 // menu. |
| 205 void RunCloseWithAppMenuCallback(Browser* browser) { | 205 void RunCloseWithAppMenuCallback(Browser* browser) { |
| 206 // ShowAppMenu is modal under views. Schedule a task that closes the window. | 206 // ShowAppMenu is modal under views. Schedule a task that closes the window. |
| 207 base::MessageLoop::current()->PostTask( | 207 base::MessageLoop::current()->task_runner()->PostTask( |
|
msw
2015/06/12 00:31:21
nit: include message_loop.h and base/location.h
Sami
2015/06/12 10:56:22
Done.
| |
| 208 FROM_HERE, base::Bind(&CloseWindowCallback, browser)); | 208 FROM_HERE, base::Bind(&CloseWindowCallback, browser)); |
| 209 chrome::ShowAppMenu(browser); | 209 chrome::ShowAppMenu(browser); |
| 210 } | 210 } |
| 211 | 211 |
| 212 // Displays "INTERSTITIAL" while the interstitial is attached. | 212 // Displays "INTERSTITIAL" while the interstitial is attached. |
| 213 // (InterstitialPage can be used in a test directly, but there would be no way | 213 // (InterstitialPage can be used in a test directly, but there would be no way |
| 214 // to visually tell if it is showing or not.) | 214 // to visually tell if it is showing or not.) |
| 215 class TestInterstitialPage : public content::InterstitialPageDelegate { | 215 class TestInterstitialPage : public content::InterstitialPageDelegate { |
| 216 public: | 216 public: |
| 217 TestInterstitialPage(WebContents* tab, bool new_navigation, const GURL& url) { | 217 TestInterstitialPage(WebContents* tab, bool new_navigation, const GURL& url) { |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 911 // ensures that it happens through the single IDC_EXIT of the test. | 911 // ensures that it happens through the single IDC_EXIT of the test. |
| 912 void TearDownOnMainThread() override { | 912 void TearDownOnMainThread() override { |
| 913 // Cycle both the MessageLoop and the Cocoa runloop twice to flush out any | 913 // Cycle both the MessageLoop and the Cocoa runloop twice to flush out any |
| 914 // Chrome work that generates Cocoa work. Do this twice since there are two | 914 // Chrome work that generates Cocoa work. Do this twice since there are two |
| 915 // Browsers that must be closed. | 915 // Browsers that must be closed. |
| 916 CycleRunLoops(); | 916 CycleRunLoops(); |
| 917 CycleRunLoops(); | 917 CycleRunLoops(); |
| 918 | 918 |
| 919 // Run the application event loop to completion, which will cycle the | 919 // Run the application event loop to completion, which will cycle the |
| 920 // native MessagePump on all platforms. | 920 // native MessagePump on all platforms. |
| 921 base::MessageLoop::current()->PostTask(FROM_HERE, | 921 base::MessageLoop::current()->task_runner()->PostTask( |
| 922 base::MessageLoop::QuitClosure()); | 922 FROM_HERE, base::MessageLoop::QuitClosure()); |
| 923 base::MessageLoop::current()->Run(); | 923 base::MessageLoop::current()->Run(); |
| 924 | 924 |
| 925 // Take care of any remaining Cocoa work. | 925 // Take care of any remaining Cocoa work. |
| 926 CycleRunLoops(); | 926 CycleRunLoops(); |
| 927 | 927 |
| 928 // At this point, quit should be for real now. | 928 // At this point, quit should be for real now. |
| 929 ASSERT_EQ(0u, chrome::GetTotalBrowserCount()); | 929 ASSERT_EQ(0u, chrome::GetTotalBrowserCount()); |
| 930 } | 930 } |
| 931 | 931 |
| 932 // A helper function that cycles the MessageLoop, and on Mac, the Cocoa run | 932 // A helper function that cycles the MessageLoop, and on Mac, the Cocoa run |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1584 } | 1584 } |
| 1585 #endif // !defined(OS_CHROMEOS) | 1585 #endif // !defined(OS_CHROMEOS) |
| 1586 | 1586 |
| 1587 // This test verifies we don't crash when closing the last window and the app | 1587 // This test verifies we don't crash when closing the last window and the app |
| 1588 // menu is showing. | 1588 // menu is showing. |
| 1589 IN_PROC_BROWSER_TEST_F(BrowserTest, CloseWithAppMenuOpen) { | 1589 IN_PROC_BROWSER_TEST_F(BrowserTest, CloseWithAppMenuOpen) { |
| 1590 if (browser_defaults::kBrowserAliveWithNoWindows) | 1590 if (browser_defaults::kBrowserAliveWithNoWindows) |
| 1591 return; | 1591 return; |
| 1592 | 1592 |
| 1593 // We need a message loop running for menus on windows. | 1593 // We need a message loop running for menus on windows. |
| 1594 base::MessageLoop::current()->PostTask( | 1594 base::MessageLoop::current()->task_runner()->PostTask( |
| 1595 FROM_HERE, base::Bind(&RunCloseWithAppMenuCallback, browser())); | 1595 FROM_HERE, base::Bind(&RunCloseWithAppMenuCallback, browser())); |
| 1596 } | 1596 } |
| 1597 | 1597 |
| 1598 #if !defined(OS_MACOSX) | 1598 #if !defined(OS_MACOSX) |
| 1599 IN_PROC_BROWSER_TEST_F(BrowserTest, OpenAppWindowLikeNtp) { | 1599 IN_PROC_BROWSER_TEST_F(BrowserTest, OpenAppWindowLikeNtp) { |
| 1600 ASSERT_TRUE(test_server()->Start()); | 1600 ASSERT_TRUE(test_server()->Start()); |
| 1601 | 1601 |
| 1602 // Load an app | 1602 // Load an app |
| 1603 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 1603 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 1604 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); | 1604 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); |
| (...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2859 // Visit a broken HTTPS url. Other conditions cannot be tested after | 2859 // Visit a broken HTTPS url. Other conditions cannot be tested after |
| 2860 // this one because once the interstitial is clicked through, all URLs | 2860 // this one because once the interstitial is clicked through, all URLs |
| 2861 // for this host will remain in a broken state. | 2861 // for this host will remain in a broken state. |
| 2862 GURL expired_url(https_test_server_expired.GetURL(std::string())); | 2862 GURL expired_url(https_test_server_expired.GetURL(std::string())); |
| 2863 ui_test_utils::NavigateToURL(browser(), expired_url); | 2863 ui_test_utils::NavigateToURL(browser(), expired_url); |
| 2864 | 2864 |
| 2865 ProceedThroughInterstitial(web_contents); | 2865 ProceedThroughInterstitial(web_contents); |
| 2866 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, | 2866 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, |
| 2867 observer.latest_security_style()); | 2867 observer.latest_security_style()); |
| 2868 } | 2868 } |
| OLD | NEW |