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

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: Comments 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 57438e5651ad9680a2dbb332466c4a30e38321fc..a8b47c052fe2d62930258d72ccc00d07bc8a5e73 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 {
@@ -329,3 +332,57 @@ 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, SyncActive()).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));
+ EXPECT_TRUE(client->IsPasswordSyncEnabled(
+ password_manager::WITHOUT_CUSTOM_PASSPHRASE));
+
+ // Again, using a custom passphrase.
+ EXPECT_CALL(*mock_sync_service, IsUsingSecondaryPassphrase())
+ .WillRepeatedly(Return(true));
+
+ EXPECT_TRUE(
+ client->IsPasswordSyncEnabled(password_manager::ONLY_CUSTOM_PASSPHRASE));
+ EXPECT_FALSE(client->IsPasswordSyncEnabled(
+ password_manager::WITHOUT_CUSTOM_PASSPHRASE));
+
+ // 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(password_manager::ONLY_CUSTOM_PASSPHRASE));
+ EXPECT_FALSE(client->IsPasswordSyncEnabled(
+ password_manager::WITHOUT_CUSTOM_PASSPHRASE));
+
+ // Again, without a custom passphrase.
+ EXPECT_CALL(*mock_sync_service, IsUsingSecondaryPassphrase())
+ .WillRepeatedly(Return(false));
+
+ EXPECT_FALSE(
+ client->IsPasswordSyncEnabled(password_manager::ONLY_CUSTOM_PASSPHRASE));
+ EXPECT_FALSE(client->IsPasswordSyncEnabled(
+ password_manager::WITHOUT_CUSTOM_PASSPHRASE));
+}

Powered by Google App Engine
This is Rietveld 408576698