Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modernized the TESTING architecture of the codebase { GSOC} #541

Merged
merged 7 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
393 changes: 338 additions & 55 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"amdclean": "~2.0",
"babel-loader": "^8.0.6",
"babel-plugin-preval": "^3.0.1",
"chai": "3.4.1",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.3",
"grunt": "~0.4.5",
Expand All @@ -24,6 +25,7 @@
"grunt-mocha": "^1.0.4",
"grunt-open": "^0.2.3",
"grunt-webpack": "^3.1.3",
"mocha": "2.3.4",
"prettier": "2.0.5",
"raw-loader": "^3.0.0",
"tslint-config-prettier": "^1.18.0",
Expand All @@ -35,6 +37,7 @@
"dependencies": {
"audioworklet-polyfill": "^1.1.2",
"p5": "1.0.0",
"sinon": "^9.0.3",
"startaudiocontext": "^1.2.1",
"tone": "0.10.0"
},
Expand Down
12 changes: 8 additions & 4 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ p5.prototype.registerMethod('remove', p5.prototype.disposeSound);


import './errorHandler';
import './audioWorklet';

import { audioWorkletInitilized } from './audioWorklet';
p5.audioWorkletInitilized = audioWorkletInitilized;




import Panner from './panner';
p5.Panner = Panner;
Expand All @@ -58,6 +63,7 @@ p5.prototype.loadSound = loadSound;
p5.prototype.registerPreloadMethod('loadSound', p5.prototype);



import Amplitude from './amplitude';
p5.Amplitude = Amplitude;

Expand Down Expand Up @@ -111,6 +117,7 @@ p5.Delay = Delay;




import { Reverb, Convolver, createConvolver } from './reverb';
p5.Reverb = Reverb;
p5.Convolver = Convolver;
Expand All @@ -137,13 +144,10 @@ import Compressor from './compressor';
p5.Compressor = Compressor;



import peakDetect from './peakDetect';
p5.peakDetect = peakDetect;




import SoundRecorder from './soundRecorder';
p5.SoundRecorder = SoundRecorder;

Expand Down
7 changes: 5 additions & 2 deletions src/audioWorklet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ const moduleSources = [
];
const ac = p5sound.audiocontext;

let initializedAudioWorklets = false;
let ResolveOnWorkletLoaded;
endurance21 marked this conversation as resolved.
Show resolved Hide resolved
export let audioWorkletInitilized = new Promise((resolve, reject) => {
endurance21 marked this conversation as resolved.
Show resolved Hide resolved
ResolveOnWorkletLoaded = resolve;
});

function loadAudioWorkletModules() {
return Promise.all(
Expand All @@ -28,7 +31,7 @@ p5.prototype.registerMethod('init', function () {
// use p5's preload system to load necessary AudioWorklet modules before setup()
this._incrementPreload();
const onWorkletModulesLoad = function () {
initializedAudioWorklets = true;
endurance21 marked this conversation as resolved.
Show resolved Hide resolved
ResolveOnWorkletLoaded();
endurance21 marked this conversation as resolved.
Show resolved Hide resolved
this._decrementPreload();
}.bind(this);
loadAudioWorkletModules().then(onWorkletModulesLoad);
Expand Down
12 changes: 9 additions & 3 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@
window.setup = function setup() {};
new p5();
</script>
<script src="./testDeps/mocha.js"></script>
<script data-main="test.js" src="./testDeps/require.js"></script>
<link rel="stylesheet" href="./testDeps/mocha.css" />
<link rel="stylesheet" href="../node_modules/mocha/mocha.css">
<script src="../node_modules/mocha/mocha.js"></script>
<script src="../node_modules/chai/chai.js"></script>
<script src="../node_modules/sinon/pkg/sinon.js"></script>


</head>
<body>
<div id="mocha"></div>
<script>

mocha.setup('bdd')

</script>
<script src="./test.js" type="module"></script>
endurance21 marked this conversation as resolved.
Show resolved Hide resolved
</body>
</html>
49 changes: 21 additions & 28 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
require.config({
baseUrl: './',
paths: {
'lib': '../lib',
'chai': './testDeps/chai',
'sinon': './testDeps/sinon'
}
});

var allTests = [
'tests/p5.Master',
'tests/p5.SoundFile',
'tests/p5.Amplitude',
'tests/p5.Oscillator',
'tests/p5.Distortion',
'tests/p5.Effect',
'tests/p5.Filter',
'tests/p5.FFT',
'tests/p5.Compressor',
'tests/p5.EQ',
'tests/p5.AudioIn',
'tests/p5.AudioVoice',
'tests/p5.MonoSynth',
'tests/p5.PolySynth',
'tests/p5.SoundRecorder'
];

import './tests/p5.Master.js'
import './tests/p5.Distortion.js'
import './tests/p5.Effect.js'
import './tests/p5.Filter.js'
import './tests/p5.FFT.js'
import './tests/p5.Compressor.js'
import './tests/p5.EQ.js'
import './tests/p5.AudioIn.js'
import './tests/p5.AudioVoice.js'
import './tests/p5.MonoSynth.js'
import './tests/p5.PolySynth.js'
import './tests/p5.SoundRecorder.js'

//this is dynamic export , it will ensure all threee AudioWorklet Processor have been loaded brfore using them
p5.audioWorkletInitilized.then(()=>{
endurance21 marked this conversation as resolved.
Show resolved Hide resolved
import('./tests/p5.SoundFile.js')
import('./tests/p5.Amplitude.js')
import('./tests/p5.Oscillator.js')
})

p5.prototype.masterVolume(0);

var test_has_run = false;

require(allTests, function () {

document.getElementById('mocha').innerHTML = 'click to begin tests';

// chromes autoplay policy requires a user interaction
Expand All @@ -44,4 +38,3 @@ require(allTests, function () {
}

document.addEventListener('click', mousePressed, false);
});
Loading