OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 /** | 5 /** |
6 * Used to create fake data for both passwords and autofill. | 6 * Used to create fake data for both passwords and autofill. |
7 * These sections are related, so it made sense to share this. | 7 * These sections are related, so it made sense to share this. |
8 */ | 8 */ |
9 function FakeDataMaker() {} | 9 function FakeDataMaker() {} |
10 /** | 10 /** |
(...skipping 26 matching lines...) Expand all Loading... |
37 */ | 37 */ |
38 FakeDataMaker.exceptionEntry = function(url) { | 38 FakeDataMaker.exceptionEntry = function(url) { |
39 url = url || FakeDataMaker.patternMaker_('www.xxxxxx.com', 16); | 39 url = url || FakeDataMaker.patternMaker_('www.xxxxxx.com', 16); |
40 return { | 40 return { |
41 exceptionUrl: url, | 41 exceptionUrl: url, |
42 linkUrl: 'http://' + url + '/login', | 42 linkUrl: 'http://' + url + '/login', |
43 }; | 43 }; |
44 }; | 44 }; |
45 | 45 |
46 /** | 46 /** |
| 47 * Creates a new fake address entry for testing. |
| 48 * @return {!chrome.autofillPrivate.AddressEntry} |
| 49 */ |
| 50 FakeDataMaker.emptyAddressEntry = function() { |
| 51 return {}; |
| 52 } |
| 53 |
| 54 /** |
47 * Creates a fake address entry for testing. | 55 * Creates a fake address entry for testing. |
48 * @return {!chrome.autofillPrivate.AddressEntry} | 56 * @return {!chrome.autofillPrivate.AddressEntry} |
49 */ | 57 */ |
50 FakeDataMaker.addressEntry = function() { | 58 FakeDataMaker.addressEntry = function() { |
51 var ret = {}; | 59 var ret = {}; |
52 ret.guid = FakeDataMaker.makeGuid_(); | 60 ret.guid = FakeDataMaker.makeGuid_(); |
53 ret.fullNames = ['John', 'Doe']; | 61 ret.fullNames = ['John Doe']; |
54 ret.companyName = 'Google'; | 62 ret.companyName = 'Google'; |
55 ret.addressLines = FakeDataMaker.patternMaker_('xxxx Main St', 10); | 63 ret.addressLines = FakeDataMaker.patternMaker_('xxxx Main St', 10); |
56 ret.addressLevel1 = "CA"; | 64 ret.addressLevel1 = 'CA'; |
57 ret.addressLevel2 = "Venice"; | 65 ret.addressLevel2 = 'Venice'; |
58 ret.postalCode = FakeDataMaker.patternMaker_('xxxxx', 10); | 66 ret.postalCode = FakeDataMaker.patternMaker_('xxxxx', 10); |
59 ret.countryCode = 'US'; | 67 ret.countryCode = 'US'; |
60 ret.phoneNumbers = [FakeDataMaker.patternMaker_('(xxx) xxx-xxxx', 10)]; | 68 ret.phoneNumbers = [FakeDataMaker.patternMaker_('(xxx) xxx-xxxx', 10)]; |
61 ret.emailAddresses = [FakeDataMaker.patternMaker_('userxxxx@gmail.com', 16)]; | 69 ret.emailAddresses = [FakeDataMaker.patternMaker_('userxxxx@gmail.com', 16)]; |
62 ret.languageCode = 'EN-US'; | 70 ret.languageCode = 'EN-US'; |
63 ret.metadata = {isLocal: true}; | 71 ret.metadata = {isLocal: true}; |
64 ret.metadata.summaryLabel = ret.fullNames[0]; | 72 ret.metadata.summaryLabel = ret.fullNames[0]; |
65 ret.metadata.summarySublabel = ' ' + ret.addressLines; | 73 ret.metadata.summarySublabel = ' ' + ret.addressLines; |
66 return ret; | 74 return ret; |
67 }; | 75 }; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 * @param {string} pattern The pattern that should be used as an input. | 120 * @param {string} pattern The pattern that should be used as an input. |
113 * @param {number} base The number base. ie: 16 for hex or 10 for decimal. | 121 * @param {number} base The number base. ie: 16 for hex or 10 for decimal. |
114 * @return {string} | 122 * @return {string} |
115 * @private | 123 * @private |
116 */ | 124 */ |
117 FakeDataMaker.patternMaker_ = function(pattern, base) { | 125 FakeDataMaker.patternMaker_ = function(pattern, base) { |
118 return pattern.replace(/x/g, function() { | 126 return pattern.replace(/x/g, function() { |
119 return Math.floor(Math.random() * base).toString(base); | 127 return Math.floor(Math.random() * base).toString(base); |
120 }); | 128 }); |
121 }; | 129 }; |
OLD | NEW |