"Fossies" - the Fresh Open Source Software Archive

Member "flutter-3.7.1/packages/flutter_test/test/all_elements_test.dart" (1 Feb 2023, 1144 Bytes) of package /linux/misc/flutter-3.7.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Dart source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // Copyright 2014 The Flutter Authors. All rights reserved.
    2 // Use of this source code is governed by a BSD-style license that can be
    3 // found in the LICENSE file.
    4 
    5 import 'package:flutter/material.dart';
    6 import 'package:flutter_test/flutter_test.dart';
    7 
    8 void main() {
    9   testWidgets('collectAllElements goes in LTR DFS', (WidgetTester tester) async {
   10     final GlobalKey key = GlobalKey();
   11     await tester.pumpWidget(Directionality(
   12       key: key,
   13       textDirection: TextDirection.ltr,
   14       child: Row(
   15         children: <Widget>[
   16           RichText(text: const TextSpan(text: 'a')),
   17           RichText(text: const TextSpan(text: 'b')),
   18         ],
   19       ),
   20     ));
   21 
   22     final List<Element> elements = collectAllElementsFrom(
   23       key.currentContext! as Element,
   24       skipOffstage: false,
   25     ).toList();
   26 
   27     expect(elements.length, 3);
   28     expect(elements[0].widget, isA<Row>());
   29     expect(elements[1].widget, isA<RichText>());
   30     expect(((elements[1].widget as RichText).text as TextSpan).text, 'a');
   31     expect(elements[2].widget, isA<RichText>());
   32     expect(((elements[2].widget as RichText).text as TextSpan).text, 'b');
   33   });
   34 }