1 // Copyright (c) 2013 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/command_line.h"
6 #include "chrome/browser/chrome_notification_types.h"
7 #include "chrome/browser/chromeos/login/existing_user_controller.h"
8 #include "chrome/browser/chromeos/login/test/oobe_base_test.h"
9 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h"
10 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
11 #include "chrome/browser/chromeos/login/ui/webui_login_display.h"
12 #include "chrome/browser/chromeos/login/wizard_controller.h"
13 #include "chrome/browser/lifetime/application_lifetime.h"
14 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/test/base/in_process_browser_test.h"
17 #include "chromeos/chromeos_switches.h"
18 #include "content/public/test/browser_test_utils.h"
19 #include "content/public/test/test_utils.h"
20 #include "google_apis/gaia/gaia_switches.h"
21 #include "net/test/embedded_test_server/embedded_test_server.h"
22 #include "net/test/embedded_test_server/http_response.h"
23 #include "testing/gtest/include/gtest/gtest.h"
24 #include "ui/base/test/ui_controls.h"
25 #include "ui/views/widget/widget.h"
27 using namespace net::test_server
;
31 class OobeTest
: public OobeBaseTest
{
34 ~OobeTest() override
{}
36 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
37 command_line
->AppendSwitch(switches::kOobeSkipPostLogin
);
39 OobeBaseTest::SetUpCommandLine(command_line
);
42 void TearDownOnMainThread() override
{
43 // If the login display is still showing, exit gracefully.
44 if (LoginDisplayHostImpl::default_host()) {
45 base::MessageLoop::current()->PostTask(FROM_HERE
,
46 base::Bind(&chrome::AttemptExit
));
47 content::RunMessageLoop();
50 OobeBaseTest::TearDownOnMainThread();
53 chromeos::WebUILoginDisplay
* GetLoginDisplay() {
54 chromeos::ExistingUserController
* controller
=
55 chromeos::ExistingUserController::current_controller();
57 return static_cast<chromeos::WebUILoginDisplay
*>(
58 controller
->login_display());
61 views::Widget
* GetLoginWindowWidget() {
62 return static_cast<chromeos::LoginDisplayHostImpl
*>(
63 chromeos::LoginDisplayHostImpl::default_host())
64 ->login_window_for_test();
68 DISALLOW_COPY_AND_ASSIGN(OobeTest
);
71 IN_PROC_BROWSER_TEST_F(OobeTest
, NewUser
) {
72 WaitForGaiaPageLoad();
74 content::WindowedNotificationObserver
session_start_waiter(
75 chrome::NOTIFICATION_SESSION_STARTED
,
76 content::NotificationService::AllSources());
78 GetLoginDisplay()->ShowSigninScreenForCreds(OobeBaseTest::kFakeUserEmail
,
79 OobeBaseTest::kFakeUserPassword
);
81 session_start_waiter
.Wait();
84 IN_PROC_BROWSER_TEST_F(OobeTest
, Accelerator
) {
85 WaitForGaiaPageLoad();
87 gfx::NativeWindow login_window
= GetLoginWindowWidget()->GetNativeWindow();
89 ui_controls::SendKeyPress(login_window
,
95 OobeScreenWaiter(OobeDisplay::SCREEN_OOBE_ENROLLMENT
).Wait();
98 } // namespace chromeos