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
3 // found in the LICENSE file.
5 #include "base/compiler_specific.h"
6 #include "base/logging.h"
7 #include "base/macros.h"
8 #include "chrome/browser/chromeos/login/captive_portal_view.h"
9 #include "chrome/browser/chromeos/login/captive_portal_window_proxy.h"
10 #include "chrome/browser/chromeos/login/login_display_host_impl.h"
11 #include "chrome/browser/chromeos/login/login_manager_test.h"
12 #include "chrome/browser/chromeos/login/simple_web_view_dialog.h"
13 #include "chrome/browser/chromeos/login/webui_login_view.h"
14 #include "chrome/browser/chromeos/profiles/profile_helper.h"
15 #include "content/public/browser/interstitial_page.h"
16 #include "content/public/browser/interstitial_page_delegate.h"
17 #include "ui/views/controls/webview/webview.h"
23 class StubDelegate
: public CaptivePortalWindowProxyDelegate
{
26 virtual ~StubDelegate() {}
27 virtual void OnPortalDetected() OVERRIDE
{}
30 DISALLOW_COPY_AND_ASSIGN(StubDelegate
);
33 class InterstitialPageDelegate
: public content::InterstitialPageDelegate
{
35 explicit InterstitialPageDelegate(content::WebContents
* web_contents
) {
36 content::InterstitialPage
* page
= content::InterstitialPage::Create(
37 web_contents
, true, GURL("http://foo"), this);
41 virtual ~InterstitialPageDelegate() {}
44 // InterstitialPageDelegate implementation:
45 virtual std::string
GetHTMLContents() OVERRIDE
{ return "HTML Contents"; }
47 DISALLOW_COPY_AND_ASSIGN(InterstitialPageDelegate
);
52 class SimpleWebViewDialogTest
: public LoginManagerTest
{
54 SimpleWebViewDialogTest(): LoginManagerTest(false) {}
55 virtual ~SimpleWebViewDialogTest() {}
57 InterstitialPageDelegate
* CreateDelegate(CaptivePortalWindowProxy
* proxy
) {
58 SimpleWebViewDialog
* dialog
= proxy
->captive_portal_view_for_testing();
59 CHECK(dialog
) << "CaptivePortalView is not initialized";
60 return new InterstitialPageDelegate(dialog
->web_view_
->web_contents());
64 DISALLOW_COPY_AND_ASSIGN(SimpleWebViewDialogTest
);
67 IN_PROC_BROWSER_TEST_F(SimpleWebViewDialogTest
, Interstitial
) {
68 content::WebContents
* web_contents
= LoginDisplayHostImpl::default_host()
71 StubDelegate delegate
;
72 CaptivePortalWindowProxy
proxy(&delegate
, web_contents
);
75 // Delegate creates a page and passes himself to it. Page owns the
76 // delegate and will be destroyed by the end of the test.
77 CreateDelegate(&proxy
);
80 } // namespace chromeos