diff --git a/quicklogin/.gitignore b/quicklogin/.gitignore deleted file mode 100644 index 796b96d1c40..00000000000 --- a/quicklogin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/quicklogin/build.gradle b/quicklogin/build.gradle deleted file mode 100644 index 777990b5d42..00000000000 --- a/quicklogin/build.gradle +++ /dev/null @@ -1,102 +0,0 @@ -plugins { - alias(libs.plugins.android.test) - alias(libs.plugins.kotlin.android) -} - -repositories { - maven { - url 'https://a8c-libs.s3.amazonaws.com/android' - content { - includeGroup "org.wordpress" - includeGroup "org.wordpress.fluxc" - includeGroup "org.wordpress.fluxc.plugins" - includeGroup "org.wordpress.wellsql" - includeGroup "org.wordpress.mediapicker" - includeGroup "com.automattic" - includeGroup "com.automattic.tracks" - } - } - maven { - url 'https://zendesk.jfrog.io/zendesk/repo' - content { - includeGroup "com.zendesk" - includeGroup "com.zendesk.belvedere2" - } - } - mavenCentral() - maven { - url "https://a8c-libs.s3.amazonaws.com/android/jcenter-mirror" - content { - includeVersion "com.android.volley", "volley", "1.1.1" - includeVersion "com.google.android", "flexbox", "2.0.1" - includeVersion "com.jraska", "falcon", "2.1.1" - includeVersion "org.wordpress", "wellsql", "1.6.0" - includeVersion "org.wordpress", "wellsql-core", "1.6.0" - } - } - maven { - url "https://jitpack.io" - content { - includeModule("com.github.Automattic", "Automattic-Tracks-Android") - includeModule("com.github.wordpress-mobile.WordPress-Aztec-Android", "aztec") - includeModule("com.github.wordpress-mobile.WordPress-Aztec-Android", "glide-loader") - includeModule("com.github.chrisbanes", "PhotoView") - includeModule("com.github.PhilJay", "MPAndroidChart") - } - } -} - -android { - namespace "com.woocommerce.android.quicklogin" - - compileSdkVersion gradle.ext.compileSdkVersion - - defaultConfig { - minSdkVersion gradle.ext.minSdkVersion - targetSdkVersion gradle.ext.targetSdkVersion - - missingDimensionStrategy 'buildType', 'wasabi' - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - testApplicationId "com.woocommerce.android.dev.quicklogin" - - buildConfigField "String", "QUICK_LOGIN_WP_EMAIL", "\"${project.getProperties().get("quickLoginWpEmail")}\"" - buildConfigField "String", "QUICK_LOGIN_WP_PASSWORD", "\"${project.getProperties().get("quickLoginWpPassword")}\"" - buildConfigField "String", "QUICK_LOGIN_WP_SITE", "\"${project.getProperties().get("quickLoginWpSite")}\"" - } - - compileOptions { - sourceCompatibility libs.versions.java.get() - targetCompatibility libs.versions.java.get() - } - - buildFeatures { - buildConfig true - } - - targetProjectPath ':WooCommerce' -} - -dependencies { - implementation(libs.androidx.lifecycle.process) - - implementation(libs.androidx.test.uiautomator) - implementation(libs.junit) - implementation(libs.androidx.test.ext.junit) - implementation(libs.androidx.test.main.runner) - implementation(libs.androidx.test.main.rules) - implementation(libs.androidx.test.main.core) -} - -if (project.hasProperty("debugStoreFile")) { - def sharedDebugStore = file(project.debugStoreFile.replaceFirst("^~", System.getProperty("user.home"))) - if (sharedDebugStore.exists()) { - android { - signingConfigs { - debug { - storeFile sharedDebugStore - } - } - } - } -} diff --git a/quicklogin/src/main/AndroidManifest.xml b/quicklogin/src/main/AndroidManifest.xml deleted file mode 100644 index 8072ee00dbf..00000000000 --- a/quicklogin/src/main/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/quicklogin/src/main/kotlin/com/woocommerce/android/quicklogin/QuickLoginWordpress.kt b/quicklogin/src/main/kotlin/com/woocommerce/android/quicklogin/QuickLoginWordpress.kt deleted file mode 100644 index f14af966a89..00000000000 --- a/quicklogin/src/main/kotlin/com/woocommerce/android/quicklogin/QuickLoginWordpress.kt +++ /dev/null @@ -1,161 +0,0 @@ -package com.woocommerce.android.quicklogin - -import android.content.ClipboardManager -import android.content.Context -import android.content.Intent -import androidx.test.core.app.ApplicationProvider -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.uiautomator.By -import androidx.test.uiautomator.Direction.DOWN -import androidx.test.uiautomator.UiDevice -import androidx.test.uiautomator.UiObject2 -import androidx.test.uiautomator.Until -import com.woocommerce.android.AppPrefs -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith - -private const val DEBUG_PACKAGE_NAME = "com.woocommerce.android.dev" -private const val SHORT_TIMEOUT = 2000L -private const val TIMEOUT = 5000L -private const val LONG_TIMEOUT = 60000L - -private const val SECOND_FACTOR_LENGTH = 6 -private const val SITE_FLINGS_COUNT = 10 - -@RunWith(AndroidJUnit4::class) -class QuickLoginWordpress { - private val instrumentation = InstrumentationRegistry.getInstrumentation() - private val device = UiDevice.getInstance(instrumentation) - private val context = ApplicationProvider.getApplicationContext() - - @Before - fun init() { - AppPrefs.init(context) - } - - @Test - fun loginWithWordpress() { - verifyEmailAndPassword() - startTheApp() - chooseWpComLogin() - enterEmail() - enterPassword() - enterSecondFactorIfNeeded() - selectSiteIfProvided() - } - - private fun verifyEmailAndPassword() { - if (BuildConfig.QUICK_LOGIN_WP_EMAIL.isBlank() || - BuildConfig.QUICK_LOGIN_WP_PASSWORD.isBlank() - ) { - exitFlowWithMessage("WP Email or password is not set. Look into quicklogin/woo_login.sh-example") - } - } - - private fun startTheApp() { - device.pressHome() - - device.wait(Until.hasObject(By.pkg(device.launcherPackageName).depth(0)), TIMEOUT) - - val launchIntentForPackage = context.packageManager.getLaunchIntentForPackage(DEBUG_PACKAGE_NAME) - if (launchIntentForPackage == null) exitFlowWithMessage("$DEBUG_PACKAGE_NAME is not installed") - val intent = launchIntentForPackage?.apply { addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK) } - context.startActivity(intent) - - device.wait( - Until.hasObject(By.pkg(DEBUG_PACKAGE_NAME).depth(0)), - TIMEOUT - ) - } - - private fun chooseWpComLogin() { - val loginWithWpButton = device - .wait(Until.findObject(By.res(DEBUG_PACKAGE_NAME, "button_login_wpcom")), TIMEOUT) - - if (loginWithWpButton == null) exitFlowWithMessage("You are logged in already") - - loginWithWpButton.click() - } - - private fun enterEmail() { - val emailInputField = device - .wait(Until.findObject(By.res(DEBUG_PACKAGE_NAME, "input")), TIMEOUT) - val continueButton = device - .wait(Until.findObject(By.res(DEBUG_PACKAGE_NAME, "login_continue_button")), TIMEOUT) - - emailInputField.text = BuildConfig.QUICK_LOGIN_WP_EMAIL - continueButton.click() - } - - private fun enterPassword() { - val passwordInputField = device - .wait(Until.findObject(By.res(DEBUG_PACKAGE_NAME, "input")), TIMEOUT) - val continueButton = device - .wait(Until.findObject(By.res(DEBUG_PACKAGE_NAME, "bottom_button")), TIMEOUT) - - if (passwordInputField == null) exitFlowWithMessage("Check used email address") - - passwordInputField.text = BuildConfig.QUICK_LOGIN_WP_PASSWORD - continueButton.click() - } - - private fun enterSecondFactorIfNeeded() { - device - .wait(Until.findObject(By.res(DEBUG_PACKAGE_NAME, "login_otp_button")), TIMEOUT) - ?: return - - val secondFactorInputField = device - .wait(Until.findObject(By.res(DEBUG_PACKAGE_NAME, "input")), TIMEOUT) - - val continueButton = device - .wait(Until.findObject(By.res(DEBUG_PACKAGE_NAME, "bottom_button")), TIMEOUT) - - instrumentation.runOnMainSync { - val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager - if (clipboard.hasPrimaryClip() && - clipboard.primaryClip!!.getItemAt(0).text.length == SECOND_FACTOR_LENGTH - ) { - secondFactorInputField.text = clipboard.primaryClip!!.getItemAt(0).text.toString() - } - } - continueButton.click() - - device.wait(Until.findObject(By.res(DEBUG_PACKAGE_NAME, "site_list_container")), LONG_TIMEOUT) - } - - private fun selectSiteIfProvided() { - if (BuildConfig.QUICK_LOGIN_WP_SITE.isBlank().not()) { - val siteList = device - .wait(Until.findObject(By.res(DEBUG_PACKAGE_NAME, "site_list_container")), TIMEOUT) - ?: return - - val selectedSite = findSelectedSite(siteList) ?: return - - val doneButton = device - .wait(Until.findObject(By.res(DEBUG_PACKAGE_NAME, "button_primary")), TIMEOUT) - - selectedSite.click() - doneButton.click() - - device.wait(Until.findObject(By.res(DEBUG_PACKAGE_NAME, "bottom_nav")), LONG_TIMEOUT) - } - } - - private fun findSelectedSite(siteList: UiObject2): UiObject2? { - fun findSiteToSelect() = device.wait(Until.findObject(By.text(BuildConfig.QUICK_LOGIN_WP_SITE)), SHORT_TIMEOUT) - var selectedSite = findSiteToSelect() - var flingsCount = 0 - while (selectedSite == null && flingsCount < SITE_FLINGS_COUNT) { - siteList.fling(DOWN) - selectedSite = findSiteToSelect() - flingsCount++ - } - return selectedSite - } - - private fun exitFlowWithMessage(message: String) { - throw IllegalStateException(message) - } -} diff --git a/quicklogin/woo_login.sh b/quicklogin/woo_login.sh deleted file mode 100755 index 16ce0d19c44..00000000000 --- a/quicklogin/woo_login.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -e - -# PASS WORDPRESS_EMAIL, WORDPRESS_SITE and WORDPRESS_PASSWORD as env variable to the script -# Optionally pass path to your adb: ADB_PATH -# Example: ADB_PATH=~/Library/Android/sdk/platform-tools/adb WORDPRESS_EMAIL=my_wp_email@gmail.com WORDPRESS_PASSWORD=my_pasword_1_# WORDPRESS_SITE=my_wordpress_site ./quicklogin/woo_login.sh - -if [[ "$ADB_PATH" ]]; then - adbPath="$ADB_PATH" -else - adbPath='~/Library/Android/sdk/platform-tools/adb' -fi - -packageName="com.woocommerce.android.dev" - -eval $adbPath shell pm clear $packageName - -./gradlew installWasabiDebug -./gradlew :quicklogin:installDebug \ --PquickLoginWpEmail="$WORDPRESS_EMAIL" \ --PquickLoginWpPassword="$WORDPRESS_PASSWORD" \ --PquickLoginWpSite="$WORDPRESS_SITE" - -eval $adbPath shell am instrument -w -r -e debug false -e class 'com.woocommerce.android.quicklogin.QuickLoginWordpress' $packageName.quicklogin/androidx.test.runner.AndroidJUnitRunner -eval $adbPath shell am start -n $packageName/com.woocommerce.android.ui.main.MainActivity diff --git a/settings.gradle b/settings.gradle index 6506be3dedd..50ff884ef85 100644 --- a/settings.gradle +++ b/settings.gradle @@ -22,7 +22,6 @@ plugins { rootProject.name = 'WCAndroid' -include ':quicklogin' include ':libs:commons' include ':libs:cardreader' include ':libs:iap'