Compare commits
87 Commits
modelv.1.2
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4db4918e39 | ||
|
|
35fbea548a | ||
|
|
05c5f3ed13 | ||
|
|
1f5ff24a59 | ||
|
|
d5e737683a | ||
|
|
753bc8e509 | ||
|
|
ec8eca030a | ||
|
|
40b602c1be | ||
|
|
4753b35567 | ||
|
|
efa2fa42fb | ||
|
|
24b156175d | ||
|
|
96e5831170 | ||
|
|
737e353454 | ||
|
|
d58fef2180 | ||
|
|
4a4e7e244c | ||
|
|
986530f6c7 | ||
|
|
0138de0725 | ||
|
|
633a6d70df | ||
|
|
52df04a5c9 | ||
|
|
9dfcad6a3b | ||
|
|
a2b3c78860 | ||
|
|
dfa6f947eb | ||
|
|
a3b0c19e3f | ||
|
|
31fa1afd13 | ||
|
|
e89127ead5 | ||
|
|
4367114a2c | ||
|
|
311eb73524 | ||
|
|
cc4169e606 | ||
|
|
1eb16401d1 | ||
|
|
b4cd61fce1 | ||
|
|
0661f98401 | ||
|
|
46a6d34ee2 | ||
|
|
307f364be9 | ||
|
|
591bb08ad1 | ||
|
|
ca2f5f0e17 | ||
|
|
b97e9b7f58 | ||
|
|
306df95ad2 | ||
|
|
6eccef7b8b | ||
|
|
3d6685d360 | ||
|
|
eaf74de979 | ||
|
|
ea3dc78def | ||
|
|
416fc5c940 | ||
|
|
9c1d75df57 | ||
|
|
94c40b0bec | ||
|
|
6b33b3bda7 | ||
|
|
e213796b6a | ||
|
|
ca17445075 | ||
|
|
4685984be6 | ||
|
|
03bbb3ac68 | ||
|
|
0dd79fcc63 | ||
|
|
c38287d5b1 | ||
|
|
83fcdda9f6 | ||
|
|
ee1cc63d67 | ||
|
|
288e90d19b | ||
|
|
bb74bcd88f | ||
|
|
2b73023ea5 | ||
|
|
ceda32d254 | ||
|
|
1ec4e2d664 | ||
|
|
bab757388b | ||
|
|
43c335f944 | ||
|
|
c37b044b98 | ||
|
|
104e076f4c | ||
|
|
d04f1d990a | ||
|
|
ac9d2e053e | ||
|
|
43b5eea6de | ||
|
|
dedc6b169b | ||
|
|
ab496a2300 | ||
|
|
954ca843fc | ||
|
|
6cd0f3d7bf | ||
|
|
e40827a466 | ||
|
|
196bd680f7 | ||
|
|
25b512e6c7 | ||
|
|
3d41ad20c8 | ||
|
|
d126f52f9d | ||
|
|
3087197ccd | ||
|
|
cdd3690d9d | ||
|
|
0ceca45b67 | ||
|
|
a651c7ed84 | ||
|
|
6a80fc19f0 | ||
|
|
0b523696c3 | ||
|
|
b8eb32e7b3 | ||
|
|
bb00b599b3 | ||
|
|
719c0137fb | ||
|
|
ce49e907a2 | ||
|
|
46feddd88f | ||
|
|
f97f15309f | ||
|
|
7540512743 |
@@ -20,6 +20,11 @@ variables:
|
||||
# when the script was last modified for latest compileSdkVersion, it was which is written down below
|
||||
ANDROID_SDK_TOOLS: "6514223"
|
||||
|
||||
# Packages installation before running script
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
|
||||
# Packages installation before running script
|
||||
before_script:
|
||||
- apt-get --quiet update --yes
|
||||
@@ -54,25 +59,61 @@ before_script:
|
||||
|
||||
# Basic android and gradle stuff
|
||||
# Check linting
|
||||
lintDebug:
|
||||
interruptible: true
|
||||
stage: build
|
||||
script:
|
||||
- ./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint
|
||||
|
||||
# Make Project
|
||||
assembleDebug:
|
||||
interruptible: true
|
||||
build_debug:
|
||||
stage: build
|
||||
script:
|
||||
- ./gradlew assembleDebug
|
||||
- ./gradlew assembleDebugAndroidTest
|
||||
|
||||
artifacts:
|
||||
paths:
|
||||
- app/build/outputs/
|
||||
|
||||
# Run all tests, if any fails, interrupt the pipeline(fail it)
|
||||
debugTests:
|
||||
interruptible: true
|
||||
|
||||
.test_lab_template: &test_lab_template_def
|
||||
stage: test
|
||||
before_script:
|
||||
# Install Google Cloud SDK
|
||||
- wget --quiet --output-document=/tmp/google-cloud-sdk.tar.gz https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.tar.gz
|
||||
- mkdir -p /opt
|
||||
- tar zxf /tmp/google-cloud-sdk.tar.gz --directory /opt
|
||||
- /opt/google-cloud-sdk/install.sh --quiet
|
||||
- source /opt/google-cloud-sdk/path.bash.inc
|
||||
|
||||
# Setup and configure the project
|
||||
- gcloud components update
|
||||
- echo $GCLOUD_PROJECT_ID
|
||||
- gcloud config set project $GCLOUD_PROJECT_ID
|
||||
|
||||
# Activate cloud credentials
|
||||
- echo $SERVICE_ACCOUNT > /tmp/service-account.json
|
||||
- gcloud auth activate-service-account --key-file /tmp/service-account.json
|
||||
|
||||
# List available options for logging purpose only (so that we can review available options)
|
||||
- gcloud firebase test android models list
|
||||
- gcloud firebase test android versions list
|
||||
|
||||
|
||||
after_script:
|
||||
- source /opt/google-cloud-sdk/path.bash.inc
|
||||
|
||||
# Iterate up to 10 possible test lab configurations and create CLI tool options
|
||||
- for i in `seq 1 10`; do export CONFIG="TEST_LAB_DEVICE_CONFIGURATION_$i"; if [ -n "${!CONFIG}" ]; then export TEST_LAB_DEVICE_CONFIGURATIONS="$TEST_LAB_DEVICE_CONFIGURATIONS --device model=${!CONFIG} "; fi; done
|
||||
|
||||
# Output for debug logging purpose only
|
||||
- echo $TEST_LAB_DEVICE_CONFIGURATIONS
|
||||
# Warn if there were no configurations
|
||||
- if [ -n "$TEST_LAB_DEVICE_CONFIGURATIONS" ]; then gcloud firebase test android run --type robo --app app.apk $TEST_LAB_DEVICE_CONFIGURATIONS --timeout 90s; fi
|
||||
|
||||
# Warn if there were no configurations
|
||||
- if [ -z "$TEST_LAB_DEVICE_CONFIGURATIONS" ]; then echo "NO FIREBASE TESTLAB CONFIGURATIONS!!!"; fi
|
||||
|
||||
|
||||
test_lab_debug:
|
||||
<<: *test_lab_template_def
|
||||
script:
|
||||
- ./gradlew -Pci --console=plain :app:testDebug
|
||||
- cp app/build/outputs/apk/debug/app-debug.apk ./app.apk
|
||||
- cp app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk ./app-test.apk
|
||||
- gcloud firebase test android run --type instrumentation --app app.apk --test app-test.apk --device model=Nexus6P,version=26,locale=en,orientation=portrait
|
||||
dependencies:
|
||||
- build_debug
|
||||
|
||||
2
.idea/.name
generated
2
.idea/.name
generated
@@ -1 +1 @@
|
||||
Spin Tube App
|
||||
arrest_tb
|
||||
6
.idea/compiler.xml
generated
Normal file
6
.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="11" />
|
||||
</component>
|
||||
</project>
|
||||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
||||
1
.idea/runConfigurations.xml
generated
1
.idea/runConfigurations.xml
generated
@@ -3,6 +3,7 @@
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
apply plugin: 'com.google.firebase.crashlytics'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.3"
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
|
||||
defaultConfig {
|
||||
applicationId "in.sminnovations.arrest_tb"
|
||||
@@ -15,6 +13,7 @@ android {
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
multiDexEnabled true
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
@@ -25,6 +24,10 @@ android {
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
aaptOptions {
|
||||
noCompress "tflite"
|
||||
noCompress "lite"
|
||||
@@ -54,6 +57,7 @@ dependencies {
|
||||
implementation 'com.google.firebase:firebase-config:20.0.0'
|
||||
implementation 'com.google.firebase:firebase-auth:20.0.1'
|
||||
|
||||
|
||||
implementation 'com.google.firebase:firebase-database:19.5.1'
|
||||
implementation 'com.google.firebase:firebase-storage:19.2.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
@@ -61,5 +65,16 @@ dependencies {
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
|
||||
implementation 'com.google.firebase:firebase-crashlytics:17.1.1'
|
||||
implementation 'com.google.firebase:firebase-perf:19.0.11'
|
||||
implementation 'com.android.support:multidex:1.0.3'
|
||||
implementation 'com.karumi:dexter:6.2.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.3.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.3.0'
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
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.replaceText;
|
||||
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;
|
||||
|
||||
@LargeTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class LoginActivity {
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<LoginScreen> mActivityTestRule = new ActivityTestRule<>(LoginScreen.class);
|
||||
|
||||
|
||||
@Test
|
||||
public void LoginSuccess_2() {
|
||||
// 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());
|
||||
try {
|
||||
Thread.sleep(160);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// onView(withText("logged in Successfully...")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||
|
||||
|
||||
// Check that the text was changed.
|
||||
}
|
||||
@Test
|
||||
public void LoginInvalidNumber_3() {
|
||||
// Type text and then press the button.
|
||||
onView(withId(R.id.contactnumber))
|
||||
.perform(typeText("977905"), 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(160);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
onView(withText("No such user exists")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||
|
||||
|
||||
// Check that the text was changed.
|
||||
}
|
||||
@Test
|
||||
public void LoginWrongPassword_4() {
|
||||
// Type text and then press the button.
|
||||
onView(withId(R.id.contactnumber))
|
||||
.perform(typeText("9779057263"), closeSoftKeyboard());
|
||||
onView(withId(R.id.password))
|
||||
.perform(typeText("Deep1"), closeSoftKeyboard());
|
||||
|
||||
|
||||
onView(withId(R.id.showpassword)).perform(click());
|
||||
onView(withId(R.id.login)).perform(click());
|
||||
try {
|
||||
Thread.sleep(160);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
onView(withText("Wrong Password")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||
|
||||
|
||||
// Check that the text was changed.
|
||||
}
|
||||
@Test
|
||||
public void EmptyPassword_5() {
|
||||
// Type text and then press the button.
|
||||
onView(withId(R.id.contactnumber))
|
||||
.perform(typeText("9779057263"), closeSoftKeyboard());
|
||||
|
||||
|
||||
onView(withId(R.id.showpassword)).perform(click());
|
||||
onView(withId(R.id.login)).perform(click());
|
||||
try {
|
||||
Thread.sleep(160);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
onView(withText("Please enter all the required fields")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||
|
||||
|
||||
// Check that the text was changed.
|
||||
}
|
||||
|
||||
@Test
|
||||
public void EmptyNumber_6() {
|
||||
// Type text and then press the button.
|
||||
onView(withId(R.id.password))
|
||||
.perform(typeText("Deep1"), closeSoftKeyboard());
|
||||
|
||||
onView(withId(R.id.showpassword)).perform(click());
|
||||
onView(withId(R.id.login)).perform(click());
|
||||
try {
|
||||
Thread.sleep(160);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
onView(withText("Please enter all the required fields")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||
|
||||
|
||||
// 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,259 @@
|
||||
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());
|
||||
|
||||
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
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());
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
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());
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
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());
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
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());
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
onView(withText("User Already Exist")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
|
||||
|
||||
|
||||
// Check that the text was changed.
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
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("34"), closeSoftKeyboard());
|
||||
// onView(withText("12345")).perform(click());
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
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 6 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("A12345"), closeSoftKeyboard());
|
||||
onView(withId(R.id.NIRTLab))
|
||||
.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 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("A12345")));
|
||||
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("A12345"), 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.
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package in.sminnovations.arrest_tb;
|
||||
|
||||
import android.os.IBinder;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.test.espresso.Root;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
|
||||
public class ToastMatcher extends TypeSafeMatcher<Root> {
|
||||
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("is toast");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(Root root) {
|
||||
int type = root.getWindowLayoutParams().get().type;
|
||||
if ((type == WindowManager.LayoutParams.TYPE_TOAST)) {
|
||||
IBinder windowToken = root.getDecorView().getWindowToken();
|
||||
IBinder appToken = root.getDecorView().getApplicationWindowToken();
|
||||
if (windowToken == appToken) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -4,21 +4,19 @@
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
|
||||
android:theme="@style/AppTheme">
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
@@ -28,66 +26,75 @@
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_path" />
|
||||
</provider>
|
||||
<activity android:name=".NegativeResults" android:screenOrientation="portrait"
|
||||
></activity>
|
||||
<activity android:name=".PositiveResult" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".TestDetails" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".Register" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".ForgetPassword" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".CreatePassword" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".Home" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".VerifyOTP.VerifyOtp" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".ForgetPasswordReset" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".VerifyOTP.VerifyOtpForgetPassword" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".SplashScreen" android:screenOrientation="portrait"
|
||||
> <intent-filter>
|
||||
|
||||
<activity
|
||||
android:name=".NegativeResults"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".PositiveResult"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".TestDetails"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".Register"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".ForgetPassword"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".CreatePassword"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".Home"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".VerifyOTP.VerifyOtp"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".ForgetPasswordReset"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".VerifyOTP.VerifyOtpForgetPassword"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".SplashScreen"
|
||||
android:screenOrientation="portrait">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter></activity>
|
||||
<activity android:name=".MainActivity" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".Report" android:screenOrientation="portrait"
|
||||
>
|
||||
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".NavigationTop" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".LoginScreen" android:screenOrientation="portrait"
|
||||
/>
|
||||
|
||||
|
||||
<activity android:name=".AddImage" android:screenOrientation="portrait"
|
||||
></activity>
|
||||
<activity android:name=".CameraGuide" android:screenOrientation="portrait"></activity>
|
||||
<activity android:name=".About" android:screenOrientation="portrait" />
|
||||
<activity android:name=".PatientDetail" android:screenOrientation="portrait"></activity>
|
||||
<activity android:name=".TestResult" android:screenOrientation="portrait" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".Report"
|
||||
android:screenOrientation="portrait"></activity>
|
||||
<activity
|
||||
android:name=".NavigationTop"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".LoginScreen"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".AddImage"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".CameraGuide"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".About"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".PatientDetail"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".TestResult"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
|
||||
|
||||
android:theme="@style/Base.Theme.AppCompat" />
|
||||
</application>
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
0 negative
|
||||
1 positive
|
||||
0 positive
|
||||
1 negative
|
||||
|
||||
Binary file not shown.
@@ -40,6 +40,7 @@ import com.theartofdev.edmodo.cropper.CropImageView;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
@@ -332,12 +333,16 @@ public class AddImage extends NavigationTop {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
||||
SimpleDateFormat currentDate = new SimpleDateFormat("MMM dd, yyyy");
|
||||
saveCurrentDate = currentDate.format(calendar.getTime());
|
||||
|
||||
SimpleDateFormat currentTime = new SimpleDateFormat("HH:mm:ss a");
|
||||
saveCurrentDate = currentDate.format(calendar.getTime());
|
||||
saveCurrentDate = saveCurrentDate .replaceAll("[^A-Za-z0-9 ]","");
|
||||
|
||||
|
||||
SimpleDateFormat currentTime = new SimpleDateFormat("h:mm a");
|
||||
saveCurrentTime = currentTime.format(calendar.getTime());
|
||||
|
||||
TestRandomKey = saveCurrentDate + saveCurrentTime+number;
|
||||
TestRandomKey = TestRandomKey .replaceAll("[^A-Za-z0-9 ]","");
|
||||
|
||||
|
||||
final StorageReference filePath1 =TestImagesRef.child(ImageUri1.getLastPathSegment() + TestRandomKey + ".jpg");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package in.sminnovations.arrest_tb;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.content.Context;
|
||||
@@ -9,7 +10,11 @@ import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -24,7 +29,22 @@ import android.widget.Toast;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.karumi.dexter.Dexter;
|
||||
import com.karumi.dexter.MultiplePermissionsReport;
|
||||
import com.karumi.dexter.PermissionToken;
|
||||
import com.karumi.dexter.listener.PermissionRequest;
|
||||
import com.karumi.dexter.listener.multi.MultiplePermissionsListener;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class PatientDetail extends NavigationTop implements AdapterView.OnItemSelectedListener {
|
||||
private Button next_act;
|
||||
@@ -33,6 +53,7 @@ public class PatientDetail extends NavigationTop implements AdapterView.OnItemSe
|
||||
String gender;
|
||||
private GpsTracker gpsTracker;
|
||||
String lat,logi;
|
||||
int diff1=0;
|
||||
|
||||
|
||||
|
||||
@@ -51,7 +72,33 @@ public class PatientDetail extends NavigationTop implements AdapterView.OnItemSe
|
||||
Age=findViewById(R.id.age);
|
||||
NikshayId=findViewById(R.id.NikshayID);
|
||||
|
||||
/*
|
||||
mDisplayDate.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
public void afterTextChanged(Editable s) {
|
||||
if(mDisplayDate.getText()!=null)
|
||||
{
|
||||
Age.setText(String.valueOf(diff1));
|
||||
}
|
||||
}
|
||||
|
||||
public void beforeTextChanged(CharSequence s, int start,
|
||||
int count, int after) {
|
||||
if(mDisplayDate.getText()!=null)
|
||||
{
|
||||
Age.setText(String.valueOf(diff1));
|
||||
}
|
||||
}
|
||||
|
||||
public void onTextChanged(CharSequence s, int start,
|
||||
int before, int count) {
|
||||
if(mDisplayDate.getText()!=null)
|
||||
{
|
||||
Age.setText(String.valueOf(diff1));
|
||||
}
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
|
||||
R.array.Gender, android.R.layout.simple_spinner_item);
|
||||
@@ -80,9 +127,59 @@ public class PatientDetail extends NavigationTop implements AdapterView.OnItemSe
|
||||
public void onDateSet(DatePicker datePicker, int year, int month, int day) {
|
||||
month = month + 1;
|
||||
|
||||
String date = month + "/" + day + "/" + year;
|
||||
String date = day + "-" + month + "-" + year;
|
||||
mDisplayDate.setText(date);
|
||||
patientdob=date;
|
||||
/* int year1 = Calendar.getInstance().get(Calendar.YEAR);
|
||||
Integer dateyear=year;
|
||||
int diff=0;
|
||||
|
||||
if(dateyear!=0)
|
||||
{
|
||||
diff=year1-year;
|
||||
diff1=diff;
|
||||
}*/
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
|
||||
Date date1 = null;
|
||||
try {
|
||||
date1 = formatter.parse(patientdob);
|
||||
Instant instant = null;
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
instant = date1.toInstant();
|
||||
ZonedDateTime zone = instant.atZone(ZoneId.systemDefault());
|
||||
LocalDate givenDate = zone.toLocalDate();
|
||||
//Calculating the difference between given date to current date.
|
||||
Period period = Period.between(givenDate, LocalDate.now());
|
||||
diff1=period.getYears();
|
||||
if(diff1>0 && diff1<=100) {
|
||||
|
||||
Age.setText(String.valueOf(diff1));
|
||||
Age.setFocusable(false);
|
||||
Age.setCursorVisible(false);
|
||||
Age.setKeyListener(null);
|
||||
|
||||
}
|
||||
if(diff1<=0 || diff1>100 ) {
|
||||
Age.setText("");
|
||||
|
||||
Age.setFocusable(false);
|
||||
Age.setCursorVisible(false);
|
||||
Age.setKeyListener(null);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//Converting obtained Date object to LocalDate object
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -95,6 +192,7 @@ public class PatientDetail extends NavigationTop implements AdapterView.OnItemSe
|
||||
// setContentView(R.layout.activity_patient_detail);
|
||||
next_act=findViewById(R.id.next);
|
||||
|
||||
|
||||
next_act.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -102,10 +200,66 @@ public class PatientDetail extends NavigationTop implements AdapterView.OnItemSe
|
||||
patientid = patient_ID.getText().toString();
|
||||
patientage = Age.getText().toString();
|
||||
patientnikshayid = NikshayId.getText().toString();
|
||||
if (patientid.equals("") || patientage.equals("") || patientnikshayid.equals("")) {
|
||||
if (patientid.equals("") || patientage.equals("") ) {
|
||||
Toast.makeText(PatientDetail.this, "Please fill all fields", Toast.LENGTH_SHORT).show();
|
||||
|
||||
} else {
|
||||
}
|
||||
else if (patientid.length()!=5 )
|
||||
{
|
||||
Toast.makeText(PatientDetail.this, "Patient Id must be 5 characters", Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
else if (patientid.matches("^[a-zA-Z]*$") || patientid.matches("^[0-9]*$") )
|
||||
{
|
||||
Toast.makeText(PatientDetail.this, "Patient Id must be alphanumeric", Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
|
||||
}
|
||||
/* else if ( patientagedigit>100)
|
||||
{
|
||||
Toast.makeText(PatientDetail.this, "Enter a valid Age", Toast.LENGTH_SHORT).show();
|
||||
|
||||
}*/
|
||||
else if (diff1>100 && diff1<1)
|
||||
{
|
||||
Toast.makeText(PatientDetail.this, "Enter a valid Age", Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
else if(Integer.parseInt(String.valueOf(Age.getText()))>100 || Integer.parseInt(String.valueOf(Age.getText()))<1) {
|
||||
|
||||
|
||||
Toast.makeText(PatientDetail.this, "Enter a valid Age", Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if ( patientnikshayid.length()<8 &&patientnikshayid.length()>=1 )
|
||||
{
|
||||
Toast.makeText(PatientDetail.this, "Nikshay Id must be 8 or 9 digit Number ", Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
}
|
||||
else if ( patientnikshayid.length()>9 &&patientnikshayid.length()>=1 )
|
||||
{
|
||||
Toast.makeText(PatientDetail.this, "Nikshay Id must be 8 or 9 digit Number ", Toast.LENGTH_SHORT).show();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
else {
|
||||
locationpermission();
|
||||
getLocation();
|
||||
|
||||
|
||||
SharedPreferences preferences = getSharedPreferences("PhoneBook", MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
@@ -196,6 +350,60 @@ public class PatientDetail extends NavigationTop implements AdapterView.OnItemSe
|
||||
gpsTracker.showSettingsAlert();
|
||||
}
|
||||
}
|
||||
private void locationpermission()
|
||||
{
|
||||
/* Dexter.withContext(this).withPermission(Manifest.permission.ACCESS_FINE_LOCATION).withListener(new PermissionListener() {
|
||||
@Override
|
||||
public void onPermissionGranted(PermissionGrantedResponse permissionGrantedResponse) {
|
||||
getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPermissionDenied(PermissionDeniedResponse permissionDeniedResponse) {
|
||||
Intent intent=new Intent();
|
||||
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
Uri uri =Uri.fromParts("package",getPackageName(),"");
|
||||
intent.setData(uri);
|
||||
startActivity(intent);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPermissionRationaleShouldBeShown(PermissionRequest permissionRequest, PermissionToken permissionToken) {
|
||||
permissionToken.continuePermissionRequest();
|
||||
|
||||
}
|
||||
}).check();
|
||||
*/
|
||||
Dexter.withContext(this).withPermissions(Manifest.permission.ACCESS_COARSE_LOCATION,Manifest.permission.ACCESS_FINE_LOCATION).withListener(new MultiplePermissionsListener() {
|
||||
@Override
|
||||
public void onPermissionsChecked(MultiplePermissionsReport multiplePermissionsReport) {
|
||||
if(multiplePermissionsReport.areAllPermissionsGranted())
|
||||
{
|
||||
getLocation();
|
||||
}
|
||||
if(multiplePermissionsReport.isAnyPermissionPermanentlyDenied())
|
||||
{
|
||||
Intent intent=new Intent();
|
||||
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
Uri uri =Uri.fromParts("package",getPackageName(),"");
|
||||
intent.setData(uri);
|
||||
startActivity(intent);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPermissionRationaleShouldBeShown(List<PermissionRequest> list, PermissionToken permissionToken) {
|
||||
permissionToken.continuePermissionRequest();
|
||||
|
||||
}
|
||||
}).check();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -101,20 +101,46 @@ String numberwithcode;
|
||||
|
||||
else {
|
||||
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()) {
|
||||
editTextMobile.setError("Enter a valid Phone ");
|
||||
Toast.makeText(Register.this, "Enter a valid Phone", Toast.LENGTH_SHORT).show();
|
||||
|
||||
// editTextMobile.setError("Enter a valid Phone");
|
||||
// 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);
|
||||
chekuser.addListenerForSingleValueEvent(new ValueEventListener() {
|
||||
@Override
|
||||
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
|
||||
if (dataSnapshot.exists()) {
|
||||
editTextMobile.setError("User Already Exist ");
|
||||
Toast.makeText(Register.this, "User Already Exist", Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
@@ -125,7 +151,7 @@ String numberwithcode;
|
||||
Log.e("main", "error " + numberwithcode);
|
||||
|
||||
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()) {
|
||||
editTextMobile.setError("Enter a valid Phone");
|
||||
|
||||
@@ -122,7 +122,7 @@ public class Report extends NavigationTop {
|
||||
Intent intent=new Intent(Intent.ACTION_SEND);
|
||||
intent.putExtra(Intent.EXTRA_TEXT,"Report");
|
||||
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N) {
|
||||
Uri path= FileProvider.getUriForFile(Report.this,"in.sminnovations.arresttb_testing.fileprovider",filePath);
|
||||
Uri path= FileProvider.getUriForFile(Report.this,"in.sminnovations.arrest_tb.fileprovider",filePath);
|
||||
intent.putExtra(Intent.EXTRA_STREAM,path);
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -28,9 +28,14 @@ public class TensorFlowImageClassifier implements Classifier {
|
||||
private static final int PIXEL_SIZE = 3;
|
||||
private static final float THRESHOLD = 0.1f;
|
||||
|
||||
private static final int IMAGE_MEAN = 128;
|
||||
private static final float IMAGE_STD = 128.0f;
|
||||
|
||||
private Interpreter interpreter;
|
||||
private int inputSize;
|
||||
private List<String> labelList;
|
||||
private boolean quant;
|
||||
|
||||
|
||||
private TensorFlowImageClassifier() {
|
||||
|
||||
@@ -52,9 +57,13 @@ public class TensorFlowImageClassifier implements Classifier {
|
||||
@Override
|
||||
public List<Recognition> recognizeImage(Bitmap bitmap) {
|
||||
ByteBuffer byteBuffer = convertBitmapToByteBuffer(bitmap);
|
||||
/* ByteBuffer byteBuffer = convertBitmapToByteBuffer(bitmap);
|
||||
byte[][] result = new byte[1][labelList.size()];
|
||||
interpreter.run(byteBuffer, result);
|
||||
return getSortedResult(result);
|
||||
return getSortedResult(result);*/
|
||||
float [][] result = new float[1][labelList.size()];
|
||||
interpreter.run(byteBuffer, result);
|
||||
return getSortedResultFloat(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -84,7 +93,8 @@ public class TensorFlowImageClassifier implements Classifier {
|
||||
}
|
||||
|
||||
private ByteBuffer convertBitmapToByteBuffer(Bitmap bitmap) {
|
||||
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(BATCH_SIZE * inputSize * inputSize * PIXEL_SIZE);
|
||||
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(4 * BATCH_SIZE * inputSize * inputSize * PIXEL_SIZE);
|
||||
|
||||
byteBuffer.order(ByteOrder.nativeOrder());
|
||||
int[] intValues = new int[inputSize * inputSize];
|
||||
bitmap.getPixels(intValues, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
|
||||
@@ -92,16 +102,18 @@ public class TensorFlowImageClassifier implements Classifier {
|
||||
for (int i = 0; i < inputSize; ++i) {
|
||||
for (int j = 0; j < inputSize; ++j) {
|
||||
final int val = intValues[pixel++];
|
||||
byteBuffer.put((byte) ((val >> 16) & 0xFF));
|
||||
byteBuffer.put((byte) ((val >> 8) & 0xFF));
|
||||
byteBuffer.put((byte) (val & 0xFF));
|
||||
byteBuffer.putFloat((((val >> 16) & 0xFF)-IMAGE_MEAN)/IMAGE_STD);
|
||||
byteBuffer.putFloat((((val >> 8) & 0xFF)-IMAGE_MEAN)/IMAGE_STD);
|
||||
byteBuffer.putFloat((((val) & 0xFF)-IMAGE_MEAN)/IMAGE_STD);
|
||||
}
|
||||
}
|
||||
return byteBuffer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
private List<Recognition> getSortedResult(byte[][] labelProbArray) {
|
||||
private List<Recognition> getSortedResultFloat(float[][] labelProbArray) {
|
||||
|
||||
PriorityQueue<Recognition> pq =
|
||||
new PriorityQueue<>(
|
||||
@@ -114,7 +126,7 @@ public class TensorFlowImageClassifier implements Classifier {
|
||||
});
|
||||
|
||||
for (int i = 0; i < labelList.size(); ++i) {
|
||||
float confidence = (labelProbArray[0][i] & 0xff) / 255.0f;
|
||||
float confidence = labelProbArray[0][i];
|
||||
if (confidence > THRESHOLD) {
|
||||
pq.add(new Recognition("" + i,
|
||||
labelList.size() > i ? labelList.get(i) : "unknown",
|
||||
|
||||
@@ -1,15 +1,33 @@
|
||||
package in.sminnovations.arrest_tb;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.pdf.PdfDocument;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.google.firebase.database.DataSnapshot;
|
||||
@@ -19,6 +37,8 @@ import com.google.firebase.database.FirebaseDatabase;
|
||||
import com.google.firebase.database.ValueEventListener;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
@@ -32,7 +52,9 @@ public class TestDetails extends NavigationTop {
|
||||
String date,time,number;
|
||||
|
||||
private String TestID = "";
|
||||
ImageButton shared ,dowbloadd;
|
||||
|
||||
File filePath=null;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -42,7 +64,10 @@ public class TestDetails extends NavigationTop {
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
View contentView = inflater.inflate(R.layout.activity_spin__test, null, false);
|
||||
draw.addView(contentView, 0);
|
||||
shared=findViewById(R.id.share);
|
||||
|
||||
|
||||
dowbloadd=findViewById(R.id.downlaod);
|
||||
patient_id=findViewById(R.id.patient_idr);
|
||||
patient_dob=findViewById(R.id.patien_dobr);
|
||||
patientnikshayid=findViewById(R.id.patient_nikshayidr);
|
||||
@@ -60,6 +85,7 @@ public class TestDetails extends NavigationTop {
|
||||
validatyd=findViewById(R.id.patient_tubevisibler);
|
||||
spintubeid=findViewById(R.id.patient_spintuber);
|
||||
nirtlab=findViewById(R.id.patient_nirtr);
|
||||
|
||||
timed=findViewById(R.id.timer);
|
||||
resultd=findViewById(R.id.patient_resultr);
|
||||
dated=findViewById(R.id.dater);
|
||||
@@ -74,6 +100,63 @@ public class TestDetails extends NavigationTop {
|
||||
|
||||
|
||||
getTestDetails(TestID);
|
||||
|
||||
shared.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(ContextCompat.checkSelfPermission(TestDetails.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED)
|
||||
{
|
||||
|
||||
ActivityCompat.requestPermissions(TestDetails.this,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},23);
|
||||
}
|
||||
else
|
||||
{
|
||||
createPdf();
|
||||
|
||||
Intent intent=new Intent(Intent.ACTION_SEND);
|
||||
intent.putExtra(Intent.EXTRA_TEXT,"Report");
|
||||
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N) {
|
||||
Uri path= FileProvider.getUriForFile(TestDetails.this,"in.sminnovations.arrest_tb.fileprovider",filePath);
|
||||
intent.putExtra(Intent.EXTRA_STREAM,path);
|
||||
}
|
||||
else{
|
||||
|
||||
intent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(filePath));
|
||||
}
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
intent.setType("application/pdf");
|
||||
startActivity(intent);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
dowbloadd.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(ContextCompat.checkSelfPermission(TestDetails.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED)
|
||||
{
|
||||
|
||||
ActivityCompat.requestPermissions(TestDetails.this,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},23);
|
||||
}
|
||||
else
|
||||
{
|
||||
createPdf();
|
||||
Toast.makeText(TestDetails.this, "File Downloaded", Toast.LENGTH_LONG).show();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
private void getTestDetails(String TestID)
|
||||
{
|
||||
@@ -114,5 +197,197 @@ public class TestDetails extends NavigationTop {
|
||||
}
|
||||
});
|
||||
}
|
||||
private void createPdf(){
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
PdfDocument document = new PdfDocument();
|
||||
|
||||
PdfDocument.PageInfo pageInfo = new PdfDocument.PageInfo.Builder(1000, 2000, 1).create();
|
||||
|
||||
PdfDocument.Page page = document.startPage(pageInfo);
|
||||
Canvas canvas = page.getCanvas();
|
||||
Paint paint = new Paint();
|
||||
paint.setTextSize(80);
|
||||
canvas.drawText("Arrest TB",40,80,paint);
|
||||
paint.setTextSize(30);
|
||||
canvas.drawText("ShanMukha Innovations Pvt Ltd",30,120,paint);
|
||||
paint.setTextAlign(Paint.Align.RIGHT);
|
||||
canvas.drawText(dated.getText().toString(),canvas.getWidth()-40,40,paint);
|
||||
canvas.drawText(timed.getText().toString(),canvas.getWidth()-40,80,paint);
|
||||
paint.setTextAlign(Paint.Align.LEFT);
|
||||
paint.setColor(Color.rgb(150,150,150));
|
||||
canvas.drawRect(30,250,canvas.getWidth()-30,300,paint);
|
||||
paint.setColor(Color.WHITE);
|
||||
canvas.drawText("Result",50,285,paint);
|
||||
// canvas.drawText("name 2",450,435,paint);
|
||||
paint.setTextAlign(Paint.Align.RIGHT);
|
||||
canvas.drawText(resultd.getText().toString(),canvas.getWidth()-40,285,paint);
|
||||
paint.setTextAlign(Paint.Align.LEFT);
|
||||
|
||||
|
||||
paint.setColor(Color.rgb(150,150,150));
|
||||
// canvas.drawRect(30,150,canvas.getWidth()-30,160,paint);
|
||||
|
||||
|
||||
canvas.drawRect(30,400,canvas.getWidth()-30,450,paint);
|
||||
paint.setColor(Color.WHITE);
|
||||
canvas.drawText("Patient ID",50,435,paint);
|
||||
canvas.drawText("Patient Gender",450,435,paint);
|
||||
paint.setTextAlign(Paint.Align.RIGHT);
|
||||
canvas.drawText("Date of Birth",canvas.getWidth()-40,435,paint);
|
||||
paint.setTextAlign(Paint.Align.LEFT);
|
||||
paint.setColor(Color.BLACK);
|
||||
|
||||
canvas.drawText(patient_id.getText().toString(),50,480,paint);
|
||||
canvas.drawText(patientgender.getText().toString(),450,480,paint);
|
||||
paint.setTextAlign(Paint.Align.RIGHT);
|
||||
canvas.drawText(patient_dob.getText().toString()+".",canvas.getWidth()-40,480,paint);
|
||||
|
||||
paint.setTextAlign(Paint.Align.RIGHT);
|
||||
|
||||
paint.setColor(Color.rgb(150,150,150));
|
||||
// canvas.drawRect(30,150,canvas.getWidth()-30,160,paint);
|
||||
|
||||
// canvas.drawRect(30,550,canvas.getWidth()-30,560,paint);
|
||||
canvas.drawRect(30,570,canvas.getWidth()-30,620,paint);
|
||||
|
||||
|
||||
paint.setColor(Color.WHITE);
|
||||
canvas.drawText("Age",100,605,paint);
|
||||
canvas.drawText("Nikshay ID ",540,605,paint);
|
||||
paint.setTextAlign(Paint.Align.RIGHT);
|
||||
canvas.drawText("NIRT Lab Number",canvas.getWidth()-40,605,paint);
|
||||
paint.setTextAlign(Paint.Align.LEFT);
|
||||
paint.setColor(Color.BLACK);
|
||||
|
||||
canvas.drawText(agepatient.getText().toString(),50,650,paint);
|
||||
canvas.drawText(patientnikshayid.getText().toString(),440,650,paint);
|
||||
paint.setTextAlign(Paint.Align.RIGHT);
|
||||
canvas.drawText(nirtlab.getText().toString(),canvas.getWidth()-40,650,paint);
|
||||
|
||||
paint.setTextAlign(Paint.Align.RIGHT);
|
||||
paint.setColor(Color.rgb(150,150,150));
|
||||
|
||||
canvas.drawRect(30,740,canvas.getWidth()-30,790,paint);
|
||||
|
||||
paint.setColor(Color.WHITE);
|
||||
canvas.drawText("SPIN Tube ID",220,775,paint);
|
||||
canvas.drawText("Type of Sample",540,775,paint);
|
||||
paint.setTextAlign(Paint.Align.RIGHT);
|
||||
canvas.drawText("Tube Validity",canvas.getWidth()-40,775,paint);
|
||||
paint.setTextAlign(Paint.Align.LEFT);
|
||||
paint.setColor(Color.BLACK);
|
||||
|
||||
canvas.drawText(spintubeid.getText().toString(),50,820,paint);
|
||||
canvas.drawText(patientsample.getText().toString(),440,820,paint);
|
||||
paint.setTextAlign(Paint.Align.RIGHT);
|
||||
canvas.drawText(validatyd.getText().toString(),canvas.getWidth()-40,820,paint);
|
||||
|
||||
paint.setTextAlign(Paint.Align.RIGHT);
|
||||
paint.setColor(Color.rgb(150,150,150));
|
||||
|
||||
// finish the page
|
||||
document.finishPage(page);
|
||||
|
||||
String directory_path = Environment.getExternalStorageDirectory().getPath() + "/ArrestTb/";
|
||||
File file = new File(directory_path);
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
String targetPdf = directory_path+"Report_"+patient_id.getText().toString()+".pdf";
|
||||
filePath = new File(targetPdf);
|
||||
|
||||
try {
|
||||
document.writeTo(new FileOutputStream(filePath));
|
||||
} catch (IOException e) {
|
||||
Log.e("main", "error "+e.toString());
|
||||
}
|
||||
|
||||
document.close();
|
||||
|
||||
}
|
||||
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater=getMenuInflater();
|
||||
inflater.inflate(R.menu.download,menu);
|
||||
MenuItem item = menu.findItem(R.id.share);
|
||||
MenuItem item1=menu.findItem(R.id.download1);
|
||||
item1.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
if(ContextCompat.checkSelfPermission(TestDetails.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED)
|
||||
{
|
||||
|
||||
ActivityCompat.requestPermissions(TestDetails.this,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},23);
|
||||
}
|
||||
else
|
||||
{
|
||||
//startCropImageActivity();
|
||||
createPdf();
|
||||
Toast.makeText(TestDetails.this, "File Downloaded", Toast.LENGTH_LONG).show();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
if(ContextCompat.checkSelfPermission(TestDetails.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED)
|
||||
{
|
||||
|
||||
ActivityCompat.requestPermissions(TestDetails.this,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},23);
|
||||
}
|
||||
else
|
||||
{
|
||||
createPdf();
|
||||
|
||||
Intent intent=new Intent(Intent.ACTION_SEND);
|
||||
intent.putExtra(Intent.EXTRA_TEXT,"Report");
|
||||
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N) {
|
||||
Uri path= FileProvider.getUriForFile(TestDetails.this,"in.sminnovations.arrest_tb.fileprovider",filePath);
|
||||
intent.putExtra(Intent.EXTRA_STREAM,path);
|
||||
}
|
||||
else{
|
||||
|
||||
intent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(filePath));
|
||||
}
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
intent.setType("application/pdf");
|
||||
startActivity(intent);
|
||||
|
||||
//startCropImageActivity();
|
||||
// createPdf(editText.getText().toString());
|
||||
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -48,9 +48,36 @@ public class TestResult extends NavigationTop implements AdapterView.OnItemSelec
|
||||
NIRTLabde = NIRTLabd.getText().toString();
|
||||
SPINTubeIDde = SPINTubeIDd.getText().toString();
|
||||
if (NIRTLabde.equals("") || SPINTubeIDde.equals("") || sampled.equals("")) {
|
||||
Toast.makeText(TestResult.this, "Please fill all fields", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(TestResult.this, "Please fill all required fields", Toast.LENGTH_SHORT).show();
|
||||
|
||||
} else {
|
||||
}
|
||||
else if ( NIRTLabde.length()!=6 )
|
||||
|
||||
{
|
||||
Toast.makeText(TestResult.this, "NIRT Lab Number must be 6 characters", Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
}
|
||||
else if (NIRTLabde.matches("^[a-zA-Z]*$") || NIRTLabde.matches("^[0-9]*$") )
|
||||
|
||||
{
|
||||
Toast.makeText(TestResult.this, "NIRT Lab Number must be alphanumeric", Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
}
|
||||
else if (SPINTubeIDde.length()!=6 )
|
||||
{
|
||||
Toast.makeText(TestResult.this, "Spin Tube ID must be 6 characters", Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
}
|
||||
else if (SPINTubeIDde.matches("^[a-zA-Z]*$") || SPINTubeIDde.matches("^[0-9]*$") )
|
||||
{
|
||||
Toast.makeText(TestResult.this, "Spin Tube ID must be alphanumeric", Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
if(ContextCompat.checkSelfPermission(TestResult.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED)
|
||||
{
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
android:textStyle="bold">
|
||||
|
||||
</ImageView>
|
||||
<TextView
|
||||
<!-- <TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
@@ -43,6 +43,18 @@
|
||||
android:textSize="@dimen/heading_size"
|
||||
android:textStyle="bold">
|
||||
|
||||
</TextView>-->
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:src="@drawable/shanmukha_logo_small"
|
||||
android:text="SpinTube App 1.0.0"
|
||||
android:textColor="#131313"
|
||||
android:textSize="@dimen/heading_size"
|
||||
android:textStyle="bold">
|
||||
|
||||
</TextView>
|
||||
<View
|
||||
android:layout_margin="20dp"
|
||||
|
||||
@@ -6,6 +6,37 @@
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical">
|
||||
<RelativeLayout
|
||||
|
||||
android:layout_width="fill_parent"
|
||||
|
||||
android:background="@android:color/holo_blue_light"
|
||||
android:layout_height="@android:dimen/app_icon_size"
|
||||
android:orientation="vertical">
|
||||
<ImageButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@android:dimen/app_icon_size"
|
||||
android:id="@+id/share"
|
||||
android:tint="@android:color/white"
|
||||
|
||||
android:layout_alignParentEnd="true"
|
||||
android:backgroundTint="@android:color/transparent"
|
||||
android:src="@android:drawable/ic_menu_share"
|
||||
android:layout_alignParentRight="true" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/downlaod"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginHorizontal="50dp"
|
||||
android:backgroundTint="@android:color/transparent"
|
||||
android:src="@android:drawable/stat_sys_download"
|
||||
android:tint="@android:color/white" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
<EditText
|
||||
android:id="@+id/NIRTLab"
|
||||
android:layout_width="match_parent"
|
||||
android:maxLength="7"
|
||||
android:maxLength="6"
|
||||
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<resources>
|
||||
<string name="app_name">Arrest TB </string>
|
||||
<string name="app_name">SpinTube App</string>
|
||||
<string name="open_navigation_drawer">Open navigation drawer</string>
|
||||
<string name="close_navigation_drawer">Close navigation drawer</string>
|
||||
<string name="asteriskred"><font color='#cc0029'>*</font></string>
|
||||
|
||||
@@ -6,7 +6,10 @@ buildscript {
|
||||
}
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:4.0.1"
|
||||
classpath 'com.google.gms:google-services:4.2.0'
|
||||
classpath 'com.google.gms:google-services:4.3.3'
|
||||
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'
|
||||
classpath "com.android.tools.build:gradle:4.0.1"
|
||||
classpath 'com.google.firebase:perf-plugin:1.3.4' // Performance Monitoring plugin
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
||||
1
image processing and models/arrest_tb_main.ipynb
Normal file
1
image processing and models/arrest_tb_main.ipynb
Normal file
File diff suppressed because one or more lines are too long
35
image processing and models/hsv.m
Normal file
35
image processing and models/hsv.m
Normal file
@@ -0,0 +1,35 @@
|
||||
clc;
|
||||
close all ;
|
||||
clear all ;
|
||||
|
||||
%% reading the image
|
||||
l=13;
|
||||
jpgFilename = strcat('e_images_',num2str(l), '.jpg');
|
||||
rgb=imread(jpgFilename);
|
||||
%% gray scaling
|
||||
gray = rgb2gray(rgb);
|
||||
figure(1);
|
||||
imshow(gray);
|
||||
title('gray scaled');
|
||||
|
||||
%% binary thresholding
|
||||
|
||||
[size1,size2]=size(gray);
|
||||
for i=1:size1
|
||||
for j=1:size2
|
||||
if gray(i,j)<60
|
||||
gray(i,j)=255;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
BW=im2bw(gray,graythresh(gray));
|
||||
|
||||
figure(2);
|
||||
imshow(BW);
|
||||
|
||||
%% hsv general
|
||||
hsv = rgb2hsv(rgb);
|
||||
figure(3);
|
||||
imshow(hsv);
|
||||
title('hsv')
|
||||
1
image processing and models/ragini-working-model.ipynb
Normal file
1
image processing and models/ragini-working-model.ipynb
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user