Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Unified Diff: chrome/browser/browsing_data/passwords_counter_browsertest.cc

Issue 2798243004: Show password sync status in CBD (Closed)
Patch Set: fix browser_tests and ios Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/browsing_data/passwords_counter_browsertest.cc
diff --git a/chrome/browser/browsing_data/passwords_counter_browsertest.cc b/chrome/browser/browsing_data/passwords_counter_browsertest.cc
index 8f5b994da687be2fdc53987fe361d39cde258687..f503c3658faeb04535d835edfb18773df43c7c0e 100644
--- a/chrome/browser/browsing_data/passwords_counter_browsertest.cc
+++ b/chrome/browser/browsing_data/passwords_counter_browsertest.cc
@@ -8,10 +8,12 @@
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/waitable_event.h"
#include "chrome/browser/password_manager/password_store_factory.h"
+#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/test/integration/passwords_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "components/autofill/core/common/password_form.h"
+#include "components/browser_sync/profile_sync_service_mock.h"
#include "components/browsing_data/core/browsing_data_utils.h"
#include "components/browsing_data/core/pref_names.h"
#include "components/prefs/pref_service.h"
@@ -84,15 +86,21 @@ class PasswordsCounterTest : public InProcessBrowserTest {
return result_;
}
+ bool HasSyncedPasswords() {
+ DCHECK(finished_);
+ return has_synced_passwords_;
+ }
+
void Callback(
std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result) {
finished_ = result->Finished();
if (finished_) {
- result_ =
- static_cast<browsing_data::BrowsingDataCounter::FinishedResult*>(
- result.get())
- ->Value();
+ auto* password_result =
+ static_cast<browsing_data::PasswordsCounter::PasswordResult*>(
+ result.get());
+ result_ = password_result->Value();
+ has_synced_passwords_ = password_result->has_synced_passwords();
}
if (finished_)
@@ -125,6 +133,7 @@ class PasswordsCounterTest : public InProcessBrowserTest {
bool finished_;
browsing_data::BrowsingDataCounter::ResultInt result_;
+ bool has_synced_passwords_;
};
// Tests that the counter correctly counts each individual credential on
@@ -138,8 +147,10 @@ IN_PROC_BROWSER_TEST_F(PasswordsCounterTest, SameDomain) {
WaitForUICallbacksFromAddingLogins();
Profile* profile = browser()->profile();
- browsing_data::PasswordsCounter counter(PasswordStoreFactory::GetForProfile(
- profile, ServiceAccessType::EXPLICIT_ACCESS));
+ browsing_data::PasswordsCounter counter(
+ PasswordStoreFactory::GetForProfile(profile,
+ ServiceAccessType::EXPLICIT_ACCESS),
+ ProfileSyncServiceFactory::GetForProfile(profile));
counter.Init(
profile->GetPrefs(), browsing_data::ClearBrowsingDataTab::ADVANCED,
base::Bind(&PasswordsCounterTest::Callback, base::Unretained(this)));
@@ -147,6 +158,7 @@ IN_PROC_BROWSER_TEST_F(PasswordsCounterTest, SameDomain) {
WaitForCounting();
EXPECT_EQ(5u, GetResult());
+ EXPECT_EQ(false, HasSyncedPasswords());
}
// Tests that the counter doesn't count blacklisted entries.
@@ -157,8 +169,10 @@ IN_PROC_BROWSER_TEST_F(PasswordsCounterTest, Blacklisted) {
WaitForUICallbacksFromAddingLogins();
Profile* profile = browser()->profile();
- browsing_data::PasswordsCounter counter(PasswordStoreFactory::GetForProfile(
- profile, ServiceAccessType::EXPLICIT_ACCESS));
+ browsing_data::PasswordsCounter counter(
+ PasswordStoreFactory::GetForProfile(profile,
+ ServiceAccessType::EXPLICIT_ACCESS),
+ ProfileSyncServiceFactory::GetForProfile(profile));
counter.Init(
profile->GetPrefs(), browsing_data::ClearBrowsingDataTab::ADVANCED,
@@ -167,6 +181,7 @@ IN_PROC_BROWSER_TEST_F(PasswordsCounterTest, Blacklisted) {
WaitForCounting();
EXPECT_EQ(1u, GetResult());
+ EXPECT_EQ(false, HasSyncedPasswords());
}
// Tests that the counter starts counting automatically when the deletion
@@ -178,8 +193,10 @@ IN_PROC_BROWSER_TEST_F(PasswordsCounterTest, PrefChanged) {
WaitForUICallbacksFromAddingLogins();
Profile* profile = browser()->profile();
- browsing_data::PasswordsCounter counter(PasswordStoreFactory::GetForProfile(
- profile, ServiceAccessType::EXPLICIT_ACCESS));
+ browsing_data::PasswordsCounter counter(
+ PasswordStoreFactory::GetForProfile(profile,
+ ServiceAccessType::EXPLICIT_ACCESS),
+ ProfileSyncServiceFactory::GetForProfile(profile));
counter.Init(
profile->GetPrefs(), browsing_data::ClearBrowsingDataTab::ADVANCED,
base::Bind(&PasswordsCounterTest::Callback, base::Unretained(this)));
@@ -187,6 +204,7 @@ IN_PROC_BROWSER_TEST_F(PasswordsCounterTest, PrefChanged) {
WaitForCounting();
EXPECT_EQ(2u, GetResult());
+ EXPECT_EQ(false, HasSyncedPasswords());
}
// Tests that the counter starts counting automatically when
@@ -196,8 +214,10 @@ IN_PROC_BROWSER_TEST_F(PasswordsCounterTest, StoreChanged) {
WaitForUICallbacksFromAddingLogins();
Profile* profile = browser()->profile();
- browsing_data::PasswordsCounter counter(PasswordStoreFactory::GetForProfile(
- profile, ServiceAccessType::EXPLICIT_ACCESS));
+ browsing_data::PasswordsCounter counter(
+ PasswordStoreFactory::GetForProfile(profile,
+ ServiceAccessType::EXPLICIT_ACCESS),
+ ProfileSyncServiceFactory::GetForProfile(profile));
counter.Init(
profile->GetPrefs(), browsing_data::ClearBrowsingDataTab::ADVANCED,
base::Bind(&PasswordsCounterTest::Callback, base::Unretained(this)));
@@ -228,8 +248,10 @@ IN_PROC_BROWSER_TEST_F(PasswordsCounterTest, PeriodChanged) {
WaitForUICallbacksFromAddingLogins();
Profile* profile = browser()->profile();
- browsing_data::PasswordsCounter counter(PasswordStoreFactory::GetForProfile(
- profile, ServiceAccessType::EXPLICIT_ACCESS));
+ browsing_data::PasswordsCounter counter(
+ PasswordStoreFactory::GetForProfile(profile,
+ ServiceAccessType::EXPLICIT_ACCESS),
+ ProfileSyncServiceFactory::GetForProfile(profile));
counter.Init(
profile->GetPrefs(), browsing_data::ClearBrowsingDataTab::ADVANCED,
base::Bind(&PasswordsCounterTest::Callback, base::Unretained(this)));

Powered by Google App Engine
This is Rietveld 408576698