- mid commit

This commit is contained in:
2023-05-15 19:28:11 +01:00
parent e5556cdb8d
commit b12af77a31
17 changed files with 384 additions and 47 deletions

View File

@@ -9,7 +9,7 @@ import h_mal.appttude.com.driver.R
fun home(func: HomeRobot.() -> Unit) = HomeRobot().apply { func() }
class HomeRobot : BaseTestRobot() {
fun checkTitleExists(title: String) = matchText(R.id.prova_title_tv, title)
fun checkTitleExists(title: String) = matchText(matchViewWaitFor(R.id.prova_title_tv), title)
fun openDrawer() {
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())

View File

@@ -2,13 +2,12 @@ package h_mal.appttude.com.driver.robots
import h_mal.appttude.com.driver.FormRobot
import h_mal.appttude.com.driver.R
import h_mal.appttude.com.driver.helpers.PROFILE_PIC
fun updateProfile(func: UpdateProfileRobot.() -> Unit) = UpdateProfileRobot().apply { func() }
class UpdateProfileRobot : FormRobot() {
fun enterName(name: String) = fillEditText(R.id.update_name, name)
// fun selectImage() = selectSingleImage(R.id.profile_img, PROFILE_PIC)
fun selectImage() = selectSingleImage(R.id.profile_img, FilePath.PROFILE_PIC)
fun submitForm(name: String) {
// selectImage()

View File

@@ -1,16 +1,16 @@
package h_mal.appttude.com.driver.robots
package h_mal.appttude.com.driver.robots.driver
import h_mal.appttude.com.driver.FormRobot
import h_mal.appttude.com.driver.R
import h_mal.appttude.com.driver.helpers.LICENSE
import h_mal.appttude.com.driver.helpers.getImagePath
fun driversLicense(func: DriversLicenseRobot.() -> Unit) = DriversLicenseRobot().apply { func() }
class DriversLicenseRobot : FormRobot() {
fun enterLicenseNumber(text: String) = fillEditText(R.id.lic_no, text)
fun enterLicenseExpiry(year: Int, monthOfYear: Int, dayOfMonth: Int) = setDate(R.id.lic_expiry, year, monthOfYear, dayOfMonth)
fun selectImage() = selectSingleImage(R.id.search_image, getImagePath(LICENSE))
fun enterLicenseExpiry(year: Int, monthOfYear: Int, dayOfMonth: Int) =
setDate(R.id.lic_expiry, year, monthOfYear, dayOfMonth)
fun selectImage() = selectSingleImage(R.id.search_image, FilePath.LICENSE)
fun submitForm(licenseNumber: String, year: Int, monthOfYear: Int, dayOfMonth: Int) {
selectImage()
@@ -18,4 +18,10 @@ class DriversLicenseRobot : FormRobot() {
enterLicenseExpiry(year, monthOfYear, dayOfMonth)
submit()
}
fun validate() {
checkImageViewHasImage(R.id.driversli_img)
}
}

View File

@@ -1,6 +1,5 @@
package h_mal.appttude.com.driver.robots
package h_mal.appttude.com.driver.robots.driver
import android.text.InputType
import h_mal.appttude.com.driver.FormRobot
import h_mal.appttude.com.driver.R
@@ -12,15 +11,28 @@ class DriversProfileRobot : FormRobot() {
fun enterPostcode(postcode: String) = fillEditText(R.id.postcode_input, postcode)
fun enterDateOfBirth(dob: String) = fillEditText(R.id.dob_input, dob)
fun enterNINumber(niNumber: String) = fillEditText(R.id.ni_number, niNumber)
fun enterDateFirstAvailable(year: Int, monthOfYear: Int, dayOfMonth: Int) = setDate(R.id.date_first, year, monthOfYear, dayOfMonth)
fun enterDateFirstAvailable(year: Int, monthOfYear: Int, dayOfMonth: Int) =
setDate(R.id.date_first, year, monthOfYear, dayOfMonth)
fun selectImage() = clickButton(R.id.add_photo)
fun selectImage() = selectSingleImage(R.id.add_photo, FilePath.PROFILE_PIC)
fun submitForm(name: String, address: String, postcode: String, dob: String, niNumber: String, year: Int, monthOfYear: Int, dayOfMonth: Int) {
fun submitForm(
name: String,
address: String,
postcode: String,
dob: String,
niNumber: String,
year: Int,
monthOfYear: Int,
dayOfMonth: Int
) {
selectImage()
// TODO: select image in gallery
enterName(name)
enterAddress(address)
enterPostcode(postcode)
enterDateOfBirth(dob)
enterNINumber(niNumber)
enterDateFirstAvailable(year, monthOfYear, dayOfMonth)
submit()
}
}

View File

@@ -0,0 +1,23 @@
package h_mal.appttude.com.driver.robots.driver
import h_mal.appttude.com.driver.FormRobot
import h_mal.appttude.com.driver.R
fun privateHireLicenseRobot(func: PrivateHireLicenseRobot.() -> Unit) =
PrivateHireLicenseRobot().apply { func() }
class PrivateHireLicenseRobot : FormRobot() {
fun enterLicenseNumber(text: String) = fillEditText(R.id.ph_no, text)
fun enterLicenseExpiry(year: Int, monthOfYear: Int, dayOfMonth: Int) =
setDate(R.id.ph_expiry, year, monthOfYear, dayOfMonth)
fun selectImage() = selectSingleImage(R.id.uploadphlic, FilePath.PRIVATE_HIRE)
fun submitForm(licenseNumber: String, year: Int, monthOfYear: Int, dayOfMonth: Int) {
selectImage()
enterLicenseNumber(licenseNumber)
enterLicenseExpiry(year, monthOfYear, dayOfMonth)
submit()
}
}

View File

@@ -0,0 +1,23 @@
package h_mal.appttude.com.driver.robots.vehicle
import h_mal.appttude.com.driver.FormRobot
import h_mal.appttude.com.driver.FormRobot.FilePath.Companion.getFilePath
import h_mal.appttude.com.driver.R
fun insurance(func: InsuranceRobot.() -> Unit) = InsuranceRobot().apply { func() }
class InsuranceRobot : FormRobot() {
fun enterInsurance(text: String) = fillEditText(R.id.insurer, text)
fun enterInsuranceExpiry(year: Int, monthOfYear: Int, dayOfMonth: Int) =
setDate(R.id.insurance_exp, year, monthOfYear, dayOfMonth)
fun selectImages() =
selectMultipleImage(R.id.uploadInsurance, arrayOf(getFilePath(FilePath.INSURANCE)))
fun submitForm(insurer: String, year: Int, monthOfYear: Int, dayOfMonth: Int) {
selectImages()
enterInsurance(insurer)
enterInsuranceExpiry(year, monthOfYear, dayOfMonth)
submit()
}
}

View File

@@ -0,0 +1,18 @@
package h_mal.appttude.com.driver.robots.vehicle
import h_mal.appttude.com.driver.FormRobot
import h_mal.appttude.com.driver.R
fun logbook(func: LogbookRobot.() -> Unit) = LogbookRobot().apply { func() }
class LogbookRobot : FormRobot() {
fun selectImages() = selectSingleImage(R.id.uploadmot, FilePath.MOT)
fun enterExpiryDate(year: Int, monthOfYear: Int, dayOfMonth: Int) =
setDate(R.id.mot_expiry, year, monthOfYear, dayOfMonth)
fun submitForm(year: Int, monthOfYear: Int, dayOfMonth: Int) {
selectImages()
enterExpiryDate(year, monthOfYear, dayOfMonth)
submit()
}
}

View File

@@ -0,0 +1,17 @@
package h_mal.appttude.com.driver.robots.vehicle
import h_mal.appttude.com.driver.FormRobot
import h_mal.appttude.com.driver.R
fun mot(func: MOTRobot.() -> Unit) = MOTRobot().apply { func() }
class MOTRobot : FormRobot() {
fun enterV5cNumber(v5c: String) = fillEditText(R.id.mot_expiry, v5c)
fun selectImages() = selectSingleImage(R.id.mot_expiry, FilePath.LOGBOOK)
fun submitForm(v5c: String) {
selectImages()
enterV5cNumber(v5c)
submit()
}
}

View File

@@ -0,0 +1,23 @@
package h_mal.appttude.com.driver.robots.vehicle
import h_mal.appttude.com.driver.FormRobot
import h_mal.appttude.com.driver.R
fun privateHireVehicleLicense(func: PrivateHireVehicleLicenseRobot.() -> Unit) =
PrivateHireVehicleLicenseRobot().apply { func() }
class PrivateHireVehicleLicenseRobot : FormRobot() {
fun enterLicenseNumber(text: String) = fillEditText(R.id.ph_no, text)
fun enterLicenseExpiry(year: Int, monthOfYear: Int, dayOfMonth: Int) =
setDate(R.id.ph_expiry, year, monthOfYear, dayOfMonth)
fun selectImage() = selectSingleImage(R.id.uploadphlic, FilePath.PRIVATE_HIRE)
fun submitForm(licenseNumber: String, year: Int, monthOfYear: Int, dayOfMonth: Int) {
selectImage()
enterLicenseNumber(licenseNumber)
enterLicenseExpiry(year, monthOfYear, dayOfMonth)
submit()
}
}

View File

@@ -0,0 +1,46 @@
package h_mal.appttude.com.driver.robots.vehicle
import h_mal.appttude.com.driver.FormRobot
import h_mal.appttude.com.driver.R
import h_mal.appttude.com.driver.helpers.EspressoHelper.setChecked
fun vehicleProfile(func: VehicleProfileRobot.() -> Unit) = VehicleProfileRobot().apply { func() }
class VehicleProfileRobot : FormRobot() {
fun enterRegistration(reg: String) = fillEditText(R.id.reg, reg)
fun enterMake(make: String) = fillEditText(R.id.make, make)
fun enterModel(model: String) = fillEditText(R.id.car_model, model)
fun enterColour(colour: String) = fillEditText(R.id.colour, colour)
fun enterAddress(address: String) = fillEditText(R.id.address, address)
fun enterPostcode(postCode: String) = fillEditText(R.id.postcode, postCode)
fun enterKeeperName(name: String) = fillEditText(R.id.keeper_name, name)
fun enterDateFirstAvailable(year: Int, monthOfYear: Int, dayOfMonth: Int) =
setDate(R.id.start_date, year, monthOfYear, dayOfMonth)
fun isSeized(seized: Boolean) = matchView(R.id.seized_checkbox).perform(setChecked(seized))
fun submitForm(
reg: String,
make: String,
model: String,
colour: String,
address: String,
postCode: String,
name: String,
year: Int,
monthOfYear: Int,
dayOfMonth: Int,
seized: Boolean = false
) {
enterRegistration(reg)
enterMake(make)
enterModel(model)
enterColour(colour)
enterAddress(address)
enterPostcode(postCode)
enterKeeperName(name)
enterDateFirstAvailable(year, monthOfYear, dayOfMonth)
isSeized(seized)
submit()
}
}

View File

@@ -7,8 +7,8 @@ import androidx.test.rule.GrantPermissionRule
import h_mal.appttude.com.driver.FirebaseTest
import h_mal.appttude.com.driver.R
import h_mal.appttude.com.driver.robots.*
import h_mal.appttude.com.driver.robots.driver.driversLicense
import h_mal.appttude.com.driver.ui.MainActivity
import h_mal.appttude.com.driver.ui.user.LoginActivity
import org.junit.*
import org.junit.runner.RunWith
@@ -18,7 +18,9 @@ import org.junit.runner.RunWith
class SubmitNewDataActivityTest :
FirebaseTest<MainActivity>(MainActivity::class.java, registered = true, signedIn = true) {
@get:Rule var permissionRule = GrantPermissionRule.grant(android.Manifest.permission.READ_EXTERNAL_STORAGE)
@get:Rule
var permissionRule =
GrantPermissionRule.grant(android.Manifest.permission.READ_EXTERNAL_STORAGE)
@Test
fun verifyUserRegistration_validUsernameAndPassword_loggedIn() {
@@ -29,13 +31,13 @@ class SubmitNewDataActivityTest :
openDriverProfile()
}
driverScreen {
driverLicense()
}
driversLicense {
submitForm("SAMPLE8456310LTU", 2022, 10, 2)
}
waitFor(5000)
}
}