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

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

Issue 10787023: Adding UMA stats. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the test. Created 8 years, 5 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 #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/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/ui/password_generation_status.h"
10 #include "chrome/common/autofill_messages.h" 11 #include "chrome/common/autofill_messages.h"
11 #include "chrome/renderer/autofill/password_generation_manager.h" 12 #include "chrome/renderer/autofill/password_generation_manager.h"
12 #include "chrome/test/base/chrome_render_view_test.h" 13 #include "chrome/test/base/chrome_render_view_test.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
17 18
18 using WebKit::WebDocument; 19 using WebKit::WebDocument;
19 using WebKit::WebElement; 20 using WebKit::WebElement;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 ASSERT_FALSE(element.isNull()); 196 ASSERT_FALSE(element.isNull());
196 WebInputElement first_password_element = element.to<WebInputElement>(); 197 WebInputElement first_password_element = element.to<WebInputElement>();
197 element = document.getElementById(WebString::fromUTF8("second_password")); 198 element = document.getElementById(WebString::fromUTF8("second_password"));
198 ASSERT_FALSE(element.isNull()); 199 ASSERT_FALSE(element.isNull());
199 WebInputElement second_password_element = element.to<WebInputElement>(); 200 WebInputElement second_password_element = element.to<WebInputElement>();
200 201
201 // Both password fields should be empty. 202 // Both password fields should be empty.
202 EXPECT_TRUE(first_password_element.value().isNull()); 203 EXPECT_TRUE(first_password_element.value().isNull());
203 EXPECT_TRUE(second_password_element.value().isNull()); 204 EXPECT_TRUE(second_password_element.value().isNull());
204 205
205 string16 password = ASCIIToUTF16("random_password"); 206 password_generation::PasswordGenerationStatus status;
206 AutofillMsg_GeneratedPasswordAccepted msg(0, password); 207 status.generated_password = "random_password";
208 status.password_accepted = true;
209 AutofillMsg_PasswordGenerationBubbleClosed msg(0, status);
207 generation_manager_->OnMessageReceived(msg); 210 generation_manager_->OnMessageReceived(msg);
208 211
209 // Password fields are filled out and set as being autofilled. 212 // Password fields are filled out and set as being autofilled.
210 EXPECT_EQ(password, first_password_element.value()); 213 EXPECT_EQ(ASCIIToUTF16(status.generated_password),
211 EXPECT_EQ(password, second_password_element.value()); 214 first_password_element.value());
215 EXPECT_EQ(ASCIIToUTF16(status.generated_password),
216 second_password_element.value());
212 EXPECT_TRUE(first_password_element.isAutofilled()); 217 EXPECT_TRUE(first_password_element.isAutofilled());
213 EXPECT_TRUE(second_password_element.isAutofilled()); 218 EXPECT_TRUE(second_password_element.isAutofilled());
214 219
215 // Focus moved to the next input field. 220 // Focus moved to the next input field.
216 // TODO(zysxqn): Change this back to the address element once Bug 90224 221 // TODO(zysxqn): Change this back to the address element once Bug 90224
217 // https://bugs.webkit.org/show_bug.cgi?id=90224 has been fixed. 222 // https://bugs.webkit.org/show_bug.cgi?id=90224 has been fixed.
218 element = document.getElementById(WebString::fromUTF8("first_password")); 223 element = document.getElementById(WebString::fromUTF8("first_password"));
219 ASSERT_FALSE(element.isNull()); 224 ASSERT_FALSE(element.isNull());
220 EXPECT_EQ(element, document.focusedNode()); 225 EXPECT_EQ(element, document.focusedNode());
221 } 226 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 ASSERT_FALSE(element.isNull()); 274 ASSERT_FALSE(element.isNull());
270 first_password_element = element.to<WebInputElement>(); 275 first_password_element = element.to<WebInputElement>();
271 EXPECT_TRUE(DecorationIsVisible(&first_password_element)); 276 EXPECT_TRUE(DecorationIsVisible(&first_password_element));
272 SimulateClickOnDecoration(&first_password_element); 277 SimulateClickOnDecoration(&first_password_element);
273 EXPECT_EQ(2u, generation_manager_->messages().size()); 278 EXPECT_EQ(2u, generation_manager_->messages().size());
274 EXPECT_EQ(AutofillHostMsg_ShowPasswordGenerationPopup::ID, 279 EXPECT_EQ(AutofillHostMsg_ShowPasswordGenerationPopup::ID,
275 generation_manager_->messages()[1]->type()); 280 generation_manager_->messages()[1]->type());
276 } 281 }
277 282
278 } // namespace autofill 283 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698