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 /** | |
55 * Creates a fake address entry for testing. | 47 * Creates a fake address entry for testing. |
56 * @return {!chrome.autofillPrivate.AddressEntry} | 48 * @return {!chrome.autofillPrivate.AddressEntry} |
57 */ | 49 */ |
58 FakeDataMaker.addressEntry = function() { | 50 FakeDataMaker.addressEntry = function() { |
59 var ret = {}; | 51 var ret = {}; |
60 ret.guid = FakeDataMaker.makeGuid_(); | 52 ret.guid = FakeDataMaker.makeGuid_(); |
61 ret.fullNames = ['John Doe']; | 53 ret.fullNames = ['John', 'Doe']; |
62 ret.companyName = 'Google'; | 54 ret.companyName = 'Google'; |
63 ret.addressLines = FakeDataMaker.patternMaker_('xxxx Main St', 10); | 55 ret.addressLines = FakeDataMaker.patternMaker_('xxxx Main St', 10); |
64 ret.addressLevel1 = 'CA'; | 56 ret.addressLevel1 = "CA"; |
65 ret.addressLevel2 = 'Venice'; | 57 ret.addressLevel2 = "Venice"; |
66 ret.postalCode = FakeDataMaker.patternMaker_('xxxxx', 10); | 58 ret.postalCode = FakeDataMaker.patternMaker_('xxxxx', 10); |
67 ret.countryCode = 'US'; | 59 ret.countryCode = 'US'; |
68 ret.phoneNumbers = [FakeDataMaker.patternMaker_('(xxx) xxx-xxxx', 10)]; | 60 ret.phoneNumbers = [FakeDataMaker.patternMaker_('(xxx) xxx-xxxx', 10)]; |
69 ret.emailAddresses = [FakeDataMaker.patternMaker_('userxxxx@gmail.com', 16)]; | 61 ret.emailAddresses = [FakeDataMaker.patternMaker_('userxxxx@gmail.com', 16)]; |
70 ret.languageCode = 'EN-US'; | 62 ret.languageCode = 'EN-US'; |
71 ret.metadata = {isLocal: true}; | 63 ret.metadata = {isLocal: true}; |
72 ret.metadata.summaryLabel = ret.fullNames[0]; | 64 ret.metadata.summaryLabel = ret.fullNames[0]; |
73 ret.metadata.summarySublabel = ' ' + ret.addressLines; | 65 ret.metadata.summarySublabel = ' ' + ret.addressLines; |
74 return ret; | 66 return ret; |
75 }; | 67 }; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 * @param {string} pattern The pattern that should be used as an input. | 112 * @param {string} pattern The pattern that should be used as an input. |
121 * @param {number} base The number base. ie: 16 for hex or 10 for decimal. | 113 * @param {number} base The number base. ie: 16 for hex or 10 for decimal. |
122 * @return {string} | 114 * @return {string} |
123 * @private | 115 * @private |
124 */ | 116 */ |
125 FakeDataMaker.patternMaker_ = function(pattern, base) { | 117 FakeDataMaker.patternMaker_ = function(pattern, base) { |
126 return pattern.replace(/x/g, function() { | 118 return pattern.replace(/x/g, function() { |
127 return Math.floor(Math.random() * base).toString(base); | 119 return Math.floor(Math.random() * base).toString(base); |
128 }); | 120 }); |
129 }; | 121 }; |
OLD | NEW |