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

Side by Side Diff: chrome/browser/ui/autofill/save_card_bubble_controller_impl_unittest.cc

Issue 2839683002: Logs different SaveCardPrompt histogram names depending on if user (Closed)
Patch Set: Uses LogUMAHistogramEnumeration instead of UMA_HISTOGRAM_ENUMERATION because we change histogram na… Created 3 years, 7 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 "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h" 5 #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/test/histogram_tester.h" 13 #include "base/test/histogram_tester.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/ui/autofill/save_card_bubble_view.h" 15 #include "chrome/browser/ui/autofill/save_card_bubble_view.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model.h"
17 #include "chrome/test/base/browser_with_test_window_test.h" 17 #include "chrome/test/base/browser_with_test_window_test.h"
18 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 18 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
19 #include "components/autofill/core/browser/autofill_metrics.h" 19 #include "components/autofill/core/browser/autofill_metrics.h"
20 #include "components/autofill/core/browser/credit_card.h" 20 #include "components/autofill/core/browser/credit_card.h"
21 #include "components/autofill/core/common/autofill_pref_names.h"
22 #include "components/user_prefs/user_prefs.h"
21 #include "content/public/browser/navigation_handle.h" 23 #include "content/public/browser/navigation_handle.h"
22 #include "testing/gmock/include/gmock/gmock.h" 24 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
24 26
25 using base::Bucket; 27 using base::Bucket;
26 using testing::ElementsAre; 28 using testing::ElementsAre;
27 29
28 namespace autofill { 30 namespace autofill {
29 31
30 class TestSaveCardBubbleControllerImpl : public SaveCardBubbleControllerImpl { 32 class TestSaveCardBubbleControllerImpl : public SaveCardBubbleControllerImpl {
(...skipping 23 matching lines...) Expand all
54 base::TimeDelta elapsed_; 56 base::TimeDelta elapsed_;
55 }; 57 };
56 58
57 class SaveCardBubbleControllerImplTest : public BrowserWithTestWindowTest { 59 class SaveCardBubbleControllerImplTest : public BrowserWithTestWindowTest {
58 public: 60 public:
59 SaveCardBubbleControllerImplTest() {} 61 SaveCardBubbleControllerImplTest() {}
60 62
61 void SetUp() override { 63 void SetUp() override {
62 BrowserWithTestWindowTest::SetUp(); 64 BrowserWithTestWindowTest::SetUp();
63 AddTab(browser(), GURL("about:blank")); 65 AddTab(browser(), GURL("about:blank"));
64 TestSaveCardBubbleControllerImpl::CreateForTesting( 66 content::WebContents* web_contents =
65 browser()->tab_strip_model()->GetActiveWebContents()); 67 browser()->tab_strip_model()->GetActiveWebContents();
68 TestSaveCardBubbleControllerImpl::CreateForTesting(web_contents);
69 user_prefs::UserPrefs::Get(web_contents->GetBrowserContext())
70 ->SetBoolean(prefs::kAutofillAcceptSaveCreditCardPromptState, true);
66 } 71 }
67 72
68 BrowserWindow* CreateBrowserWindow() override { 73 BrowserWindow* CreateBrowserWindow() override {
69 return new SaveCardBubbleTestBrowserWindow(); 74 return new SaveCardBubbleTestBrowserWindow();
70 } 75 }
71 76
72 void SetLegalMessage(const std::string& message_json, 77 void SetLegalMessage(const std::string& message_json,
73 bool should_cvc_be_requested = false) { 78 bool should_cvc_be_requested = false) {
74 std::unique_ptr<base::Value> value(base::JSONReader::Read(message_json)); 79 std::unique_ptr<base::Value> value(base::JSONReader::Read(message_json));
75 ASSERT_TRUE(value); 80 ASSERT_TRUE(value);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 ShowUploadBubble(true /* should_cvc_be_requested */); 159 ShowUploadBubble(true /* should_cvc_be_requested */);
155 EXPECT_TRUE(controller()->ShouldRequestCvcFromUser()); 160 EXPECT_TRUE(controller()->ShouldRequestCvcFromUser());
156 } 161 }
157 162
158 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Local_FirstShow_ShowBubble) { 163 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Local_FirstShow_ShowBubble) {
159 base::HistogramTester histogram_tester; 164 base::HistogramTester histogram_tester;
160 ShowLocalBubble(); 165 ShowLocalBubble();
161 166
162 EXPECT_THAT( 167 EXPECT_THAT(
163 histogram_tester.GetAllSamples( 168 histogram_tester.GetAllSamples(
164 "Autofill.SaveCreditCardPrompt.Local.FirstShow"), 169 "Autofill.SaveCreditCardPrompt.Local.FirstShow.PreviouslyAccepted"),
165 ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1), 170 ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1),
166 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1))); 171 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1)));
167 } 172 }
168 173
169 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Local_Reshows_ShowBubble) { 174 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Local_Reshows_ShowBubble) {
170 ShowLocalBubble(); 175 ShowLocalBubble();
171 176
172 base::HistogramTester histogram_tester; 177 base::HistogramTester histogram_tester;
173 CloseAndReshowBubble(); 178 CloseAndReshowBubble();
174 179
175 EXPECT_THAT( 180 EXPECT_THAT(
176 histogram_tester.GetAllSamples( 181 histogram_tester.GetAllSamples(
177 "Autofill.SaveCreditCardPrompt.Local.Reshows"), 182 "Autofill.SaveCreditCardPrompt.Local.Reshows.PreviouslyAccepted"),
178 ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1), 183 ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1),
179 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1))); 184 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1)));
180 } 185 }
181 186
182 TEST_F(SaveCardBubbleControllerImplTest, 187 TEST_F(SaveCardBubbleControllerImplTest,
183 Metrics_Upload_FirstShow_ShowBubble_NotRequestCvc) { 188 Metrics_Upload_FirstShow_ShowBubble_NotRequestCvc) {
184 base::HistogramTester histogram_tester; 189 base::HistogramTester histogram_tester;
185 ShowUploadBubble(); 190 ShowUploadBubble();
186 191
187 EXPECT_THAT( 192 EXPECT_THAT(
188 histogram_tester.GetAllSamples( 193 histogram_tester.GetAllSamples(
189 "Autofill.SaveCreditCardPrompt.Upload.FirstShow"), 194 "Autofill.SaveCreditCardPrompt.Upload.FirstShow.PreviouslyAccepted"),
190 ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1), 195 ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1),
191 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1))); 196 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1)));
192 } 197 }
193 198
194 TEST_F(SaveCardBubbleControllerImplTest, 199 TEST_F(SaveCardBubbleControllerImplTest,
195 Metrics_Upload_FirstShow_ShowBubble_RequestCvc) { 200 Metrics_Upload_FirstShow_ShowBubble_RequestCvc) {
196 base::HistogramTester histogram_tester; 201 base::HistogramTester histogram_tester;
197 ShowUploadBubble(true /* should_cvc_be_requested */); 202 ShowUploadBubble(true /* should_cvc_be_requested */);
198 203
199 EXPECT_THAT( 204 EXPECT_THAT(
200 histogram_tester.GetAllSamples( 205 histogram_tester.GetAllSamples(
201 "Autofill.SaveCreditCardPrompt.Upload.FirstShow"), 206 "Autofill.SaveCreditCardPrompt.Upload.FirstShow.PreviouslyAccepted"),
202 ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1), 207 ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1),
203 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1))); 208 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1)));
204 } 209 }
205 210
206 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_Reshows_ShowBubble) { 211 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_Reshows_ShowBubble) {
207 ShowUploadBubble(); 212 ShowUploadBubble();
208 213
209 base::HistogramTester histogram_tester; 214 base::HistogramTester histogram_tester;
210 CloseAndReshowBubble(); 215 CloseAndReshowBubble();
211 216
212 EXPECT_THAT( 217 EXPECT_THAT(
213 histogram_tester.GetAllSamples( 218 histogram_tester.GetAllSamples(
214 "Autofill.SaveCreditCardPrompt.Upload.Reshows"), 219 "Autofill.SaveCreditCardPrompt.Upload.Reshows.PreviouslyAccepted"),
215 ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1), 220 ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1),
216 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1))); 221 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1)));
217 } 222 }
218 223
219 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Local_FirstShow_SaveButton) { 224 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Local_FirstShow_SaveButton) {
220 ShowLocalBubble(); 225 ShowLocalBubble();
221 226
222 base::HistogramTester histogram_tester; 227 base::HistogramTester histogram_tester;
223 controller()->OnSaveButton(); 228 controller()->OnSaveButton();
224 controller()->OnBubbleClosed(); 229 controller()->OnBubbleClosed();
225 230
226 histogram_tester.ExpectUniqueSample( 231 histogram_tester.ExpectUniqueSample(
227 "Autofill.SaveCreditCardPrompt.Local.FirstShow", 232 "Autofill.SaveCreditCardPrompt.Local.FirstShow.PreviouslyAccepted",
228 AutofillMetrics::SAVE_CARD_PROMPT_END_ACCEPTED, 1); 233 AutofillMetrics::SAVE_CARD_PROMPT_END_ACCEPTED, 1);
229 } 234 }
230 235
231 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Local_Reshows_SaveButton) { 236 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Local_Reshows_SaveButton) {
232 ShowLocalBubble(); 237 ShowLocalBubble();
233 CloseAndReshowBubble(); 238 CloseAndReshowBubble();
234 239
235 base::HistogramTester histogram_tester; 240 base::HistogramTester histogram_tester;
236 controller()->OnSaveButton(); 241 controller()->OnSaveButton();
237 controller()->OnBubbleClosed(); 242 controller()->OnBubbleClosed();
238 243
239 histogram_tester.ExpectUniqueSample( 244 histogram_tester.ExpectUniqueSample(
240 "Autofill.SaveCreditCardPrompt.Local.Reshows", 245 "Autofill.SaveCreditCardPrompt.Local.Reshows.PreviouslyAccepted",
241 AutofillMetrics::SAVE_CARD_PROMPT_END_ACCEPTED, 1); 246 AutofillMetrics::SAVE_CARD_PROMPT_END_ACCEPTED, 1);
242 } 247 }
243 248
244 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Local_FirstShow_CancelButton) { 249 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Local_FirstShow_CancelButton) {
245 ShowLocalBubble(); 250 ShowLocalBubble();
246 251
247 base::HistogramTester histogram_tester; 252 base::HistogramTester histogram_tester;
248 controller()->OnCancelButton(); 253 controller()->OnCancelButton();
249 controller()->OnBubbleClosed(); 254 controller()->OnBubbleClosed();
250 255
251 histogram_tester.ExpectUniqueSample( 256 histogram_tester.ExpectUniqueSample(
252 "Autofill.SaveCreditCardPrompt.Local.FirstShow", 257 "Autofill.SaveCreditCardPrompt.Local.FirstShow.PreviouslyAccepted",
253 AutofillMetrics::SAVE_CARD_PROMPT_END_DENIED, 1); 258 AutofillMetrics::SAVE_CARD_PROMPT_END_DENIED, 1);
254 } 259 }
255 260
256 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Local_Reshows_CancelButton) { 261 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Local_Reshows_CancelButton) {
257 ShowLocalBubble(); 262 ShowLocalBubble();
258 CloseAndReshowBubble(); 263 CloseAndReshowBubble();
259 264
260 base::HistogramTester histogram_tester; 265 base::HistogramTester histogram_tester;
261 controller()->OnCancelButton(); 266 controller()->OnCancelButton();
262 controller()->OnBubbleClosed(); 267 controller()->OnBubbleClosed();
263 268
264 histogram_tester.ExpectUniqueSample( 269 histogram_tester.ExpectUniqueSample(
265 "Autofill.SaveCreditCardPrompt.Local.Reshows", 270 "Autofill.SaveCreditCardPrompt.Local.Reshows.PreviouslyAccepted",
266 AutofillMetrics::SAVE_CARD_PROMPT_END_DENIED, 1); 271 AutofillMetrics::SAVE_CARD_PROMPT_END_DENIED, 1);
267 } 272 }
268 273
269 TEST_F(SaveCardBubbleControllerImplTest, 274 TEST_F(SaveCardBubbleControllerImplTest,
275 Metrics_Local_FirstShow_CancelButton_FirstShow) {
276 base::HistogramTester histogram_tester;
277 ShowLocalBubble();
278 controller()->OnCancelButton();
279 controller()->OnBubbleClosed();
280
281 ShowLocalBubble();
282 controller()->OnCancelButton();
283 controller()->OnBubbleClosed();
284
285 EXPECT_THAT(
286 histogram_tester.GetAllSamples(
287 "Autofill.SaveCreditCardPrompt.Local.FirstShow.PreviouslyAccepted"),
288 ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1),
289 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1),
290 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_END_DENIED, 1)));
291 EXPECT_THAT(
292 histogram_tester.GetAllSamples(
293 "Autofill.SaveCreditCardPrompt.Local.FirstShow.PreviouslyDenied"),
294 ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1),
295 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1),
296 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_END_DENIED, 1)));
297 }
298
299 TEST_F(SaveCardBubbleControllerImplTest,
300 Metrics_Local_FirstShow_CancelButton_FirstShow_SaveButton_FirstShow) {
301 base::HistogramTester histogram_tester;
302 ShowLocalBubble();
303 controller()->OnCancelButton();
304 controller()->OnBubbleClosed();
305
306 ShowLocalBubble();
307 controller()->OnSaveButton();
308 controller()->OnBubbleClosed();
309
310 ShowLocalBubble();
311
312 EXPECT_THAT(
313 histogram_tester.GetAllSamples(
314 "Autofill.SaveCreditCardPrompt.Local.FirstShow.PreviouslyAccepted"),
315 ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 2),
316 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 2),
317 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_END_DENIED, 1)));
318 EXPECT_THAT(
319 histogram_tester.GetAllSamples(
320 "Autofill.SaveCreditCardPrompt.Local.FirstShow.PreviouslyDenied"),
321 ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1),
322 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1),
323 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_END_ACCEPTED, 1)));
324 }
325
326 TEST_F(SaveCardBubbleControllerImplTest,
270 Metrics_Local_FirstShow_NavigateWhileShowing) { 327 Metrics_Local_FirstShow_NavigateWhileShowing) {
271 ShowLocalBubble(); 328 ShowLocalBubble();
272 329
273 base::HistogramTester histogram_tester; 330 base::HistogramTester histogram_tester;
274 // Fake-navigate after bubble has been visible for a long time. 331 // Fake-navigate after bubble has been visible for a long time.
275 controller()->set_elapsed(base::TimeDelta::FromMinutes(1)); 332 controller()->set_elapsed(base::TimeDelta::FromMinutes(1));
276 333
277 controller()->SimulateNavigation(); 334 controller()->SimulateNavigation();
278 335
279 histogram_tester.ExpectUniqueSample( 336 histogram_tester.ExpectUniqueSample(
280 "Autofill.SaveCreditCardPrompt.Local.FirstShow", 337 "Autofill.SaveCreditCardPrompt.Local.FirstShow.PreviouslyAccepted",
281 AutofillMetrics::SAVE_CARD_PROMPT_END_NAVIGATION_SHOWING, 1); 338 AutofillMetrics::SAVE_CARD_PROMPT_END_NAVIGATION_SHOWING, 1);
282 } 339 }
283 340
284 TEST_F(SaveCardBubbleControllerImplTest, 341 TEST_F(SaveCardBubbleControllerImplTest,
285 Metrics_Local_Reshows_NavigateWhileShowing) { 342 Metrics_Local_Reshows_NavigateWhileShowing) {
286 ShowLocalBubble(); 343 ShowLocalBubble();
287 CloseAndReshowBubble(); 344 CloseAndReshowBubble();
288 345
289 base::HistogramTester histogram_tester; 346 base::HistogramTester histogram_tester;
290 // Fake-navigate after bubble has been visible for a long time. 347 // Fake-navigate after bubble has been visible for a long time.
291 controller()->set_elapsed(base::TimeDelta::FromMinutes(1)); 348 controller()->set_elapsed(base::TimeDelta::FromMinutes(1));
292 controller()->SimulateNavigation(); 349 controller()->SimulateNavigation();
293 350
294 histogram_tester.ExpectUniqueSample( 351 histogram_tester.ExpectUniqueSample(
295 "Autofill.SaveCreditCardPrompt.Local.Reshows", 352 "Autofill.SaveCreditCardPrompt.Local.Reshows.PreviouslyAccepted",
296 AutofillMetrics::SAVE_CARD_PROMPT_END_NAVIGATION_SHOWING, 1); 353 AutofillMetrics::SAVE_CARD_PROMPT_END_NAVIGATION_SHOWING, 1);
297 } 354 }
298 355
299 TEST_F(SaveCardBubbleControllerImplTest, 356 TEST_F(SaveCardBubbleControllerImplTest,
300 Metrics_Local_FirstShow_NavigateWhileHidden) { 357 Metrics_Local_FirstShow_NavigateWhileHidden) {
301 ShowLocalBubble(); 358 ShowLocalBubble();
302 359
303 base::HistogramTester histogram_tester; 360 base::HistogramTester histogram_tester;
304 controller()->OnBubbleClosed(); 361 controller()->OnBubbleClosed();
305 // Fake-navigate after bubble has been visible for a long time. 362 // Fake-navigate after bubble has been visible for a long time.
306 controller()->set_elapsed(base::TimeDelta::FromMinutes(1)); 363 controller()->set_elapsed(base::TimeDelta::FromMinutes(1));
307 controller()->SimulateNavigation(); 364 controller()->SimulateNavigation();
308 365
309 histogram_tester.ExpectUniqueSample( 366 histogram_tester.ExpectUniqueSample(
310 "Autofill.SaveCreditCardPrompt.Local.FirstShow", 367 "Autofill.SaveCreditCardPrompt.Local.FirstShow.PreviouslyAccepted",
311 AutofillMetrics::SAVE_CARD_PROMPT_END_NAVIGATION_HIDDEN, 1); 368 AutofillMetrics::SAVE_CARD_PROMPT_END_NAVIGATION_HIDDEN, 1);
312 } 369 }
313 370
314 TEST_F(SaveCardBubbleControllerImplTest, 371 TEST_F(SaveCardBubbleControllerImplTest,
315 Metrics_Local_Reshows_NavigateWhileHidden) { 372 Metrics_Local_Reshows_NavigateWhileHidden) {
316 ShowLocalBubble(); 373 ShowLocalBubble();
317 CloseAndReshowBubble(); 374 CloseAndReshowBubble();
318 375
319 base::HistogramTester histogram_tester; 376 base::HistogramTester histogram_tester;
320 controller()->OnBubbleClosed(); 377 controller()->OnBubbleClosed();
321 // Fake-navigate after bubble has been visible for a long time. 378 // Fake-navigate after bubble has been visible for a long time.
322 controller()->set_elapsed(base::TimeDelta::FromMinutes(1)); 379 controller()->set_elapsed(base::TimeDelta::FromMinutes(1));
323 controller()->SimulateNavigation(); 380 controller()->SimulateNavigation();
324 381
325 histogram_tester.ExpectUniqueSample( 382 histogram_tester.ExpectUniqueSample(
326 "Autofill.SaveCreditCardPrompt.Local.Reshows", 383 "Autofill.SaveCreditCardPrompt.Local.Reshows.PreviouslyAccepted",
327 AutofillMetrics::SAVE_CARD_PROMPT_END_NAVIGATION_HIDDEN, 1); 384 AutofillMetrics::SAVE_CARD_PROMPT_END_NAVIGATION_HIDDEN, 1);
328 } 385 }
329 386
330 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_FirstShow_LearnMore) { 387 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_FirstShow_LearnMore) {
331 ShowUploadBubble(); 388 ShowUploadBubble();
332 389
333 base::HistogramTester histogram_tester; 390 base::HistogramTester histogram_tester;
334 controller()->OnLearnMoreClicked(); 391 controller()->OnLearnMoreClicked();
335 392
336 histogram_tester.ExpectUniqueSample( 393 histogram_tester.ExpectUniqueSample(
337 "Autofill.SaveCreditCardPrompt.Upload.FirstShow", 394 "Autofill.SaveCreditCardPrompt.Upload.FirstShow.PreviouslyAccepted",
338 AutofillMetrics::SAVE_CARD_PROMPT_DISMISS_CLICK_LEARN_MORE, 1); 395 AutofillMetrics::SAVE_CARD_PROMPT_DISMISS_CLICK_LEARN_MORE, 1);
339 } 396 }
340 397
341 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_Reshows_LearnMore) { 398 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_Reshows_LearnMore) {
342 ShowUploadBubble(); 399 ShowUploadBubble();
343 CloseAndReshowBubble(); 400 CloseAndReshowBubble();
344 401
345 base::HistogramTester histogram_tester; 402 base::HistogramTester histogram_tester;
346 controller()->OnLearnMoreClicked(); 403 controller()->OnLearnMoreClicked();
347 404
348 histogram_tester.ExpectUniqueSample( 405 histogram_tester.ExpectUniqueSample(
349 "Autofill.SaveCreditCardPrompt.Upload.Reshows", 406 "Autofill.SaveCreditCardPrompt.Upload.Reshows.PreviouslyAccepted",
350 AutofillMetrics::SAVE_CARD_PROMPT_DISMISS_CLICK_LEARN_MORE, 1); 407 AutofillMetrics::SAVE_CARD_PROMPT_DISMISS_CLICK_LEARN_MORE, 1);
351 } 408 }
352 409
353 TEST_F(SaveCardBubbleControllerImplTest, 410 TEST_F(SaveCardBubbleControllerImplTest,
354 Metrics_Upload_FirstShow_LegalMessageLink) { 411 Metrics_Upload_FirstShow_LegalMessageLink) {
355 ShowUploadBubble(); 412 ShowUploadBubble();
356 413
357 base::HistogramTester histogram_tester; 414 base::HistogramTester histogram_tester;
358 controller()->OnLegalMessageLinkClicked(GURL("http://www.example.com")); 415 controller()->OnLegalMessageLinkClicked(GURL("http://www.example.com"));
359 416
360 histogram_tester.ExpectUniqueSample( 417 histogram_tester.ExpectUniqueSample(
361 "Autofill.SaveCreditCardPrompt.Upload.FirstShow", 418 "Autofill.SaveCreditCardPrompt.Upload.FirstShow.PreviouslyAccepted",
362 AutofillMetrics::SAVE_CARD_PROMPT_DISMISS_CLICK_LEGAL_MESSAGE, 1); 419 AutofillMetrics::SAVE_CARD_PROMPT_DISMISS_CLICK_LEGAL_MESSAGE, 1);
363 } 420 }
364 421
365 TEST_F(SaveCardBubbleControllerImplTest, 422 TEST_F(SaveCardBubbleControllerImplTest,
366 Metrics_Upload_Reshows_LegalMessageLink) { 423 Metrics_Upload_Reshows_LegalMessageLink) {
367 ShowUploadBubble(); 424 ShowUploadBubble();
368 CloseAndReshowBubble(); 425 CloseAndReshowBubble();
369 426
370 base::HistogramTester histogram_tester; 427 base::HistogramTester histogram_tester;
371 controller()->OnLegalMessageLinkClicked(GURL("http://www.example.com")); 428 controller()->OnLegalMessageLinkClicked(GURL("http://www.example.com"));
372 429
373 histogram_tester.ExpectUniqueSample( 430 histogram_tester.ExpectUniqueSample(
374 "Autofill.SaveCreditCardPrompt.Upload.Reshows", 431 "Autofill.SaveCreditCardPrompt.Upload.Reshows.PreviouslyAccepted",
375 AutofillMetrics::SAVE_CARD_PROMPT_DISMISS_CLICK_LEGAL_MESSAGE, 1); 432 AutofillMetrics::SAVE_CARD_PROMPT_DISMISS_CLICK_LEGAL_MESSAGE, 1);
376 } 433 }
377 434
378 // SAVE_CARD_PROMPT_END_INVALID_LEGAL_MESSAGE is only possible for 435 // SAVE_CARD_PROMPT_END_INVALID_LEGAL_MESSAGE is only possible for
379 // Upload.FirstShow. 436 // Upload.FirstShow.
380 TEST_F(SaveCardBubbleControllerImplTest, 437 TEST_F(SaveCardBubbleControllerImplTest,
381 Metrics_Upload_FirstShow_InvalidLegalMessage) { 438 Metrics_Upload_FirstShow_InvalidLegalMessage) {
382 base::HistogramTester histogram_tester; 439 base::HistogramTester histogram_tester;
383 440
384 // Legal message is invalid because it's missing the url. 441 // Legal message is invalid because it's missing the url.
385 SetLegalMessage( 442 SetLegalMessage(
386 "{" 443 "{"
387 " \"line\" : [ {" 444 " \"line\" : [ {"
388 " \"template\": \"Panda {0}.\"," 445 " \"template\": \"Panda {0}.\","
389 " \"template_parameter\": [ {" 446 " \"template_parameter\": [ {"
390 " \"display_text\": \"bear\"" 447 " \"display_text\": \"bear\""
391 " } ]" 448 " } ]"
392 " } ]" 449 " } ]"
393 "}"); 450 "}");
394 451
395 EXPECT_THAT( 452 EXPECT_THAT(
396 histogram_tester.GetAllSamples( 453 histogram_tester.GetAllSamples(
397 "Autofill.SaveCreditCardPrompt.Upload.FirstShow"), 454 "Autofill.SaveCreditCardPrompt.Upload.FirstShow.PreviouslyAccepted"),
398 ElementsAre( 455 ElementsAre(
399 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1), 456 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1),
400 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_END_INVALID_LEGAL_MESSAGE, 457 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_END_INVALID_LEGAL_MESSAGE,
401 1))); 458 1)));
402 } 459 }
403 460
404 } // namespace autofill 461 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698