Commit 9d52b640 authored by Roman Sorokin's avatar Roman Sorokin Committed by Commit Bot

Fix ActiveDirectoryLoginTest for MSAN

Prevents network error screen shown by setting maximum offline timeout

Bug: 770738
Change-Id: I19ae30e1775e758df682a9bab3adb4b2c4037b96
Reviewed-on: https://chromium-review.googlesource.com/700639
Commit-Queue: Roman Sorokin <rsorokin@chromium.org>
Reviewed-by: default avatarAchuith Bhandarkar <achuith@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506688}
parent 67d4e602
......@@ -19,6 +19,7 @@
#include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/settings/stub_install_attributes.h"
#include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/interactive_test_utils.h"
......@@ -111,8 +112,15 @@ class ActiveDirectoryLoginTest : public LoginManagerTest {
}
void SetUpOnMainThread() override {
LoginManagerTest::SetUpOnMainThread();
// Set the threshold to a max value to disable the offline message screen
// on slow configurations like MSAN, where it otherwise triggers on every
// run.
LoginDisplayHost::default_host()
->GetOobeUI()
->signin_screen_handler()
->SetOfflineTimeoutForTesting(base::TimeDelta::Max());
fake_auth_policy_client()->DisableOperationDelayForTesting();
LoginManagerTest::SetUpOnMainThread();
}
void MarkAsActiveDirectoryEnterprise() {
......@@ -229,7 +237,6 @@ class ActiveDirectoryLoginTest : public LoginManagerTest {
return "document.querySelector('#" + parent_id + " /deep/ #" + element_id +
"')";
}
TestAuthPolicyClient* fake_auth_policy_client() {
return fake_auth_policy_client_;
}
......@@ -257,8 +264,7 @@ IN_PROC_BROWSER_TEST_F(ActiveDirectoryLoginTest, PRE_LoginSuccess) {
}
// Test successful Active Directory login.
// Fails on MSAN: https://crbug.com/770738.
IN_PROC_BROWSER_TEST_F(ActiveDirectoryLoginTest, DISABLED_LoginSuccess) {
IN_PROC_BROWSER_TEST_F(ActiveDirectoryLoginTest, LoginSuccess) {
TestNoError();
TestDomainVisible();
......@@ -275,8 +281,7 @@ IN_PROC_BROWSER_TEST_F(ActiveDirectoryLoginTest, PRE_LoginErrors) {
}
// Test different UI errors for Active Directory login.
// Fails on MSAN: https://crbug.com/770738.
IN_PROC_BROWSER_TEST_F(ActiveDirectoryLoginTest, DISABLED_LoginErrors) {
IN_PROC_BROWSER_TEST_F(ActiveDirectoryLoginTest, LoginErrors) {
SetupActiveDirectoryJSNotifications();
TestNoError();
TestDomainVisible();
......
......@@ -213,7 +213,8 @@ IN_PROC_BROWSER_TEST_F(DeviceDisablingTest, DisableWithEphemeralUsers) {
SigninScreenHandler* const signin_screen_handler =
oobe_ui->signin_screen_handler();
ASSERT_TRUE(signin_screen_handler);
signin_screen_handler->ZeroOfflineTimeoutForTesting();
signin_screen_handler->SetOfflineTimeoutForTesting(
base::TimeDelta::FromSeconds(0));
SimulateNetworkOffline();
network_state_change_wait_run_loop_->Run();
network_state_informer->RemoveObserver(this);
......
......@@ -578,8 +578,10 @@ void SigninScreenHandler::SetFocusPODCallbackForTesting(
test_focus_pod_callback_ = callback;
}
void SigninScreenHandler::ZeroOfflineTimeoutForTesting() {
zero_offline_timeout_for_test_ = true;
void SigninScreenHandler::SetOfflineTimeoutForTesting(
base::TimeDelta offline_timeout) {
is_offline_timeout_for_test_set_ = true;
offline_timeout_for_test_ = offline_timeout;
}
bool SigninScreenHandler::GetKeyboardRemappedPrefValue(
......@@ -687,8 +689,9 @@ void SigninScreenHandler::UpdateStateInternal(NetworkError::ErrorReason reason,
true));
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, update_state_closure_.callback(),
base::TimeDelta::FromSeconds(
zero_offline_timeout_for_test_ ? 0 : kOfflineTimeoutSec));
is_offline_timeout_for_test_set_
? offline_timeout_for_test_
: base::TimeDelta::FromSeconds(kOfflineTimeoutSec));
return;
}
......
......@@ -287,9 +287,11 @@ class SigninScreenHandler
// To avoid spurious error messages on flaky networks, the offline message is
// only shown if the network is offline for a threshold number of seconds.
// This method reduces the threshold to zero, allowing the offline message to
// show instantaneously in tests.
void ZeroOfflineTimeoutForTesting();
// This method provides an ability to reduce the threshold to zero, allowing
// the offline message to show instantaneously in tests. The threshold can
// also be set to a high value to disable the offline message on slow
// configurations like MSAN, where it otherwise triggers on every run.
void SetOfflineTimeoutForTesting(base::TimeDelta offline_timeout);
// Gets the keyboard remapped pref value for |pref_name| key. Returns true if
// successful, otherwise returns false.
......@@ -549,7 +551,8 @@ class SigninScreenHandler
// True if SigninScreenHandler has already been added to OobeUI observers.
bool oobe_ui_observer_added_ = false;
bool zero_offline_timeout_for_test_ = false;
bool is_offline_timeout_for_test_set_ = false;
base::TimeDelta offline_timeout_for_test_;
std::unique_ptr<ErrorScreensHistogramHelper> histogram_helper_;
......
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