Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / chromeos / login / oobe_browsertest.cc
blob2f13bd1750b19f317f419f5162cb5c453c66f803
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;
29 namespace chromeos {
31 // Boolean parameter is used to run this test for webview (true) and for
32 // iframe (false) GAIA sign in.
33 class OobeTest : public OobeBaseTest, public testing::WithParamInterface<bool> {
34 public:
35 OobeTest() { set_use_webview(GetParam()); }
36 ~OobeTest() override {}
38 void SetUpCommandLine(base::CommandLine* command_line) override {
39 command_line->AppendSwitch(switches::kOobeSkipPostLogin);
41 OobeBaseTest::SetUpCommandLine(command_line);
44 void TearDownOnMainThread() override {
45 // If the login display is still showing, exit gracefully.
46 if (LoginDisplayHostImpl::default_host()) {
47 base::MessageLoop::current()->PostTask(FROM_HERE,
48 base::Bind(&chrome::AttemptExit));
49 content::RunMessageLoop();
52 OobeBaseTest::TearDownOnMainThread();
55 chromeos::WebUILoginDisplay* GetLoginDisplay() {
56 chromeos::ExistingUserController* controller =
57 chromeos::ExistingUserController::current_controller();
58 CHECK(controller);
59 return static_cast<chromeos::WebUILoginDisplay*>(
60 controller->login_display());
63 views::Widget* GetLoginWindowWidget() {
64 return static_cast<chromeos::LoginDisplayHostImpl*>(
65 chromeos::LoginDisplayHostImpl::default_host())
66 ->login_window_for_test();
69 private:
70 DISALLOW_COPY_AND_ASSIGN(OobeTest);
73 IN_PROC_BROWSER_TEST_P(OobeTest, NewUser) {
74 WaitForGaiaPageLoad();
76 content::WindowedNotificationObserver session_start_waiter(
77 chrome::NOTIFICATION_SESSION_STARTED,
78 content::NotificationService::AllSources());
80 GetLoginDisplay()->ShowSigninScreenForCreds(OobeBaseTest::kFakeUserEmail,
81 OobeBaseTest::kFakeUserPassword);
83 session_start_waiter.Wait();
86 IN_PROC_BROWSER_TEST_P(OobeTest, Accelerator) {
87 WaitForGaiaPageLoad();
89 gfx::NativeWindow login_window = GetLoginWindowWidget()->GetNativeWindow();
91 ui_controls::SendKeyPress(login_window,
92 ui::VKEY_E,
93 true, // control
94 false, // shift
95 true, // alt
96 false); // command
97 OobeScreenWaiter(OobeDisplay::SCREEN_OOBE_ENROLLMENT).Wait();
100 INSTANTIATE_TEST_CASE_P(OobeSuite, OobeTest, testing::Bool());
102 } // namespace chromeos