| 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 package org.chromium.chrome.browser.autofill; | 5 package org.chromium.chrome.browser.autofill; |
| 6 | 6 |
| 7 import android.test.suitebuilder.annotation.MediumTest; | 7 import android.test.suitebuilder.annotation.MediumTest; |
| 8 import android.text.TextUtils; | 8 import android.text.TextUtils; |
| 9 import android.view.View; | 9 import android.view.View; |
| 10 import android.view.ViewGroup; | 10 import android.view.ViewGroup; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 private static final String DEPENDENT_LOCALITY = ""; | 44 private static final String DEPENDENT_LOCALITY = ""; |
| 45 private static final String STATE = "CA"; | 45 private static final String STATE = "CA"; |
| 46 private static final String ZIP_CODE = "94102"; | 46 private static final String ZIP_CODE = "94102"; |
| 47 private static final String SORTING_CODE = ""; | 47 private static final String SORTING_CODE = ""; |
| 48 private static final String COUNTRY = "US"; | 48 private static final String COUNTRY = "US"; |
| 49 private static final String PHONE_NUMBER = "4158889999"; | 49 private static final String PHONE_NUMBER = "4158889999"; |
| 50 private static final String EMAIL = "john@acme.inc"; | 50 private static final String EMAIL = "john@acme.inc"; |
| 51 private static final String LANGUAGE_CODE = ""; | 51 private static final String LANGUAGE_CODE = ""; |
| 52 private static final String ORIGIN = "https://www.example.com"; | 52 private static final String ORIGIN = "https://www.example.com"; |
| 53 | 53 |
| 54 private static final String BASIC_PAGE_DATA = UrlUtils.encodeHtmlDataUri( | 54 private static final String BASIC_PAGE_DATA = UrlUtils.encodeHtmlDataUri("<h
tml><head>" |
| 55 "<html><head><meta name=\"viewport\"" + | 55 + "<meta name=\"viewport\"" |
| 56 "content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0\
" /></head>" + | 56 + "content=\"width=device-width, initial-scale=1.0, maximum-scale=1.
0\" /></head>" |
| 57 "<body><form method=\"POST\">" + | 57 + "<body><form method=\"POST\">" |
| 58 "<input type=\"text\" id=\"fn\" autocomplete=\"given-name\" /><br>"
+ | 58 + "<input type=\"text\" id=\"fn\" autocomplete=\"given-name\" /><br>
" |
| 59 "<input type=\"text\" id=\"ln\" autocomplete=\"family-name\" /><br>"
+ | 59 + "<input type=\"text\" id=\"ln\" autocomplete=\"family-name\" /><br
>" |
| 60 "<textarea id=\"sa\" autocomplete=\"street-address\"></textarea><br>
" + | 60 + "<textarea id=\"sa\" autocomplete=\"street-address\"></textarea><b
r>" |
| 61 "<input type=\"text\" id=\"a1\" autocomplete=\"address-line1\" /><br
>" + | 61 + "<input type=\"text\" id=\"a1\" autocomplete=\"address-line1\" /><
br>" |
| 62 "<input type=\"text\" id=\"a2\" autocomplete=\"address-line2\" /><br
>" + | 62 + "<input type=\"text\" id=\"a2\" autocomplete=\"address-line2\" /><
br>" |
| 63 "<input type=\"text\" id=\"ct\" autocomplete=\"locality\" /><br>" + | 63 + "<input type=\"text\" id=\"ct\" autocomplete=\"locality\" /><br>" |
| 64 "<input type=\"text\" id=\"zc\" autocomplete=\"postal-code\" /><br>"
+ | 64 + "<input type=\"text\" id=\"zc\" autocomplete=\"postal-code\" /><br
>" |
| 65 "<input type=\"text\" id=\"em\" autocomplete=\"email\" /><br>" + | 65 + "<input type=\"text\" id=\"em\" autocomplete=\"email\" /><br>" |
| 66 "<input type=\"text\" id=\"ph\" autocomplete=\"tel\" /><br>" + | 66 + "<input type=\"text\" id=\"ph\" autocomplete=\"tel\" /><br>" |
| 67 "<input type=\"text\" id=\"fx\" autocomplete=\"fax\" /><br>" + | 67 + "<input type=\"text\" id=\"fx\" autocomplete=\"fax\" /><br>" |
| 68 "<select id=\"co\" autocomplete=\"country\"><br>" + | 68 + "<select id=\"co\" autocomplete=\"country\"><br>" |
| 69 "<option value=\"BR\">Brazil</option>" + | 69 + "<option value=\"BR\">Brazil</option>" |
| 70 "<option value=\"US\">United States</option>" + | 70 + "<option value=\"US\">United States</option>" |
| 71 "</select>" + | 71 + "</select>" |
| 72 "<input type=\"submit\" />" + | 72 + "<input type=\"submit\" />" |
| 73 "</form></body></html>"); | 73 + "</form></body></html>"); |
| 74 | 74 |
| 75 private static final String INITIATING_ELEMENT_FILLED = UrlUtils.encodeHtmlD
ataUri( | 75 private static final String INITIATING_ELEMENT_FILLED = UrlUtils.encodeHtmlD
ataUri("<html>" |
| 76 "<html><head><meta name=\"viewport\"" + | 76 + "<head><meta name=\"viewport\"" |
| 77 "content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0\
" /></head>" + | 77 + "content=\"width=device-width, initial-scale=1.0, maximum-scale=1.
0\" /></head>" |
| 78 "<body><form method=\"POST\">" + | 78 + "<body><form method=\"POST\">" |
| 79 "<input type=\"text\" id=\"fn\" autocomplete=\"given-name\" value=\"
J\"><br>" + | 79 + "<input type=\"text\" id=\"fn\" autocomplete=\"given-name\" value=
\"J\"><br>" |
| 80 "<input type=\"text\" id=\"ln\" autocomplete=\"family-name\"><br>" + | 80 + "<input type=\"text\" id=\"ln\" autocomplete=\"family-name\"><br>" |
| 81 "<input type=\"text\" id=\"em\" autocomplete=\"email\"><br>" + | 81 + "<input type=\"text\" id=\"em\" autocomplete=\"email\"><br>" |
| 82 "<select id=\"co\" autocomplete=\"country\"><br>" + | 82 + "<select id=\"co\" autocomplete=\"country\"><br>" |
| 83 "<option value=\"US\">United States</option>" + | 83 + "<option value=\"US\">United States</option>" |
| 84 "<option value=\"BR\">Brazil</option>" + | 84 + "<option value=\"BR\">Brazil</option>" |
| 85 "</select>" + | 85 + "</select>" |
| 86 "<input type=\"submit\" />" + | 86 + "<input type=\"submit\" />" |
| 87 "</form></body></html>"); | 87 + "</form></body></html>"); |
| 88 | 88 |
| 89 private static final String ANOTHER_ELEMENT_FILLED = UrlUtils.encodeHtmlData
Uri( | 89 private static final String ANOTHER_ELEMENT_FILLED = UrlUtils.encodeHtmlData
Uri("<html><head>" |
| 90 "<html><head><meta name=\"viewport\"" + | 90 + "<meta name=\"viewport\"" |
| 91 "content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0\
" /></head>" + | 91 + "content=\"width=device-width, initial-scale=1.0, maximum-scale=1.
0\" /></head>" |
| 92 "<body><form method=\"POST\">" + | 92 + "<body><form method=\"POST\">" |
| 93 "<input type=\"text\" id=\"fn\" autocomplete=\"given-name\"><br>" + | 93 + "<input type=\"text\" id=\"fn\" autocomplete=\"given-name\"><br>" |
| 94 "<input type=\"text\" id=\"ln\" autocomplete=\"family-name\"><br>" + | 94 + "<input type=\"text\" id=\"ln\" autocomplete=\"family-name\"><br>" |
| 95 "<input type=\"text\" id=\"em\" autocomplete=\"email\" value=\"foo@e
xample.com\"><br>" + | 95 + "<input type=\"text\" id=\"em\" autocomplete=\"email\" value=\"foo
@example.com\"><br>" |
| 96 "<select id=\"co\" autocomplete=\"country\"><br>" + | 96 + "<select id=\"co\" autocomplete=\"country\"><br>" |
| 97 "<option></option>" + | 97 + "<option></option>" |
| 98 "<option value=\"BR\">Brazil</option>" + | 98 + "<option value=\"BR\">Brazil</option>" |
| 99 "<option value=\"US\">United States</option>" + | 99 + "<option value=\"US\">United States</option>" |
| 100 "</select>" + | 100 + "</select>" |
| 101 "<input type=\"submit\" />" + | 101 + "<input type=\"submit\" />" |
| 102 "</form></body></html>"); | 102 + "</form></body></html>"); |
| 103 | 103 |
| 104 private static final String INVALID_OPTION = UrlUtils.encodeHtmlDataUri( | 104 private static final String INVALID_OPTION = UrlUtils.encodeHtmlDataUri("<ht
ml><head>" |
| 105 "<html><head><meta name=\"viewport\"" + | 105 + "<meta name=\"viewport\"" |
| 106 "content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0\
" /></head>" + | 106 + "content=\"width=device-width, initial-scale=1.0, maximum-scale=1.
0\" /></head>" |
| 107 "<body><form method=\"POST\">" + | 107 + "<body><form method=\"POST\">" |
| 108 "<input type=\"text\" id=\"fn\" autocomplete=\"given-name\" value=\"
J\"><br>" + | 108 + "<input type=\"text\" id=\"fn\" autocomplete=\"given-name\" value=
\"J\"><br>" |
| 109 "<input type=\"text\" id=\"ln\" autocomplete=\"family-name\"><br>" + | 109 + "<input type=\"text\" id=\"ln\" autocomplete=\"family-name\"><br>" |
| 110 "<input type=\"text\" id=\"em\" autocomplete=\"email\"><br>" + | 110 + "<input type=\"text\" id=\"em\" autocomplete=\"email\"><br>" |
| 111 "<select id=\"co\" autocomplete=\"country\"><br>" + | 111 + "<select id=\"co\" autocomplete=\"country\"><br>" |
| 112 "<option value=\"GB\">Great Britain</option>" + | 112 + "<option value=\"GB\">Great Britain</option>" |
| 113 "<option value=\"BR\">Brazil</option>" + | 113 + "<option value=\"BR\">Brazil</option>" |
| 114 "</select>" + | 114 + "</select>" |
| 115 "<input type=\"submit\" />" + | 115 + "<input type=\"submit\" />" |
| 116 "</form></body></html>"); | 116 + "</form></body></html>"); |
| 117 | 117 |
| 118 private AutofillTestHelper mHelper; | 118 private AutofillTestHelper mHelper; |
| 119 private List<AutofillLogger.LogEntry> mAutofillLoggedEntries; | 119 private List<AutofillLogger.LogEntry> mAutofillLoggedEntries; |
| 120 | 120 |
| 121 @Override | 121 @Override |
| 122 public void setUp() throws Exception { | 122 public void setUp() throws Exception { |
| 123 super.setUp(); | 123 super.setUp(); |
| 124 clearAppData(); | 124 clearAppData(); |
| 125 mAutofillLoggedEntries = new ArrayList<AutofillLogger.LogEntry>(); | 125 mAutofillLoggedEntries = new ArrayList<AutofillLogger.LogEntry>(); |
| 126 AutofillLogger.setLogger( | 126 AutofillLogger.setLogger( |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 } catch (TimeoutException e) { | 337 } catch (TimeoutException e) { |
| 338 return false; | 338 return false; |
| 339 } | 339 } |
| 340 | 340 |
| 341 } | 341 } |
| 342 })); | 342 })); |
| 343 } | 343 } |
| 344 | 344 |
| 345 private void assertLogged(String autofilledValue, String profileFullName) { | 345 private void assertLogged(String autofilledValue, String profileFullName) { |
| 346 for (AutofillLogger.LogEntry entry : mAutofillLoggedEntries) { | 346 for (AutofillLogger.LogEntry entry : mAutofillLoggedEntries) { |
| 347 if (entry.getAutofilledValue().equals(autofilledValue) && | 347 if (entry.getAutofilledValue().equals(autofilledValue) |
| 348 entry.getProfileFullName().equals(profileFullName)) { | 348 && entry.getProfileFullName().equals(profileFullName)) { |
| 349 return; | 349 return; |
| 350 } | 350 } |
| 351 } | 351 } |
| 352 fail("Logged entry not found [" + autofilledValue + "," + profileFullNam
e + "]"); | 352 fail("Logged entry not found [" + autofilledValue + "," + profileFullNam
e + "]"); |
| 353 } | 353 } |
| 354 } | 354 } |
| OLD | NEW |