forked from jonataslaw/VideoCompress
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from dhitiwatAgoda/integration-test
Add Integration test & workaround Android audio transcoding issue
- Loading branch information
Showing
7 changed files
with
185 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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,34 @@ | ||
name: Integration Test | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
iOS-Test: | ||
runs-on: macos-latest | ||
timeout-minutes: 15 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: subosito/flutter-action@v1 | ||
- run: flutter emulators --launch apple_ios_simulator | ||
- run: flutter drive --target=test_driver/app.dart | ||
working-directory: example | ||
|
||
Android-Test: | ||
# Linux machine doesn't support running Android emulator due to lack of nested virtualization | ||
runs-on: macos-latest | ||
timeout-minutes: 30 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: subosito/flutter-action@v1 | ||
- run: $ANDROID_HOME/tools/bin/sdkmanager "system-images;android-27;google_apis_playstore;x86" | ||
- run: flutter emulators --create | ||
- run: flutter emulators --launch flutter_emulator | ||
- run: adb wait-for-device | ||
- run: flutter drive --target=test_driver/app.dart | ||
working-directory: example |
This file contains 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
Binary file not shown.
This file contains 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 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 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,7 @@ | ||
import 'package:flutter_driver/driver_extension.dart'; | ||
import 'package:video_compress_example/main.dart' as app; | ||
|
||
void main() { | ||
enableFlutterDriverExtension(); | ||
app.main(); | ||
} |
This file contains 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,46 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:flutter_driver/flutter_driver.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
final useSampleVideoBtnFinder = find.byValueKey('use_sample_video'); | ||
final clearCacheBtnFinder = find.byValueKey('clear_cache'); | ||
final statusFinder = find.byValueKey('status'); | ||
final outputFileSizeFinder = find.byValueKey('output_file_size'); | ||
|
||
FlutterDriver driver; | ||
|
||
setUpAll(() async { | ||
driver = await FlutterDriver.connect(); | ||
}); | ||
|
||
tearDownAll(() async { | ||
if (driver != null) { | ||
driver.close(); | ||
} | ||
}); | ||
|
||
test('compress video and clear cache', () async { | ||
expect(await driver.getText(statusFinder), 'init'); | ||
|
||
// Initialize compression | ||
await driver.tap(useSampleVideoBtnFinder); | ||
|
||
// Wait for compression to finish | ||
await driver.waitFor(find.text('compressed')); | ||
|
||
// Output file should not be empty and should be smaller than original size | ||
final originalSize = await File('assets/samples/sample.mp4').length(); | ||
final outputSize = int.parse(await driver.getText(outputFileSizeFinder)); | ||
expect(outputSize, greaterThan(0)); | ||
expect(outputSize, lessThan(originalSize)); | ||
|
||
// Clear the cache | ||
await driver.tap(clearCacheBtnFinder); | ||
|
||
// After clear cache, output file should be deleted | ||
await driver.waitFor(find.text('cache cleared')); | ||
expect(await driver.getText(outputFileSizeFinder), "-1"); | ||
}); | ||
} |