Commit 211a835e authored by Anqing Zhao's avatar Anqing Zhao Committed by Commit Bot

Add browser tests for the default keyboard behavior in sessions

According to the design spec of the new policy 'Virtual Keyboard
Features' (go/pwa-api-key-dd), the keyboard features will be disabled by
default in the Web Kiosk session. This is an intended behavior change.

For other sessions, the original behaviors will still remain (i.e.,
enabled by default).

In this cl, some browser tests are added to ensure the following sessions
are correctly impacted (or not impacted) by the new policy.
- Guest session.
- Regular session.
- Chrome App Kiosk session.
- Web Kiosk session.

Bug: 1083893
Change-Id: If627ba3126f47a503f7793d1e7f9211b4f471079
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2276278Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Reviewed-by: default avatarAnatoliy Potapchuk <apotapchuk@chromium.org>
Reviewed-by: default avatarSergey Poromov <poromov@chromium.org>
Commit-Queue: Anqing Zhao <anqing@chromium.org>
Cr-Commit-Position: refs/heads/master@{#784437}
parent dd815982
......@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/public/cpp/keyboard/keyboard_controller.h"
#include "ash/public/cpp/login_screen_test_api.h"
#include "chrome/browser/chromeos/login/test/login_manager_mixin.h"
#include "chrome/browser/ui/browser.h"
......@@ -94,6 +95,35 @@ IN_PROC_BROWSER_TEST_F(GuestLoginTest, ExitFullscreenOnSuspend) {
EXPECT_FALSE(browser_window->IsFullscreen());
}
IN_PROC_BROWSER_TEST_F(GuestLoginTest,
PRE_VirtualKeyboardFeaturesEnabledByDefault) {
base::RunLoop restart_job_waiter;
FakeSessionManagerClient::Get()->set_restart_job_callback(
restart_job_waiter.QuitClosure());
ASSERT_TRUE(ash::LoginScreenTestApi::ClickGuestButton());
restart_job_waiter.Run();
EXPECT_TRUE(FakeSessionManagerClient::Get()->restart_job_argv().has_value());
}
IN_PROC_BROWSER_TEST_F(GuestLoginTest,
VirtualKeyboardFeaturesEnabledByDefault) {
login_manager_.WaitForActiveSession();
user_manager::UserManager* user_manager = user_manager::UserManager::Get();
EXPECT_TRUE(user_manager->IsLoggedInAsGuest());
keyboard::KeyboardConfig config =
ash::KeyboardController::Get()->GetKeyboardConfig();
EXPECT_TRUE(config.auto_capitalize);
EXPECT_TRUE(config.auto_complete);
EXPECT_TRUE(config.auto_correct);
EXPECT_TRUE(config.handwriting);
EXPECT_TRUE(config.spell_check);
EXPECT_TRUE(config.voice_input);
}
IN_PROC_BROWSER_TEST_F(GuestLoginWithLoginSwitchesTest, PRE_Login) {
base::RunLoop restart_job_waiter;
FakeSessionManagerClient::Get()->set_restart_job_callback(
......
......@@ -7,6 +7,7 @@
#include "apps/test/app_window_waiter.h"
#include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/keyboard/keyboard_controller.h"
#include "ash/public/cpp/keyboard/keyboard_switches.h"
#include "ash/public/cpp/login_screen_test_api.h"
#include "ash/public/cpp/wallpaper_controller_observer.h"
......@@ -868,6 +869,24 @@ IN_PROC_BROWSER_TEST_F(KioskTest, InstallAndLaunchApp) {
EXPECT_EQ(extensions::Manifest::EXTERNAL_PREF, GetInstalledAppLocation());
}
IN_PROC_BROWSER_TEST_F(KioskTest, VirtualKeyboardFeaturesEnabledByDefault) {
StartAppLaunchFromLoginScreen(
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE);
WaitForAppLaunchSuccess();
user_manager::UserManager* user_manager = user_manager::UserManager::Get();
EXPECT_TRUE(user_manager->IsLoggedInAsKioskApp());
keyboard::KeyboardConfig config =
ash::KeyboardController::Get()->GetKeyboardConfig();
EXPECT_TRUE(config.auto_capitalize);
EXPECT_TRUE(config.auto_complete);
EXPECT_TRUE(config.auto_correct);
EXPECT_TRUE(config.handwriting);
EXPECT_TRUE(config.spell_check);
EXPECT_TRUE(config.voice_input);
}
IN_PROC_BROWSER_TEST_F(KioskTest, ZoomSupport) {
ExtensionTestMessageListener app_window_loaded_listener("appWindowLoaded",
false);
......
......@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/public/cpp/keyboard/keyboard_controller.h"
#include "base/command_line.h"
#include "chrome/browser/chromeos/login/login_manager_test.h"
#include "chrome/browser/chromeos/login/startup_utils.h"
......@@ -12,6 +13,7 @@
#include "chrome/browser/ui/view_ids.h"
#include "chrome/common/chrome_switches.h"
#include "components/session_manager/core/session_manager.h"
#include "components/user_manager/user_manager.h"
#include "content/public/test/browser_test.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/views/focus/focus_manager.h"
......@@ -70,4 +72,31 @@ IN_PROC_BROWSER_TEST_F(BrowserLoginTest, BrowserActive) {
EXPECT_EQ(VIEW_ID_OMNIBOX, focused_view->GetID());
}
IN_PROC_BROWSER_TEST_F(BrowserLoginTest,
PRE_VirtualKeyboardFeaturesEnabledByDefault) {
RegisterUser(AccountId::FromUserEmailGaiaId(kTestUser, kTestUserGaiaId));
EXPECT_EQ(session_manager::SessionState::OOBE,
session_manager::SessionManager::Get()->session_state());
chromeos::StartupUtils::MarkOobeCompleted();
}
IN_PROC_BROWSER_TEST_F(BrowserLoginTest,
VirtualKeyboardFeaturesEnabledByDefault) {
base::HistogramTester histograms;
EXPECT_EQ(session_manager::SessionState::LOGIN_PRIMARY,
session_manager::SessionManager::Get()->session_state());
LoginUser(AccountId::FromUserEmailGaiaId(kTestUser, kTestUserGaiaId));
EXPECT_TRUE(
user_manager::UserManager::Get()->IsLoggedInAsUserWithGaiaAccount());
keyboard::KeyboardConfig config =
ash::KeyboardController::Get()->GetKeyboardConfig();
EXPECT_TRUE(config.auto_capitalize);
EXPECT_TRUE(config.auto_complete);
EXPECT_TRUE(config.auto_correct);
EXPECT_TRUE(config.handwriting);
EXPECT_TRUE(config.spell_check);
EXPECT_TRUE(config.voice_input);
}
} // namespace chromeos
......@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/public/cpp/keyboard/keyboard_controller.h"
#include "chrome/browser/chromeos/app_mode/web_app/mock_web_kiosk_app_launcher.h"
#include "chrome/browser/chromeos/login/web_kiosk_controller.h"
#include "chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client_test_helper.h"
......@@ -59,6 +60,23 @@ class WebKioskControllerTest : public InProcessBrowserTest {
EXPECT_EQ(network_state, controller_->network_ui_state_);
}
void ExpectKeyboardConfig() {
const keyboard::KeyboardConfig config =
ash::KeyboardController::Get()->GetKeyboardConfig();
// |auto_capitalize| is not controlled by the policy
// 'VirtualKeyboardFeatures', and its default value remains true.
EXPECT_TRUE(config.auto_capitalize);
// The other features are controlled by the policy
// 'VirtualKeyboardFeatures', and their default values should be false.
EXPECT_FALSE(config.auto_complete);
EXPECT_FALSE(config.auto_correct);
EXPECT_FALSE(config.handwriting);
EXPECT_FALSE(config.spell_check);
EXPECT_FALSE(config.voice_input);
}
void FireSplashScreenTimer() { controller_->OnTimerFire(); }
void SetOnline(bool online) {
......@@ -100,6 +118,8 @@ IN_PROC_BROWSER_TEST_F(WebKioskControllerTest, RegularFlow) {
launch_controls()->OnAppLaunched();
ExpectState(AppState::LAUNCHED, NetworkUIState::NOT_SHOWING);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
ExpectKeyboardConfig();
}
IN_PROC_BROWSER_TEST_F(WebKioskControllerTest, AlreadyInstalled) {
......@@ -118,6 +138,8 @@ IN_PROC_BROWSER_TEST_F(WebKioskControllerTest, AlreadyInstalled) {
launch_controls()->OnAppLaunched();
ExpectState(AppState::LAUNCHED, NetworkUIState::NOT_SHOWING);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
ExpectKeyboardConfig();
}
IN_PROC_BROWSER_TEST_F(WebKioskControllerTest, ConfigureNetworkBeforeProfile) {
......@@ -147,6 +169,8 @@ IN_PROC_BROWSER_TEST_F(WebKioskControllerTest, ConfigureNetworkBeforeProfile) {
launch_controls()->OnAppLaunched();
ExpectState(AppState::LAUNCHED, NetworkUIState::NOT_SHOWING);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
ExpectKeyboardConfig();
}
IN_PROC_BROWSER_TEST_F(WebKioskControllerTest,
......@@ -186,6 +210,8 @@ IN_PROC_BROWSER_TEST_F(WebKioskControllerTest,
launch_controls()->OnAppLaunched();
ExpectState(AppState::LAUNCHED, NetworkUIState::NOT_SHOWING);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
ExpectKeyboardConfig();
}
IN_PROC_BROWSER_TEST_F(WebKioskControllerTest,
......@@ -224,6 +250,8 @@ IN_PROC_BROWSER_TEST_F(WebKioskControllerTest,
launch_controls()->OnAppLaunched();
ExpectState(AppState::LAUNCHED, NetworkUIState::NOT_SHOWING);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
ExpectKeyboardConfig();
}
} // namespace chromeos
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment