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

Side by Side Diff: chrome/renderer/autofill/password_generation_agent_browsertest.cc

Issue 643493003: [Password Generation] Update UMA stats for popups per page not per event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <string.h> 5 #include <string.h>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/metrics/histogram_samples.h"
9 #include "base/metrics/statistics_recorder.h"
Ilya Sherman 2014/10/14 20:17:20 nit: Are these two still needed?
Garrett Casto 2014/10/15 00:10:01 Done.
8 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/test/histogram_tester.h"
9 #include "chrome/test/base/chrome_render_view_test.h" 12 #include "chrome/test/base/chrome_render_view_test.h"
10 #include "components/autofill/content/common/autofill_messages.h" 13 #include "components/autofill/content/common/autofill_messages.h"
11 #include "components/autofill/content/renderer/autofill_agent.h" 14 #include "components/autofill/content/renderer/autofill_agent.h"
12 #include "components/autofill/content/renderer/test_password_generation_agent.h" 15 #include "components/autofill/content/renderer/test_password_generation_agent.h"
13 #include "components/autofill/core/common/form_data.h" 16 #include "components/autofill/core/common/form_data.h"
17 #include "components/autofill/core/common/password_generation_util.h"
14 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
15 #include "third_party/WebKit/public/platform/WebString.h" 19 #include "third_party/WebKit/public/platform/WebString.h"
16 #include "third_party/WebKit/public/web/WebDocument.h" 20 #include "third_party/WebKit/public/web/WebDocument.h"
17 #include "third_party/WebKit/public/web/WebLocalFrame.h" 21 #include "third_party/WebKit/public/web/WebLocalFrame.h"
18 #include "third_party/WebKit/public/web/WebWidget.h" 22 #include "third_party/WebKit/public/web/WebWidget.h"
19 23
20 using blink::WebDocument; 24 using blink::WebDocument;
21 using blink::WebElement; 25 using blink::WebElement;
22 using blink::WebInputElement; 26 using blink::WebInputElement;
23 using blink::WebNode; 27 using blink::WebNode;
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 ExecuteJavaScript("document.getElementById('username').focus();"); 325 ExecuteJavaScript("document.getElementById('username').focus();");
322 EXPECT_EQ(0u, password_generation_->messages().size()); 326 EXPECT_EQ(0u, password_generation_->messages().size());
323 password_generation_->clear_messages(); 327 password_generation_->clear_messages();
324 328
325 // Focusing the password field will bring up the generation UI again. 329 // Focusing the password field will bring up the generation UI again.
326 ExecuteJavaScript("document.getElementById('first_password').focus();"); 330 ExecuteJavaScript("document.getElementById('first_password').focus();");
327 EXPECT_EQ(1u, password_generation_->messages().size()); 331 EXPECT_EQ(1u, password_generation_->messages().size());
328 EXPECT_EQ(AutofillHostMsg_ShowPasswordGenerationPopup::ID, 332 EXPECT_EQ(AutofillHostMsg_ShowPasswordGenerationPopup::ID,
329 password_generation_->messages()[0]->type()); 333 password_generation_->messages()[0]->type());
330 password_generation_->clear_messages(); 334 password_generation_->clear_messages();
335
336 // Loading a different page triggers UMA stat upload. Verify that only one
337 // display event is sent even though
338 LoadHTML(kSigninFormHTML);
339
340 base::HistogramTester histogram_tester;
341 histogram_tester->ExpectBucketCount(
342 "PasswordGeneration.Event",
343 autofill::password_generation::GENERATION_POPUP_SHOWN,
344 1);
331 } 345 }
332 346
333 } // namespace autofill 347 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698