-
Notifications
You must be signed in to change notification settings - Fork 825
feat: added integration tests #2853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| import 'dart:io'; | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:integration_test/integration_test.dart'; | ||
| import 'package:pslab/constants.dart'; | ||
| import 'package:pslab/main.dart' as app; | ||
| import 'utils.dart'; | ||
|
|
||
| void main() async { | ||
| final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
| setUpAll(() { | ||
| return Future(() async { | ||
| WidgetsApp.debugAllowBannerOverride = false; // Hide the debug banner | ||
| if (Platform.isAndroid) { | ||
| await binding.convertFlutterSurfaceToImage(); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| group('E2E Group', () { | ||
| testWidgets('Take Screenshots', (tester) async { | ||
| app.main(); | ||
| await tester.pumpAndSettle(); | ||
|
|
||
| final instrumentsScreenTitle = | ||
| find.byKey(const ValueKey(instrumentsScreenTitleKey)); | ||
| final powerSourceScreenTitle = | ||
| find.byKey(const ValueKey(powerSourceScreenTitleKey)); | ||
| final multimeterScreenTitle = | ||
| find.byKey(const ValueKey(multimeterScreenTitleKey)); | ||
| final waveGeneratorScreenTitle = | ||
| find.byKey(const ValueKey(waveGeneratorScreenTitleKey)); | ||
| final oscilloscopeScreenTitle = | ||
| find.byKey(const ValueKey(oscilloscopeScreenTitleKey)); | ||
|
|
||
| final notConnectedText = find.text('Not Connected'); | ||
| final backButton = find.byIcon(Icons.arrow_back); | ||
|
|
||
| await pumpUntilFound(tester, instrumentsScreenTitle); | ||
| await binding.takeScreenshot('1_instruments_screen'); | ||
|
|
||
| ScaffoldState state = tester.firstState(find.byType(Scaffold)); | ||
| state.openDrawer(); | ||
| await pumpUntilFound(tester, notConnectedText); | ||
| await tester.pump(const Duration(seconds: 5)); | ||
| await tester.pumpAndSettle(); | ||
| await tester.pump(const Duration(seconds: 5)); | ||
| await tester.pumpAndSettle(); | ||
| await binding.takeScreenshot('2_nav_drawer'); | ||
|
|
||
| state.closeDrawer(); | ||
| await pumpUntilFound(tester, instrumentsScreenTitle); | ||
| await tester.pumpAndSettle(); | ||
|
|
||
| final accelerometerCard = find.text('ACCELEROMETER'); | ||
| await tester.scrollUntilVisible( | ||
| accelerometerCard, | ||
| 200.0, | ||
| scrollable: find.byType(Scrollable), | ||
| ); | ||
| await tester.pumpAndSettle(); | ||
| await tester.tap(accelerometerCard); | ||
| await tester.pump(const Duration(seconds: 5)); | ||
|
|
||
| final infoIcon = find.byIcon(Icons.info); | ||
| await tester.tap(infoIcon); | ||
| await tester.pump(const Duration(seconds: 5)); | ||
| await binding.takeScreenshot('3_accelerometer'); | ||
|
|
||
| final hideGuideText = find.text('Hide Guide'); | ||
| await tester.tap(hideGuideText); | ||
| await tester.pump(const Duration(seconds: 5)); | ||
|
|
||
| await tester.tap(backButton); | ||
| await pumpUntilFound(tester, instrumentsScreenTitle); | ||
|
|
||
| final powerSourceCard = find.text('POWER SOURCE'); | ||
| await tester.scrollUntilVisible( | ||
| powerSourceCard, | ||
| 200.0, | ||
| scrollable: find.byType(Scrollable), | ||
| ); | ||
| await tester.pumpAndSettle(); | ||
| await tester.tap(powerSourceCard); | ||
| await pumpUntilFound(tester, powerSourceScreenTitle); | ||
| await tester.pump(const Duration(seconds: 5)); | ||
| await tester.pumpAndSettle(); | ||
| await tester.pump(const Duration(seconds: 5)); | ||
| await tester.pumpAndSettle(); | ||
| await binding.takeScreenshot('4_power_source'); | ||
|
|
||
| await tester.tap(backButton); | ||
| await pumpUntilFound(tester, instrumentsScreenTitle); | ||
|
|
||
| final multimeterCard = find.text('MULTIMETER'); | ||
| await tester.scrollUntilVisible( | ||
| multimeterCard, | ||
| 200.0, | ||
| scrollable: find.byType(Scrollable), | ||
| ); | ||
| await tester.pumpAndSettle(); | ||
| await tester.tap(multimeterCard); | ||
| await pumpUntilFound(tester, multimeterScreenTitle); | ||
| await tester.pump(const Duration(seconds: 5)); | ||
| await tester.pumpAndSettle(); | ||
| await tester.pump(const Duration(seconds: 5)); | ||
| await tester.pumpAndSettle(); | ||
| await binding.takeScreenshot('5_multimeter'); | ||
|
|
||
| await tester.tap(backButton); | ||
| await pumpUntilFound(tester, instrumentsScreenTitle); | ||
|
|
||
| final waveGeneratorCard = find.text('WAVE GENERATOR'); | ||
| await tester.scrollUntilVisible( | ||
| waveGeneratorCard, | ||
| 200.0, | ||
| scrollable: find.byType(Scrollable), | ||
| ); | ||
| await tester.pumpAndSettle(); | ||
| await tester.tap(waveGeneratorCard); | ||
| await pumpUntilFound(tester, waveGeneratorScreenTitle); | ||
|
|
||
| final freqText = find.text('Freq'); | ||
| await tester.tap(freqText); | ||
| await tester.pump(const Duration(seconds: 5)); | ||
| await tester.pumpAndSettle(); | ||
| await tester.pump(const Duration(seconds: 5)); | ||
| await tester.pumpAndSettle(); | ||
| await binding.takeScreenshot('6_wave_generator'); | ||
|
|
||
| await tester.tap(backButton); | ||
| await pumpUntilFound(tester, instrumentsScreenTitle); | ||
|
|
||
| final oscilloscopeCard = find.text('OSCILLOSCOPE'); | ||
| await tester.scrollUntilVisible( | ||
| oscilloscopeCard, | ||
| 200.0, | ||
| scrollable: find.byType(Scrollable), | ||
| ); | ||
| await tester.pumpAndSettle(); | ||
| await tester.tap(oscilloscopeCard); | ||
| await pumpUntilFound(tester, oscilloscopeScreenTitle); | ||
| await tester.pump(const Duration(seconds: 5)); | ||
| await tester.pumpAndSettle(); | ||
| await tester.pump(const Duration(seconds: 5)); | ||
| await tester.pumpAndSettle(); | ||
| await binding.takeScreenshot('7_oscilloscope'); | ||
| }); | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // ignore_for_file: avoid_print | ||
|
|
||
| import 'dart:io'; | ||
| import 'package:integration_test/integration_test_driver_extended.dart'; | ||
|
|
||
| Future<void> main() async { | ||
| final deviceName = Platform.environment['DEVICE_NAME'] ?? 'unknown_device'; | ||
| final formattedDeviceName = deviceName.replaceAll(RegExp(r'\s+'), '_'); | ||
| await integrationDriver( | ||
| onScreenshot: (String screenshotName, List<int> screenshotBytes, | ||
| [Map<String, Object?>? args]) async { | ||
| final filePath = 'screenshots/$formattedDeviceName-$screenshotName.png'; | ||
| print('Writing screenshot to $filePath'); | ||
|
|
||
| final File image = await File(filePath).create(recursive: true); | ||
| image.writeAsBytesSync(screenshotBytes); | ||
| return true; | ||
| }, | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import 'dart:async'; | ||
|
|
||
| import 'package:flutter_test/flutter_test.dart'; | ||
|
|
||
| Future<void> pumpUntilFound( | ||
| WidgetTester tester, | ||
| Finder finder, { | ||
| Duration timeout = const Duration(seconds: 10), | ||
| }) async { | ||
| bool timerDone = false; | ||
| final timer = Timer(timeout, () => timerDone = true); | ||
| while (timerDone != true) { | ||
| await tester.pumpAndSettle(); | ||
|
|
||
| final found = tester.any(finder); | ||
| if (found) { | ||
| timerDone = true; | ||
| } | ||
| } | ||
| timer.cancel(); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.