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

Unified Diff: chrome/browser/ui/cocoa/browser/password_generation_bubble_controller_unittest.mm

Issue 538173002: [Password Generation] Remove old UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/ui/cocoa/browser/password_generation_bubble_controller_unittest.mm
diff --git a/chrome/browser/ui/cocoa/browser/password_generation_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/browser/password_generation_bubble_controller_unittest.mm
deleted file mode 100644
index 0c8884239be3635c6792e87882100f635d26fd5d..0000000000000000000000000000000000000000
--- a/chrome/browser/ui/cocoa/browser/password_generation_bubble_controller_unittest.mm
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import "chrome/browser/ui/cocoa/browser/password_generation_bubble_controller.h"
-
-#include "base/logging.h"
-#include "base/metrics/histogram_samples.h"
-#include "base/metrics/statistics_recorder.h"
-#include "base/strings/sys_string_conversions.h"
-#include "base/test/histogram_tester.h"
-#include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
-#include "components/autofill/core/browser/password_generator.h"
-#include "components/autofill/core/common/password_form.h"
-#include "testing/gtest_mac.h"
-
-const char kHistogramName[] = "PasswordGeneration.UserActions";
-
-class PasswordGenerationBubbleControllerTest : public CocoaProfileTest {
- public:
- PasswordGenerationBubbleControllerTest()
- : controller_(nil) {}
-
- static void SetUpTestCase() {
- base::StatisticsRecorder::Initialize();
- }
-
- virtual void SetUp() {
- CocoaProfileTest::SetUp();
-
- generator_.reset(new autofill::PasswordGenerator(20));
-
- SetUpController();
- }
-
- PasswordGenerationBubbleController* controller() { return controller_; }
-
- void SetUpController() {
- autofill::PasswordForm form;
- NSRect frame = [test_window() frame];
- NSPoint point = NSMakePoint(NSMidX(frame), NSMidY(frame));
-
- // |controller_| is self deleting.
- controller_ = [[PasswordGenerationBubbleController alloc]
- initWithWindow:test_window()
- anchoredAt:point
- renderViewHost:nil
- passwordManager:nil
- usingGenerator:generator_.get()
- forForm:form];
- }
-
- void CloseController() {
- [controller_ close];
- [controller_ windowWillClose:nil];
- controller_ = nil;
- }
-
- protected:
- // Weak.
- PasswordGenerationBubbleController* controller_;
-
- scoped_ptr<autofill::PasswordGenerator> generator_;
-};
-
-TEST_F(PasswordGenerationBubbleControllerTest, Regenerate) {
- [controller() showWindow:nil];
-
- PasswordGenerationTextField* textfield = controller().textField;
- // Grab the starting password value.
- NSString* before = [textfield stringValue];
-
- // Click on the regenerate icon.
- [textfield simulateIconClick];
-
- // Make sure that the password has changed. Technically this will fail
- // about once every 1e28 times, but not something we really need to worry
- // about.
- NSString* after = [textfield stringValue];
- EXPECT_FALSE([before isEqualToString:after]);
-}
-
-TEST_F(PasswordGenerationBubbleControllerTest, UMALogging) {
- base::HistogramTester histogram_tester;
- [controller() showWindow:nil];
-
- // Do nothing.
- CloseController();
-
- histogram_tester.ExpectUniqueSample(
- kHistogramName, autofill::password_generation::IGNORE_FEATURE, 1);
-
- SetUpController();
-
- // Pretend like the user changed the password and accepted it.
- [controller() controlTextDidChange:nil];
- [controller() fillPassword:nil];
- CloseController();
-
- histogram_tester.ExpectBucketCount(
- kHistogramName, autofill::password_generation::IGNORE_FEATURE, 1);
- histogram_tester.ExpectBucketCount(
- kHistogramName, autofill::password_generation::ACCEPT_AFTER_EDITING, 1);
- histogram_tester.ExpectTotalCount(kHistogramName, 2);
-
- SetUpController();
-
- // Just accept the password
- [controller() fillPassword:nil];
- CloseController();
-
- histogram_tester.ExpectBucketCount(
- kHistogramName, autofill::password_generation::IGNORE_FEATURE, 1);
- histogram_tester.ExpectBucketCount(
- kHistogramName, autofill::password_generation::ACCEPT_AFTER_EDITING, 1);
- histogram_tester.ExpectBucketCount(
- kHistogramName,
- autofill::password_generation::ACCEPT_ORIGINAL_PASSWORD,
- 1);
- histogram_tester.ExpectTotalCount(kHistogramName, 3);
-}

Powered by Google App Engine
This is Rietveld 408576698