@@ -14,6 +14,8 @@ import 'package:flutter/rendering.dart';
14
14
import 'package:flutter/widgets.dart' ;
15
15
import 'package:flutter_test/flutter_test.dart' ;
16
16
17
+ import 'widget_inspector_test_utils.dart' ;
18
+
17
19
// Start of block of code where widget creation location line numbers and
18
20
// columns will impact whether tests pass.
19
21
@@ -222,64 +224,10 @@ int getChildLayerCount(OffsetLayer layer) {
222
224
}
223
225
224
226
void main () {
225
- TestWidgetInspectorService .runTests ();
227
+ _TestWidgetInspectorService .runTests ();
226
228
}
227
229
228
- class TestWidgetInspectorService extends Object with WidgetInspectorService {
229
- final Map <String , InspectorServiceExtensionCallback > extensions = < String , InspectorServiceExtensionCallback > {};
230
-
231
- final Map <String , List <Map <Object , Object >>> eventsDispatched = < String , List <Map <Object , Object >>> {};
232
-
233
- @override
234
- void registerServiceExtension ({
235
- @required String name,
236
- @required FutureOr <Map <String , Object >> callback (Map <String , String > parameters),
237
- }) {
238
- assert (! extensions.containsKey (name));
239
- extensions[name] = callback;
240
- }
241
-
242
- @override
243
- void postEvent (String eventKind, Map <Object , Object > eventData) {
244
- getEventsDispatched (eventKind).add (eventData);
245
- }
246
-
247
- List <Map <Object , Object >> getEventsDispatched (String eventKind) {
248
- return eventsDispatched.putIfAbsent (eventKind, () => < Map <Object , Object >> []);
249
- }
250
-
251
- Iterable <Map <Object , Object >> getServiceExtensionStateChangedEvents (String extensionName) {
252
- return getEventsDispatched ('Flutter.ServiceExtensionStateChanged' )
253
- .where ((Map <Object , Object > event) => event['extension' ] == extensionName);
254
- }
255
-
256
- Future <Object > testExtension (String name, Map <String , String > arguments) async {
257
- expect (extensions, contains (name));
258
- // Encode and decode to JSON to match behavior using a real service
259
- // extension where only JSON is allowed.
260
- return json.decode (json.encode (await extensions[name](arguments)))['result' ];
261
- }
262
-
263
- Future <String > testBoolExtension (String name, Map <String , String > arguments) async {
264
- expect (extensions, contains (name));
265
- // Encode and decode to JSON to match behavior using a real service
266
- // extension where only JSON is allowed.
267
- return json.decode (json.encode (await extensions[name](arguments)))['enabled' ] as String ;
268
- }
269
-
270
- int rebuildCount = 0 ;
271
-
272
- @override
273
- Future <void > forceRebuild () async {
274
- rebuildCount++ ;
275
- final WidgetsBinding binding = WidgetsBinding .instance;
276
-
277
- if (binding.renderViewElement != null ) {
278
- binding.buildOwner.reassemble (binding.renderViewElement);
279
- }
280
- }
281
-
282
-
230
+ class _TestWidgetInspectorService extends TestWidgetInspectorService {
283
231
// These tests need access to protected members of WidgetInspectorService.
284
232
static void runTests () {
285
233
final TestWidgetInspectorService service = TestWidgetInspectorService ();
@@ -1725,7 +1673,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
1725
1673
_CreationLocation location = knownLocations[id];
1726
1674
expect (location.file, equals (file));
1727
1675
// ClockText widget.
1728
- expect (location.line, equals (51 ));
1676
+ expect (location.line, equals (53 ));
1729
1677
expect (location.column, equals (9 ));
1730
1678
expect (count, equals (1 ));
1731
1679
@@ -1734,7 +1682,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
1734
1682
location = knownLocations[id];
1735
1683
expect (location.file, equals (file));
1736
1684
// Text widget in _ClockTextState build method.
1737
- expect (location.line, equals (89 ));
1685
+ expect (location.line, equals (91 ));
1738
1686
expect (location.column, equals (12 ));
1739
1687
expect (count, equals (1 ));
1740
1688
@@ -1759,7 +1707,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
1759
1707
location = knownLocations[id];
1760
1708
expect (location.file, equals (file));
1761
1709
// ClockText widget.
1762
- expect (location.line, equals (51 ));
1710
+ expect (location.line, equals (53 ));
1763
1711
expect (location.column, equals (9 ));
1764
1712
expect (count, equals (3 )); // 3 clock widget instances rebuilt.
1765
1713
@@ -1768,7 +1716,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
1768
1716
location = knownLocations[id];
1769
1717
expect (location.file, equals (file));
1770
1718
// Text widget in _ClockTextState build method.
1771
- expect (location.line, equals (89 ));
1719
+ expect (location.line, equals (91 ));
1772
1720
expect (location.column, equals (12 ));
1773
1721
expect (count, equals (3 )); // 3 clock widget instances rebuilt.
1774
1722
0 commit comments