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

Side by Side Diff: chrome/browser/ui/cocoa/browser/password_generation_bubble_controller_unittest.mm

Issue 12207058: Connect SparseHistogram with the rest of stats system (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
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/sys_string_conversions.h" 11 #include "base/sys_string_conversions.h"
12 #include "chrome/browser/autofill/password_generator.h" 12 #include "chrome/browser/autofill/password_generator.h"
13 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" 13 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
14 #include "content/public/common/password_form.h" 14 #include "content/public/common/password_form.h"
15 #include "testing/gtest_mac.h" 15 #include "testing/gtest_mac.h"
16 16
17 using base::Histogram; 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:
25 PasswordGenerationBubbleControllerTest() 25 PasswordGenerationBubbleControllerTest()
26 : controller_(nil) {} 26 : controller_(nil) {}
27 27
28 static void SetUpTestCase() { 28 static void SetUpTestCase() {
29 StatisticsRecorder::Initialize(); 29 StatisticsRecorder::Initialize();
30 } 30 }
31 31
32 virtual void SetUp() { 32 virtual void SetUp() {
33 CocoaProfileTest::SetUp(); 33 CocoaProfileTest::SetUp();
34 34
35 generator_.reset(new autofill::PasswordGenerator(20)); 35 generator_.reset(new autofill::PasswordGenerator(20));
36 36
37 Histogram* histogram = StatisticsRecorder::FindHistogram(kHistogramName); 37 HistogramBase* histogram =
38 StatisticsRecorder::FindHistogram(kHistogramName);
38 if (histogram) 39 if (histogram)
39 original_ = histogram->SnapshotSamples(); 40 original_ = histogram->SnapshotSamples();
40 41
41 SetUpController(); 42 SetUpController();
42 } 43 }
43 44
44 PasswordGenerationBubbleController* controller() { return controller_; } 45 PasswordGenerationBubbleController* controller() { return controller_; }
45 46
46 void SetUpController() { 47 void SetUpController() {
47 content::PasswordForm form; 48 content::PasswordForm form;
(...skipping 10 matching lines...) Expand all
58 forForm:form]; 59 forForm:form];
59 } 60 }
60 61
61 void CloseController() { 62 void CloseController() {
62 [controller_ close]; 63 [controller_ close];
63 [controller_ windowWillClose:nil]; 64 [controller_ windowWillClose:nil];
64 controller_ = nil; 65 controller_ = nil;
65 } 66 }
66 67
67 HistogramSamples* GetHistogramSamples() { 68 HistogramSamples* GetHistogramSamples() {
68 Histogram* histogram = 69 HistogramBase* histogram =
69 StatisticsRecorder::FindHistogram(kHistogramName); 70 StatisticsRecorder::FindHistogram(kHistogramName);
70 if (histogram) { 71 if (histogram) {
71 current_ = histogram->SnapshotSamples(); 72 current_ = histogram->SnapshotSamples();
72 if (original_.get()) 73 if (original_.get())
73 current_->Subtract(*original_.get()); 74 current_->Subtract(*original_.get());
74 } 75 }
75 return current_.get(); 76 return current_.get();
76 } 77 }
77 78
78 protected: 79 protected:
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 [controller() fillPassword:nil]; 137 [controller() fillPassword:nil];
137 CloseController(); 138 CloseController();
138 139
139 samples = GetHistogramSamples(); 140 samples = GetHistogramSamples();
140 EXPECT_EQ(1, samples->GetCount(password_generation::IGNORE_FEATURE)); 141 EXPECT_EQ(1, samples->GetCount(password_generation::IGNORE_FEATURE));
141 EXPECT_EQ(1, samples->GetCount(password_generation::ACCEPT_AFTER_EDITING)); 142 EXPECT_EQ(1, samples->GetCount(password_generation::ACCEPT_AFTER_EDITING));
142 EXPECT_EQ(1, samples->GetCount( 143 EXPECT_EQ(1, samples->GetCount(
143 password_generation::ACCEPT_ORIGINAL_PASSWORD)); 144 password_generation::ACCEPT_ORIGINAL_PASSWORD));
144 145
145 } 146 }
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker/spellcheck_host_metrics_unittest.cc ('k') | chrome/common/metrics/metrics_service_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698