Commit 2e717336 authored by Roman Sorokin's avatar Roman Sorokin Committed by Commit Bot

Fix GuestSessionRlzTest.DeviceIsLocked

Check if it's inited before setting a callback to wait

Fixed: 1151851
Change-Id: I94ae394067474c277d0f7c5786c611d637aa98fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2560508
Commit-Queue: Roman Sorokin [CET] <rsorokin@chromium.org>
Commit-Queue: Roman Aleksandrov <raleksandrov@google.com>
Reviewed-by: default avatarRoman Aleksandrov <raleksandrov@google.com>
Auto-Submit: Roman Sorokin [CET] <rsorokin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#831003}
parent 772c82a3
......@@ -66,6 +66,7 @@ IN_PROC_BROWSER_TEST_F(LoginUtilsTest, RlzInitialized) {
{
base::RunLoop loop;
WizardController::SkipPostLoginScreensForTesting();
EXPECT_FALSE(UserSessionInitializer::Get()->get_inited_for_testing());
UserSessionInitializer::Get()->set_init_rlz_impl_closure_for_testing(
loop.QuitClosure());
......
......@@ -278,12 +278,14 @@ class GuestSessionRlzTest : public InProcessBrowserTest,
DISALLOW_COPY_AND_ASSIGN(GuestSessionRlzTest);
};
// TODO(crbug.com/1151851) flaky test
IN_PROC_BROWSER_TEST_P(GuestSessionRlzTest, DISABLED_DeviceIsLocked) {
base::RunLoop loop;
UserSessionInitializer::Get()->set_init_rlz_impl_closure_for_testing(
loop.QuitClosure());
loop.Run();
IN_PROC_BROWSER_TEST_P(GuestSessionRlzTest, DeviceIsLocked) {
if (!UserSessionInitializer::Get()->get_inited_for_testing()) {
// Wait for initialization.
base::RunLoop loop;
UserSessionInitializer::Get()->set_init_rlz_impl_closure_for_testing(
loop.QuitClosure());
loop.Run();
}
const char* const expected_brand =
stub_install_attributes()->IsDeviceLocked() ? "TEST" : "";
EXPECT_EQ(expected_brand, google_brand::chromeos::GetBrand());
......
......@@ -266,6 +266,7 @@ void UserSessionInitializer::InitRlzImpl(Profile* profile,
#endif
if (init_rlz_impl_closure_for_testing_)
std::move(init_rlz_impl_closure_for_testing_).Run();
inited_for_testing_ = true;
}
} // namespace chromeos
......@@ -52,6 +52,8 @@ class UserSessionInitializer : public session_manager::SessionManagerObserver {
init_rlz_impl_closure_for_testing_ = std::move(closure);
}
bool get_inited_for_testing() { return inited_for_testing_; }
private:
// Initialize RLZ.
void InitRlz(Profile* profile);
......@@ -76,6 +78,7 @@ class UserSessionInitializer : public session_manager::SessionManagerObserver {
Profile* primary_profile_ = nullptr;
bool inited_for_testing_ = false;
base::OnceClosure init_rlz_impl_closure_for_testing_;
// Clipboard html image generator for the primary user.
......
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