@@ -34,6 +34,9 @@ void main() {
3434 late ErrorBadgeManager errorBadgeManager;
3535
3636 group ('ErrorBadgeManager' , () {
37+ int getActiveErrorCount (screenId) =>
38+ errorBadgeManager.erroredItemsForPage (screenId).value.entries.length;
39+
3740 setUp (() {
3841 errorBadgeManager = ErrorBadgeManager ();
3942 });
@@ -60,7 +63,7 @@ void main() {
6063 }
6164 });
6265
63- test ('clearErrors resets counts' , () {
66+ test ('clearErrorCount resets counts' , () {
6467 allScreenIds.forEach (errorBadgeManager.incrementBadgeCount);
6568
6669 for (final id in allScreenIds) {
@@ -71,11 +74,55 @@ void main() {
7174 }
7275 }
7376
74- allScreenIds.forEach (errorBadgeManager.clearErrors );
77+ allScreenIds.forEach (errorBadgeManager.clearErrorCount );
7578
7679 for (final id in allScreenIds) {
7780 expect (errorBadgeManager.errorCountNotifier (id).value, equals (0 ));
7881 }
7982 });
83+
84+ // TODO(https://github.com/flutter/devtools/issues/9105): This logic should
85+ // be moved to the inspector.
86+ test ('appendError works for inspector screen only' , () {
87+ for (final id in allScreenIds) {
88+ errorBadgeManager.appendError (id, DevToolsError ('An error' , id));
89+ }
90+
91+ for (final id in allScreenIds) {
92+ if (id == InspectorScreen .id) {
93+ expect (getActiveErrorCount (id), equals (1 ));
94+ } else {
95+ expect (getActiveErrorCount (id), equals (0 ));
96+ }
97+ }
98+ });
99+
100+ test ('clearErrors resets counts and removes errors' , () {
101+ expect (getActiveErrorCount (InspectorScreen .id), equals (0 ));
102+ expect (
103+ errorBadgeManager.errorCountNotifier (InspectorScreen .id).value,
104+ equals (0 ),
105+ );
106+
107+ errorBadgeManager.appendError (
108+ InspectorScreen .id,
109+ DevToolsError ('An error' , InspectorScreen .id),
110+ );
111+ errorBadgeManager.incrementBadgeCount (InspectorScreen .id);
112+
113+ expect (getActiveErrorCount (InspectorScreen .id), equals (1 ));
114+ expect (
115+ errorBadgeManager.errorCountNotifier (InspectorScreen .id).value,
116+ equals (1 ),
117+ );
118+
119+ errorBadgeManager.clearErrors (InspectorScreen .id);
120+
121+ expect (getActiveErrorCount (InspectorScreen .id), equals (0 ));
122+ expect (
123+ errorBadgeManager.errorCountNotifier (InspectorScreen .id).value,
124+ equals (0 ),
125+ );
126+ });
80127 });
81128}
0 commit comments