Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix web tests
  • Loading branch information
LouiseHsu committed Dec 5, 2023
commit 2b97d044318e176badfb17d64fc27bee2791a276
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ void main() {
expect(element.id, isNot('background-html-view'));
}, semanticsEnabled: false);

testWidgets(
'on wrapped elements with intercepting set to false, the browser hits the background-html-view',
(WidgetTester tester) async {
app.main();
await tester.pumpAndSettle();

final html.Element element =
_getHtmlElementAtCenter(clickableWrappedButtonFinder, tester);

expect(element.id, 'background-html-view');
}, semanticsEnabled: false);

testWidgets(
'on unwrapped elements, the browser hits the background-html-view',
(WidgetTester tester) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'dart:ui_web' as ui_web;

import 'package:flutter/material.dart';
import 'package:pointer_interceptor_platform_interface/pointer_interceptor_platform_interface.dart';
import 'package:pointer_interceptor_web/pointer_interceptor_web.dart';

const String _htmlElementViewType = '_htmlElementViewType';
const double _videoWidth = 640;
Expand Down Expand Up @@ -129,6 +130,16 @@ class _MyHomePageState extends State<MyHomePage> {
_clickedOn('transparent-button');
},
),
PointerInterceptorWeb().buildWidget(
intercepting: false,
child:
ElevatedButton(
key: const Key('transparent-button'),
child: const Text('Never calls onPressed'),
onPressed: () {
_clickedOn('transparent-button');
},
)),
PointerInterceptorPlatform.instance.buildWidget(
child: ElevatedButton(
key: const Key('clickable-button'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ dependencies:
cupertino_icons: ^1.0.2
flutter:
sdk: flutter
pointer_interceptor_web:
path: ../../pointer_interceptor_web
pointer_interceptor_platform_interface: ^0.10.0

dev_dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,17 @@ class PointerInterceptorWeb extends PointerInterceptorPlatform {
Widget buildWidget({
required Widget child,
bool debug = false,
bool intercepting = true,
Key? key,
}) {
final String viewType = _getViewType(debug: debug);

if (!_registered) {
_register();
}

if (!intercepting) {
return child;
}
return Stack(
alignment: Alignment.center,
children: <Widget>[
Expand Down