Chromium Code Reviews| Index: chrome/browser/ui/webui/interstitials/interstitial_ui_browsertest.cc |
| diff --git a/chrome/browser/ui/webui/interstitials/interstitial_ui_browsertest.cc b/chrome/browser/ui/webui/interstitials/interstitial_ui_browsertest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5aa72bae00eacd588db0da1b0ca23eb1ed80b433 |
| --- /dev/null |
| +++ b/chrome/browser/ui/webui/interstitials/interstitial_ui_browsertest.cc |
| @@ -0,0 +1,57 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/strings/utf_string_conversions.h" |
| +#include "chrome/browser/chrome_notification_types.h" |
| +#include "chrome/browser/devtools/devtools_window.h" |
| +#include "chrome/browser/ui/browser.h" |
| +#include "chrome/browser/ui/tabs/tab_strip_model.h" |
| +#include "chrome/test/base/in_process_browser_test.h" |
| +#include "chrome/test/base/ui_test_utils.h" |
| +#include "content/public/browser/devtools_manager.h" |
| +#include "content/public/browser/web_contents.h" |
| + |
| +class InterstitialUITest : public InProcessBrowserTest { |
| + public: |
| + InterstitialUITest() {} |
| + virtual ~InterstitialUITest() {} |
| + |
| + protected: |
| + content::WebContents* GetInspectedTab() { |
|
Bernhard Bauer
2014/07/16 10:22:45
Is this used?
meacer
2014/07/16 21:21:40
Done.
|
| + return browser()->tab_strip_model()->GetWebContentsAt(0); |
| + } |
| + |
| + void TestInterstitial(GURL url, std::string page_title) { |
|
Bernhard Bauer
2014/07/16 10:22:45
const std::string&
meacer
2014/07/16 21:21:40
Done.
|
| + ui_test_utils::NavigateToURL(browser(), url); |
| + EXPECT_EQ( |
| + base::ASCIIToUTF16(page_title), |
| + browser()->tab_strip_model()->GetActiveWebContents()->GetTitle()); |
| + |
| + // Should also be able to open and close devtools. |
| + content::RenderViewHost* rvh = |
| + browser()->tab_strip_model()->GetWebContentsAt(0)->GetRenderViewHost(); |
| + DevToolsWindow* window = DevToolsWindow::OpenDevToolsWindowForTest(rvh, |
| + true); |
| + ui_test_utils::WaitUntilDevToolsWindowLoaded(window); |
| + // Try closing the devtools. |
| + content::WindowedNotificationObserver close_observer( |
| + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| + content::Source<content::WebContents>( |
| + window->web_contents_for_test())); |
| + DevToolsWindow::ToggleDevToolsWindow( |
| + browser(), |
| + DevToolsToggleAction::Toggle()); |
| + close_observer.Wait(); |
| + } |
| +}; |
| + |
| +IN_PROC_BROWSER_TEST_F(InterstitialUITest, OpenInterstitial) { |
| + TestInterstitial(GURL("chrome://interstitials"), "Interstitials"); |
| + TestInterstitial(GURL("chrome://interstitials/--invalid--"), "Interstitials"); |
| + TestInterstitial(GURL("chrome://interstitials/ssl"), "Privacy error"); |
| + TestInterstitial(GURL("chrome://interstitials/safebrowsing?type=malware"), |
| + "Security error"); |
| + TestInterstitial(GURL("chrome://interstitials/safebrowsing?type=phishing"), |
| + "Security error"); |
| +} |