Chromium Code Reviews| 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 b086529e529ac5328138c55ca097d30b8a695b62..49d4d5e5a5f30e94c30e4caad299872241413471 100644 |
| --- a/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc |
| +++ b/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc |
| @@ -14,6 +14,7 @@ |
| #include "base/strings/string16.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "base/test/scoped_feature_list.h" |
| +#include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
| #include "chrome/browser/sync/profile_sync_service_factory.h" |
| #include "chrome/browser/sync/profile_sync_test_util.h" |
| #include "chrome/common/channel_info.h" |
| @@ -352,3 +353,50 @@ TEST_F(ChromePasswordManagerClientTest, WebUINoLogging) { |
| log_router->UnregisterReceiver(&log_receiver); |
| } |
| + |
| +TEST_F(ChromePasswordManagerClientTest, ShouldAnnotateNavigationEntry) { |
| + ProfileSyncServiceMock* mock_sync_service = |
| + static_cast<ProfileSyncServiceMock*>( |
| + ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| + profile(), BuildMockProfileSyncService)); |
| + |
| + EXPECT_CALL(*mock_sync_service, IsFirstSetupComplete()) |
| + .WillRepeatedly(Return(true)); |
| + EXPECT_CALL(*mock_sync_service, IsSyncActive()).WillRepeatedly(Return(true)); |
| + |
| + // Connect our bool for testing. |
| + bool metrics_enabled = false; |
| + ChromeMetricsServiceAccessor::SetMetricsAndCrashReportingForTesting( |
| + &metrics_enabled); |
| + |
| + // Metrics disabled w/ non-custom passphrase: do not annotate |
| + metrics_enabled = false; |
| + EXPECT_CALL(*mock_sync_service, IsUsingSecondaryPassphrase()) |
| + .WillRepeatedly(Return(false)); |
| + EXPECT_FALSE( |
| + ChromePasswordManagerClient::ShouldAnnotateNavigationEntries(profile())); |
| + |
| + // Metrics enabled w/ non-custom passphrase: do annotate |
|
vabr (Chromium)
2016/09/02 09:12:20
Please split the 4 blocks at lines 373, 379, 386 a
Nathan Parker
2016/09/02 22:42:36
Done. And I split apart the new test I added.
|
| + metrics_enabled = true; |
| + EXPECT_CALL(*mock_sync_service, IsUsingSecondaryPassphrase()) |
| + .WillRepeatedly(Return(false)); |
| + EXPECT_TRUE( |
| + ChromePasswordManagerClient::ShouldAnnotateNavigationEntries(profile())); |
| + |
| + // Metrics enabled w/ custom passphrase: do not annotate |
| + metrics_enabled = true; |
| + EXPECT_CALL(*mock_sync_service, IsUsingSecondaryPassphrase()) |
| + .WillRepeatedly(Return(true)); |
| + EXPECT_FALSE( |
| + ChromePasswordManagerClient::ShouldAnnotateNavigationEntries(profile())); |
| + |
| + // Metrics disabled w/ custom passphrase: do not annotate |
| + metrics_enabled = false; |
| + EXPECT_CALL(*mock_sync_service, IsUsingSecondaryPassphrase()) |
| + .WillRepeatedly(Return(true)); |
| + EXPECT_FALSE( |
| + ChromePasswordManagerClient::ShouldAnnotateNavigationEntries(profile())); |
| + |
| + // Disconnect our bool for testing. |
| + ChromeMetricsServiceAccessor::SetMetricsAndCrashReportingForTesting(nullptr); |
| +} |