Skip to content

Commit

Permalink
[glance_integration_test] Run flutter clean before each test to ensur…
Browse files Browse the repository at this point in the history
…e a clean build (#16)

Fix #10
  • Loading branch information
littleGnAl authored Sep 24, 2024
1 parent 68e00b7 commit 4b0a391
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
14 changes: 11 additions & 3 deletions example/glance_integration_test/_test_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,19 @@ Future<bool> _runTestCase(ProcessManager processManager,
GlanceLogger.log(
'Running TestCase(${testCase.description}, ${testCase.testFilePath}) on ${runOn == RunOnPlatform.android ? 'Android' : 'iOS'} ...',
prefixTag: false);

// Run `flutter clean` to get a clean build.
await processManager.run([
'flutter',
'clean',
]);
GlanceLogger.log('Cleaned cache.', prefixTag: false);
GlanceLogger.log('Building ${testCase.testFilePath} ...', prefixTag: false);
final buildDir = fileSystem.directory('build');
if ((await buildDir.exists())) {
await fileSystem.directory('build').delete(recursive: true);

if ((fileSystem.directory('debug-info-integration').existsSync())) {
fileSystem.directory('debug-info-integration').deleteSync(recursive: true);
}
fileSystem.directory('debug-info-integration').createSync(recursive: true);

final processResult = await processManager.run([
'flutter',
Expand Down
7 changes: 3 additions & 4 deletions example/glance_integration_test/build_phase_jank_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class BuildPhaseJankWidget extends StatefulWidget {
class _BuildPhaseJankWidgetState extends State<BuildPhaseJankWidget> {
bool _isExpensiveBuild = false;

void triggerExpensiveBuild() {
Future<void> triggerExpensiveBuild() async {
await WidgetsBinding.instance.waitUntilFirstFrameRasterized;
setState(() {
_isExpensiveBuild = true;
});
Expand All @@ -27,9 +28,7 @@ class _BuildPhaseJankWidgetState extends State<BuildPhaseJankWidget> {
void initState() {
super.initState();

Future.delayed(const Duration(seconds: 5), () {
triggerExpensiveBuild();
});
triggerExpensiveBuild();
}

@override
Expand Down
8 changes: 4 additions & 4 deletions example/glance_integration_test/touch_event_jank_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ class TouchEventJankWidgetState extends State<TouchEventJankWidget> {
void initState() {
super.initState();

Future.delayed(const Duration(seconds: 5), () {
_click();
});
_click();
}

void _click() {
Future<void> _click() async {
await WidgetsBinding.instance.waitUntilFirstFrameRasterized;

final offset = _getElevatedButtonOffset();

// Simulate click the button
Expand Down

0 comments on commit 4b0a391

Please sign in to comment.