mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

This test fails consistently on mac2 and mac3 with the attached Moto G4
devices but passes consistently on other machines.
Adding a delay of 1s right after driver.connect() in setUpAll() causes
it to pass on the machines in question, which suggests a race condition.
Specifically it looks like connect returns the moment Flutter Driver
identifies that the isolate is up and running, but empirically it looks
like we start running the first test before the UI is actually up. This
triggers a failure wherein we start looking for elements before they're
onstage.
Link to viewport.dart:213 at HEAD:
b2b4665926/packages/flutter/lib/src/widgets/viewport.dart (L213)
Stack trace:
FlutterDriver waitFor should find text "present"
```
DriverError: Error in Flutter application: Uncaught extension error while executing waitFor: NoSuchMethodError: The getter 'visible' was called on null.
Receiver: null
Tried calling: visible
#0 Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:46:5)
#1 _ViewportElement.debugVisitOnstageChildren. (package:flutter/src/widgets/viewport.dart:213:36)
#2 WhereIterator.moveNext (dart:_internal/iterable.dart:439:11)
#3 Iterable.forEach (dart:core/iterable.dart)
#4 _ViewportElement.debugVisitOnstageChildren (package:flutter/src/widgets/viewport.dart:214:8)
#5 _DepthFirstChildIterator._reverseChildrenOf (package:flutter_test/src/all_elements.dart:54:15)
#6 _DepthFirstChildIterator.moveNext (package:flutter_test/src/all_elements.dart:45:19)
#7 CachingIterable._fillNext (package:flutter/src/foundation/basic_types.dart:252:27)
#8 _LazyListIterator.moveNext (package:flutter/src/foundation/basic_types.dart:279:21)
#9 WhereIterator.moveNext (dart:_internal/iterable.dart:438:22)
#10 CachingIterable._fillNext (package:flutter/src/foundation/basic_types.dart:252:27)
#11 _LazyListIterator.moveNext (package:flutter/src/foundation/basic_types.dart:279:21)
#12 Iterable.isEmpty (dart:core/iterable.dart:449:33)
#13 Iterable.isNotEmpty (dart:core/iterable.dart:456:27)
#14 FlutterDriverExtension._waitForElement. (package:flutter_driver/src/extension/extension.dart:215:51)
#15 FlutterDriverExtension._waitUntilFrame (package:flutter_driver/src/extension/extension.dart:197:19)
#16 FlutterDriverExtension._waitForElement (package:flutter_driver/src/extension/extension.dart:215:11)
#17 FlutterDriverExtension._waitFor (package:flutter_driver/src/extension/extension.dart:286:11)
#18 FlutterDriverExtension.call (package:flutter_driver/src/extension/extension.dart:168:51)
#19 BindingBase.registerServiceExtension. (package:flutter/src/foundation/binding.dart:370:32)
```
Removes a previous hack that no longer appears to help (adding a 1
second delay in setUpAll() does seem to work around this issue though).
94 lines
2.8 KiB
Dart
94 lines
2.8 KiB
Dart
// Copyright 2017 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
import 'package:flutter_driver/driver_extension.dart';
|
|
|
|
void main() {
|
|
enableFlutterDriverExtension();
|
|
runApp(new DriverTestApp());
|
|
}
|
|
|
|
class DriverTestApp extends StatefulWidget {
|
|
@override
|
|
State<StatefulWidget> createState() {
|
|
return new DriverTestAppState();
|
|
}
|
|
}
|
|
|
|
class DriverTestAppState extends State<DriverTestApp> {
|
|
bool present = true;
|
|
Letter _selectedValue = Letter.a;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return new MaterialApp(
|
|
home: new Scaffold(
|
|
appBar: new AppBar(
|
|
title: const Text('FlutterDriver test'),
|
|
),
|
|
body: new ListView(
|
|
padding: const EdgeInsets.all(5.0),
|
|
children: <Widget>[
|
|
new Row(
|
|
children: <Widget>[
|
|
new Expanded(
|
|
child: new Text(present ? 'present' : 'absent'),
|
|
),
|
|
new RaisedButton(
|
|
child: const Text(
|
|
'toggle',
|
|
key: const ValueKey<String>('togglePresent'),
|
|
),
|
|
onPressed: () {
|
|
setState(() {
|
|
present = !present;
|
|
});
|
|
},
|
|
),
|
|
],
|
|
),
|
|
new Row(
|
|
children: <Widget>[
|
|
const Expanded(
|
|
child: const Text('hit testability'),
|
|
),
|
|
new DropdownButton<Letter>(
|
|
key: const ValueKey<String>('dropdown'),
|
|
value: _selectedValue,
|
|
onChanged: (Letter newValue) {
|
|
setState(() {
|
|
_selectedValue = newValue;
|
|
});
|
|
},
|
|
items: const <DropdownMenuItem<Letter>>[
|
|
const DropdownMenuItem<Letter>(
|
|
value: Letter.a,
|
|
child: const Text('Aaa', key: const ValueKey<String>('a')),
|
|
),
|
|
const DropdownMenuItem<Letter>(
|
|
value: Letter.b,
|
|
child: const Text('Bbb', key: const ValueKey<String>('b')),
|
|
),
|
|
const DropdownMenuItem<Letter>(
|
|
value: Letter.c,
|
|
child: const Text('Ccc', key: const ValueKey<String>('c')),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
const TextField(
|
|
key: const ValueKey<String>('enter-text-field'),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
enum Letter { a, b, c }
|