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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/resources/context-properties.js

Issue 2779103002: Convert context property tests to new Audit. (Closed)
Patch Set: Address review comments Created 3 years, 8 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
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/offlineaudiocontext-properties.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // The list of the 'own' properties in various AudioContexts. These lists were 1 // The list of the 'own' properties in various AudioContexts. These lists were
2 // populated by running: 2 // populated by running:
3 // 3 //
4 // Object.getOwnPropertyNames(FooAudioContext.prototype); 4 // Object.getOwnPropertyNames(FooAudioContext.prototype);
5 // 5 //
6 // https://webaudio.github.io/web-audio-api/#BaseAudioContext 6 // https://webaudio.github.io/web-audio-api/#BaseAudioContext
7 7
8 8
9 let BaseAudioContextOwnProperties = [ 9 let BaseAudioContextOwnProperties = [
10 'constructor', 10 'constructor',
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 /** 66 /**
67 * Verify properties in the prototype with the pre-populated list. This is a 67 * Verify properties in the prototype with the pre-populated list. This is a
68 * 2-way comparison to detect the missing and the unexpected property at the 68 * 2-way comparison to detect the missing and the unexpected property at the
69 * same time. 69 * same time.
70 * @param {Object} targetPrototype Target prototype. 70 * @param {Object} targetPrototype Target prototype.
71 * @param {Array} populatedList Property dictionary. 71 * @param {Array} populatedList Property dictionary.
72 * @param {Function} should |Should| assertion function. 72 * @param {Function} should |Should| assertion function.
73 * @return {Map} Verification result map. 73 * @return {Map} Verification result map.
74 */ 74 */
75 function verifyPrototypeOwnProperties (targetPrototype, populatedList, should) { 75 function verifyPrototypeOwnProperties(targetPrototype, populatedList, should) {
76 let propertyMap = new Map(); 76 let propertyMap = new Map();
77 let generatedList = Object.getOwnPropertyNames(targetPrototype); 77 let generatedList = Object.getOwnPropertyNames(targetPrototype);
78 78
79 for (let index in populatedList) { 79 for (let index in populatedList) {
80 propertyMap.set(populatedList[index], { 80 propertyMap.set(populatedList[index], {actual: false, expected: true});
81 actual: false,
82 expected: true
83 });
84 } 81 }
85 82
86 for (let index in generatedList) { 83 for (let index in generatedList) {
87 if (propertyMap.has(generatedList[index])) { 84 if (propertyMap.has(generatedList[index])) {
88 propertyMap.get(generatedList[index]).actual = true; 85 propertyMap.get(generatedList[index]).actual = true;
89 } else { 86 } else {
90 propertyMap.set(generatedList[index], { 87 propertyMap.set(generatedList[index], {actual: true, expected: false});
91 actual: true,
92 expected: false
93 });
94 } 88 }
95 } 89 }
96 90
97 // TODO(hongchan): replace the Should assertion when the new test infra lands.
98 for (let [property, result] of propertyMap) { 91 for (let [property, result] of propertyMap) {
92 let prefix = 'The property "' + property + '"';
99 if (result.expected && result.actual) { 93 if (result.expected && result.actual) {
100 // The test meets the expectation. 94 // The test meets the expectation.
101 should('The property "' + property + '"') 95 should(true, prefix).message('was expected and found successfully', '');
102 ._testPassed('was expected and found successfully', false);
103 } else if (result.expected && !result.actual) { 96 } else if (result.expected && !result.actual) {
104 // The expected property is missing. 97 // The expected property is missing.
105 should('The property "' + property + '" was expected but not found.') 98 should(false, prefix).message('', 'was expected but not found.');
106 ._testFailed('', false);
107 } else if (!result.expected && result.actual) { 99 } else if (!result.expected && result.actual) {
108 // Something unexpected was found. 100 // Something unexpected was found.
109 should('The property "' + property + '" was not expected but found.') 101 should(false, prefix).message('', 'was not expected but found.');
110 ._testFailed('', false);
111 } 102 }
112 } 103 }
113 } 104 }
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/offlineaudiocontext-properties.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698