-
-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add GitHub Actions, Tests and Integration Tests to ensure further quality * Fix double and null handling on Android * Fix HomeWidget.updateWidget not completing on Android (Fixes #26)
- Loading branch information
Showing
16 changed files
with
452 additions
and
93 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,77 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
quality: | ||
name: Quality Checks | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: subosito/flutter-action@v1.4.0 | ||
with: | ||
channel: stable | ||
- name: Get Packages | ||
run: flutter pub get | ||
- name: Analyze | ||
run: flutter analyze | ||
- name: Format | ||
run: flutter format . --set-exit-if-changed | ||
- name: Publishability | ||
run: flutter pub publish --dry-run | ||
- name: Test | ||
run: flutter test --coverage | ||
- uses: VeryGoodOpenSource/very_good_coverage@v1.1.1 | ||
|
||
android: | ||
name: Android Integration Tests | ||
runs-on: macos-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: subosito/flutter-action@v1.4.0 | ||
with: | ||
channel: stable | ||
- name: Run Android Integration Tests | ||
uses: reactivecircus/android-emulator-runner@v2 | ||
with: | ||
api-level: 29 | ||
working-directory: example | ||
script: flutter drive --driver=test_driver/integration_test.dart --target=integration_test/android_test.dart -d emulator-5554 | ||
|
||
# iOS Test based on https://medium.com/flutter-community/run-flutter-driver-tests-on-github-actions-13c639c7e4ab | ||
# by @kate_sheremet | ||
ios: | ||
name: iOS Integration Tests | ||
strategy: | ||
matrix: | ||
device: | ||
- "iPhone 12 Pro Max (14.4)" | ||
fail-fast: false | ||
runs-on: macOS-latest | ||
steps: | ||
- name: List Available Devices | ||
run: xcrun xctrace list devices 2>&1 | ||
- name: Set Simulator Id | ||
run: | | ||
echo "::set-output name=UDID::$(xcrun xctrace list devices 2>&1 | | ||
awk -F '( |\\()' \ | ||
-v 'device=${{ matrix.device }}' \ | ||
'length($0) == length(device)+39 && substr($0,0,length(device)) == device { print substr($NF,0, length($NF) - 1)}')" | ||
id: udid | ||
- name: "Start Simulator" | ||
run: | | ||
xcrun simctl boot "${{steps.udid.outputs.UDID}}" | ||
- uses: actions/checkout@v2 | ||
- uses: subosito/flutter-action@v1 | ||
with: | ||
channel: stable | ||
- name: "Run iOS integration tests" | ||
run: flutter drive --driver=test_driver/integration_test.dart --target=integration_test/ios_test.dart -d ${{steps.udid.outputs.UDID}} | ||
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
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 |
---|---|---|
@@ -1,61 +1,5 @@ | ||
# include: package:pedantic/analysis_options.yaml | ||
# Directly specify rules to work around https://github.com/dart-lang/sdk/issues/42910 | ||
|
||
analyzer: | ||
exclude: example/** | ||
include: package:flutter_lints/flutter.yaml | ||
|
||
linter: | ||
rules: | ||
- always_declare_return_types | ||
- always_require_non_null_named_parameters | ||
- annotate_overrides | ||
- avoid_init_to_null | ||
- avoid_null_checks_in_equality_operators | ||
- avoid_relative_lib_imports | ||
- avoid_return_types_on_setters | ||
- avoid_shadowing_type_parameters | ||
- avoid_single_cascade_in_expression_statements | ||
- avoid_types_as_parameter_names | ||
- await_only_futures | ||
- camel_case_extensions | ||
- curly_braces_in_flow_control_structures | ||
- empty_catches | ||
- empty_constructor_bodies | ||
- library_names | ||
- library_prefixes | ||
- no_duplicate_case_values | ||
- null_closures | ||
- omit_local_variable_types | ||
- prefer_adjacent_string_concatenation | ||
- prefer_collection_literals | ||
- prefer_conditional_assignment | ||
- prefer_contains | ||
- prefer_equal_for_default_values | ||
- prefer_final_fields | ||
- prefer_for_elements_to_map_fromIterable | ||
- prefer_generic_function_type_aliases | ||
- prefer_if_null_operators | ||
- prefer_inlined_adds | ||
- prefer_is_empty | ||
- prefer_is_not_empty | ||
- prefer_iterable_whereType | ||
- prefer_single_quotes | ||
- prefer_spread_collections | ||
- recursive_getters | ||
- slash_for_doc_comments | ||
- sort_child_properties_last | ||
- type_init_formals | ||
- unawaited_futures | ||
- unnecessary_brace_in_string_interps | ||
- unnecessary_const | ||
- unnecessary_getters_setters | ||
- unnecessary_new | ||
- unnecessary_null_in_if_null_operators | ||
- unnecessary_this | ||
- unrelated_type_equality_checks | ||
- unsafe_html | ||
- use_full_hex_values_for_flutter_colors | ||
- use_function_type_syntax_for_parameters | ||
- use_rethrow_when_possible | ||
- valid_regexps | ||
- public_member_api_docs |
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
Empty file.
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,61 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:home_widget/home_widget.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
|
||
void main() { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
final testData = <String, dynamic>{ | ||
'stringKey': 'stringValue', | ||
'intKey': 12, | ||
'boolKey': true, | ||
'floatingNumberKey': 12.1, | ||
'nullValueKey': null, | ||
}; | ||
|
||
final defaultValue = MapEntry('defaultKey', 'defaultValue'); | ||
|
||
setUpAll(() { | ||
// Clear all Data | ||
for (final key in testData.keys) { | ||
HomeWidget.saveWidgetData(key, null); | ||
} | ||
}); | ||
|
||
group('Test Data operations', () { | ||
for (final testSet in testData.entries) { | ||
testWidgets('Test ${testSet.value?.runtimeType}', (tester) async { | ||
// Save Data | ||
await HomeWidget.saveWidgetData(testSet.key, testSet.value); | ||
|
||
final retrievedData = await HomeWidget.getWidgetData(testSet.key); | ||
expect(retrievedData, testSet.value); | ||
}); | ||
} | ||
|
||
testWidgets('Delte Value successful', (tester) async { | ||
final initialData = await HomeWidget.getWidgetData(testData.keys.first); | ||
expect(initialData, testData.values.first); | ||
|
||
await HomeWidget.saveWidgetData(testData.values.first, null); | ||
|
||
final deletedData = await HomeWidget.getWidgetData(testData.keys.first); | ||
expect(deletedData, testData.values.first); | ||
}); | ||
|
||
testWidgets('Returns default Value', (tester) async { | ||
final returnValue = await HomeWidget.getWidgetData(defaultValue.key, | ||
defaultValue: defaultValue.value); | ||
|
||
expect(returnValue, defaultValue.value); | ||
}); | ||
}); | ||
|
||
testWidgets('Update Widget completes', (tester) async { | ||
final returnValue = await HomeWidget.updateWidget( | ||
name: 'HomeWidgetExampleProvider', | ||
).timeout(Duration(seconds: 5)); | ||
|
||
expect(returnValue, true); | ||
}); | ||
} |
Oops, something went wrong.