Last active
June 19, 2019 10:18
-
-
Save Pyozer/3d3830ea74c7d069dc5f91b5e3f6641b to your computer and use it in GitHub Desktop.
SplashScreen codes, one that is not working and another that's works.
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
| import 'dart:io'; | |
| import 'package:flutter_driver/flutter_driver.dart'; | |
| import 'package:test/test.dart'; | |
| void main() { | |
| group('Testing app', () { | |
| FlutterDriver driver; | |
| // Connect to the Flutter driver before running any tests. | |
| setUpAll(() async { | |
| driver = await FlutterDriver.connect(); | |
| }); | |
| // Close the connection to the driver after the tests have completed. | |
| tearDownAll(() async { | |
| if (driver != null) { | |
| driver.close(); | |
| } | |
| }); | |
| Future<void> tap(SerializableFinder finder) async { | |
| await driver.waitFor(finder); | |
| await driver.tap(finder); | |
| } | |
| // This test is working | |
| test('Check flutter driver health', () async { | |
| Health health = await driver.checkHealth(); | |
| expect(health.status, HealthStatus.ok); | |
| }); | |
| // This test is working | |
| test('Test onboarding', () async { | |
| await tap(find.text("Skip")); | |
| await tap(find.text("Done")); | |
| }); | |
| // This test is not working if there is the Align widget | |
| test('Test splashscreen', () async { | |
| await driver.waitFor(find.text("Loading")); | |
| }); | |
| // This test is not working, but I think it's same issue as the splashscreen | |
| test('Click on site ESCP Europe - République', () async { | |
| await Future.delayed(const Duration(seconds: 10)); | |
| await tap(find.text("ESCP Europe - République")); | |
| }); | |
| // This test is working | |
| test('Test to like multiple times a site', () async { | |
| for (var i = 0; i < 100; i++) { | |
| await tap(find.byType("FavButton")); | |
| await Future.delayed(Duration(milliseconds: 300)); | |
| } | |
| }); | |
| // This test is working | |
| test('Test booking', () async { | |
| await tap(find.text("Book")); | |
| await tap(find.text("Group study rooms")); | |
| await tap(find.byValueKey("bookRes750")); | |
| await tap(find.byValueKey("booking_email")); | |
| await driver.enterText("jeancharles.msse@gmail.com"); | |
| }); | |
| }); | |
| } |
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
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| body: Stack( | |
| alignment: Alignment.center, | |
| children: [ | |
| SplashScreenLogo(), | |
| SafeArea( | |
| child: Padding( | |
| padding: const EdgeInsets.all(20.0), | |
| child: Column( | |
| crossAxisAlignment: CrossAxisAlignment.stretch, | |
| children: [ | |
| FutureBuilder<PackageInfo>( | |
| future: PackageInfo.fromPlatform(), | |
| builder: (context, snap) { | |
| if (!snap.hasData) return Text(""); | |
| return Text( | |
| '${snap.data.version} (${snap.data.buildNumber})', | |
| textAlign: TextAlign.end, | |
| style: const TextStyle(color: Colors.black26), | |
| ); | |
| }, | |
| ), | |
| const Expanded(child: SizedBox.shrink()), | |
| Text( | |
| "Loading", | |
| textAlign: TextAlign.center, | |
| style: const TextStyle(fontSize: 18.0), | |
| ), | |
| const SizedBox(height: 24.0), | |
| _isLoading | |
| ? const SizedBox.shrink() | |
| : Center(child: RetryButton(onPress: _initAllData)), | |
| ], | |
| ), | |
| ), | |
| ), | |
| Align( | |
| alignment: Alignment.bottomCenter, | |
| child: LinearProgressIndicator(value: _isLoading ? null : 0), | |
| ), | |
| ], | |
| ), | |
| ); | |
| } |
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
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| body: Stack( | |
| alignment: Alignment.center, | |
| children: [ | |
| SplashScreenLogo(), | |
| SafeArea( | |
| child: Padding( | |
| padding: const EdgeInsets.all(20.0), | |
| child: Column( | |
| crossAxisAlignment: CrossAxisAlignment.stretch, | |
| children: [ | |
| FutureBuilder<PackageInfo>( | |
| future: PackageInfo.fromPlatform(), | |
| builder: (context, snap) { | |
| if (!snap.hasData) return Text(""); | |
| return Text( | |
| '${snap.data.version} (${snap.data.buildNumber})', | |
| textAlign: TextAlign.end, | |
| style: const TextStyle(color: Colors.black26), | |
| ); | |
| }, | |
| ), | |
| const Expanded(child: SizedBox.shrink()), | |
| Text( | |
| "Loading", | |
| textAlign: TextAlign.center, | |
| style: const TextStyle(fontSize: 18.0), | |
| ), | |
| const SizedBox(height: 24.0), | |
| _isLoading | |
| ? const SizedBox.shrink() | |
| : Center(child: RetryButton(onPress: _initAllData)), | |
| ], | |
| ), | |
| ), | |
| ), | |
| /* | |
| If Align widget is remove, or LinearProgressIndicator is replaced by a Container, it's working | |
| Align( | |
| alignment: Alignment.bottomCenter, | |
| child: Container(height: 20.0, color: Colors.red), | |
| ), | |
| */ | |
| ], | |
| ), | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment