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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_bubble_model_unittest.cc

Issue 848723002: Credential Manager API: Showing both local and federated logins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/metrics/histogram_samples.h" 5 #include "base/metrics/histogram_samples.h"
6 #include "base/prefs/pref_service.h" 6 #include "base/prefs/pref_service.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/test/histogram_tester.h" 8 #include "base/test/histogram_tester.h"
9 #include "chrome/browser/ui/passwords/manage_passwords_bubble.h" 9 #include "chrome/browser/ui/passwords/manage_passwords_bubble.h"
10 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" 10 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
11 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h" 11 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h"
12 #include "chrome/test/base/testing_profile.h" 12 #include "chrome/test/base/testing_profile.h"
13 #include "components/password_manager/content/common/credential_manager_types.h"
13 #include "components/password_manager/core/browser/password_manager_metrics_util .h" 14 #include "components/password_manager/core/browser/password_manager_metrics_util .h"
14 #include "components/password_manager/core/browser/password_manager_url_collecti on_experiment.h" 15 #include "components/password_manager/core/browser/password_manager_url_collecti on_experiment.h"
15 #include "components/password_manager/core/common/password_manager_pref_names.h" 16 #include "components/password_manager/core/common/password_manager_pref_names.h"
16 #include "components/password_manager/core/common/password_manager_ui.h" 17 #include "components/password_manager/core/common/password_manager_ui.h"
17 #include "content/public/test/test_browser_thread_bundle.h" 18 #include "content/public/test/test_browser_thread_bundle.h"
18 #include "content/public/test/web_contents_tester.h" 19 #include "content/public/test/web_contents_tester.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 const char kUIDismissalReasonMetric[] = "PasswordManager.UIDismissalReason"; 22 const char kUIDismissalReasonMetric[] = "PasswordManager.UIDismissalReason";
22 const char kAllowToCollectURLBubbleUIDismissalReasonMetric[] = 23 const char kAllowToCollectURLBubbleUIDismissalReasonMetric[] =
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 kUIDismissalReasonMetric, 251 kUIDismissalReasonMetric,
251 password_manager::metrics_util::CLICKED_UNBLACKLIST, 252 password_manager::metrics_util::CLICKED_UNBLACKLIST,
252 1); 253 1);
253 } 254 }
254 255
255 TEST_F(ManagePasswordsBubbleModelTest, ClickCredential) { 256 TEST_F(ManagePasswordsBubbleModelTest, ClickCredential) {
256 base::HistogramTester histogram_tester; 257 base::HistogramTester histogram_tester;
257 PretendCredentialsWaiting(); 258 PretendCredentialsWaiting();
258 EXPECT_FALSE(controller()->choose_credential()); 259 EXPECT_FALSE(controller()->choose_credential());
259 autofill::PasswordForm form; 260 autofill::PasswordForm form;
260 model_->OnChooseCredentials(form); 261 model_->OnChooseCredentials(
262 form, password_manager::CredentialType::CREDENTIAL_TYPE_LOCAL);
261 model_->OnBubbleHidden(); 263 model_->OnBubbleHidden();
262 EXPECT_EQ(model_->dismissal_reason(), 264 EXPECT_EQ(model_->dismissal_reason(),
263 password_manager::metrics_util::CLICKED_CREDENTIAL); 265 password_manager::metrics_util::CLICKED_CREDENTIAL);
264 EXPECT_FALSE(controller()->saved_password()); 266 EXPECT_FALSE(controller()->saved_password());
265 EXPECT_FALSE(controller()->never_saved_password()); 267 EXPECT_FALSE(controller()->never_saved_password());
266 EXPECT_TRUE(controller()->choose_credential()); 268 EXPECT_TRUE(controller()->choose_credential());
267 269
268 histogram_tester.ExpectUniqueSample( 270 histogram_tester.ExpectUniqueSample(
269 kUIDismissalReasonMetric, 271 kUIDismissalReasonMetric,
270 password_manager::metrics_util::CLICKED_CREDENTIAL, 272 password_manager::metrics_util::CLICKED_CREDENTIAL,
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 model_->set_state(password_manager::ui::MANAGE_STATE); 410 model_->set_state(password_manager::ui::MANAGE_STATE);
409 EXPECT_FALSE(password_manager::ui::IsPendingState(model_->state())); 411 EXPECT_FALSE(password_manager::ui::IsPendingState(model_->state()));
410 model_->set_state(password_manager::ui::BLACKLIST_STATE); 412 model_->set_state(password_manager::ui::BLACKLIST_STATE);
411 EXPECT_FALSE(password_manager::ui::IsPendingState(model_->state())); 413 EXPECT_FALSE(password_manager::ui::IsPendingState(model_->state()));
412 414
413 model_->set_state(password_manager::ui::PENDING_PASSWORD_AND_BUBBLE_STATE); 415 model_->set_state(password_manager::ui::PENDING_PASSWORD_AND_BUBBLE_STATE);
414 EXPECT_TRUE(password_manager::ui::IsPendingState(model_->state())); 416 EXPECT_TRUE(password_manager::ui::IsPendingState(model_->state()));
415 model_->set_state(password_manager::ui::PENDING_PASSWORD_STATE); 417 model_->set_state(password_manager::ui::PENDING_PASSWORD_STATE);
416 EXPECT_TRUE(password_manager::ui::IsPendingState(model_->state())); 418 EXPECT_TRUE(password_manager::ui::IsPendingState(model_->state()));
417 } 419 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698