-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[M116][UPMLocalPwd] Don't show the warning more than once a month
Every time a warning is shown the timestamp is stored in a pref. When attempting to show another warning, the time interval is checked. If less than 30 days have passed since the last time it was shown, no prompt is triggered. This CL also introduces a feature param that allows bypassing the 1 month timeout for manual testing. (cherry picked from commit f0607cd) Bug: 1439853 Change-Id: I45577881a2cc95e6335918cb18fce436fd05f886 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4620688 Reviewed-by: Ivana Žužić <izuzic@google.com> Code-Coverage: Findit <findit-for-me@appspot.gserviceaccount.com> Reviewed-by: Vasilii Sukhanov <vasilii@chromium.org> Commit-Queue: Ioana Pandele <ioanap@chromium.org> Cr-Original-Commit-Position: refs/heads/main@{#1161803} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4645370 Cr-Commit-Position: refs/branch-heads/5845@{#90} Cr-Branched-From: 5a5dff6-refs/heads/main@{#1160321}
- Loading branch information
Ioana Pandele
authored and
Chromium LUCI CQ
committed
Jun 26, 2023
1 parent
1534ce3
commit 67e510a
Showing
19 changed files
with
174 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
chrome/browser/password_manager/android/local_passwords_migration_warning_util_unittest.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/password_manager/android/local_passwords_migration_warning_util.h" | ||
#include "base/test/scoped_feature_list.h" | ||
#include "base/time/time.h" | ||
#include "chrome/test/base/testing_profile.h" | ||
#include "components/password_manager/core/common/password_manager_features.h" | ||
#include "components/password_manager/core/common/password_manager_pref_names.h" | ||
#include "components/prefs/pref_registry_simple.h" | ||
#include "components/prefs/testing_pref_service.h" | ||
#include "components/sync_preferences/testing_pref_service_syncable.h" | ||
#include "content/public/test/browser_task_environment.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
class LocalPasswordsMigrationWarningUtilTest : public testing::Test { | ||
protected: | ||
LocalPasswordsMigrationWarningUtilTest() = default; | ||
~LocalPasswordsMigrationWarningUtilTest() override = default; | ||
|
||
sync_preferences::TestingPrefServiceSyncable* pref_service() { | ||
return profile_.GetTestingPrefService(); | ||
} | ||
|
||
Profile* profile() { return &profile_; } | ||
|
||
base::test::TaskEnvironment* task_env() { return &task_env_; } | ||
|
||
private: | ||
content::BrowserTaskEnvironment task_env_{ | ||
base::test::TaskEnvironment::TimeSource::MOCK_TIME}; | ||
TestingProfile profile_; | ||
}; | ||
|
||
TEST_F(LocalPasswordsMigrationWarningUtilTest, | ||
TestShouldNotShowWhenFeatureDisabled) { | ||
base::test::ScopedFeatureList scoped_feature_list; | ||
scoped_feature_list.InitAndDisableFeature( | ||
password_manager::features:: | ||
kUnifiedPasswordManagerLocalPasswordsMigrationWarning); | ||
EXPECT_FALSE(local_password_migration::ShouldShowWarning(profile())); | ||
} | ||
|
||
TEST_F(LocalPasswordsMigrationWarningUtilTest, | ||
TestShouldShowWhenMoreThanAMonth) { | ||
base::test::ScopedFeatureList scoped_feature_list( | ||
password_manager::features:: | ||
kUnifiedPasswordManagerLocalPasswordsMigrationWarning); | ||
pref_service()->SetTime( | ||
password_manager::prefs::kLocalPasswordsMigrationWarningShownTimestamp, | ||
base::Time::Now()); | ||
task_env()->FastForwardBy(base::Days(31)); | ||
EXPECT_TRUE(local_password_migration::ShouldShowWarning(profile())); | ||
} | ||
|
||
TEST_F(LocalPasswordsMigrationWarningUtilTest, | ||
TestShouldNotShowWhenLessThanAMonth) { | ||
base::test::ScopedFeatureList scoped_feature_list( | ||
password_manager::features:: | ||
kUnifiedPasswordManagerLocalPasswordsMigrationWarning); | ||
pref_service()->SetTime( | ||
password_manager::prefs::kLocalPasswordsMigrationWarningShownTimestamp, | ||
base::Time::Now()); | ||
task_env()->FastForwardBy(base::Days(29)); | ||
EXPECT_FALSE(local_password_migration::ShouldShowWarning(profile())); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.