OLD | NEW |
1 var TestUtils = (function() { | 1 var TestUtils = (function() { |
2 function randomString() { | 2 function randomString() { |
3 var result = ""; | 3 var result = ""; |
4 for (var i = 0; i < 5; i++) | 4 for (var i = 0; i < 5; i++) |
5 result += String.fromCharCode(97 + Math.floor(Math.random() * 26)); | 5 result += String.fromCharCode(97 + Math.floor(Math.random() * 26)); |
6 return result; | 6 return result; |
7 }; | 7 }; |
8 | 8 |
9 /** | 9 /** |
10 * Representation of one datatype. | 10 * Representation of one datatype. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 if (mask & (1 << datatype)) | 68 if (mask & (1 << datatype)) |
69 combination.push(TestUtils.DATATYPES[datatype]); | 69 combination.push(TestUtils.DATATYPES[datatype]); |
70 } | 70 } |
71 | 71 |
72 combinations.push(combination); | 72 combinations.push(combination); |
73 } | 73 } |
74 return combinations; | 74 return combinations; |
75 })(); | 75 })(); |
76 | 76 |
77 /** | 77 /** |
| 78 * Ensures that all datatypes are nonempty. Should be called in the test |
| 79 * setup phase. |
| 80 */ |
| 81 TestUtils.populateDatatypes = function() { |
| 82 return Promise.all(TestUtils.DATATYPES.map(function(datatype) { |
| 83 return new Promise(function(resolve, reject) { |
| 84 datatype.add().then(function() { |
| 85 datatype.isEmpty().then(function(isEmpty) { |
| 86 assert_false( |
| 87 isEmpty, |
| 88 datatype.name + |
| 89 " has to be nonempty before the test starts."); |
| 90 resolve(); |
| 91 }); |
| 92 }); |
| 93 }); |
| 94 })); |
| 95 }; |
| 96 |
| 97 /** |
78 * Get the support server URL that returns a Clear-Site-Data header | 98 * Get the support server URL that returns a Clear-Site-Data header |
79 * to clear |datatypes|. | 99 * to clear |datatypes|. |
80 * @param{Array.<Datatype>} datatypes The list of datatypes to be deleted. | 100 * @param{Array.<Datatype>} datatypes The list of datatypes to be deleted. |
81 * @return string The URL to be queried. | 101 * @return string The URL to be queried. |
82 */ | 102 */ |
83 TestUtils.getClearSiteDataUrl = function(datatypes) { | 103 TestUtils.getClearSiteDataUrl = function(datatypes) { |
84 names = datatypes.map(function(e) { return e.name }); | 104 names = datatypes.map(function(e) { return e.name }); |
85 return "support/echo-clear-site-data.py?" + names.join("&"); | 105 return "support/echo-clear-site-data.py?" + names.join("&"); |
86 } | 106 } |
87 | 107 |
88 return TestUtils; | 108 return TestUtils; |
89 })(); | 109 })(); |
OLD | NEW |