@@ -6,6 +6,7 @@ import 'dart:mirrors';
66
77import 'package:test/test.dart' ;
88import 'package:unified_analytics/src/enums.dart' ;
9+ import 'package:unified_analytics/src/event.dart' ;
910import 'package:unified_analytics/unified_analytics.dart' ;
1011
1112void main () {
@@ -559,6 +560,7 @@ void main() {
559560
560561 test ('Event.devtoolsEvent constructed' , () {
561562 Event generateEvent () => Event .devtoolsEvent (
563+ screen: 'screen' ,
562564 eventCategory: 'eventCategory' ,
563565 label: 'label' ,
564566 value: 1 ,
@@ -575,25 +577,17 @@ void main() {
575577 isEmbedded: 'isEmbedded' ,
576578 ideLaunchedFeature: 'ideLaunchedFeature' ,
577579 isWasm: 'true' ,
578- uiDurationMicros: 123 ,
579- rasterDurationMicros: 123 ,
580- shaderCompilationDurationMicros: 123 ,
581- traceEventCount: 123 ,
582- cpuSampleCount: 123 ,
583- cpuStackDepth: 123 ,
584- heapDiffObjectsBefore: 123 ,
585- heapDiffObjectsAfter: 123 ,
586- heapObjectsTotal: 123 ,
587- rootSetCount: 123 ,
588- rowCount: 123 ,
589- inspectorTreeControllerId: 123 ,
590- androidAppId: 'androidAppId' ,
591- iosBundleId: 'iosBundleId' ,
580+ additionalMetrics: _TestMetrics (
581+ stringField: 'test' ,
582+ intField: 100 ,
583+ boolField: false ,
584+ ),
592585 );
593586
594587 final constructedEvent = generateEvent ();
595588
596589 expect (generateEvent, returnsNormally);
590+ expect (constructedEvent.eventData['screen' ], 'screen' );
597591 expect (constructedEvent.eventData['eventCategory' ], 'eventCategory' );
598592 expect (constructedEvent.eventData['label' ], 'label' );
599593 expect (constructedEvent.eventData['value' ], 1 );
@@ -609,24 +603,15 @@ void main() {
609603 expect (constructedEvent.eventData['isExternalBuild' ], 'isExternalBuild' );
610604 expect (constructedEvent.eventData['isEmbedded' ], 'isEmbedded' );
611605 expect (
612- constructedEvent.eventData['ideLaunchedFeature' ], 'ideLaunchedFeature' );
606+ constructedEvent.eventData['ideLaunchedFeature' ],
607+ 'ideLaunchedFeature' ,
608+ );
613609 expect (constructedEvent.eventData['isWasm' ], 'true' );
614-
615- expect (constructedEvent.eventData['uiDurationMicros' ], 123 );
616- expect (constructedEvent.eventData['rasterDurationMicros' ], 123 );
617- expect (constructedEvent.eventData['shaderCompilationDurationMicros' ], 123 );
618- expect (constructedEvent.eventData['traceEventCount' ], 123 );
619- expect (constructedEvent.eventData['cpuSampleCount' ], 123 );
620- expect (constructedEvent.eventData['cpuStackDepth' ], 123 );
621- expect (constructedEvent.eventData['heapDiffObjectsBefore' ], 123 );
622- expect (constructedEvent.eventData['heapDiffObjectsAfter' ], 123 );
623- expect (constructedEvent.eventData['heapObjectsTotal' ], 123 );
624- expect (constructedEvent.eventData['rootSetCount' ], 123 );
625- expect (constructedEvent.eventData['rowCount' ], 123 );
626- expect (constructedEvent.eventData['inspectorTreeControllerId' ], 123 );
627- expect (constructedEvent.eventData['androidAppId' ], 'androidAppId' );
628- expect (constructedEvent.eventData['iosBundleId' ], 'iosBundleId' );
629- expect (constructedEvent.eventData.length, 30 );
610+ expect (constructedEvent.eventData['stringField' ], 'test' );
611+ expect (constructedEvent.eventData['intField' ], 100 );
612+ expect (constructedEvent.eventData['boolField' ], false );
613+ expect (constructedEvent.eventData.containsKey ('nullableField' ), false );
614+ expect (constructedEvent.eventData.length, 20 );
630615 });
631616
632617 test ('Confirm all constructors were checked' , () {
@@ -700,3 +685,22 @@ void main() {
700685 expect (eventConstructed, isNull);
701686 });
702687}
688+
689+ final class _TestMetrics extends CustomMetrics {
690+ _TestMetrics ({
691+ required this .stringField,
692+ required this .intField,
693+ required this .boolField,
694+ });
695+
696+ final String stringField;
697+ final int intField;
698+ final bool boolField;
699+
700+ @override
701+ Map <String , Object > toMap () => {
702+ 'stringField' : stringField,
703+ 'intField' : intField,
704+ 'boolField' : boolField,
705+ };
706+ }
0 commit comments