@@ -40,38 +40,10 @@ void main() {
4040 reason: 'Model should produce surfaces' ,
4141 );
4242
43- final created = < String > [];
44- final removed = < String > [];
45- final updated = < String > [];
46- var content = 0 ;
47- var waiting = 0 ;
48- final errors = < String > [];
49-
50- for (final ConversationEvent event in tester.events) {
51- print (event.runtimeType);
52- switch (event) {
53- case ConversationSurfaceAdded ():
54- created.add (event.surfaceId);
55- case ConversationComponentsUpdated ():
56- updated.add (event.surfaceId);
57- case ConversationSurfaceRemoved ():
58- removed.add (event.surfaceId);
59- case ConversationContentReceived ():
60- content++ ;
61- case ConversationWaiting ():
62- waiting++ ;
63- case ConversationError ():
64- errors.add (event.error.toString ());
65- }
66- }
43+ tester.verifyEvents ();
6744
68- print ('Created: $created ' );
69- print ('Removed: $removed ' );
70- print ('Updated: $updated ' );
71- print ('Content: $content ' );
72- print ('Waiting: $waiting ' );
73- print ('Errors: $errors ' );
74- });
45+ tester.reporter.failIfIssuesFound ();
46+ }, timeout: const Timeout (Duration (seconds: 120 )));
7547}
7648
7749/// Helper class to manage a chat session from simple chat example.
@@ -103,11 +75,6 @@ class _ChatSessionTester {
10375
10476 Future <void > sendMessageAndWaitForResponse (String message) async {
10577 await chatSession.sendMessage (message);
106- reporter.expect (
107- chatSession.isProcessing,
108- 'chatSession.isProcessing should be true after sending a message' ,
109- );
110-
11178 await _waitForProcessingToComplete ();
11279 }
11380
@@ -118,6 +85,45 @@ class _ChatSessionTester {
11885 .whereType <String >();
11986 }
12087
88+ void verifyEvents () {
89+ final created = < String > [];
90+ final removed = < String > [];
91+ final updated = < String > [];
92+ var content = 0 ;
93+ var waiting = 0 ;
94+ final errors = < String > [];
95+ for (final ConversationEvent event in events) {
96+ switch (event) {
97+ case ConversationSurfaceAdded ():
98+ created.add (event.surfaceId);
99+ case ConversationComponentsUpdated ():
100+ updated.add (event.surfaceId);
101+ case ConversationSurfaceRemoved ():
102+ removed.add (event.surfaceId);
103+ case ConversationContentReceived ():
104+ content++ ;
105+ case ConversationWaiting ():
106+ waiting++ ;
107+ case ConversationError ():
108+ errors.add (event.error.toString ());
109+ }
110+ }
111+
112+ print ('Conversation summary:' );
113+ print (' Created surfaces: $created ' );
114+ print (' Removed surfaces: $removed ' );
115+ print (' Updated surfaces: $updated ' );
116+ print (' Text content: $content ' );
117+ print (' Waiting: $waiting ' );
118+ print (' Errors: $errors ' );
119+
120+ reporter.expect (errors.isEmpty, 'No errors should occur' );
121+ reporter.expect (
122+ updated.isEmpty,
123+ 'In chat setup surfaces should not be updated' ,
124+ );
125+ }
126+
121127 void dispose () {
122128 chatSession.dispose ();
123129 }
0 commit comments