Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
646 additions
and
760 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
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 |
---|---|---|
|
@@ -11,3 +11,5 @@ fastlane/report.xml | |
coverage | ||
test-results | ||
/vendor | ||
|
||
/.vscode |
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,44 @@ | ||
## Tests | ||
|
||
### Re-generating demo project | ||
|
||
Create a new Flutter project: | ||
|
||
```shell | ||
$ flutter create demo | ||
$ cd demo | ||
``` | ||
|
||
Edit pubspec.yaml: | ||
|
||
```diff | ||
dev_dependencies: | ||
flutter_test: | ||
sdk: flutter | ||
|
||
+ intl_translation: any | ||
+ build_runner: any | ||
``` | ||
|
||
Install dependencies: | ||
|
||
```shell | ||
$ flutter packages get | ||
``` | ||
|
||
Create file `lib/intl/intl.dart`: | ||
|
||
```dart | ||
import 'dart:async'; | ||
import 'messages_all.dart'; | ||
import 'package:intl/intl.dart'; | ||
class DemoIntl { | ||
String get helloWorld => Intl.message( | ||
'Hello, World!', | ||
name: 'helloWorld', | ||
desc: 'Text displayed in the center of the login screen', | ||
); | ||
} | ||
``` |
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,13 +1,132 @@ | ||
default_platform(:android) | ||
|
||
desc "Useful on CI, this lane installs Flutter and accepts some of the Android" | ||
desc "SDK licenses. Note that it does not install Android SDK itself, which is" | ||
desc "installed by Gradle automatically during the first build." | ||
desc "Nevertheless, ANDROID_SDK_ROOT or ANDROID_HOME environment variable must" | ||
desc "point to a destination directory (which might be empty)." | ||
lane :bootstrap do | ||
flutter_bootstrap(android_licenses: { | ||
'android-sdk-license' => '24333f8a63b6825ea9c5514f83c2829b004d1fee', | ||
}) | ||
end | ||
|
||
desc "Generate files, format, lint and build project." | ||
lane :build do | ||
flutter(action: 'l10n', | ||
l10n_strings_file: 'lib/messages.dart', | ||
l10n_reformat_arb: true) | ||
flutter(action: 'format') | ||
flutter(action: 'analyze') | ||
# Generate intl and other files. | ||
flutter_generate( | ||
# File with all the Intl.message() calls. | ||
intl_strings_file: 'lib/strings.dart', | ||
# Actual locale of default values provided in that Dart file. | ||
intl_strings_locale: 'en_US', | ||
) | ||
|
||
# Reformat the source code. | ||
flutter(args: %w(format .)) | ||
|
||
# Uncomment the following on CI. For Git repositories, it will verify that | ||
# 'format' and 'generate' actions didn't change anything from what a developer | ||
# has been doing. | ||
# ensure_git_status_clean | ||
|
||
# Lint (statically find errors). | ||
flutter(args: %w(analyze lib)) | ||
|
||
# Build a debug version of the app (release will require signing config). | ||
flutter_build( | ||
debug: true, | ||
# Uncomment to build an AAB instead of an APK (requires adb, why?!). | ||
# build: 'appbundle', | ||
# Override version from pubspec.yaml. | ||
build_number: 123, | ||
build_name: '1.2.3', | ||
) | ||
end | ||
|
||
platform :android do | ||
lane :build do | ||
flutter(action: 'build', debug: true) | ||
######## Internal tests for the plugin ######## | ||
|
||
desc "This is an internal test for Fastlane Flutter plugin. You shouldn't" | ||
desc "need to do anything like that in your Fastfile." | ||
desc "It uses 'bootstrap' lane from above to install Flutter, then creates a" | ||
desc "temporary (but real) Flutter project, and builds it via 'build' lane." | ||
lane :end_to_end_test do | ||
Dir.mktmpdir('fastlane-plugin-flutter-') do |root| | ||
# Override environment in case Flutter / Android SDK is preinstalled. In | ||
# this test, we want to really test full installation procedure. | ||
ENV.delete('ANDROID_HOME') | ||
ENV['ANDROID_SDK_ROOT'] = File.join(root, 'android') | ||
ENV['FLUTTER_SDK_ROOT'] = File.join(root, 'flutter') | ||
|
||
# Install our dependencies to this temporary directory. | ||
bootstrap | ||
|
||
app = File.join(root, 'fastlanetest') | ||
flutter(args: ['create', app]) | ||
|
||
# A little hack. Since Fastlane always runs actions in 1 directory level | ||
# above current, we have to chdir 1 level into application dir structure: | ||
# https://docs.fastlane.tools/advanced/fastlane/#directory-behavior | ||
fastlane = File.join(app, 'fastlane') | ||
Dir.mkdir(fastlane) | ||
Dir.chdir(fastlane) do | ||
# Add dependencies on built_value and intl, and add some code to trigger | ||
# (and validate) generators. | ||
pubspec = File.join('..', 'pubspec.yaml') | ||
File.write(pubspec, File.read(pubspec).sub( | ||
"dependencies:", | ||
"dependencies:\n" \ | ||
" built_value:\n" | ||
).sub( | ||
"dev_dependencies:", | ||
"dev_dependencies:\n" \ | ||
" build_runner:\n" \ | ||
" built_value_generator:\n" \ | ||
" intl_translation:\n" | ||
)) | ||
|
||
File.write(File.join('..', 'lib', 'strings.dart'), <<-'DART') | ||
import 'package:intl/intl.dart'; | ||
class Strings { | ||
static String get helloWorld => Intl.message( | ||
'Hello World', | ||
name: 'helloWorld', | ||
desc: 'Hello World text on the splash screen', | ||
); | ||
} | ||
DART | ||
|
||
File.write(File.join('..', 'lib', 'message.dart'), <<-'DART') | ||
import 'package:built_value/built_value.dart'; | ||
part 'message.g.dart'; | ||
abstract class Message implements Built<Message, MessageBuilder> { | ||
String get text; | ||
factory Message([void Function(MessageBuilder) updates]) = _$Message; | ||
Message._(); | ||
} | ||
DART | ||
|
||
File.write(File.join('..', 'lib', 'splash.dart'), <<-'DART') | ||
import 'strings.dart'; | ||
import 'message.dart'; | ||
// messages_all.dart file should be generated by Intl. | ||
import 'messages_all.dart' as messages_all; | ||
Future<Message> splashScreenMessage() async { | ||
await messages_all.initializeMessages('en_US'); | ||
// MessageBuilder class should be generated by built_value. | ||
return (MessageBuilder()..text = Strings.helloWorld).build(); | ||
} | ||
DART | ||
|
||
# Now that we've created our test application, run a real lane. | ||
build | ||
|
||
# Call build one more time with files already generated, as we expect it | ||
# to be idempotent. | ||
build | ||
|
||
# Call bootstrap one more time with Flutter already installed. This is | ||
# to ensure that upgrade path in our plugin is working correctly. | ||
bootstrap | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.