| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #import "chrome/browser/ui/cocoa/browser/password_generation_bubble_controller.h
" | 5 #import "chrome/browser/ui/cocoa/browser/password_generation_bubble_controller.h
" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/metrics/histogram_samples.h" | 9 #include "base/metrics/histogram_samples.h" |
| 10 #include "base/metrics/statistics_recorder.h" | 10 #include "base/metrics/statistics_recorder.h" |
| 11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
| 12 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 12 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
| 13 #include "components/autofill/core/browser/password_generator.h" | 13 #include "components/autofill/core/browser/password_generator.h" |
| 14 #include "content/public/common/password_form.h" | 14 #include "components/autofill/core/common/password_form.h" |
| 15 #include "testing/gtest_mac.h" | 15 #include "testing/gtest_mac.h" |
| 16 | 16 |
| 17 using base::HistogramBase; | 17 using base::HistogramBase; |
| 18 using base::HistogramSamples; | 18 using base::HistogramSamples; |
| 19 using base::StatisticsRecorder; | 19 using base::StatisticsRecorder; |
| 20 | 20 |
| 21 const char kHistogramName[] = "PasswordGeneration.UserActions"; | 21 const char kHistogramName[] = "PasswordGeneration.UserActions"; |
| 22 | 22 |
| 23 class PasswordGenerationBubbleControllerTest : public CocoaProfileTest { | 23 class PasswordGenerationBubbleControllerTest : public CocoaProfileTest { |
| 24 public: | 24 public: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 38 StatisticsRecorder::FindHistogram(kHistogramName); | 38 StatisticsRecorder::FindHistogram(kHistogramName); |
| 39 if (histogram) | 39 if (histogram) |
| 40 original_ = histogram->SnapshotSamples(); | 40 original_ = histogram->SnapshotSamples(); |
| 41 | 41 |
| 42 SetUpController(); | 42 SetUpController(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 PasswordGenerationBubbleController* controller() { return controller_; } | 45 PasswordGenerationBubbleController* controller() { return controller_; } |
| 46 | 46 |
| 47 void SetUpController() { | 47 void SetUpController() { |
| 48 content::PasswordForm form; | 48 autofill::PasswordForm form; |
| 49 NSRect frame = [test_window() frame]; | 49 NSRect frame = [test_window() frame]; |
| 50 NSPoint point = NSMakePoint(NSMidX(frame), NSMidY(frame)); | 50 NSPoint point = NSMakePoint(NSMidX(frame), NSMidY(frame)); |
| 51 | 51 |
| 52 // |controller_| is self deleting. | 52 // |controller_| is self deleting. |
| 53 controller_ = [[PasswordGenerationBubbleController alloc] | 53 controller_ = [[PasswordGenerationBubbleController alloc] |
| 54 initWithWindow:test_window() | 54 initWithWindow:test_window() |
| 55 anchoredAt:point | 55 anchoredAt:point |
| 56 renderViewHost:nil | 56 renderViewHost:nil |
| 57 passwordManager:nil | 57 passwordManager:nil |
| 58 usingGenerator:generator_.get() | 58 usingGenerator:generator_.get() |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 samples->GetCount(autofill::password_generation::IGNORE_FEATURE)); | 155 samples->GetCount(autofill::password_generation::IGNORE_FEATURE)); |
| 156 EXPECT_EQ( | 156 EXPECT_EQ( |
| 157 1, | 157 1, |
| 158 samples->GetCount(autofill::password_generation::ACCEPT_AFTER_EDITING)); | 158 samples->GetCount(autofill::password_generation::ACCEPT_AFTER_EDITING)); |
| 159 EXPECT_EQ( | 159 EXPECT_EQ( |
| 160 1, | 160 1, |
| 161 samples->GetCount( | 161 samples->GetCount( |
| 162 autofill::password_generation::ACCEPT_ORIGINAL_PASSWORD)); | 162 autofill::password_generation::ACCEPT_ORIGINAL_PASSWORD)); |
| 163 | 163 |
| 164 } | 164 } |
| OLD | NEW |