blob: bbb3d70e8b3104bfd21955de39e323bfda1611f7 [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "build/build_config.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/signin_view_controller.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "components/signin/core/browser/signin_metrics.h"
#include "content/public/browser/notification_service.h"
#include "content/public/test/test_utils.h"
class SignInViewControllerBrowserTest : public InProcessBrowserTest {
public:
void SetUpOnMainThread() override {
// Many hotkeys are defined by the main menu. The value of these hotkeys
// depends on the focused window. We must focus the browser window. This is
// also why this test must be an interactive_ui_test rather than a browser
// test.
ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(
browser()->window()->GetNativeWindow()));
}
};
IN_PROC_BROWSER_TEST_F(SignInViewControllerBrowserTest, Accelerators) {
ASSERT_EQ(1, browser()->tab_strip_model()->count());
browser()->signin_view_controller()->ShowSignin(
profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, browser(),
signin_metrics::AccessPoint::ACCESS_POINT_SETTINGS);
content::WindowedNotificationObserver wait_for_new_tab(
chrome::NOTIFICATION_TAB_PARENTED,
content::NotificationService::AllSources());
// Press Ctrl/Cmd+T, which will open a new tab.
#if defined(OS_MACOSX)
ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
browser(), ui::VKEY_T, /*control=*/false, /*shift=*/false, /*alt=*/false,
/*command=*/true));
#else
ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
browser(), ui::VKEY_T, /*control=*/true, /*shift=*/false, /*alt=*/false,
/*command=*/false));
#endif
wait_for_new_tab.Wait();
EXPECT_EQ(2, browser()->tab_strip_model()->count());
}