OLD | NEW |
---|---|
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" | |
8 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/test/base/chrome_render_view_test.h" | 11 #include "chrome/test/base/chrome_render_view_test.h" |
10 #include "components/autofill/content/common/autofill_messages.h" | 12 #include "components/autofill/content/common/autofill_messages.h" |
11 #include "components/autofill/content/renderer/autofill_agent.h" | 13 #include "components/autofill/content/renderer/autofill_agent.h" |
12 #include "components/autofill/content/renderer/test_password_generation_agent.h" | 14 #include "components/autofill/content/renderer/test_password_generation_agent.h" |
13 #include "components/autofill/core/common/form_data.h" | 15 #include "components/autofill/core/common/form_data.h" |
16 #include "components/autofill/core/common/password_generation_util.h" | |
14 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "third_party/WebKit/public/platform/WebString.h" | 18 #include "third_party/WebKit/public/platform/WebString.h" |
16 #include "third_party/WebKit/public/web/WebDocument.h" | 19 #include "third_party/WebKit/public/web/WebDocument.h" |
17 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 20 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
18 #include "third_party/WebKit/public/web/WebWidget.h" | 21 #include "third_party/WebKit/public/web/WebWidget.h" |
19 | 22 |
20 using blink::WebDocument; | 23 using blink::WebDocument; |
21 using blink::WebElement; | 24 using blink::WebElement; |
22 using blink::WebInputElement; | 25 using blink::WebInputElement; |
23 using blink::WebNode; | 26 using blink::WebNode; |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 ExecuteJavaScript("document.getElementById('username').focus();"); | 324 ExecuteJavaScript("document.getElementById('username').focus();"); |
322 EXPECT_EQ(0u, password_generation_->messages().size()); | 325 EXPECT_EQ(0u, password_generation_->messages().size()); |
323 password_generation_->clear_messages(); | 326 password_generation_->clear_messages(); |
324 | 327 |
325 // Focusing the password field will bring up the generation UI again. | 328 // Focusing the password field will bring up the generation UI again. |
326 ExecuteJavaScript("document.getElementById('first_password').focus();"); | 329 ExecuteJavaScript("document.getElementById('first_password').focus();"); |
327 EXPECT_EQ(1u, password_generation_->messages().size()); | 330 EXPECT_EQ(1u, password_generation_->messages().size()); |
328 EXPECT_EQ(AutofillHostMsg_ShowPasswordGenerationPopup::ID, | 331 EXPECT_EQ(AutofillHostMsg_ShowPasswordGenerationPopup::ID, |
329 password_generation_->messages()[0]->type()); | 332 password_generation_->messages()[0]->type()); |
330 password_generation_->clear_messages(); | 333 password_generation_->clear_messages(); |
334 | |
335 // Loading a different page triggers UMA stat upload. Verify that only one | |
336 // display event is sent even though | |
337 LoadHTML(kSigninFormHTML); | |
338 | |
339 base::HistogramBase* event_histogram = | |
340 base::StatisticsRecorder::FindHistogram( | |
341 "PasswordGeneration.Event"); | |
342 ASSERT_TRUE(event_histogram); | |
343 scoped_ptr<base::HistogramSamples> snapshot = | |
344 event_histogram->SnapshotSamples(); | |
345 EXPECT_EQ(1, snapshot->GetCount( | |
346 autofill::password_generation::GENERATION_POPUP_SHOWN)); | |
Ilya Sherman
2014/10/09 22:03:58
Please use base/test/histogram_tester.h for this.
Garrett Casto
2014/10/14 18:40:05
Neat, didn't know about that. Updated.
| |
331 } | 347 } |
332 | 348 |
333 } // namespace autofill | 349 } // namespace autofill |
OLD | NEW |