Complete Automation Test Cases
This commit is contained in:
@@ -1,26 +0,0 @@
|
|||||||
package in.sminnovations.arrest_tb;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.test.platform.app.InstrumentationRegistry;
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.getInstrumentation().getTargetContext();
|
|
||||||
assertEquals("in.sminnovations.arrest_tb", appContext.getPackageName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -65,7 +65,7 @@ public class LoginActivity {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
onView(withText("No such user Exists")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
onView(withText("No such user exists")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
|
||||||
// Check that the text was changed.
|
// Check that the text was changed.
|
||||||
|
|||||||
@@ -0,0 +1,634 @@
|
|||||||
|
package in.sminnovations.arrest_tb;
|
||||||
|
|
||||||
|
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewParent;
|
||||||
|
|
||||||
|
import androidx.test.espresso.contrib.DrawerActions;
|
||||||
|
import androidx.test.espresso.contrib.NavigationViewActions;
|
||||||
|
import androidx.test.filters.LargeTest;
|
||||||
|
import androidx.test.rule.ActivityTestRule;
|
||||||
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
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 static androidx.test.espresso.Espresso.onView;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.click;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.replaceText;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.typeText;
|
||||||
|
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
||||||
|
import static androidx.test.espresso.contrib.DrawerMatchers.isClosed;
|
||||||
|
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||||
|
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||||
|
|
||||||
|
@LargeTest
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class Navigationdrawer {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public ActivityTestRule<LoginScreen> mActivityTestRule2 = new ActivityTestRule<>(LoginScreen.class);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*@Before
|
||||||
|
public void stubCameraIntent() {
|
||||||
|
Instrumentation.ActivityResult result = createImageCaptureActivityResultStub();
|
||||||
|
|
||||||
|
// Stub the Intent.
|
||||||
|
intending(hasAction(MediaStore.ACTION_IMAGE_CAPTURE)).respondWith(result);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
/* private Instrumentation.ActivityResult createImageCaptureActivityResultStub() {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putParcelable(AddImage., BitmapFactory.decodeResource(
|
||||||
|
mActivityTestRule2.getActivity().getResources(), R.drawable.ic_launcher_background));
|
||||||
|
|
||||||
|
// Create the Intent that will include the bundle.
|
||||||
|
Intent resultData = new Intent();
|
||||||
|
resultData.putExtras(bundle);
|
||||||
|
|
||||||
|
// Create the ActivityResult with the Intent.
|
||||||
|
return new ActivityResult(Activity.RESULT_OK, resultData);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void NavAddTest() {
|
||||||
|
// Type text and then press the button.
|
||||||
|
onView(withId(R.id.contactnumber))
|
||||||
|
.perform(replaceText("9779057263"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.password))
|
||||||
|
.perform(typeText("Deep"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
|
||||||
|
onView(withId(R.id.showpassword)).perform(click());
|
||||||
|
onView(withId(R.id.login)).perform(click());
|
||||||
|
/*ViewInteraction appCompatImageButton2 = onView(
|
||||||
|
allOf(withContentDescription("Open navigation drawer"),
|
||||||
|
childAtPosition(
|
||||||
|
allOf(withId(R.id.tollbar),
|
||||||
|
childAtPosition(
|
||||||
|
withId(R.id.line),
|
||||||
|
0)),
|
||||||
|
1),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatImageButton2.perform(click());
|
||||||
|
|
||||||
|
ViewInteraction navigationMenuItemView2 = onView(
|
||||||
|
allOf(childAtPosition(
|
||||||
|
allOf(withId(R.id.design_navigation_view),
|
||||||
|
childAtPosition(
|
||||||
|
withId(R.id.navigation),
|
||||||
|
0)),
|
||||||
|
2),
|
||||||
|
isDisplayed()));
|
||||||
|
navigationMenuItemView2.perform(click());*/
|
||||||
|
try {
|
||||||
|
Thread.sleep(15000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
onView(withId(R.id.Drawer))
|
||||||
|
.check(matches(isClosed(Gravity.LEFT))) // Left Drawer should be closed.
|
||||||
|
.perform(DrawerActions.open()); // Open Drawer
|
||||||
|
|
||||||
|
// Start the screen of your activity.
|
||||||
|
onView(withId(R.id.navigation))
|
||||||
|
.perform(NavigationViewActions.navigateTo(R.id.nav_add_Test));
|
||||||
|
|
||||||
|
// Check that you Activity was opened.
|
||||||
|
|
||||||
|
// 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(3000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void NavPositiveTest() {
|
||||||
|
// Type text and then press the button.
|
||||||
|
onView(withId(R.id.contactnumber))
|
||||||
|
.perform(replaceText("9779057263"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.password))
|
||||||
|
.perform(typeText("Deep"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
|
||||||
|
onView(withId(R.id.showpassword)).perform(click());
|
||||||
|
onView(withId(R.id.login)).perform(click());
|
||||||
|
/*ViewInteraction appCompatImageButton2 = onView(
|
||||||
|
allOf(withContentDescription("Open navigation drawer"),
|
||||||
|
childAtPosition(
|
||||||
|
allOf(withId(R.id.tollbar),
|
||||||
|
childAtPosition(
|
||||||
|
withId(R.id.line),
|
||||||
|
0)),
|
||||||
|
1),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatImageButton2.perform(click());
|
||||||
|
|
||||||
|
ViewInteraction navigationMenuItemView2 = onView(
|
||||||
|
allOf(childAtPosition(
|
||||||
|
allOf(withId(R.id.design_navigation_view),
|
||||||
|
childAtPosition(
|
||||||
|
withId(R.id.navigation),
|
||||||
|
0)),
|
||||||
|
2),
|
||||||
|
isDisplayed()));
|
||||||
|
navigationMenuItemView2.perform(click());*/
|
||||||
|
try {
|
||||||
|
Thread.sleep(15000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
onView(withId(R.id.Drawer))
|
||||||
|
.check(matches(isClosed(Gravity.LEFT))) // Left Drawer should be closed.
|
||||||
|
.perform(DrawerActions.open()); // Open Drawer
|
||||||
|
|
||||||
|
// Start the screen of your activity.
|
||||||
|
onView(withId(R.id.navigation))
|
||||||
|
.perform(NavigationViewActions.navigateTo(R.id.nav_positive));
|
||||||
|
|
||||||
|
// Check that you Activity was opened.
|
||||||
|
|
||||||
|
// 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(3000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void NavHomeTest() {
|
||||||
|
// Type text and then press the button.
|
||||||
|
onView(withId(R.id.contactnumber))
|
||||||
|
.perform(replaceText("9779057263"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.password))
|
||||||
|
.perform(typeText("Deep"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
|
||||||
|
onView(withId(R.id.showpassword)).perform(click());
|
||||||
|
onView(withId(R.id.login)).perform(click());
|
||||||
|
/*ViewInteraction appCompatImageButton2 = onView(
|
||||||
|
allOf(withContentDescription("Open navigation drawer"),
|
||||||
|
childAtPosition(
|
||||||
|
allOf(withId(R.id.tollbar),
|
||||||
|
childAtPosition(
|
||||||
|
withId(R.id.line),
|
||||||
|
0)),
|
||||||
|
1),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatImageButton2.perform(click());
|
||||||
|
|
||||||
|
ViewInteraction navigationMenuItemView2 = onView(
|
||||||
|
allOf(childAtPosition(
|
||||||
|
allOf(withId(R.id.design_navigation_view),
|
||||||
|
childAtPosition(
|
||||||
|
withId(R.id.navigation),
|
||||||
|
0)),
|
||||||
|
2),
|
||||||
|
isDisplayed()));
|
||||||
|
navigationMenuItemView2.perform(click());*/
|
||||||
|
try {
|
||||||
|
Thread.sleep(15000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
onView(withId(R.id.Drawer))
|
||||||
|
.check(matches(isClosed(Gravity.LEFT))) // Left Drawer should be closed.
|
||||||
|
.perform(DrawerActions.open()); // Open Drawer
|
||||||
|
|
||||||
|
// Start the screen of your activity.
|
||||||
|
onView(withId(R.id.navigation))
|
||||||
|
.perform(NavigationViewActions.navigateTo(R.id.nav_home));
|
||||||
|
|
||||||
|
// Check that you Activity was opened.
|
||||||
|
|
||||||
|
// 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(3000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void NavNegativeTest() {
|
||||||
|
// Type text and then press the button.
|
||||||
|
onView(withId(R.id.contactnumber))
|
||||||
|
.perform(replaceText("9779057263"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.password))
|
||||||
|
.perform(typeText("Deep"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
|
||||||
|
onView(withId(R.id.showpassword)).perform(click());
|
||||||
|
onView(withId(R.id.login)).perform(click());
|
||||||
|
/*ViewInteraction appCompatImageButton2 = onView(
|
||||||
|
allOf(withContentDescription("Open navigation drawer"),
|
||||||
|
childAtPosition(
|
||||||
|
allOf(withId(R.id.tollbar),
|
||||||
|
childAtPosition(
|
||||||
|
withId(R.id.line),
|
||||||
|
0)),
|
||||||
|
1),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatImageButton2.perform(click());
|
||||||
|
|
||||||
|
ViewInteraction navigationMenuItemView2 = onView(
|
||||||
|
allOf(childAtPosition(
|
||||||
|
allOf(withId(R.id.design_navigation_view),
|
||||||
|
childAtPosition(
|
||||||
|
withId(R.id.navigation),
|
||||||
|
0)),
|
||||||
|
2),
|
||||||
|
isDisplayed()));
|
||||||
|
navigationMenuItemView2.perform(click());*/
|
||||||
|
try {
|
||||||
|
Thread.sleep(15000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
onView(withId(R.id.Drawer))
|
||||||
|
.check(matches(isClosed(Gravity.LEFT))) // Left Drawer should be closed.
|
||||||
|
.perform(DrawerActions.open()); // Open Drawer
|
||||||
|
|
||||||
|
// Start the screen of your activity.
|
||||||
|
onView(withId(R.id.navigation))
|
||||||
|
.perform(NavigationViewActions.navigateTo(R.id.nav_negative));
|
||||||
|
|
||||||
|
// Check that you Activity was opened.
|
||||||
|
|
||||||
|
// 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(3000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void NavResultTest() {
|
||||||
|
// Type text and then press the button.
|
||||||
|
onView(withId(R.id.contactnumber))
|
||||||
|
.perform(typeText("9779057263"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.password))
|
||||||
|
.perform(typeText("Deep"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
|
||||||
|
onView(withId(R.id.showpassword)).perform(click());
|
||||||
|
onView(withId(R.id.login)).perform(click());
|
||||||
|
/*ViewInteraction appCompatImageButton2 = onView(
|
||||||
|
allOf(withContentDescription("Open navigation drawer"),
|
||||||
|
childAtPosition(
|
||||||
|
allOf(withId(R.id.tollbar),
|
||||||
|
childAtPosition(
|
||||||
|
withId(R.id.line),
|
||||||
|
0)),
|
||||||
|
1),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatImageButton2.perform(click());
|
||||||
|
|
||||||
|
ViewInteraction navigationMenuItemView2 = onView(
|
||||||
|
allOf(childAtPosition(
|
||||||
|
allOf(withId(R.id.design_navigation_view),
|
||||||
|
childAtPosition(
|
||||||
|
withId(R.id.navigation),
|
||||||
|
0)),
|
||||||
|
2),
|
||||||
|
isDisplayed()));
|
||||||
|
navigationMenuItemView2.perform(click());*/
|
||||||
|
try {
|
||||||
|
Thread.sleep(15000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
onView(withId(R.id.Drawer))
|
||||||
|
.check(matches(isClosed(Gravity.LEFT))) // Left Drawer should be closed.
|
||||||
|
.perform(DrawerActions.open()); // Open Drawer
|
||||||
|
|
||||||
|
// Start the screen of your activity.
|
||||||
|
onView(withId(R.id.navigation))
|
||||||
|
.perform(NavigationViewActions.navigateTo(R.id.nav_results));
|
||||||
|
|
||||||
|
// Check that you Activity was opened.
|
||||||
|
|
||||||
|
// 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(3000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void NavAboutTest() {
|
||||||
|
// Type text and then press the button.
|
||||||
|
onView(withId(R.id.contactnumber))
|
||||||
|
.perform(typeText("9779057263"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.password))
|
||||||
|
.perform(typeText("Deep"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
|
||||||
|
onView(withId(R.id.showpassword)).perform(click());
|
||||||
|
onView(withId(R.id.login)).perform(click());
|
||||||
|
/*ViewInteraction appCompatImageButton2 = onView(
|
||||||
|
allOf(withContentDescription("Open navigation drawer"),
|
||||||
|
childAtPosition(
|
||||||
|
allOf(withId(R.id.tollbar),
|
||||||
|
childAtPosition(
|
||||||
|
withId(R.id.line),
|
||||||
|
0)),
|
||||||
|
1),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatImageButton2.perform(click());
|
||||||
|
|
||||||
|
ViewInteraction navigationMenuItemView2 = onView(
|
||||||
|
allOf(childAtPosition(
|
||||||
|
allOf(withId(R.id.design_navigation_view),
|
||||||
|
childAtPosition(
|
||||||
|
withId(R.id.navigation),
|
||||||
|
0)),
|
||||||
|
2),
|
||||||
|
isDisplayed()));
|
||||||
|
navigationMenuItemView2.perform(click());*/
|
||||||
|
try {
|
||||||
|
Thread.sleep(15000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
onView(withId(R.id.Drawer))
|
||||||
|
.check(matches(isClosed(Gravity.LEFT))) // Left Drawer should be closed.
|
||||||
|
.perform(DrawerActions.open()); // Open Drawer
|
||||||
|
|
||||||
|
// Start the screen of your activity.
|
||||||
|
onView(withId(R.id.navigation))
|
||||||
|
.perform(NavigationViewActions.navigateTo(R.id.nav_contact_us));
|
||||||
|
|
||||||
|
// Check that you Activity was opened.
|
||||||
|
|
||||||
|
// 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(3000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void NavLogoutTest() {
|
||||||
|
// Type text and then press the button.
|
||||||
|
onView(withId(R.id.contactnumber))
|
||||||
|
.perform(typeText("9779057263"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.password))
|
||||||
|
.perform(typeText("Deep"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
|
||||||
|
onView(withId(R.id.showpassword)).perform(click());
|
||||||
|
onView(withId(R.id.login)).perform(click());
|
||||||
|
/*ViewInteraction appCompatImageButton2 = onView(
|
||||||
|
allOf(withContentDescription("Open navigation drawer"),
|
||||||
|
childAtPosition(
|
||||||
|
allOf(withId(R.id.tollbar),
|
||||||
|
childAtPosition(
|
||||||
|
withId(R.id.line),
|
||||||
|
0)),
|
||||||
|
1),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatImageButton2.perform(click());
|
||||||
|
|
||||||
|
ViewInteraction navigationMenuItemView2 = onView(
|
||||||
|
allOf(childAtPosition(
|
||||||
|
allOf(withId(R.id.design_navigation_view),
|
||||||
|
childAtPosition(
|
||||||
|
withId(R.id.navigation),
|
||||||
|
0)),
|
||||||
|
2),
|
||||||
|
isDisplayed()));
|
||||||
|
navigationMenuItemView2.perform(click());*/
|
||||||
|
try {
|
||||||
|
Thread.sleep(15000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
onView(withId(R.id.Drawer))
|
||||||
|
.check(matches(isClosed(Gravity.LEFT))) // Left Drawer should be closed.
|
||||||
|
.perform(DrawerActions.open()); // Open Drawer
|
||||||
|
|
||||||
|
// Start the screen of your activity.
|
||||||
|
onView(withId(R.id.navigation))
|
||||||
|
.perform(NavigationViewActions.navigateTo(R.id.nav_logout));
|
||||||
|
|
||||||
|
// Check that you Activity was opened.
|
||||||
|
|
||||||
|
// 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(3000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void NavUserNameTest() {
|
||||||
|
// Type text and then press the button.
|
||||||
|
onView(withId(R.id.contactnumber))
|
||||||
|
.perform(typeText("9779057263"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.password))
|
||||||
|
.perform(typeText("Deep"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
|
||||||
|
onView(withId(R.id.showpassword)).perform(click());
|
||||||
|
onView(withId(R.id.login)).perform(click());
|
||||||
|
/*ViewInteraction appCompatImageButton2 = onView(
|
||||||
|
allOf(withContentDescription("Open navigation drawer"),
|
||||||
|
childAtPosition(
|
||||||
|
allOf(withId(R.id.tollbar),
|
||||||
|
childAtPosition(
|
||||||
|
withId(R.id.line),
|
||||||
|
0)),
|
||||||
|
1),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatImageButton2.perform(click());
|
||||||
|
|
||||||
|
ViewInteraction navigationMenuItemView2 = onView(
|
||||||
|
allOf(childAtPosition(
|
||||||
|
allOf(withId(R.id.design_navigation_view),
|
||||||
|
childAtPosition(
|
||||||
|
withId(R.id.navigation),
|
||||||
|
0)),
|
||||||
|
2),
|
||||||
|
isDisplayed()));
|
||||||
|
navigationMenuItemView2.perform(click());*/
|
||||||
|
try {
|
||||||
|
Thread.sleep(15000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
onView(withId(R.id.Drawer))
|
||||||
|
.check(matches(isClosed(Gravity.LEFT))) // Left Drawer should be closed.
|
||||||
|
.perform(DrawerActions.open()); // Open Drawer
|
||||||
|
|
||||||
|
// Start the screen of your activity.
|
||||||
|
|
||||||
|
onView(withId(R.id.text))
|
||||||
|
.check(
|
||||||
|
matches(withText("Ramandeep")));
|
||||||
|
|
||||||
|
|
||||||
|
// Check that you Activity was opened.
|
||||||
|
|
||||||
|
// 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(3000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void NavPhoneTest() {
|
||||||
|
// Type text and then press the button.
|
||||||
|
onView(withId(R.id.contactnumber))
|
||||||
|
.perform(typeText("9779057263"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.password))
|
||||||
|
.perform(typeText("Deep"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
|
||||||
|
onView(withId(R.id.showpassword)).perform(click());
|
||||||
|
onView(withId(R.id.login)).perform(click());
|
||||||
|
/*ViewInteraction appCompatImageButton2 = onView(
|
||||||
|
allOf(withContentDescription("Open navigation drawer"),
|
||||||
|
childAtPosition(
|
||||||
|
allOf(withId(R.id.tollbar),
|
||||||
|
childAtPosition(
|
||||||
|
withId(R.id.line),
|
||||||
|
0)),
|
||||||
|
1),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatImageButton2.perform(click());
|
||||||
|
|
||||||
|
ViewInteraction navigationMenuItemView2 = onView(
|
||||||
|
allOf(childAtPosition(
|
||||||
|
allOf(withId(R.id.design_navigation_view),
|
||||||
|
childAtPosition(
|
||||||
|
withId(R.id.navigation),
|
||||||
|
0)),
|
||||||
|
2),
|
||||||
|
isDisplayed()));
|
||||||
|
navigationMenuItemView2.perform(click());*/
|
||||||
|
try {
|
||||||
|
Thread.sleep(15000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
onView(withId(R.id.Drawer))
|
||||||
|
.check(matches(isClosed(Gravity.LEFT))) // Left Drawer should be closed.
|
||||||
|
.perform(DrawerActions.open()); // Open Drawer
|
||||||
|
|
||||||
|
// Start the screen of your activity.
|
||||||
|
|
||||||
|
onView(withId(R.id.not_sign_in))
|
||||||
|
.check(
|
||||||
|
matches(withText("9779057263")));
|
||||||
|
|
||||||
|
|
||||||
|
// Check that you Activity was opened.
|
||||||
|
|
||||||
|
// 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(3000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Check that the text was changed.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,292 @@
|
|||||||
|
package in.sminnovations.arrest_tb;
|
||||||
|
|
||||||
|
|
||||||
|
import androidx.test.espresso.Espresso;
|
||||||
|
import androidx.test.espresso.ViewInteraction;
|
||||||
|
import androidx.test.filters.LargeTest;
|
||||||
|
import androidx.test.rule.ActivityTestRule;
|
||||||
|
import androidx.test.rule.GrantPermissionRule;
|
||||||
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import static androidx.test.espresso.Espresso.onView;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.click;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.replaceText;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.scrollTo;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.typeText;
|
||||||
|
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
||||||
|
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||||
|
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||||
|
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||||
|
import static org.hamcrest.Matchers.allOf;
|
||||||
|
import static org.hamcrest.Matchers.instanceOf;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
|
@LargeTest
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class PatientDetails {
|
||||||
|
@Rule
|
||||||
|
public GrantPermissionRule mGrantPermissionRule =
|
||||||
|
GrantPermissionRule.grant(
|
||||||
|
"android.permission.ACCESS_FINE_LOCATION",
|
||||||
|
"android.permission.READ_EXTERNAL_STORAGE",
|
||||||
|
"android.permission.WRITE_EXTERNAL_STORAGE",
|
||||||
|
|
||||||
|
"android.permission.ACCESS_COARSE_LOCATION"
|
||||||
|
);
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public ActivityTestRule<PatientDetail> mActivityTestRule = new ActivityTestRule<>(PatientDetail.class);
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void PatientIdDigitOnly() {
|
||||||
|
onView(withId(R.id.patientid))
|
||||||
|
.perform(typeText("12345"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.spinner_gender)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Female"))).perform(click());
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.age),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("77"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText4 = onView(
|
||||||
|
allOf(withId(R.id.NikshayID),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText4.perform(scrollTo(), replaceText("777777777"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
onView(withId(R.id.next))
|
||||||
|
.perform(scrollTo())
|
||||||
|
|
||||||
|
.perform(click());
|
||||||
|
|
||||||
|
onView(withText("Patient Id must be alphanumeric")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void PatientIdwrongchar() {
|
||||||
|
onView(withId(R.id.patientid))
|
||||||
|
.perform(typeText("A23"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.spinner_gender)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Female"))).perform(click());
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.age),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("77"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText4 = onView(
|
||||||
|
allOf(withId(R.id.NikshayID),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText4.perform(scrollTo(), replaceText("777777777"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
onView(withId(R.id.next))
|
||||||
|
.perform(scrollTo())
|
||||||
|
|
||||||
|
.perform(click());
|
||||||
|
|
||||||
|
onView(withText("Patient Id must be 5 characters")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void PatientIdAlphabetOnly() {
|
||||||
|
onView(withId(R.id.patientid))
|
||||||
|
.perform(typeText("ABCDE"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.spinner_gender)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Female"))).perform(click());
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.age),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("77"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText4 = onView(
|
||||||
|
allOf(withId(R.id.NikshayID),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText4.perform(scrollTo(), replaceText("777777777"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
onView(withId(R.id.next))
|
||||||
|
.perform(scrollTo())
|
||||||
|
|
||||||
|
.perform(click());
|
||||||
|
|
||||||
|
onView(withText("Patient Id must be alphanumeric")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void PatientGenderValidation() {
|
||||||
|
onView(withId(R.id.spinner_gender)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Female"))).perform(click());
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void PatientAgeLess() {
|
||||||
|
onView(withId(R.id.patientid))
|
||||||
|
.perform(typeText("A2345"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.spinner_gender)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Female"))).perform(click());
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.age),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("0"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText4 = onView(
|
||||||
|
allOf(withId(R.id.NikshayID),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText4.perform(scrollTo(), replaceText("777777777"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
onView(withId(R.id.next))
|
||||||
|
.perform(scrollTo())
|
||||||
|
|
||||||
|
.perform(click());
|
||||||
|
onView(withText("Enter a valid Age")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void PatientAgeMore() {
|
||||||
|
onView(withId(R.id.patientid))
|
||||||
|
.perform(typeText("A2345"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.spinner_gender)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Female"))).perform(click());
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.age),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("123"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText4 = onView(
|
||||||
|
allOf(withId(R.id.NikshayID),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText4.perform(scrollTo(), replaceText("777777777"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
onView(withId(R.id.next))
|
||||||
|
.perform(scrollTo())
|
||||||
|
|
||||||
|
.perform(click());
|
||||||
|
onView(withText("Enter a valid Age")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void LeaveAge() {
|
||||||
|
onView(withId(R.id.patientid))
|
||||||
|
.perform(typeText("A2345"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.patientid))
|
||||||
|
.check(matches(withText("A2345")));
|
||||||
|
onView(withId(R.id.spinner_gender)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Female"))).perform(click());
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.NikshayID),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("A77777777"), closeSoftKeyboard());
|
||||||
|
appCompatEditText2.check(
|
||||||
|
matches(withText("A77777777")));
|
||||||
|
ViewInteraction appCompatEditText3 = onView(
|
||||||
|
allOf(withId(R.id.next),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText3.perform(scrollTo(), click());
|
||||||
|
onView(withText("Please fill all fields")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void LeaveNikshayId() {
|
||||||
|
onView(withId(R.id.patientid))
|
||||||
|
.perform(typeText("A2345"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.patientid))
|
||||||
|
.check(matches(withText("A2345")));
|
||||||
|
onView(withId(R.id.spinner_gender)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Female"))).perform(click());
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.age),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("77"), closeSoftKeyboard());
|
||||||
|
appCompatEditText2.check(
|
||||||
|
matches(withText("77")));
|
||||||
|
ViewInteraction appCompatEditText3 = onView(
|
||||||
|
allOf(withId(R.id.next),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText3.perform(scrollTo(), click());
|
||||||
|
onView(withText("Please fill all fields")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void LeavePatientId() {
|
||||||
|
|
||||||
|
onView(withId(R.id.spinner_gender)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Female"))).perform(click());
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.age),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("77"), closeSoftKeyboard());
|
||||||
|
appCompatEditText2.check(
|
||||||
|
matches(withText("77")));
|
||||||
|
ViewInteraction appCompatEditText4 = onView(
|
||||||
|
allOf(withId(R.id.NikshayID),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText4.perform(scrollTo(), replaceText("A77777777"), closeSoftKeyboard());
|
||||||
|
appCompatEditText4.check(
|
||||||
|
matches(withText("A77777777")));
|
||||||
|
ViewInteraction appCompatEditText3 = onView(
|
||||||
|
allOf(withId(R.id.next),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText3.perform(scrollTo(), click());
|
||||||
|
onView(withText("Please fill all fields")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void PatientNikshayIdValidation() {
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.NikshayID),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("7777777777777"), closeSoftKeyboard());
|
||||||
|
appCompatEditText2.check(
|
||||||
|
matches(withText("777777777")));
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void AllData() {
|
||||||
|
onView(withId(R.id.patientid))
|
||||||
|
.perform(typeText("A2345"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.spinner_gender)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Female"))).perform(click());
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.age),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("77"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText4 = onView(
|
||||||
|
allOf(withId(R.id.NikshayID),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText4.perform(scrollTo(), replaceText("777777777"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
onView(withId(R.id.next))
|
||||||
|
.perform(scrollTo())
|
||||||
|
|
||||||
|
.perform(click());
|
||||||
|
|
||||||
|
/*ViewInteraction appCompatEditText3 = onView(
|
||||||
|
allOf(withId(R.id.next),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText3.perform(scrollTo(), click());*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* onView(withId(R.id.))
|
||||||
|
.perform(typeText("123456789"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*onView(withId(R.id.spinner_gender)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Female"))).perform(click());
|
||||||
|
|
||||||
|
*/
|
||||||
|
// Type text and then press the button.
|
||||||
|
|
||||||
|
// Check that the text was changed.
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,235 @@
|
|||||||
|
package in.sminnovations.arrest_tb;
|
||||||
|
|
||||||
|
|
||||||
|
import androidx.test.espresso.ViewInteraction;
|
||||||
|
import androidx.test.filters.LargeTest;
|
||||||
|
import androidx.test.rule.ActivityTestRule;
|
||||||
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import static androidx.test.espresso.Espresso.onView;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.click;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.replaceText;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.scrollTo;
|
||||||
|
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
||||||
|
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||||
|
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||||
|
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||||
|
import static org.hamcrest.Matchers.allOf;
|
||||||
|
|
||||||
|
@LargeTest
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class RegisterActivity {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public ActivityTestRule<Register> mActivityTestRule = new ActivityTestRule<>(Register.class);
|
||||||
|
|
||||||
|
|
||||||
|
/* @Test
|
||||||
|
public void loginactivityv() {
|
||||||
|
// Type text and then press the button.
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.register_user),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("Ramandeep Bains ............"), closeSoftKeyboard());
|
||||||
|
appCompatEditText2.check(
|
||||||
|
matches(withText("123456")));
|
||||||
|
// Check that the text was changed.
|
||||||
|
}*/
|
||||||
|
@Test
|
||||||
|
public void RegisterEmptyName() {
|
||||||
|
// Type text and then press the button.
|
||||||
|
ViewInteraction appCompatEditText6 = onView(
|
||||||
|
allOf(withId(R.id.editTextName),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText6.perform(scrollTo(), closeSoftKeyboard());
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText31 = onView(
|
||||||
|
allOf(withId(R.id.editTextMobile),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText31.perform(scrollTo(), closeSoftKeyboard());
|
||||||
|
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.editTextMobile),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("9779057833"), closeSoftKeyboard());
|
||||||
|
ViewInteraction appCompatEditText3 = onView(
|
||||||
|
allOf(withId(R.id.buttonContinue),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText3.perform(click());
|
||||||
|
|
||||||
|
|
||||||
|
onView(withText("Please enter all the required fields")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
|
||||||
|
// Check that the text was changed.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void RegisterEmptyNumber() {
|
||||||
|
// Type text and then press the button.
|
||||||
|
ViewInteraction appCompatEditText6 = onView(
|
||||||
|
allOf(withId(R.id.editTextName),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText6.perform(scrollTo(), closeSoftKeyboard());
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText31 = onView(
|
||||||
|
allOf(withId(R.id.editTextMobile),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText31.perform(scrollTo(), closeSoftKeyboard());
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.editTextName),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("Ramandeep"), closeSoftKeyboard());
|
||||||
|
ViewInteraction appCompatEditText3 = onView(
|
||||||
|
allOf(withId(R.id.buttonContinue),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText3.perform(click());
|
||||||
|
|
||||||
|
|
||||||
|
onView(withText("Please enter all the required fields")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
|
||||||
|
// Check that the text was changed.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void RegisterDigitLess() {
|
||||||
|
// Type text and then press the button.
|
||||||
|
ViewInteraction appCompatEditText6 = onView(
|
||||||
|
allOf(withId(R.id.editTextName),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText6.perform(scrollTo(), closeSoftKeyboard());
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText3 = onView(
|
||||||
|
allOf(withId(R.id.editTextMobile),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText3.perform(scrollTo(), closeSoftKeyboard());
|
||||||
|
|
||||||
|
|
||||||
|
appCompatEditText3.perform(scrollTo(), replaceText("98760"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.editTextName),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("Ramandeep"), closeSoftKeyboard());
|
||||||
|
ViewInteraction appCompatEditText4 = onView(
|
||||||
|
allOf(withId(R.id.buttonContinue),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText4.perform(click());
|
||||||
|
|
||||||
|
onView(withText("Enter a valid Phone")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
|
||||||
|
// Check that the text was changed.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void RegisterDigitMore() {
|
||||||
|
// Type text and then press the button.
|
||||||
|
ViewInteraction appCompatEditText6 = onView(
|
||||||
|
allOf(withId(R.id.editTextName),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText6.perform(scrollTo(), closeSoftKeyboard());
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText7 = onView(
|
||||||
|
allOf(withId(R.id.editTextMobile),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText7.perform(scrollTo(), closeSoftKeyboard());
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText3 = onView(
|
||||||
|
allOf(withId(R.id.editTextMobile),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText3.perform(scrollTo(), replaceText("9876007249123"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.editTextName),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("Ramandeep"), closeSoftKeyboard());
|
||||||
|
ViewInteraction appCompatEditText4 = onView(
|
||||||
|
allOf(withId(R.id.buttonContinue),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText4.perform(click());
|
||||||
|
|
||||||
|
onView(withText("Enter a valid Phone")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
|
||||||
|
// Check that the text was changed.
|
||||||
|
}
|
||||||
|
|
||||||
|
/* @Test
|
||||||
|
public void RegisterNumberExist() {
|
||||||
|
// Type text and then press the button.
|
||||||
|
*//* ViewInteraction appCompatEditText678 = onView(
|
||||||
|
allOf(withId(R.id.editTextName),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText678.perform(scrollTo(), closeSoftKeyboard());
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText679 = onView(
|
||||||
|
allOf(withId(R.id.editTextMobile),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText679.perform(scrollTo(), closeSoftKeyboard());
|
||||||
|
*//*
|
||||||
|
ViewInteraction appCompatEditText113 = onView(
|
||||||
|
allOf(withId(R.id.editTextMobile),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText113.perform(scrollTo(), replaceText("9779057263"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText112 = onView(
|
||||||
|
allOf(withId(R.id.editTextName),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText112.perform(scrollTo(), replaceText("Ramandeep"), closeSoftKeyboard());
|
||||||
|
ViewInteraction appCompatEditText411 = onView(
|
||||||
|
allOf(withId(R.id.buttonContinue),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText411.perform(click());
|
||||||
|
onView(withText("User Already Exist")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
|
||||||
|
// Check that the text was changed.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void RegisterNumberExist1() {
|
||||||
|
// Type text and then press the button.
|
||||||
|
ViewInteraction appCompatEditText6 = onView(
|
||||||
|
allOf(withId(R.id.editTextName),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText6.perform(scrollTo(), closeSoftKeyboard());
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText7 = onView(
|
||||||
|
allOf(withId(R.id.editTextMobile),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText7.perform(scrollTo(), closeSoftKeyboard());
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText3 = onView(
|
||||||
|
allOf(withId(R.id.editTextMobile),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText3.perform(scrollTo(), replaceText("9779057263"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.editTextName),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("Ramandeep"), closeSoftKeyboard());
|
||||||
|
ViewInteraction appCompatEditText4 = onView(
|
||||||
|
allOf(withId(R.id.buttonContinue),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText4.perform(click());
|
||||||
|
|
||||||
|
onView(withText("User Already Exist")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
|
||||||
|
// Check that the text was changed.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package in.sminnovations.arrest_tb;
|
||||||
|
|
||||||
|
|
||||||
|
import androidx.test.filters.LargeTest;
|
||||||
|
import androidx.test.rule.ActivityTestRule;
|
||||||
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import static androidx.test.espresso.Espresso.onView;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.click;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.typeText;
|
||||||
|
import static androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition;
|
||||||
|
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||||
|
|
||||||
|
@LargeTest
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class SearchOperation {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public ActivityTestRule<LoginScreen> mActivityTestRule = new ActivityTestRule<>(LoginScreen.class);
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void SearchData() {
|
||||||
|
onView(withId(R.id.contactnumber))
|
||||||
|
.perform(typeText("9779057263"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.password))
|
||||||
|
.perform(typeText("Deep"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
|
||||||
|
onView(withId(R.id.showpassword)).perform(click());
|
||||||
|
onView(withId(R.id.login)).perform(click());
|
||||||
|
try {
|
||||||
|
Thread.sleep(5000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
onView(withId(R.id.search))
|
||||||
|
.perform(typeText("12345"), closeSoftKeyboard());
|
||||||
|
// onView(withText("12345")).perform(click());
|
||||||
|
onView(withId(R.id.recycler_view))
|
||||||
|
.perform(actionOnItemAtPosition(0, click()));
|
||||||
|
|
||||||
|
|
||||||
|
/* onView(withId(R.id.textToBeChanged))
|
||||||
|
.check(matches(withText("12345")));*/
|
||||||
|
// Type text and then press the button.
|
||||||
|
// onView(withId(R.id.search)).perform(click());
|
||||||
|
|
||||||
|
|
||||||
|
/* onView(withId(R.id.search)).p
|
||||||
|
.perform(typeText("9779057263"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.password))
|
||||||
|
.perform(typeText("Deep"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
|
||||||
|
onView(withId(R.id.showpassword)).perform(click());
|
||||||
|
onView(withId(R.id.login)).perform(click());
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Check that the text was changed.
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package in.sminnovations.arrest_tb;
|
||||||
|
|
||||||
|
|
||||||
|
import androidx.test.filters.LargeTest;
|
||||||
|
import androidx.test.rule.ActivityTestRule;
|
||||||
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
@LargeTest
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class SplashActivity {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public ActivityTestRule<SplashScreen> mActivityTestRule = new ActivityTestRule<>(SplashScreen.class);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void SplashActivity_1() {
|
||||||
|
// 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(3000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,294 @@
|
|||||||
|
package in.sminnovations.arrest_tb;
|
||||||
|
|
||||||
|
|
||||||
|
import androidx.test.espresso.Espresso;
|
||||||
|
import androidx.test.espresso.ViewInteraction;
|
||||||
|
import androidx.test.filters.LargeTest;
|
||||||
|
import androidx.test.rule.ActivityTestRule;
|
||||||
|
import androidx.test.rule.GrantPermissionRule;
|
||||||
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import static androidx.test.espresso.Espresso.onView;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.click;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.replaceText;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.scrollTo;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.typeText;
|
||||||
|
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
||||||
|
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||||
|
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||||
|
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||||
|
import static org.hamcrest.Matchers.allOf;
|
||||||
|
import static org.hamcrest.Matchers.instanceOf;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
|
@LargeTest
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class TestDetail_Data {
|
||||||
|
@Rule
|
||||||
|
public GrantPermissionRule mGrantPermissionRule =
|
||||||
|
GrantPermissionRule.grant(
|
||||||
|
"android.permission.ACCESS_FINE_LOCATION",
|
||||||
|
"android.permission.READ_EXTERNAL_STORAGE",
|
||||||
|
"android.permission.WRITE_EXTERNAL_STORAGE",
|
||||||
|
|
||||||
|
"android.permission.ACCESS_COARSE_LOCATION"
|
||||||
|
);
|
||||||
|
@Rule
|
||||||
|
public ActivityTestRule<TestResult> mActivityTestRule = new ActivityTestRule<>(TestResult.class);
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void NIRTLabDigitOnly() {
|
||||||
|
onView(withId(R.id.NIRTLab))
|
||||||
|
.perform(typeText("123456789"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.SPINTubeID),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("A12345678"), closeSoftKeyboard());
|
||||||
|
appCompatEditText2.check(
|
||||||
|
matches(withText("A12345")));
|
||||||
|
onView(withId(R.id.spinner_sample)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Culture"))).perform(click());
|
||||||
|
|
||||||
|
onView(withId(R.id.spinner_validity)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Valid"))).perform(click());
|
||||||
|
ViewInteraction appCompatEditText3 = onView(
|
||||||
|
allOf(withId(R.id.startTest),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText3.perform(scrollTo(), click());
|
||||||
|
onView(withText("NIRT Lab Number must be alphanumeric")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void NIRTLabAlphabetOnly() {
|
||||||
|
onView(withId(R.id.NIRTLab))
|
||||||
|
.perform(typeText("ABCDEFGH"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.SPINTubeID),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("A12345678"), closeSoftKeyboard());
|
||||||
|
appCompatEditText2.check(
|
||||||
|
matches(withText("A12345")));
|
||||||
|
onView(withId(R.id.spinner_sample)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Culture"))).perform(click());
|
||||||
|
|
||||||
|
onView(withId(R.id.spinner_validity)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Valid"))).perform(click());
|
||||||
|
ViewInteraction appCompatEditText3 = onView(
|
||||||
|
allOf(withId(R.id.startTest),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText3.perform(scrollTo(), click());
|
||||||
|
onView(withText("NIRT Lab Number must be alphanumeric")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void NIRTLabInvalidChar() {
|
||||||
|
onView(withId(R.id.NIRTLab))
|
||||||
|
.perform(typeText("A1222"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.SPINTubeID),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("A12345"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
onView(withId(R.id.spinner_sample)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Culture"))).perform(click());
|
||||||
|
|
||||||
|
onView(withId(R.id.spinner_validity)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Valid"))).perform(click());
|
||||||
|
ViewInteraction appCompatEditText3 = onView(
|
||||||
|
allOf(withId(R.id.startTest),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText3.perform(scrollTo(), click());
|
||||||
|
onView(withText("NIRT Lab Number must be 7 characters")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void SampleValidation() {
|
||||||
|
onView(withId(R.id.spinner_sample)).perform(scrollTo(), closeSoftKeyboard());
|
||||||
|
|
||||||
|
onView(withId(R.id.spinner_sample)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Culture"))).perform(click());
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void TubeValidation() {
|
||||||
|
|
||||||
|
onView(withId(R.id.spinner_validity)).perform(scrollTo(), closeSoftKeyboard());
|
||||||
|
|
||||||
|
onView(withId(R.id.spinner_validity)).perform(scrollTo(), click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Valid"))).perform(scrollTo(), click());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void SPINTubeIdValidation(){
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.SPINTubeID),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("A12345678"), closeSoftKeyboard());
|
||||||
|
appCompatEditText2.check(
|
||||||
|
matches(withText("A12345")));
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void LeaveSpinTubeId() {
|
||||||
|
|
||||||
|
|
||||||
|
onView(withId(R.id.NIRTLab))
|
||||||
|
.perform(typeText("A123456"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.NIRTLab))
|
||||||
|
.check(matches(withText("A123456")));
|
||||||
|
onView(withId(R.id.spinner_sample)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Culture"))).perform(click());
|
||||||
|
|
||||||
|
onView(withId(R.id.spinner_validity)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Valid"))).perform(click());
|
||||||
|
ViewInteraction appCompatEditText3 = onView(
|
||||||
|
allOf(withId(R.id.startTest),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText3.perform(scrollTo(), click());
|
||||||
|
onView(withText("Please fill all required fields")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void LeaveNirtLab() {
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.SPINTubeID),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("A12345678"), closeSoftKeyboard());
|
||||||
|
appCompatEditText2.check(
|
||||||
|
matches(withText("A12345")));
|
||||||
|
onView(withId(R.id.spinner_sample)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Culture"))).perform(click());
|
||||||
|
|
||||||
|
onView(withId(R.id.spinner_validity)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Valid"))).perform(click());
|
||||||
|
ViewInteraction appCompatEditText3 = onView(
|
||||||
|
allOf(withId(R.id.startTest),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText3.perform(scrollTo(), click());
|
||||||
|
onView(withText("Please fill all required fields")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void AllDataTest() {
|
||||||
|
onView(withId(R.id.NIRTLab))
|
||||||
|
.perform(typeText("A12345678"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.NIRTLab))
|
||||||
|
.check(matches(withText("A123456")));
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.SPINTubeID),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("A12345678"), closeSoftKeyboard());
|
||||||
|
appCompatEditText2.check(
|
||||||
|
matches(withText("A12345")));
|
||||||
|
onView(withId(R.id.spinner_sample)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Culture"))).perform(click());
|
||||||
|
|
||||||
|
onView(withId(R.id.spinner_validity)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Valid"))).perform(click());
|
||||||
|
ViewInteraction appCompatEditText3 = onView(
|
||||||
|
allOf(withId(R.id.startTest),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText3.perform(scrollTo(), click());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void SpinTubeInvalidChar() {
|
||||||
|
onView(withId(R.id.NIRTLab))
|
||||||
|
.perform(typeText("A123456"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.SPINTubeID),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("A123"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
onView(withId(R.id.spinner_sample)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Culture"))).perform(click());
|
||||||
|
|
||||||
|
onView(withId(R.id.spinner_validity)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Valid"))).perform(click());
|
||||||
|
ViewInteraction appCompatEditText3 = onView(
|
||||||
|
allOf(withId(R.id.startTest),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText3.perform(scrollTo(), click());
|
||||||
|
onView(withText("Spin Tube ID must be 6 characters")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
}
|
||||||
|
public void SpinTubeDigitOnly() {
|
||||||
|
onView(withId(R.id.NIRTLab))
|
||||||
|
.perform(typeText("A12345678"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.NIRTLab))
|
||||||
|
.check(matches(withText("A123456")));
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.SPINTubeID),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("123456"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
onView(withId(R.id.spinner_sample)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Culture"))).perform(click());
|
||||||
|
|
||||||
|
onView(withId(R.id.spinner_validity)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Valid"))).perform(click());
|
||||||
|
ViewInteraction appCompatEditText3 = onView(
|
||||||
|
allOf(withId(R.id.startTest),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText3.perform(scrollTo(), click());
|
||||||
|
onView(withText("Spin Tube ID must be alphanumeric")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
}
|
||||||
|
public void SpinTubeNumericOnly() {
|
||||||
|
onView(withId(R.id.NIRTLab))
|
||||||
|
.perform(typeText("A12345678"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.NIRTLab))
|
||||||
|
.check(matches(withText("A123456")));
|
||||||
|
ViewInteraction appCompatEditText2 = onView(
|
||||||
|
allOf(withId(R.id.SPINTubeID),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText2.perform(scrollTo(), replaceText("A12345678"), closeSoftKeyboard());
|
||||||
|
appCompatEditText2.check(
|
||||||
|
matches(withText("A12345")));
|
||||||
|
onView(withId(R.id.spinner_sample)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Culture"))).perform(click());
|
||||||
|
|
||||||
|
onView(withId(R.id.spinner_validity)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Valid"))).perform(click());
|
||||||
|
ViewInteraction appCompatEditText3 = onView(
|
||||||
|
allOf(withId(R.id.startTest),
|
||||||
|
isDisplayed()));
|
||||||
|
appCompatEditText3.perform(scrollTo(), click());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* onView(withId(R.id.))
|
||||||
|
.perform(typeText("123456789"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*onView(withId(R.id.spinner_gender)).perform(click());
|
||||||
|
Espresso.onData(allOf(is(instanceOf(String.class)), is("Female"))).perform(click());
|
||||||
|
|
||||||
|
*/
|
||||||
|
// Type text and then press the button.
|
||||||
|
|
||||||
|
// Check that the text was changed.
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
0 negative
|
0 positive
|
||||||
1 positive
|
1 negative
|
||||||
|
|||||||
Binary file not shown.
@@ -101,20 +101,44 @@ String numberwithcode;
|
|||||||
|
|
||||||
else {
|
else {
|
||||||
if (mobile.equals("") || name.equals("")) {
|
if (mobile.equals("") || name.equals("")) {
|
||||||
Toast.makeText(Register.this, "please enter all the required fields", Toast.LENGTH_SHORT).show();
|
Toast.makeText(Register.this, "Please enter all the required fields", Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
} else if (!Patterns.PHONE.matcher(mobile).matches()) {
|
} else if (!Patterns.PHONE.matcher(mobile).matches()) {
|
||||||
editTextMobile.setError("Enter a valid Phone ");
|
editTextMobile.setError("Enter a valid Phone");
|
||||||
// Toast.makeText(Consumer_register.this, "Please Enter a valid email", Toast.LENGTH_SHORT).show();
|
// Toast.makeText(Consumer_register.this, "Please Enter a valid email", Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
else if (mobile.length() <9 ) {
|
||||||
|
Toast.makeText(Register.this, "Enter a valid Phone", Toast.LENGTH_SHORT).show();
|
||||||
|
// Toast.makeText(Consumer_register.this, "Please Enter a valid email", Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (mobile.length() >=11 ) {
|
||||||
|
Toast.makeText(Register.this, "Enter a valid Phone", Toast.LENGTH_SHORT).show();
|
||||||
|
// Toast.makeText(Consumer_register.this, "Please Enter a valid email", Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
else {
|
||||||
|
|
||||||
Query chekuser = FirebaseDatabase.getInstance().getReference("USERS").orderByChild("number").equalTo(mobile);
|
Query chekuser = FirebaseDatabase.getInstance().getReference("USERS").orderByChild("number").equalTo(mobile);
|
||||||
chekuser.addListenerForSingleValueEvent(new ValueEventListener() {
|
chekuser.addListenerForSingleValueEvent(new ValueEventListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
|
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
|
||||||
if (dataSnapshot.exists()) {
|
if (dataSnapshot.exists()) {
|
||||||
editTextMobile.setError("User Already Exist ");
|
Toast.makeText(Register.this, "User Already Exist", Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -125,10 +149,10 @@ String numberwithcode;
|
|||||||
Log.e("main", "error " + numberwithcode);
|
Log.e("main", "error " + numberwithcode);
|
||||||
|
|
||||||
if (mobile.equals("") || name.equals("")) {
|
if (mobile.equals("") || name.equals("")) {
|
||||||
Toast.makeText(Register.this, "please enter all the required fields", Toast.LENGTH_SHORT).show();
|
Toast.makeText(Register.this, "Please enter all the required fields", Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
} else if (!Patterns.PHONE.matcher(mobile).matches()) {
|
} else if (!Patterns.PHONE.matcher(mobile).matches()) {
|
||||||
editTextMobile.setError("Enter a valid Phone ");
|
editTextMobile.setError("Enter a valid Phone");
|
||||||
// Toast.makeText(Consumer_register.this, "Please Enter a valid email", Toast.LENGTH_SHORT).show();
|
// Toast.makeText(Consumer_register.this, "Please Enter a valid email", Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user