Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "chrome/browser/chrome_notification_types.h" | 6 #include "chrome/browser/chrome_notification_types.h" |
| 7 #include "chrome/browser/devtools/devtools_window.h" | 7 #include "chrome/browser/devtools/devtools_window.h" |
| 8 #include "chrome/browser/devtools/devtools_window_testing.h" | 8 #include "chrome/browser/devtools/devtools_window_testing.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_commands.h" | 10 #include "chrome/browser/ui/browser_commands.h" |
| 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 12 #include "chrome/test/base/in_process_browser_test.h" | 12 #include "chrome/test/base/in_process_browser_test.h" |
| 13 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
| 14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 15 | 15 |
| 16 class InterstitialUITest : public InProcessBrowserTest { | 16 class InterstitialUITest : public InProcessBrowserTest { |
| 17 public: | 17 public: |
| 18 InterstitialUITest() {} | 18 InterstitialUITest() {} |
| 19 ~InterstitialUITest() override {} | 19 ~InterstitialUITest() override {} |
| 20 | 20 |
| 21 protected: | 21 protected: |
| 22 void TestInterstitial(GURL url, const std::string& page_title) { | 22 void TestInterstitial(GURL url, const std::string& page_title) { |
| 23 ui_test_utils::NavigateToURL(browser(), url); | 23 ui_test_utils::NavigateToURL(browser(), url); |
| 24 EXPECT_EQ( | 24 EXPECT_EQ( |
| 25 base::ASCIIToUTF16(page_title), | 25 base::ASCIIToUTF16(page_title), |
| 26 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle()); | 26 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle()); |
|
meacer
2017/06/27 21:10:17
nit: Not necessary for this CL, but we might also
sperigo
2017/06/27 21:31:27
Good idea. I noticed these tests were pretty bare.
meacer
2017/06/27 21:32:50
Sure, feel free to file as a new bug.
| |
| 27 | 27 |
| 28 // Should also be able to open and close devtools. | 28 // Should also be able to open and close devtools. |
| 29 DevToolsWindow* window = | 29 DevToolsWindow* window = |
| 30 DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), true); | 30 DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), true); |
| 31 EXPECT_TRUE(window); | 31 EXPECT_TRUE(window); |
| 32 DevToolsWindowTesting::CloseDevToolsWindowSync(window); | 32 DevToolsWindowTesting::CloseDevToolsWindowSync(window); |
| 33 } | 33 } |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 IN_PROC_BROWSER_TEST_F(InterstitialUITest, HomePage) { | 36 IN_PROC_BROWSER_TEST_F(InterstitialUITest, HomePage) { |
| 37 TestInterstitial( | 37 TestInterstitial( |
| 38 GURL("chrome://interstitials"), | 38 GURL("chrome://interstitials"), |
| 39 "Interstitials"); | 39 "Interstitials"); |
| 40 } | 40 } |
| 41 | 41 |
| 42 IN_PROC_BROWSER_TEST_F(InterstitialUITest, InvalidURLShouldOpenHomePage) { | 42 IN_PROC_BROWSER_TEST_F(InterstitialUITest, InvalidURLShouldOpenHomePage) { |
| 43 // Invalid path should open the main page: | 43 // Invalid path should open the main page: |
| 44 TestInterstitial( | 44 TestInterstitial( |
| 45 GURL("chrome://interstitials/--invalid--"), | 45 GURL("chrome://interstitials/--invalid--"), |
| 46 "Interstitials"); | 46 "Interstitials"); |
| 47 } | 47 } |
| 48 | 48 |
| 49 IN_PROC_BROWSER_TEST_F(InterstitialUITest, SSLInterstitial) { | 49 IN_PROC_BROWSER_TEST_F(InterstitialUITest, SSLInterstitial) { |
| 50 TestInterstitial( | 50 TestInterstitial( |
| 51 GURL("chrome://interstitials/ssl"), | 51 GURL("chrome://interstitials/ssl"), |
| 52 "Privacy error"); | 52 "Privacy error"); |
| 53 } | 53 } |
| 54 | 54 |
| 55 IN_PROC_BROWSER_TEST_F(InterstitialUITest, PinnedCertInterstitial) { | |
| 56 TestInterstitial(GURL("chrome://interstitials/ssl?type=hpkp_failure"), | |
| 57 "Privacy error"); | |
| 58 } | |
| 59 | |
| 55 IN_PROC_BROWSER_TEST_F(InterstitialUITest, MalwareInterstitial) { | 60 IN_PROC_BROWSER_TEST_F(InterstitialUITest, MalwareInterstitial) { |
| 56 TestInterstitial( | 61 TestInterstitial( |
| 57 GURL("chrome://interstitials/safebrowsing?type=malware"), | 62 GURL("chrome://interstitials/safebrowsing?type=malware"), |
| 58 "Security error"); | 63 "Security error"); |
| 59 } | 64 } |
| 60 | 65 |
| 61 IN_PROC_BROWSER_TEST_F(InterstitialUITest, PhishingInterstitial) { | 66 IN_PROC_BROWSER_TEST_F(InterstitialUITest, PhishingInterstitial) { |
| 62 TestInterstitial( | 67 TestInterstitial( |
| 63 GURL("chrome://interstitials/safebrowsing?type=phishing"), | 68 GURL("chrome://interstitials/safebrowsing?type=phishing"), |
| 64 "Security error"); | 69 "Security error"); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 | 112 |
| 108 // Duplicate the tab and close it. | 113 // Duplicate the tab and close it. |
| 109 chrome::DuplicateTab(browser()); | 114 chrome::DuplicateTab(browser()); |
| 110 EXPECT_NE(current_tab, browser()->tab_strip_model()->active_index()); | 115 EXPECT_NE(current_tab, browser()->tab_strip_model()->active_index()); |
| 111 chrome::CloseTab(browser()); | 116 chrome::CloseTab(browser()); |
| 112 EXPECT_EQ(current_tab, browser()->tab_strip_model()->active_index()); | 117 EXPECT_EQ(current_tab, browser()->tab_strip_model()->active_index()); |
| 113 | 118 |
| 114 // Reloading the page shouldn't cause a crash. | 119 // Reloading the page shouldn't cause a crash. |
| 115 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB); | 120 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB); |
| 116 } | 121 } |
| OLD | NEW |