diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 872b82e336..0000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,40 +0,0 @@ -version: 2.1 -orbs: - codecov: codecov/codecov@1.0.2 -executors: - default-executor: - docker: - - image: cirrusci/flutter:stable - resource_class: large - shell: /bin/bash -jobs: - build: - executor: default-executor - steps: - - checkout - - run: flutter --version - - run: - name: Set up environment - command: | - echo 'export PATH=$HOME/.pub-cache/bin:$PATH' >> $BASH_ENV - source $BASH_ENV - - run: - name: Setup melos - command: | - flutter pub global activate melos - melos --version - melos bootstrap - - run: - name: Run Test Suite - command: melos run test - - run: - name: Generate Coverage Report - command: melos run gen_coverage - - codecov/upload: - file: coverage_report/lcov.info - - run: - name: Run flutter analyze - command: melos analyze --fatal-infos - - run: - name: Check That Flutter Code is Formatted Correctly - command: dart format -o none --set-exit-if-changed . diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000000..0a1df1def5 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,33 @@ +name: Test flutter_html + +on: + pull_request: + branches: [ main ] + push: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dart-lang/setup-dart@v1 + - uses: flutter-actions/setup-flutter@54feb1e258158303e041b9eaf89314dcfbf6d38a + - name: Setup Melos + run: flutter pub global activate melos + - name: Bootstrap Project + run: flutter pub global run melos bootstrap + - name: Run Test Suite + run: flutter pub global run melos run test + - name: Compile Test Coverage Report + run: flutter pub global run melos run gen_coverage + - name: Upload Coverage to Codecov + uses: codecov/codecov-action@v5 + with: + files: coverage_report/lcov.info + disable_search: true + token: ${{ secrets.CODECOV_TOKEN }} + - name: Run Dart Analysis + run: flutter pub global run melos analyze --fatal-infos + - name: Check that `dart format` has been run on every file + run: dart format -o none --set-exit-if-changed diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index ab73b3a234..e900dfd40f 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -1 +1,7 @@ -void main() {} +import 'package:flutter_test/flutter_test.dart'; + +void main() { + test('Dummy test', () { + expect(2 + 2, equals(4)); + }); +} diff --git a/lib/src/builtins/interactive_element_builtin.dart b/lib/src/builtins/interactive_element_builtin.dart index e7a88f1098..d430b3a847 100644 --- a/lib/src/builtins/interactive_element_builtin.dart +++ b/lib/src/builtins/interactive_element_builtin.dart @@ -62,7 +62,8 @@ class InteractiveElementBuiltIn extends HtmlExtension { ?.map((e) => _processInteractableChild(context, e)) .toList(), recognizer: TapGestureRecognizer()..onTap = onTap, - style: context.styledElement?.style.generateTextStyle() ?? childSpan.style, + style: + context.styledElement?.style.generateTextStyle() ?? childSpan.style, semanticsLabel: childSpan.semanticsLabel, locale: childSpan.locale, mouseCursor: childSpan.mouseCursor, diff --git a/lib/src/css_box_widget.dart b/lib/src/css_box_widget.dart index b21418986a..c6870a3929 100644 --- a/lib/src/css_box_widget.dart +++ b/lib/src/css_box_widget.dart @@ -80,7 +80,8 @@ class CssBoxWidget extends StatelessWidget { child: top ? child : MediaQuery( - data: MediaQuery.of(context).copyWith(textScaler: TextScaler.linear(1.0)), + data: MediaQuery.of(context) + .copyWith(textScaler: TextScaler.linear(1.0)), child: child, ), ), @@ -484,8 +485,8 @@ class RenderCSSBox extends RenderBox } @override - double? computeDryBaseline(covariant BoxConstraints constraints, - TextBaseline baseline) { + double? computeDryBaseline( + covariant BoxConstraints constraints, TextBaseline baseline) { return null; } @@ -532,9 +533,15 @@ class RenderCSSBox extends RenderBox // `width: double.infinity` on the inner Container, but we do it here // to keep the infinite width from being applied if the parent's width is // also infinite. - if(display.isBlock && !shrinkWrap && !childIsReplaced && containingBlockSize.width.isFinite) { + if (display.isBlock && + !shrinkWrap && + !childIsReplaced && + containingBlockSize.width.isFinite) { childConstraints = childConstraints.enforce(BoxConstraints( - maxWidth: math.max(containingBlockSize.width, childConstraints.maxWidth), + maxWidth: math.max( + containingBlockSize.width, + childConstraints.maxWidth, + ), minWidth: childConstraints.maxWidth, )); } @@ -556,7 +563,9 @@ class RenderCSSBox extends RenderBox width = childSize.width + horizontalMargins; height = childSize.height + verticalMargins; } else if (display.isBlock) { - width = (shrinkWrap || childIsReplaced || containingBlockSize.width.isInfinite) + width = (shrinkWrap || + childIsReplaced || + containingBlockSize.width.isInfinite) ? childSize.width + horizontalMargins : containingBlockSize.width; height = childSize.height + verticalMargins; @@ -808,7 +817,9 @@ extension Normalize on Dimension { double _calculateEmValue(Style style, BuildContext buildContext) { return (style.fontSize?.emValue ?? 16) * - (MediaQuery.maybeTextScalerOf(buildContext)?.scale(style.fontSize?.emValue ?? 16) ?? 1.0) * + (MediaQuery.maybeTextScalerOf(buildContext) + ?.scale(style.fontSize?.emValue ?? 16) ?? + 1.0) * MediaQuery.of(buildContext).devicePixelRatio; } diff --git a/lib/src/tree/styled_element.dart b/lib/src/tree/styled_element.dart index 0797bfe69a..f91ebf7c8e 100644 --- a/lib/src/tree/styled_element.dart +++ b/lib/src/tree/styled_element.dart @@ -33,7 +33,7 @@ class StyledElement { return false; } } - + bool matchesSelector(String selector) { return (element != null && matches(element!, selector)) || name == selector; } diff --git a/packages/flutter_html_audio/lib/flutter_html_audio.dart b/packages/flutter_html_audio/lib/flutter_html_audio.dart index 78816f9af9..ec15cf9182 100644 --- a/packages/flutter_html_audio/lib/flutter_html_audio.dart +++ b/packages/flutter_html_audio/lib/flutter_html_audio.dart @@ -60,8 +60,8 @@ class _AudioWidgetState extends State { ]; if (sources.isNotEmpty && sources.first != null) { - audioController = VideoPlayerController.network( - sources.first ?? "", + audioController = VideoPlayerController.networkUrl( + Uri.tryParse(sources.first ?? "") ?? Uri(), ); chewieAudioController = ChewieAudioController( videoPlayerController: audioController!, diff --git a/packages/flutter_html_video/lib/flutter_html_video.dart b/packages/flutter_html_video/lib/flutter_html_video.dart index 6aa5298c95..94edcd836e 100644 --- a/packages/flutter_html_video/lib/flutter_html_video.dart +++ b/packages/flutter_html_video/lib/flutter_html_video.dart @@ -83,8 +83,7 @@ class _VideoWidgetState extends State { VideoPlayerController.file(File.fromUri(sourceUri)); break; default: - _videoController = - VideoPlayerController.networkUrl(sourceUri); + _videoController = VideoPlayerController.networkUrl(sourceUri); break; } _chewieController = ChewieController( diff --git a/test/elements/a_test.dart b/test/elements/a_test.dart index 4b67971773..a64e17135c 100644 --- a/test/elements/a_test.dart +++ b/test/elements/a_test.dart @@ -57,9 +57,10 @@ void main() { ), ), ); - expect(find.text("Hello, world!", findRichText: true), findsOneWidget); + final finder = find.textRange.ofSubstring("Hello, world!"); + expect(finder, findsOne); expect(tappedUrl, equals("")); - await tester.tap(find.text("Hello, world!", findRichText: true)); + await tester.tapOnText(finder); expect(tappedUrl, equals("https://example.com")); });