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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_TEST_OOBE_BASE_TEST_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_TEST_OOBE_BASE_TEST_H_
10 #include "base/callback.h"
11 #include "base/command_line.h"
12 #include "chrome/browser/chromeos/login/test/https_forwarder.h"
13 #include "chrome/browser/chromeos/login/test/js_checker.h"
14 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
15 #include "chrome/browser/chromeos/login/ui/webui_login_display.h"
16 #include "chrome/browser/extensions/extension_apitest.h"
17 #include "chrome/test/base/in_process_browser_test.h"
18 #include "content/public/test/test_utils.h"
19 #include "google_apis/gaia/fake_gaia.h"
20 #include "net/test/embedded_test_server/embedded_test_server.h"
24 class WindowedNotificationObserver
;
27 namespace extensions
{
28 class ScopedCurrentChannel
;
33 class NetworkPortalDetectorTestImpl
;
35 // Base class for OOBE, login, SAML and Kiosk tests.
36 class OobeBaseTest
: public ExtensionApiTest
{
38 // Default fake user email and password, may be used by tests.
40 static const char kFakeUserEmail
[];
41 static const char kFakeUserPassword
[];
43 // FakeGaia is configured to return these cookies for kFakeUserEmail.
44 static const char kFakeSIDCookie
[];
45 static const char kFakeLSIDCookie
[];
48 ~OobeBaseTest() override
;
50 // Subclasses may register their own custom request handlers that will
51 // process requests prior it gets handled by FakeGaia instance.
52 virtual void RegisterAdditionalRequestHandlers();
55 // InProcessBrowserTest overrides.
56 void SetUp() override
;
57 void SetUpInProcessBrowserTestFixture() override
;
58 bool SetUpUserDataDirectory() override
;
59 void SetUpOnMainThread() override
;
60 void TearDownOnMainThread() override
;
61 void SetUpCommandLine(base::CommandLine
* command_line
) override
;
63 virtual void InitHttpsForwarders();
65 // Network status control functions.
66 void SimulateNetworkOffline();
67 void SimulateNetworkOnline();
68 void SimulateNetworkPortal();
70 base::Closure
SimulateNetworkOfflineClosure();
71 base::Closure
SimulateNetworkOnlineClosure();
72 base::Closure
SimulateNetworkPortalClosure();
74 // Checks JavaScript |expression| in login screen.
75 void JsExpect(const std::string
& expression
);
77 test::JSChecker
& JS() { return js_checker_
; }
79 bool use_webview() { return use_webview_
; }
80 void set_use_webview(bool use_webview
) { use_webview_
= use_webview
; }
82 bool initialize_fake_merge_session() {
83 return initialize_fake_merge_session_
;
85 void set_initialize_fake_merge_session(bool value
) {
86 initialize_fake_merge_session_
= value
;
89 // Returns chrome://oobe WebUI.
90 content::WebUI
* GetLoginUI();
92 // Returns login display.
93 WebUILoginDisplay
* GetLoginDisplay();
95 void WaitForGaiaPageLoad();
96 void WaitForSigninScreen();
97 void ExecuteJsInSigninFrame(const std::string
& js
);
98 void SetSignFormField(const std::string
& field_id
,
99 const std::string
& field_value
);
101 scoped_ptr
<FakeGaia
> fake_gaia_
;
102 NetworkPortalDetectorTestImpl
* network_portal_detector_
;
104 // Whether to use background networking. Note this is only effective when it
105 // is set before SetUpCommandLine is invoked.
106 bool needs_background_networking_
;
108 scoped_ptr
<content::WindowedNotificationObserver
> login_screen_load_observer_
;
109 scoped_ptr
<extensions::ScopedCurrentChannel
> scoped_channel_
;
110 HTTPSForwarder gaia_https_forwarder_
;
111 std::string gaia_frame_parent_
;
113 bool initialize_fake_merge_session_
;
114 test::JSChecker js_checker_
;
116 DISALLOW_COPY_AND_ASSIGN(OobeBaseTest
);
119 } // namespace chromeos
121 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_TEST_OOBE_BASE_TEST_H_