Skip to content

Commit

Permalink
Appium Flavor (#928)
Browse files Browse the repository at this point in the history
* Added Appium flavor.

* Update browserstack CI

* Update browerstack.yml
  • Loading branch information
jigar-f authored Oct 10, 2023
1 parent 5ff6078 commit bd226a0
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/browerstack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
CI: "true"
run: |
flutter pub get
make do-android-debug ANDROID_ARCH=all
make appium-test-build
- name: List files in current directory
run: ls -la
Expand All @@ -82,7 +82,7 @@ jobs:
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
BROWSERSTACK_APP_PATH: "build/app/outputs/flutter-apk/app-prod-debug.apk"
BROWSERSTACK_APP_PATH: "build/app/outputs/flutter-apk/app-appiumtest-debug.apk"
run: |
response=$(curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
Expand Down
8 changes: 8 additions & 0 deletions .run/Appium Test.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Appium Test" type="FlutterRunConfigurationType" factoryName="Flutter">
<option name="additionalArgs" value="--dart-define=app.flavor=appiumTest" />
<option name="buildFlavor" value="appiumTest" />
<option name="filePath" value="$PROJECT_DIR$/lib/main.dart" />
<method v="2" />
</configuration>
</component>
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,12 @@ $(MOBILE_ANDROID_LIB): $(ANDROID_LIB)
mkdir -p $(MOBILE_LIBS) && \
cp $(ANDROID_LIB) $(MOBILE_ANDROID_LIB)

.PHONY: android-lib
.PHONY: android-lib appium-test-build
android-lib: $(MOBILE_ANDROID_LIB)

appium-test-build:
flutter build apk --flavor=appiumTest --dart-define=app.flavor=appiumTest --debug

$(MOBILE_TEST_APK) $(MOBILE_TESTS_APK): $(MOBILE_SOURCES) $(MOBILE_ANDROID_LIB)
@$(GRADLE) -PandroidArch=$(ANDROID_ARCH) \
-PandroidArchJava="$(ANDROID_ARCH_JAVA)" \
Expand Down
6 changes: 4 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ android {
}

buildTypes {

debug {
debug {
minifyEnabled false
shrinkResources false
debuggable true
Expand Down Expand Up @@ -254,6 +253,9 @@ android {
autoTest {
versionCode 1 // so we can always test auto-update.
}
appiumTest {
buildConfigField "boolean", "CI", "true"
}
}

splits {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ abstract class SessionManager(application: Application) : Session {
val isPaymentTestMode: Boolean
get() {
val paymentTestMode = prefs.getBoolean(PAYMENT_TEST_MODE, false)
val ciValue = BuildConfig.CI
val ciValue = BuildConfig.FLAVOR == "appiumTest"
return ciValue || paymentTestMode
}

Expand Down
9 changes: 5 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import 'package:lantern/common/common.dart';

Future<void> main() async {
// CI will be true only when running appium test
var CI = const String.fromEnvironment('CI', defaultValue: 'false');
var boolCI = bool.fromEnvironment("CI", defaultValue: false);
print('Appium CI is running $CI and bool $boolCI');
if (CI == 'true') {
const String flavor = String.fromEnvironment('app.flavor');
print("Running Flavor $flavor");
if (flavor == 'appiumTest') {
print("Flutter extension enabled $flavor");
enableFlutterDriverExtension();
}

WidgetsFlutterBinding.ensureInitialized();
await _initGoogleMobileAds();
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
Expand Down

0 comments on commit bd226a0

Please sign in to comment.