diff --git a/mediapipe/tasks/web/audio/audio_classifier/audio_classifier_test.ts b/mediapipe/tasks/web/audio/audio_classifier/audio_classifier_test.ts index 2089f184f..b7bb158de 100644 --- a/mediapipe/tasks/web/audio/audio_classifier/audio_classifier_test.ts +++ b/mediapipe/tasks/web/audio/audio_classifier/audio_classifier_test.ts @@ -34,7 +34,8 @@ class AudioClassifierFake extends AudioClassifier implements attachListenerSpies: jasmine.Spy[] = []; graph: CalculatorGraphConfig|undefined; - private protoVectorListener: ((binaryProtos: Uint8Array[]) => void)|undefined; + private protoVectorListener: + ((binaryProtos: Uint8Array[], timestamp: number) => void)|undefined; private resultProtoVector: ClassificationResult[] = []; constructor() { @@ -59,8 +60,10 @@ class AudioClassifierFake extends AudioClassifier implements }); spyOn(this.graphRunner, 'finishProcessing').and.callFake(() => { if (!this.protoVectorListener) return; - this.protoVectorListener(this.resultProtoVector.map( - classificationResult => classificationResult.serializeBinary())); + this.protoVectorListener( + this.resultProtoVector.map( + classificationResult => classificationResult.serializeBinary()), + 1337); }); spyOn(this.graphRunner, 'setGraph').and.callFake(binaryGraph => { this.graph = CalculatorGraphConfig.deserializeBinary(binaryGraph); @@ -138,12 +141,12 @@ describe('AudioClassifier', () => { classifcations.setHeadIndex(1); classifcations.setHeadName('headName'); let classificationList = new ClassificationList(); - let clasification = new Classification(); - clasification.setIndex(1); - clasification.setScore(0.2); - clasification.setDisplayName('displayName'); - clasification.setLabel('categoryName'); - classificationList.addClassification(clasification); + let classification = new Classification(); + classification.setIndex(1); + classification.setScore(0.2); + classification.setDisplayName('displayName'); + classification.setLabel('categoryName'); + classificationList.addClassification(classification); classifcations.setClassificationList(classificationList); classificationResult.addClassifications(classifcations); resultProtoVector.push(classificationResult); @@ -152,10 +155,10 @@ describe('AudioClassifier', () => { classificationResult.setTimestampMs(1); classifcations = new Classifications(); classificationList = new ClassificationList(); - clasification = new Classification(); - clasification.setIndex(2); - clasification.setScore(0.3); - classificationList.addClassification(clasification); + classification = new Classification(); + classification.setIndex(2); + classification.setScore(0.3); + classificationList.addClassification(classification); classifcations.setClassificationList(classificationList); classificationResult.addClassifications(classifcations); resultProtoVector.push(classificationResult); @@ -191,8 +194,8 @@ describe('AudioClassifier', () => { const classificationResult = new ClassificationResult(); const classifcations = new Classifications(); const classificationList = new ClassificationList(); - const clasification = new Classification(); - classificationList.addClassification(clasification); + const classification = new Classification(); + classificationList.addClassification(classification); classifcations.setClassificationList(classificationList); classificationResult.addClassifications(classifcations); diff --git a/mediapipe/tasks/web/audio/audio_embedder/audio_embedder_test.ts b/mediapipe/tasks/web/audio/audio_embedder/audio_embedder_test.ts index dde61a6e9..a8a2b232b 100644 --- a/mediapipe/tasks/web/audio/audio_embedder/audio_embedder_test.ts +++ b/mediapipe/tasks/web/audio/audio_embedder/audio_embedder_test.ts @@ -34,8 +34,10 @@ class AudioEmbedderFake extends AudioEmbedder implements MediapipeTasksFake { attachListenerSpies: jasmine.Spy[] = []; fakeWasmModule: SpyWasmModule; - protoListener: ((binaryProto: Uint8Array) => void)|undefined; - protoVectorListener: ((binaryProtos: Uint8Array[]) => void)|undefined; + protoListener: + ((binaryProto: Uint8Array, timestamp: number) => void)|undefined; + protoVectorListener: + ((binaryProtos: Uint8Array[], timestamp: number) => void)|undefined; constructor() { super(createSpyWasmModule(), /* glCanvas= */ null); @@ -163,7 +165,7 @@ describe('AudioEmbedder', () => { audioEmbedder.fakeWasmModule._waitUntilIdle.and.callFake(() => { verifyListenersRegistered(audioEmbedder); // Pass the test data to our listener - audioEmbedder.protoListener!(resultProto.serializeBinary()); + audioEmbedder.protoListener!(resultProto.serializeBinary(), 1337); }); // Invoke the audio embedder @@ -175,7 +177,8 @@ describe('AudioEmbedder', () => { audioEmbedder.fakeWasmModule._waitUntilIdle.and.callFake(() => { verifyListenersRegistered(audioEmbedder); // Pass the test data to our listener - audioEmbedder.protoVectorListener!([resultProto.serializeBinary()]); + audioEmbedder.protoVectorListener! + ([resultProto.serializeBinary()], 1337); }); // Invoke the audio embedder diff --git a/mediapipe/tasks/web/text/text_classifier/text_classifier_test.ts b/mediapipe/tasks/web/text/text_classifier/text_classifier_test.ts index 5578362cb..d9eb14865 100644 --- a/mediapipe/tasks/web/text/text_classifier/text_classifier_test.ts +++ b/mediapipe/tasks/web/text/text_classifier/text_classifier_test.ts @@ -32,7 +32,8 @@ class TextClassifierFake extends TextClassifier implements MediapipeTasksFake { attachListenerSpies: jasmine.Spy[] = []; graph: CalculatorGraphConfig|undefined; fakeWasmModule: SpyWasmModule; - protoListener: ((binaryProto: Uint8Array) => void)|undefined; + protoListener: + ((binaryProto: Uint8Array, timestamp: number) => void)|undefined; constructor() { super(createSpyWasmModule(), /* glCanvas= */ null); @@ -118,19 +119,20 @@ describe('TextClassifier', () => { classifcations.setHeadIndex(1); classifcations.setHeadName('headName'); const classificationList = new ClassificationList(); - const clasification = new Classification(); - clasification.setIndex(1); - clasification.setScore(0.2); - clasification.setDisplayName('displayName'); - clasification.setLabel('categoryName'); - classificationList.addClassification(clasification); + const classification = new Classification(); + classification.setIndex(1); + classification.setScore(0.2); + classification.setDisplayName('displayName'); + classification.setLabel('categoryName'); + classificationList.addClassification(classification); classifcations.setClassificationList(classificationList); classificationResult.addClassifications(classifcations); // Pass the test data to our listener textClassifier.fakeWasmModule._waitUntilIdle.and.callFake(() => { verifyListenersRegistered(textClassifier); - textClassifier.protoListener!(classificationResult.serializeBinary()); + textClassifier.protoListener! + (classificationResult.serializeBinary(), 1337); }); // Invoke the text classifier diff --git a/mediapipe/tasks/web/text/text_embedder/text_embedder_test.ts b/mediapipe/tasks/web/text/text_embedder/text_embedder_test.ts index 2804e4deb..e26b85bf4 100644 --- a/mediapipe/tasks/web/text/text_embedder/text_embedder_test.ts +++ b/mediapipe/tasks/web/text/text_embedder/text_embedder_test.ts @@ -31,7 +31,8 @@ class TextEmbedderFake extends TextEmbedder implements MediapipeTasksFake { graph: CalculatorGraphConfig|undefined; attachListenerSpies: jasmine.Spy[] = []; fakeWasmModule: SpyWasmModule; - protoListener: ((binaryProtos: Uint8Array) => void)|undefined; + protoListener: + ((binaryProtos: Uint8Array, timestamp: number) => void)|undefined; constructor() { super(createSpyWasmModule(), /* glCanvas= */ null); @@ -120,7 +121,7 @@ describe('TextEmbedder', () => { // Pass the test data to our listener textEmbedder.fakeWasmModule._waitUntilIdle.and.callFake(() => { verifyListenersRegistered(textEmbedder); - textEmbedder.protoListener!(resultProto.serializeBinary()); + textEmbedder.protoListener!(resultProto.serializeBinary(), 1337); }); // Invoke the text embedder @@ -149,7 +150,7 @@ describe('TextEmbedder', () => { // Pass the test data to our listener textEmbedder.fakeWasmModule._waitUntilIdle.and.callFake(() => { verifyListenersRegistered(textEmbedder); - textEmbedder.protoListener!(resultProto.serializeBinary()); + textEmbedder.protoListener!(resultProto.serializeBinary(), 1337); }); // Invoke the text embedder diff --git a/mediapipe/tasks/web/vision/gesture_recognizer/gesture_recognizer_test.ts b/mediapipe/tasks/web/vision/gesture_recognizer/gesture_recognizer_test.ts index ee51fd32a..3611c3a7d 100644 --- a/mediapipe/tasks/web/vision/gesture_recognizer/gesture_recognizer_test.ts +++ b/mediapipe/tasks/web/vision/gesture_recognizer/gesture_recognizer_test.ts @@ -26,7 +26,7 @@ import {GestureRecognizer, GestureRecognizerOptions} from './gesture_recognizer' // The OSS JS API does not support the builder pattern. // tslint:disable:jspb-use-builder-pattern -type ProtoListener = ((binaryProtos: Uint8Array[]) => void); +type ProtoListener = ((binaryProtos: Uint8Array[], timestamp: number) => void); function createHandednesses(): Uint8Array[] { const handsProto = new ClassificationList(); @@ -254,11 +254,13 @@ describe('GestureRecognizer', () => { // Pass the test data to our listener gestureRecognizer.fakeWasmModule._waitUntilIdle.and.callFake(() => { verifyListenersRegistered(gestureRecognizer); - gestureRecognizer.listeners.get('hand_landmarks')!(createLandmarks()); + gestureRecognizer.listeners.get('hand_landmarks')! + (createLandmarks(), 1337); gestureRecognizer.listeners.get('world_hand_landmarks')! - (createWorldLandmarks()); - gestureRecognizer.listeners.get('handedness')!(createHandednesses()); - gestureRecognizer.listeners.get('hand_gestures')!(createGestures()); + (createWorldLandmarks(), 1337); + gestureRecognizer.listeners.get('handedness')! + (createHandednesses(), 1337); + gestureRecognizer.listeners.get('hand_gestures')!(createGestures(), 1337); }); // Invoke the gesture recognizer @@ -290,11 +292,13 @@ describe('GestureRecognizer', () => { it('clears results between invoations', async () => { // Pass the test data to our listener gestureRecognizer.fakeWasmModule._waitUntilIdle.and.callFake(() => { - gestureRecognizer.listeners.get('hand_landmarks')!(createLandmarks()); + gestureRecognizer.listeners.get('hand_landmarks')! + (createLandmarks(), 1337); gestureRecognizer.listeners.get('world_hand_landmarks')! - (createWorldLandmarks()); - gestureRecognizer.listeners.get('handedness')!(createHandednesses()); - gestureRecognizer.listeners.get('hand_gestures')!(createGestures()); + (createWorldLandmarks(), 1337); + gestureRecognizer.listeners.get('handedness')! + (createHandednesses(), 1337); + gestureRecognizer.listeners.get('hand_gestures')!(createGestures(), 1337); }); // Invoke the gesture recognizer twice @@ -310,11 +314,13 @@ describe('GestureRecognizer', () => { // Pass the test data to our listener gestureRecognizer.fakeWasmModule._waitUntilIdle.and.callFake(() => { verifyListenersRegistered(gestureRecognizer); - gestureRecognizer.listeners.get('hand_landmarks')!(createLandmarks()); + gestureRecognizer.listeners.get('hand_landmarks')! + (createLandmarks(), 1337); gestureRecognizer.listeners.get('world_hand_landmarks')! - (createWorldLandmarks()); - gestureRecognizer.listeners.get('handedness')!(createHandednesses()); - gestureRecognizer.listeners.get('hand_gestures')!([]); + (createWorldLandmarks(), 1337); + gestureRecognizer.listeners.get('handedness')! + (createHandednesses(), 1337); + gestureRecognizer.listeners.get('hand_gestures')!([], 1337); }); // Invoke the gesture recognizer diff --git a/mediapipe/tasks/web/vision/hand_landmarker/hand_landmarker_test.ts b/mediapipe/tasks/web/vision/hand_landmarker/hand_landmarker_test.ts index 76e77b4bf..1a813c6f7 100644 --- a/mediapipe/tasks/web/vision/hand_landmarker/hand_landmarker_test.ts +++ b/mediapipe/tasks/web/vision/hand_landmarker/hand_landmarker_test.ts @@ -27,7 +27,7 @@ import {HandLandmarkerOptions} from './hand_landmarker_options'; // The OSS JS API does not support the builder pattern. // tslint:disable:jspb-use-builder-pattern -type ProtoListener = ((binaryProtos: Uint8Array[]) => void); +type ProtoListener = ((binaryProtos: Uint8Array[], timestamp: number) => void); function createHandednesses(): Uint8Array[] { const handsProto = new ClassificationList(); @@ -206,10 +206,10 @@ describe('HandLandmarker', () => { // Pass the test data to our listener handLandmarker.fakeWasmModule._waitUntilIdle.and.callFake(() => { verifyListenersRegistered(handLandmarker); - handLandmarker.listeners.get('hand_landmarks')!(createLandmarks()); + handLandmarker.listeners.get('hand_landmarks')!(createLandmarks(), 1337); handLandmarker.listeners.get('world_hand_landmarks')! - (createWorldLandmarks()); - handLandmarker.listeners.get('handedness')!(createHandednesses()); + (createWorldLandmarks(), 1337); + handLandmarker.listeners.get('handedness')!(createHandednesses(), 1337); }); // Invoke the hand landmarker @@ -235,10 +235,10 @@ describe('HandLandmarker', () => { it('clears results between invoations', async () => { // Pass the test data to our listener handLandmarker.fakeWasmModule._waitUntilIdle.and.callFake(() => { - handLandmarker.listeners.get('hand_landmarks')!(createLandmarks()); + handLandmarker.listeners.get('hand_landmarks')!(createLandmarks(), 1337); handLandmarker.listeners.get('world_hand_landmarks')! - (createWorldLandmarks()); - handLandmarker.listeners.get('handedness')!(createHandednesses()); + (createWorldLandmarks(), 1337); + handLandmarker.listeners.get('handedness')!(createHandednesses(), 1337); }); // Invoke the hand landmarker twice diff --git a/mediapipe/tasks/web/vision/image_classifier/image_classifier_test.ts b/mediapipe/tasks/web/vision/image_classifier/image_classifier_test.ts index da4a01d02..60595310e 100644 --- a/mediapipe/tasks/web/vision/image_classifier/image_classifier_test.ts +++ b/mediapipe/tasks/web/vision/image_classifier/image_classifier_test.ts @@ -35,7 +35,8 @@ class ImageClassifierFake extends ImageClassifier implements graph: CalculatorGraphConfig|undefined; fakeWasmModule: SpyWasmModule; - protoListener: ((binaryProto: Uint8Array) => void)|undefined; + protoListener: + ((binaryProto: Uint8Array, timestamp: number) => void)|undefined; constructor() { super(createSpyWasmModule(), /* glCanvas= */ null); @@ -128,7 +129,8 @@ describe('ImageClassifier', () => { // Pass the test data to our listener imageClassifier.fakeWasmModule._waitUntilIdle.and.callFake(() => { verifyListenersRegistered(imageClassifier); - imageClassifier.protoListener!(classificationResult.serializeBinary()); + imageClassifier.protoListener! + (classificationResult.serializeBinary(), 1337); }); // Invoke the image classifier diff --git a/mediapipe/tasks/web/vision/image_embedder/image_embedder_test.ts b/mediapipe/tasks/web/vision/image_embedder/image_embedder_test.ts index b63bb374c..01ec751e3 100644 --- a/mediapipe/tasks/web/vision/image_embedder/image_embedder_test.ts +++ b/mediapipe/tasks/web/vision/image_embedder/image_embedder_test.ts @@ -31,7 +31,8 @@ class ImageEmbedderFake extends ImageEmbedder implements MediapipeTasksFake { graph: CalculatorGraphConfig|undefined; attachListenerSpies: jasmine.Spy[] = []; fakeWasmModule: SpyWasmModule; - protoListener: ((binaryProtos: Uint8Array) => void)|undefined; + protoListener: + ((binaryProtos: Uint8Array, timestamp: number) => void)|undefined; constructor() { super(createSpyWasmModule(), /* glCanvas= */ null); @@ -125,7 +126,7 @@ describe('ImageEmbedder', () => { // Pass the test data to our listener imageEmbedder.fakeWasmModule._waitUntilIdle.and.callFake(() => { verifyListenersRegistered(imageEmbedder); - imageEmbedder.protoListener!(resultProto.serializeBinary()); + imageEmbedder.protoListener!(resultProto.serializeBinary(), 1337); }); }); diff --git a/mediapipe/tasks/web/vision/object_detector/object_detector_test.ts b/mediapipe/tasks/web/vision/object_detector/object_detector_test.ts index 43b7035d5..5bfb74ab6 100644 --- a/mediapipe/tasks/web/vision/object_detector/object_detector_test.ts +++ b/mediapipe/tasks/web/vision/object_detector/object_detector_test.ts @@ -35,7 +35,8 @@ class ObjectDetectorFake extends ObjectDetector implements MediapipeTasksFake { graph: CalculatorGraphConfig|undefined; fakeWasmModule: SpyWasmModule; - protoListener: ((binaryProtos: Uint8Array[]) => void)|undefined; + protoListener: + ((binaryProtos: Uint8Array[], timestamp: number) => void)|undefined; constructor() { super(createSpyWasmModule(), /* glCanvas= */ null); @@ -200,7 +201,7 @@ describe('ObjectDetector', () => { // Pass the test data to our listener objectDetector.fakeWasmModule._waitUntilIdle.and.callFake(() => { verifyListenersRegistered(objectDetector); - objectDetector.protoListener!(detectionProtos); + objectDetector.protoListener!(detectionProtos, 1337); }); // Invoke the object detector