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

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: Test 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
« no previous file with comments | « no previous file | components/autofill/content/renderer/password_generation_agent.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/test/histogram_tester.h"
9 #include "chrome/test/base/chrome_render_view_test.h" 10 #include "chrome/test/base/chrome_render_view_test.h"
10 #include "components/autofill/content/common/autofill_messages.h" 11 #include "components/autofill/content/common/autofill_messages.h"
11 #include "components/autofill/content/renderer/autofill_agent.h" 12 #include "components/autofill/content/renderer/autofill_agent.h"
12 #include "components/autofill/content/renderer/test_password_generation_agent.h" 13 #include "components/autofill/content/renderer/test_password_generation_agent.h"
13 #include "components/autofill/core/common/form_data.h" 14 #include "components/autofill/core/common/form_data.h"
15 #include "components/autofill/core/common/password_generation_util.h"
14 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
15 #include "third_party/WebKit/public/platform/WebString.h" 17 #include "third_party/WebKit/public/platform/WebString.h"
16 #include "third_party/WebKit/public/web/WebDocument.h" 18 #include "third_party/WebKit/public/web/WebDocument.h"
17 #include "third_party/WebKit/public/web/WebLocalFrame.h" 19 #include "third_party/WebKit/public/web/WebLocalFrame.h"
18 #include "third_party/WebKit/public/web/WebWidget.h" 20 #include "third_party/WebKit/public/web/WebWidget.h"
19 21
20 using blink::WebDocument; 22 using blink::WebDocument;
21 using blink::WebElement; 23 using blink::WebElement;
22 using blink::WebInputElement; 24 using blink::WebInputElement;
23 using blink::WebNode; 25 using blink::WebNode;
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 251
250 // Receive the account creation forms detected message. Show password 252 // Receive the account creation forms detected message. Show password
251 // generation icon. 253 // generation icon.
252 LoadHTML(kAccountCreationFormHTML); 254 LoadHTML(kAccountCreationFormHTML);
253 SetNotBlacklistedMessage(kAccountCreationFormHTML); 255 SetNotBlacklistedMessage(kAccountCreationFormHTML);
254 SetAccountCreationFormsDetectedMessage(kAccountCreationFormHTML); 256 SetAccountCreationFormsDetectedMessage(kAccountCreationFormHTML);
255 ExpectPasswordGenerationAvailable("first_password", true); 257 ExpectPasswordGenerationAvailable("first_password", true);
256 } 258 }
257 259
258 TEST_F(PasswordGenerationAgentTest, MaximumOfferSize) { 260 TEST_F(PasswordGenerationAgentTest, MaximumOfferSize) {
261 base::HistogramTester histogram_tester;
262
259 LoadHTML(kAccountCreationFormHTML); 263 LoadHTML(kAccountCreationFormHTML);
260 SetNotBlacklistedMessage(kAccountCreationFormHTML); 264 SetNotBlacklistedMessage(kAccountCreationFormHTML);
261 SetAccountCreationFormsDetectedMessage(kAccountCreationFormHTML); 265 SetAccountCreationFormsDetectedMessage(kAccountCreationFormHTML);
262 ExpectPasswordGenerationAvailable("first_password", true); 266 ExpectPasswordGenerationAvailable("first_password", true);
263 267
264 WebDocument document = GetMainFrame()->document(); 268 WebDocument document = GetMainFrame()->document();
265 WebElement element = 269 WebElement element =
266 document.getElementById(WebString::fromUTF8("first_password")); 270 document.getElementById(WebString::fromUTF8("first_password"));
267 ASSERT_FALSE(element.isNull()); 271 ASSERT_FALSE(element.isNull());
268 WebInputElement first_password_element = element.to<WebInputElement>(); 272 WebInputElement first_password_element = element.to<WebInputElement>();
(...skipping 52 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 histogram_tester.ExpectBucketCount(
341 "PasswordGeneration.Event",
342 autofill::password_generation::GENERATION_POPUP_SHOWN,
343 1);
331 } 344 }
332 345
333 } // namespace autofill 346 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | components/autofill/content/renderer/password_generation_agent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698