Commit ebda9b6b authored by Aya ElAttar's avatar Aya ElAttar Committed by Commit Bot

Add browsertests for managed-guest sessions warnings

Added browsertests to test that the login screen warnings
for the managed-guest sessions are controlled via
ManagedGuestSessionPrivacyWarningsEnabled policy, which
was added by this CL crrev.com/c/2254605.

Bug: 1099648
Change-Id: I18b7d0b15ca13182ff62b3bc23d3378aa59ced3e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2270458
Commit-Queue: Aya Elsayed <ayaelattar@google.com>
Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#783864}
parent df261d5d
......@@ -425,6 +425,16 @@ bool LoginScreenTestApi::IsExpandedPublicSessionAdvanced() {
return expanded_test.advanced_view()->GetVisible();
}
bool LoginScreenTestApi::IsPublicSessionWarningShown() {
LockScreen::TestApi lock_screen_test(LockScreen::Get());
LockContentsView::TestApi lock_contents_test(
lock_screen_test.contents_view());
LoginExpandedPublicAccountView::TestApi expanded_test(
lock_contents_test.expanded_view());
return expanded_test.monitoring_warning_icon() &&
expanded_test.monitoring_warning_label();
}
// static
void LoginScreenTestApi::ClickPublicExpandedAdvancedViewButton() {
LockScreen::TestApi lock_screen_test(LockScreen::Get());
......
......@@ -56,6 +56,7 @@ class ASH_PUBLIC_EXPORT LoginScreenTestApi {
static bool HidePublicSessionExpandedPod();
static bool IsPublicSessionExpanded();
static bool IsExpandedPublicSessionAdvanced();
static bool IsPublicSessionWarningShown();
static void ClickPublicExpandedAdvancedViewButton();
static void ClickPublicExpandedSubmitButton();
static void SetPublicSessionLocale(const std::string& locale);
......
......@@ -2222,6 +2222,52 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, PolicyForExtensions) {
*policy_service->GetPolicies(ns).GetValue("string"));
}
IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, LoginWarningShown) {
UploadAndInstallDeviceLocalAccountPolicy();
AddPublicSessionToDevicePolicy(kAccountId1);
WaitForPolicy();
ExpandPublicSessionPod(false);
// Click the link that switches the pod to its advanced form. Verify that the
// pod switches from basic to advanced.
ash::LoginScreenTestApi::ClickPublicExpandedAdvancedViewButton();
ASSERT_TRUE(ash::LoginScreenTestApi::IsExpandedPublicSessionAdvanced());
ASSERT_TRUE(ash::LoginScreenTestApi::IsPublicSessionWarningShown());
}
class DeviceLocalAccountWarnings : public DeviceLocalAccountTest {
void SetUpInProcessBrowserTestFixture() override {
DeviceLocalAccountTest::SetUpInProcessBrowserTestFixture();
SetManagedSessionsWarningDisabled();
}
void SetManagedSessionsWarningDisabled() {
em::ChromeDeviceSettingsProto& proto(device_policy()->payload());
em::ManagedGuestSessionPrivacyWarningsProto* managed_sessions_warnings =
proto.mutable_managed_guest_session_privacy_warnings();
managed_sessions_warnings->set_enabled(false);
RefreshDevicePolicy();
ASSERT_TRUE(local_policy_mixin_.UpdateDevicePolicy(proto));
}
};
IN_PROC_BROWSER_TEST_F(DeviceLocalAccountWarnings, NoLoginWarningShown) {
UploadAndInstallDeviceLocalAccountPolicy();
AddPublicSessionToDevicePolicy(kAccountId1);
WaitForPolicy();
ExpandPublicSessionPod(false);
// Click the link that switches the pod to its advanced form. Verify that the
// pod switches from basic to advanced.
ash::LoginScreenTestApi::ClickPublicExpandedAdvancedViewButton();
ASSERT_TRUE(ash::LoginScreenTestApi::IsExpandedPublicSessionAdvanced());
ASSERT_FALSE(ash::LoginScreenTestApi::IsPublicSessionWarningShown());
}
class ManagedSessionsTest : public DeviceLocalAccountTest {
protected:
class CertsObserver : public chromeos::PolicyCertificateProvider::Observer {
......
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