Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / chromeos / login / test / oobe_base_test.h
blobdc511239bea06380ecb893a6d32b67892d093c1d
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_
8 #include <string>
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"
22 namespace content {
23 class WebUI;
24 class WindowedNotificationObserver;
27 namespace extensions {
28 class ScopedCurrentChannel;
31 namespace chromeos {
33 class NetworkPortalDetectorTestImpl;
35 // Base class for OOBE, login, SAML and Kiosk tests.
36 class OobeBaseTest : public ExtensionApiTest {
37 public:
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[];
47 OobeBaseTest();
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();
54 protected:
55 // InProcessBrowserTest overrides.
56 void SetUp() override;
57 void SetUpInProcessBrowserTestFixture() override;
58 void SetUpOnMainThread() override;
59 void TearDownOnMainThread() override;
60 void SetUpCommandLine(base::CommandLine* command_line) override;
62 virtual void InitHttpsForwarders();
64 // Network status control functions.
65 void SimulateNetworkOffline();
66 void SimulateNetworkOnline();
67 void SimulateNetworkPortal();
69 base::Closure SimulateNetworkOfflineClosure();
70 base::Closure SimulateNetworkOnlineClosure();
71 base::Closure SimulateNetworkPortalClosure();
73 // Checks JavaScript |expression| in login screen.
74 void JsExpect(const std::string& expression);
76 test::JSChecker& JS() { return js_checker_; }
78 bool initialize_fake_merge_session() {
79 return initialize_fake_merge_session_;
81 void set_initialize_fake_merge_session(bool value) {
82 initialize_fake_merge_session_ = value;
85 // Returns chrome://oobe WebUI.
86 content::WebUI* GetLoginUI();
88 // Returns login display.
89 WebUILoginDisplay* GetLoginDisplay();
91 void WaitForGaiaPageLoad();
92 void WaitForSigninScreen();
93 void ExecuteJsInSigninFrame(const std::string& js);
94 void SetSignFormField(const std::string& field_id,
95 const std::string& field_value);
97 scoped_ptr<FakeGaia> fake_gaia_;
98 NetworkPortalDetectorTestImpl* network_portal_detector_;
100 // Whether to use background networking. Note this is only effective when it
101 // is set before SetUpCommandLine is invoked.
102 bool needs_background_networking_;
104 scoped_ptr<content::WindowedNotificationObserver> login_screen_load_observer_;
105 scoped_ptr<extensions::ScopedCurrentChannel> scoped_channel_;
106 HTTPSForwarder gaia_https_forwarder_;
107 std::string gaia_frame_parent_;
108 bool initialize_fake_merge_session_;
109 test::JSChecker js_checker_;
111 DISALLOW_COPY_AND_ASSIGN(OobeBaseTest);
114 } // namespace chromeos
116 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_TEST_OOBE_BASE_TEST_H_