mirror of
https://github.com/hmalik144/Driver.git
synced 2026-03-18 15:36:03 +00:00
Circleci project setup (#7)
This commit is contained in:
40
app/src/androidTest/java/h_mal/appttude/com/BaseTestRobot.kt
Normal file
40
app/src/androidTest/java/h_mal/appttude/com/BaseTestRobot.kt
Normal file
@@ -0,0 +1,40 @@
|
||||
package h_mal.appttude.com
|
||||
|
||||
import android.content.res.Resources
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.test.espresso.Espresso.onData
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.ViewInteraction
|
||||
import androidx.test.espresso.action.ViewActions
|
||||
import androidx.test.espresso.assertion.ViewAssertions
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import org.hamcrest.CoreMatchers.*
|
||||
|
||||
open class BaseTestRobot {
|
||||
|
||||
fun fillEditText(resId: Int, text: String): ViewInteraction =
|
||||
onView(withId(resId)).perform(ViewActions.replaceText(text), ViewActions.closeSoftKeyboard())
|
||||
|
||||
fun clickButton(resId: Int): ViewInteraction = onView((withId(resId))).perform(ViewActions.click())
|
||||
|
||||
fun textView(resId: Int): ViewInteraction = onView(withId(resId))
|
||||
|
||||
fun matchText(viewInteraction: ViewInteraction, text: String): ViewInteraction = viewInteraction
|
||||
.check(ViewAssertions.matches(ViewMatchers.withText(text)))
|
||||
|
||||
fun matchText(resId: Int, text: String): ViewInteraction = matchText(textView(resId), text)
|
||||
|
||||
fun clickListItem(listRes: Int, position: Int) {
|
||||
onData(anything())
|
||||
.inAdapterView(allOf(withId(listRes)))
|
||||
.atPosition(position).perform(ViewActions.click())
|
||||
}
|
||||
|
||||
fun checkErrorOnTextEntry(resId: Int, errorMessage: String): ViewInteraction =
|
||||
onView(withId(resId)).check(matches(checkErrorMessage(errorMessage)))
|
||||
|
||||
fun getStringFromResource(@StringRes resId: Int): String = Resources.getSystem().getString(resId)
|
||||
|
||||
}
|
||||
38
app/src/androidTest/java/h_mal/appttude/com/BaseUiTest.kt
Normal file
38
app/src/androidTest/java/h_mal/appttude/com/BaseUiTest.kt
Normal file
@@ -0,0 +1,38 @@
|
||||
package h_mal.appttude.com
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.rule.ActivityTestRule
|
||||
import h_mal.appttude.com.espresso.IdlingResourceClass
|
||||
import org.junit.AfterClass
|
||||
import org.junit.BeforeClass
|
||||
import org.junit.Ignore
|
||||
import org.junit.Rule
|
||||
|
||||
abstract class BaseUiTest<T : AppCompatActivity> {
|
||||
|
||||
@Ignore
|
||||
abstract fun getApplicationClass(): Class<T>
|
||||
|
||||
@get:Rule
|
||||
var mActivityTestRule = ActivityTestRule(getApplicationClass())
|
||||
|
||||
companion object {
|
||||
@BeforeClass
|
||||
@JvmStatic
|
||||
fun setUp() {
|
||||
IdlingRegistry.getInstance().register(IdlingResourceClass.countingIdlingResource)
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@JvmStatic
|
||||
fun tearDown() {
|
||||
IdlingRegistry.getInstance().unregister(IdlingResourceClass.countingIdlingResource)
|
||||
}
|
||||
}
|
||||
|
||||
fun getResourceString(@StringRes stringRes: Int): String {
|
||||
return mActivityTestRule.activity.getString(stringRes)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package h_mal.appttude.com
|
||||
|
||||
import android.view.View
|
||||
import android.widget.EditText
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import org.hamcrest.Description
|
||||
import org.hamcrest.Matcher
|
||||
import org.hamcrest.TypeSafeMatcher
|
||||
|
||||
|
||||
/**
|
||||
* Matcher for testing error of TextInputLayout
|
||||
*/
|
||||
fun checkErrorMessage(expectedErrorText: String): Matcher<View?>? {
|
||||
return object : TypeSafeMatcher<View?>() {
|
||||
override fun matchesSafely(view: View?): Boolean {
|
||||
if (view is EditText) {
|
||||
return view.error.toString() == expectedErrorText
|
||||
}
|
||||
|
||||
if (view !is TextInputLayout) return false
|
||||
|
||||
val error = view.error ?: return false
|
||||
return expectedErrorText == error.toString()
|
||||
}
|
||||
override fun describeTo(d: Description?) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package h_mal.appttude.com.driver;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
assertEquals("h_mal.appttude.com.driver", appContext.getPackageName());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package h_mal.appttude.com.driver;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.test.rule.ActivityTestRule;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import h_mal.appttude.com.driver.ui.driver.HomeFragment;
|
||||
import h_mal.appttude.com.driver.ui.driver.MainActivity;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
public class MainActivityTest {
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<MainActivity> activityActivityTestRule = new ActivityTestRule<MainActivity>(MainActivity.class);
|
||||
|
||||
|
||||
private MainActivity mainActivity = null;
|
||||
private HomeFragment hdf;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mainActivity = activityActivityTestRule.getActivity();
|
||||
|
||||
hdf = new HomeFragment();
|
||||
mainActivity.getSupportFragmentManager().beginTransaction().replace(R.id.container, hdf).commit();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testViews(){
|
||||
View view = hdf.getView().findViewById(R.id.driver);
|
||||
|
||||
assertNotNull(view);
|
||||
|
||||
// Bundle bundle = new Bundle();
|
||||
// bundle.putInt("selectedListItem", 0);
|
||||
// FragmentFactory factory = new FragmentFactory();
|
||||
// homeDriverFragment hdf = new homeDriverFragment();
|
||||
//
|
||||
// launchInContainer(hdf.getClass(), bundle, factory);
|
||||
// Espresso.onView(ViewMatchers.withId(2131231038)).check(ViewAssertions.matches(ViewMatchers.withText("Hello World!")));
|
||||
}
|
||||
|
||||
@After
|
||||
public void TearDown() throws Exception{
|
||||
mainActivity = null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package h_mal.appttude.com.driver.base
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
class BaseActivityTest{
|
||||
|
||||
|
||||
}
|
||||
@@ -1,199 +0,0 @@
|
||||
package h_mal.appttude.com.driver.user;
|
||||
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
|
||||
import androidx.test.espresso.ViewInteraction;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.rule.ActivityTestRule;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import h_mal.appttude.com.driver.R;
|
||||
import h_mal.appttude.com.driver.ui.user.LoginActivity;
|
||||
|
||||
import static androidx.test.espresso.Espresso.onView;
|
||||
import static androidx.test.espresso.action.ViewActions.*;
|
||||
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.*;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
@LargeTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class EspressoTestTwo {
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<LoginActivity> mActivityTestRule = new ActivityTestRule<>(LoginActivity.class);
|
||||
|
||||
@Test
|
||||
public void espressoTestTwo() {
|
||||
// Added a sleep statement to match the app's execution delay.
|
||||
// The recommended way to handle such scenarios is to use Espresso idling resources:
|
||||
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
|
||||
try {
|
||||
Thread.sleep(7000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ViewInteraction appCompatEditText = onView(
|
||||
allOf(withId(R.id.email),
|
||||
childAtPosition(
|
||||
childAtPosition(
|
||||
withId(R.id.fields_holder),
|
||||
0),
|
||||
0),
|
||||
isDisplayed()));
|
||||
appCompatEditText.perform(replaceText("h.malik144.au@gmail.com"), closeSoftKeyboard());
|
||||
|
||||
ViewInteraction appCompatEditText2 = onView(
|
||||
allOf(withId(R.id.password),
|
||||
childAtPosition(
|
||||
childAtPosition(
|
||||
withId(R.id.fields_holder),
|
||||
1),
|
||||
0),
|
||||
isDisplayed()));
|
||||
appCompatEditText2.perform(replaceText("crack167"), closeSoftKeyboard());
|
||||
|
||||
ViewInteraction appCompatEditText3 = onView(
|
||||
allOf(withId(R.id.password), withText("crack167"),
|
||||
childAtPosition(
|
||||
childAtPosition(
|
||||
withId(R.id.fields_holder),
|
||||
1),
|
||||
0),
|
||||
isDisplayed()));
|
||||
appCompatEditText3.perform(pressImeActionButton());
|
||||
|
||||
// Added a sleep statement to match the app's execution delay.
|
||||
// The recommended way to handle such scenarios is to use Espresso idling resources:
|
||||
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
|
||||
try {
|
||||
Thread.sleep(7000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ViewInteraction button = onView(
|
||||
allOf(withId(R.id.driver),
|
||||
childAtPosition(
|
||||
childAtPosition(
|
||||
withId(R.id.container),
|
||||
0),
|
||||
0),
|
||||
isDisplayed()));
|
||||
button.check(matches(isDisplayed()));
|
||||
|
||||
// Added a sleep statement to match the app's execution delay.
|
||||
// The recommended way to handle such scenarios is to use Espresso idling resources:
|
||||
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
|
||||
try {
|
||||
Thread.sleep(7000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ViewInteraction appCompatImageButton = onView(
|
||||
allOf(withContentDescription("Open navigation drawer"),
|
||||
childAtPosition(
|
||||
allOf(withId(R.id.toolbar),
|
||||
childAtPosition(
|
||||
withClassName(is("android.support.design.widget.AppBarLayout")),
|
||||
0)),
|
||||
1),
|
||||
isDisplayed()));
|
||||
appCompatImageButton.perform(click());
|
||||
|
||||
ViewInteraction cardView = onView(
|
||||
allOf(withId(R.id.car),
|
||||
childAtPosition(
|
||||
childAtPosition(
|
||||
withId(R.id.container),
|
||||
1),
|
||||
1),
|
||||
isDisplayed()));
|
||||
cardView.perform(click());
|
||||
|
||||
ViewInteraction cardView2 = onView(
|
||||
allOf(withId(R.id.vehicle_prof),
|
||||
childAtPosition(
|
||||
childAtPosition(
|
||||
withId(R.id.container),
|
||||
1),
|
||||
0),
|
||||
isDisplayed()));
|
||||
cardView2.perform(click());
|
||||
|
||||
pressBack();
|
||||
|
||||
ViewInteraction appCompatButton = onView(
|
||||
allOf(withId(R.id.driver), withText("Driver Profile"),
|
||||
childAtPosition(
|
||||
childAtPosition(
|
||||
withId(R.id.container),
|
||||
1),
|
||||
0),
|
||||
isDisplayed()));
|
||||
appCompatButton.perform(click());
|
||||
|
||||
ViewInteraction cardView3 = onView(
|
||||
allOf(withId(R.id.driver_prof),
|
||||
childAtPosition(
|
||||
childAtPosition(
|
||||
withId(R.id.container),
|
||||
1),
|
||||
0),
|
||||
isDisplayed()));
|
||||
cardView3.perform(click());
|
||||
|
||||
pressBack();
|
||||
|
||||
ViewInteraction cardView4 = onView(
|
||||
allOf(withId(R.id.private_hire),
|
||||
childAtPosition(
|
||||
childAtPosition(
|
||||
withId(R.id.container),
|
||||
1),
|
||||
1),
|
||||
isDisplayed()));
|
||||
cardView4.perform(click());
|
||||
|
||||
ViewInteraction appCompatButton2 = onView(
|
||||
allOf(withId(android.R.id.button1), withText("View/Edit"),
|
||||
childAtPosition(
|
||||
childAtPosition(
|
||||
withClassName(is("android.widget.ScrollView")),
|
||||
0),
|
||||
3)));
|
||||
appCompatButton2.perform(scrollTo(), click());
|
||||
}
|
||||
|
||||
private static Matcher<View> childAtPosition(
|
||||
final Matcher<View> parentMatcher, final int position) {
|
||||
|
||||
return new TypeSafeMatcher<View>() {
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("Child at position " + position + " in parent ");
|
||||
parentMatcher.describeTo(description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(View view) {
|
||||
ViewParent parent = view.getParent();
|
||||
return parent instanceof ViewGroup && parentMatcher.matches(parent)
|
||||
&& view.equals(((ViewGroup) parent).getChildAt(position));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,147 +0,0 @@
|
||||
package h_mal.appttude.com.driver.user;
|
||||
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
|
||||
import androidx.test.espresso.ViewInteraction;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.rule.ActivityTestRule;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import h_mal.appttude.com.driver.R;
|
||||
import h_mal.appttude.com.driver.ui.user.LoginActivity;
|
||||
|
||||
import static androidx.test.espresso.Espresso.onView;
|
||||
import static androidx.test.espresso.action.ViewActions.*;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.*;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
@LargeTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class LoginActivityTest {
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<LoginActivity> mActivityTestRule = new ActivityTestRule<>(LoginActivity.class);
|
||||
|
||||
@Test
|
||||
public void loginActivityTest() {
|
||||
// Added a sleep statement to match the app's execution delay.
|
||||
// The recommended way to handle such scenarios is to use Espresso idling resources:
|
||||
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
|
||||
try {
|
||||
Thread.sleep(7000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ViewInteraction appCompatEditText = onView(
|
||||
allOf(withId(R.id.email),
|
||||
childAtPosition(
|
||||
childAtPosition(
|
||||
withId(R.id.fields_holder),
|
||||
0),
|
||||
0),
|
||||
isDisplayed()));
|
||||
appCompatEditText.perform(replaceText("h.malik144.au@gmail.com"), closeSoftKeyboard());
|
||||
|
||||
// Added a sleep statement to match the app's execution delay.
|
||||
// The recommended way to handle such scenarios is to use Espresso idling resources:
|
||||
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
|
||||
try {
|
||||
Thread.sleep(7000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ViewInteraction appCompatEditText2 = onView(
|
||||
allOf(withId(R.id.password),
|
||||
childAtPosition(
|
||||
childAtPosition(
|
||||
withId(R.id.fields_holder),
|
||||
1),
|
||||
0),
|
||||
isDisplayed()));
|
||||
appCompatEditText2.perform(replaceText("crack167"), closeSoftKeyboard());
|
||||
|
||||
// ViewInteraction appCompatButton = onView(
|
||||
// allOf(withId(R.id.email_sign_in_button), withText("Sign in"),
|
||||
// childAtPosition(
|
||||
// allOf(withId(R.id.email_login_form),
|
||||
// childAtPosition(
|
||||
// withClassName(is("android.widget.RelativeLayout")),
|
||||
// 0)),
|
||||
// 1),
|
||||
// isDisplayed()));
|
||||
// appCompatButton.perform(click());
|
||||
|
||||
// Added a sleep statement to match the app's execution delay.
|
||||
// The recommended way to handle such scenarios is to use Espresso idling resources:
|
||||
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
|
||||
try {
|
||||
Thread.sleep(7000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// ViewInteraction textView = onView(
|
||||
// allOf(withText("Choice Minicabs"),
|
||||
// childAtPosition(
|
||||
// allOf(withId(R.id.toolbar),
|
||||
// childAtPosition(
|
||||
// IsInstanceOf.<View>instanceOf(android.widget.LinearLayout.class),
|
||||
// 0)),
|
||||
// 1),
|
||||
// isDisplayed()));
|
||||
// textView.check(matches(isDisplayed()));
|
||||
|
||||
// Added a sleep statement to match the app's execution delay.
|
||||
// The recommended way to handle such scenarios is to use Espresso idling resources:
|
||||
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
|
||||
try {
|
||||
Thread.sleep(7000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ViewInteraction appCompatButton2 = onView(
|
||||
allOf(withId(R.id.driver), withText("Driver Profile"),
|
||||
childAtPosition(
|
||||
childAtPosition(
|
||||
withId(R.id.container),
|
||||
1),
|
||||
0),
|
||||
isDisplayed()));
|
||||
appCompatButton2.perform(click());
|
||||
}
|
||||
|
||||
private static Matcher<View> childAtPosition(
|
||||
final Matcher<View> parentMatcher, final int position) {
|
||||
|
||||
return new TypeSafeMatcher<View>() {
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("Child at position " + position + " in parent ");
|
||||
parentMatcher.describeTo(description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(View view) {
|
||||
ViewParent parent = view.getParent();
|
||||
return parent instanceof ViewGroup && parentMatcher.matches(parent)
|
||||
&& view.equals(((ViewGroup) parent).getChildAt(position));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package h_mal.appttude.com.robots
|
||||
|
||||
import h_mal.appttude.com.BaseTestRobot
|
||||
import h_mal.appttude.com.R
|
||||
|
||||
fun home(func: HomeRobot.() -> Unit) = HomeRobot().apply { func() }
|
||||
class HomeRobot: BaseTestRobot() {
|
||||
|
||||
fun checkTitleExists(title: String) = matchText(R.id.prova_title_tv, title)
|
||||
|
||||
fun clickLogin() = clickButton(R.id.email_sign_in_button)
|
||||
|
||||
fun clickRegister() = clickButton(R.id.register_button)
|
||||
|
||||
fun clickForgotPassword() = clickButton(R.id.forgot)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package h_mal.appttude.com.robots
|
||||
|
||||
import h_mal.appttude.com.BaseTestRobot
|
||||
import h_mal.appttude.com.R
|
||||
|
||||
|
||||
fun login(func: LoginRobot.() -> Unit) = LoginRobot().apply { func() }
|
||||
class LoginRobot: BaseTestRobot() {
|
||||
|
||||
fun setEmail(email: String) = fillEditText(R.id.email, email);
|
||||
|
||||
fun setPassword(pass: String) = fillEditText(R.id.password, pass)
|
||||
|
||||
fun clickLogin() = clickButton(R.id.email_sign_in_button)
|
||||
|
||||
fun clickRegister() = clickButton(R.id.register_button)
|
||||
|
||||
fun clickForgotPassword() = clickButton(R.id.forgot)
|
||||
|
||||
fun checkEmailError(err: String) = checkErrorOnTextEntry(R.id.email, err)
|
||||
|
||||
fun checkPasswordError(err: String) = checkErrorOnTextEntry(R.id.password, err)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package h_mal.appttude.com.robots
|
||||
|
||||
import h_mal.appttude.com.BaseTestRobot
|
||||
import h_mal.appttude.com.R
|
||||
|
||||
fun register(func: RegisterRobot.() -> Unit) = RegisterRobot().apply { func() }
|
||||
class RegisterRobot: BaseTestRobot() {
|
||||
|
||||
fun setName(name: String) = fillEditText(R.id.name_register, name)
|
||||
|
||||
fun setEmail(email: String) = fillEditText(R.id.email_register, email)
|
||||
|
||||
fun setPassword(pass: String) = fillEditText(R.id.password_top, pass)
|
||||
|
||||
fun setPasswordConfirm(pass: String) = fillEditText(R.id.password_bottom, pass)
|
||||
|
||||
fun clickLogin() = clickButton(R.id.email_sign_up)
|
||||
|
||||
fun checkNameError(err: String) = checkErrorOnTextEntry(R.id.name_register, err)
|
||||
|
||||
fun checkEmailError(err: String) = checkErrorOnTextEntry(R.id.email_register, err)
|
||||
|
||||
fun checkPasswordError(err: String) = checkErrorOnTextEntry(R.id.password_top, err)
|
||||
|
||||
fun checkPasswordConfirmError(err: String) = checkErrorOnTextEntry(R.id.password_bottom, err)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package h_mal.appttude.com.tests
|
||||
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import androidx.test.rule.ActivityTestRule
|
||||
import com.google.firebase.auth.FirebaseAuth
|
||||
import h_mal.appttude.com.BaseUiTest
|
||||
import h_mal.appttude.com.R
|
||||
import h_mal.appttude.com.robots.home
|
||||
import h_mal.appttude.com.ui.user.LoginActivity
|
||||
import h_mal.appttude.com.robots.login
|
||||
import h_mal.appttude.com.robots.register
|
||||
import org.junit.*
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
|
||||
@LargeTest
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class LoginActivityTest: BaseUiTest<LoginActivity>() {
|
||||
|
||||
@Ignore
|
||||
override fun getApplicationClass() = LoginActivity::class.java
|
||||
|
||||
@After
|
||||
fun afterTest(){
|
||||
FirebaseAuth.getInstance().signOut()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun verifyUserLogin_validUsernameAndPassword_loggedIn() {
|
||||
login {
|
||||
setEmail("test-user@testuserdriver.com")
|
||||
setPassword("Password1234")
|
||||
clickLogin()
|
||||
}
|
||||
home {
|
||||
checkTitleExists(getResourceString(R.string.welcome_title))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user