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 /** | 6 /** |
7 * @fileOverview WebAudio layout test utility library. Built around W3C's | 7 * @fileOverview WebAudio layout test utility library. Built around W3C's |
8 * testharness.js. Includes asynchronous test task manager, | 8 * testharness.js. Includes asynchronous test task manager, |
9 * assertion utilities. | 9 * assertion utilities. |
10 * @dependency testharness.js | 10 * @dependency testharness.js |
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
957 * should(true, 'The message is').message('truthful!', 'false!'); | 957 * should(true, 'The message is').message('truthful!', 'false!'); |
958 * | 958 * |
959 * @result | 959 * @result |
960 * "PASS The message is truthful!" | 960 * "PASS The message is truthful!" |
961 */ | 961 */ |
962 message(passDetail, failDetail) { | 962 message(passDetail, failDetail) { |
963 return this._assert(this._actual, | 963 return this._assert(this._actual, |
964 '${actual} ' + passDetail, | 964 '${actual} ' + passDetail, |
965 '${actual} ' + failDetail); | 965 '${actual} ' + failDetail); |
966 } | 966 } |
967 | |
968 /** | |
969 * Check if |expected| property is truly owned by |actual| object. | |
970 * | |
971 * @example | |
972 * should(BaseAudioContext.prototype, | |
973 * 'BaseAudioContext.prototype').ownProperty('createGain'); | |
974 * | |
975 * @result | |
976 * "PASS BaseAudioContext.prototype has an own property of | |
977 * 'createGain'." | |
978 */ | |
979 ownProperty () { | |
980 this._processArguments(arguments); | |
981 | |
982 return this._assert( | |
983 this._actual.hasOwnProperty(this._expected), | |
984 '${actual} has an own property of "${expected}".', | |
985 '${actual} does not own the property of "${expected}".'); | |
986 } | |
987 | |
988 | |
989 /** | |
990 * Check if |expected| property is not owned by |actual| object. | |
991 * | |
992 * @example | |
993 * should(BaseAudioContext.prototype, | |
994 * 'BaseAudioContext.prototype').notOwnProperty('startRendering'); | |
995 * | |
996 * @result | |
997 * "PASS BaseAudioContext.prototype does not have an own property of | |
998 * 'startRendering'." | |
999 */ | |
1000 notOwnProperty () { | |
1001 this._processArguments(arguments); | |
1002 | |
1003 return this._assert( | |
1004 !this._actual.hasOwnProperty(this._expected), | |
1005 '${actual} does not have an own own property of "${expected}".', | |
Raymond Toy
2017/04/07 16:10:58
"own own"?
hongchan
2017/04/07 17:22:17
Oops.
| |
1006 '${actual} has an own the property of "${expected}".') | |
1007 } | |
1008 | |
1009 | |
1010 /** | |
1011 * Check if an object is inherited from a class. This looks up the entire | |
1012 * prototype chain of a given object and tries to find a match. | |
1013 * | |
1014 * @example | |
1015 * should(sourceNode, 'A buffer source node') | |
1016 * .inheritFrom('AudioScheduledSourceNode'); | |
1017 * | |
1018 * @result | |
1019 * "PASS A buffer source node inherits from 'AudioScheduledSourceNode'." | |
1020 */ | |
1021 inheritFrom () { | |
1022 this._processArguments(arguments); | |
1023 | |
1024 let prototypes = []; | |
1025 let currentPrototype = Object.getPrototypeOf(this._actual); | |
1026 while (currentPrototype) { | |
1027 prototypes.push(currentPrototype.constructor.name); | |
1028 currentPrototype = Object.getPrototypeOf(currentPrototype); | |
1029 } | |
1030 | |
1031 return this._assert( | |
1032 prototypes.includes(this._expected), | |
1033 '${actual} inherits from "${expected}".', | |
1034 '${actual} does not inherit from "${expected}".'); | |
1035 } | |
967 } | 1036 } |
968 | 1037 |
969 | 1038 |
970 // Task Class state enum. | 1039 // Task Class state enum. |
971 const TaskState = { | 1040 const TaskState = { |
972 PENDING: 0, | 1041 PENDING: 0, |
973 STARTED: 1, | 1042 STARTED: 1, |
974 FINISHED: 2 | 1043 FINISHED: 2 |
975 }; | 1044 }; |
976 | 1045 |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1269 | 1338 |
1270 /** | 1339 /** |
1271 * Load file from a given URL and pass ArrayBuffer to the following promise. | 1340 * Load file from a given URL and pass ArrayBuffer to the following promise. |
1272 * See |loadFileFromUrl| method for the detail. | 1341 * See |loadFileFromUrl| method for the detail. |
1273 */ | 1342 */ |
1274 loadFileFromUrl: loadFileFromUrl | 1343 loadFileFromUrl: loadFileFromUrl |
1275 | 1344 |
1276 }; | 1345 }; |
1277 | 1346 |
1278 })(); | 1347 })(); |
OLD | NEW |