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

Unified Diff: chrome/browser/password_manager/chrome_password_manager_client_unittest.cc

Issue 644053003: [Password Manager] Add UMA stats for custom passphrase users. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 2 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/password_manager/chrome_password_manager_client_unittest.cc
diff --git a/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc b/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc
index a07ad6dec0d2cfc3dd04ef53f9081572ee3f579c..aa4fb5acc017234f2f5dbe5c42d78a91b9e58705 100644
--- a/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc
+++ b/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc
@@ -7,6 +7,8 @@
#include "base/command_line.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/sync/profile_sync_service_factory.h"
+#include "chrome/browser/sync/profile_sync_service_mock.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_profile.h"
@@ -25,6 +27,7 @@
using content::BrowserContext;
using content::WebContents;
+using testing::Return;
namespace {
@@ -330,3 +333,49 @@ TEST_F(ChromePasswordManagerClientTest,
"https://passwords.google.com&rart=234"));
EXPECT_TRUE(client->IsPasswordManagerEnabledForCurrentPage());
}
+
+TEST_F(ChromePasswordManagerClientTest, IsPasswordSyncEnabled) {
+ ChromePasswordManagerClient* client = GetClient();
+
+ ProfileSyncServiceMock* mock_sync_service =
+ static_cast<ProfileSyncServiceMock*>(
+ ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
+ profile(), ProfileSyncServiceMock::BuildMockProfileSyncService));
+
+ syncer::ModelTypeSet active_types;
+ active_types.Put(syncer::PASSWORDS);
+ EXPECT_CALL(*mock_sync_service, HasSyncSetupCompleted())
+ .WillRepeatedly(Return(true));
+ EXPECT_CALL(*mock_sync_service, sync_initialized())
+ .WillRepeatedly(Return(true));
+ EXPECT_CALL(*mock_sync_service, GetActiveDataTypes())
+ .WillRepeatedly(Return(active_types));
+ EXPECT_CALL(*mock_sync_service, IsUsingSecondaryPassphrase())
+ .WillRepeatedly(Return(false));
+
+ // Passwords are syncing and custom passphrase isn't used.
+ EXPECT_FALSE(client->IsPasswordSyncEnabled(
+ password_manager::ONLY_CUSTOM_PASSPHRASE_USERS));
+ EXPECT_TRUE(client->IsPasswordSyncEnabled(
+ password_manager::EXCLUDE_CUSTOM_PASSPHRASE_USERS));
+
+ // Again, using a custom passphrase.
+ EXPECT_CALL(*mock_sync_service, IsUsingSecondaryPassphrase())
+ .WillRepeatedly(Return(true));
+
+ EXPECT_TRUE(client->IsPasswordSyncEnabled(
+ password_manager::ONLY_CUSTOM_PASSPHRASE_USERS));
+ EXPECT_FALSE(client->IsPasswordSyncEnabled(
+ password_manager::EXCLUDE_CUSTOM_PASSPHRASE_USERS));
+
+ // Always return false if we aren't syncing passwords.
+ active_types.Remove(syncer::PASSWORDS);
+ active_types.Put(syncer::BOOKMARKS);
+ EXPECT_CALL(*mock_sync_service, GetActiveDataTypes())
+ .WillRepeatedly(Return(active_types));
+
+ EXPECT_FALSE(client->IsPasswordSyncEnabled(
vabr (Chromium) 2014/10/13 09:24:18 Should you also mock the two possible values of Is
Garrett Casto 2014/10/13 20:57:56 Sure, done.
+ password_manager::ONLY_CUSTOM_PASSPHRASE_USERS));
+ EXPECT_FALSE(client->IsPasswordSyncEnabled(
+ password_manager::EXCLUDE_CUSTOM_PASSPHRASE_USERS));
+}

Powered by Google App Engine
This is Rietveld 408576698