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() { | |
Raymond Toy
2017/04/06 23:13:14
ownProperty or beOwnPropertyOf (as mentioned in th
hongchan
2017/04/07 15:55:36
I think this is cleaner. Let me know if you think
Raymond Toy
2017/04/07 16:10:58
Maybe
should(obj).haveOwnProperty(property)
? b
hongchan
2017/04/07 17:22:16
I llke haveOwnProperty().
| |
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 an object is inherited from a class. This looks up the entire | |
991 * prototype chain of a given object and tries to find a match. | |
992 * | |
993 * @example | |
994 * should(sourceNode, 'A buffer source node') | |
995 * .inheritFrom('AudioScheduledSourceNode'); | |
996 * | |
997 * @result | |
998 * "PASS A buffer source node inherits from 'AudioScheduledSourceNode'." | |
999 */ | |
1000 inheritFrom() { | |
1001 this._processArguments(arguments); | |
1002 | |
1003 let prototypes = []; | |
1004 let currentPrototype = Object.getPrototypeOf(this._actual); | |
1005 while (currentPrototype) { | |
1006 prototypes.push(currentPrototype.constructor.name); | |
1007 currentPrototype = Object.getPrototypeOf(currentPrototype); | |
1008 } | |
1009 | |
1010 return this._assert( | |
1011 prototypes.includes(this._expected), | |
1012 '${actual} inherits from "${expected}".', | |
1013 '${actual} does not inherit from "${expected}".'); | |
1014 } | |
967 } | 1015 } |
968 | 1016 |
969 | 1017 |
970 // Task Class state enum. | 1018 // Task Class state enum. |
971 const TaskState = { | 1019 const TaskState = { |
972 PENDING: 0, | 1020 PENDING: 0, |
973 STARTED: 1, | 1021 STARTED: 1, |
974 FINISHED: 2 | 1022 FINISHED: 2 |
975 }; | 1023 }; |
976 | 1024 |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1269 | 1317 |
1270 /** | 1318 /** |
1271 * Load file from a given URL and pass ArrayBuffer to the following promise. | 1319 * Load file from a given URL and pass ArrayBuffer to the following promise. |
1272 * See |loadFileFromUrl| method for the detail. | 1320 * See |loadFileFromUrl| method for the detail. |
1273 */ | 1321 */ |
1274 loadFileFromUrl: loadFileFromUrl | 1322 loadFileFromUrl: loadFileFromUrl |
1275 | 1323 |
1276 }; | 1324 }; |
1277 | 1325 |
1278 })(); | 1326 })(); |
OLD | NEW |