87 Commits

Author SHA1 Message Date
Ramandeep
4db4918e39 Arresttb Model latest 2021-09-21 00:44:52 +05:30
Raman deep
35fbea548a Ragini Working Model 2021-09-15 12:11:31 +00:00
Ragini.N
05c5f3ed13 Upload New File 2021-07-02 18:23:44 +00:00
Ragini.N
1f5ff24a59 Delete arrest-tb-MAIN_1.ipynb 2021-07-02 18:22:37 +00:00
Ragini.N
d5e737683a Upload New File 2021-07-02 14:40:27 +00:00
Ragini.N
753bc8e509 Delete arrest-tb-main__1_.ipynb 2021-07-02 14:39:30 +00:00
Ragini.N
ec8eca030a Upload New File 2021-07-02 13:55:52 +00:00
Ragini.N
40b602c1be Delete arrest-tb-main.ipynb 2021-07-02 13:55:05 +00:00
Ragini.N
4753b35567 Upload New File 2021-07-02 07:51:32 +00:00
Ragini.N
efa2fa42fb Delete arrest-tb-main.ipynb 2021-07-02 07:51:03 +00:00
Ragini.N
24b156175d Upload New File 2021-06-16 11:18:32 +00:00
Ragini.N
96e5831170 Upload New File 2021-06-16 11:18:08 +00:00
developerraman
737e353454 Merge remote-tracking branch 'origin/master' 2021-05-23 02:47:49 +05:30
developerraman
d58fef2180 Added sharing and downloading button for previous results.
Date of birth format change from month-date-year to date-month-year
2021-05-23 02:47:03 +05:30
Ragini.N
4a4e7e244c Upload New File 2021-03-02 07:33:26 +00:00
Ragini.N
986530f6c7 Upload New File 2021-03-02 07:26:36 +00:00
Ragini.N
0138de0725 Delete converted_tflite_quantized_14-02-2021_.zip 2021-03-02 07:25:41 +00:00
Ragini.N
633a6d70df Delete converted_tflite_floating_14-02-2021_.zip 2021-03-02 07:25:23 +00:00
developerraman
52df04a5c9 Removed compulsion on Nikshay number,Added the calculation of age automatically,
character limit NIRT lab number and spin tube ID are 6 ,All the Automation Test Cases are edited ,About app Version Added ,Email ids for notify pipeline output are added.
2021-03-02 00:39:08 +05:30
Raman deep
9dfcad6a3b Update .gitlab-ci.yml 2021-03-01 18:18:44 +00:00
Raman deep
a2b3c78860 Updated the gitlab-ci.yml yaml file, character limit NIRT lab number and spin tube ID are 6 ,All the Automation Test Cases are edited ,About app Version Added ,Email ids for notify pipeline output are added. 2021-03-01 17:50:13 +00:00
developerraman
dfa6f947eb Removed compulsion on Nikshay number,Added the calculation of age automatically,
character limit NIRT lab number and spin tube ID are 6 ,All the Automation Test Cases are edited ,About app Version Added ,Email ids for notify pipeline output are added.
2021-03-01 22:50:21 +05:30
developerraman
a3b0c19e3f Complete Automation Test Cases 2021-02-18 05:08:50 +05:30
Raman deep
31fa1afd13 Update .gitlab-ci.yml 2021-02-17 18:24:49 +00:00
Raman deep
e89127ead5 Update .gitlab-ci.yml 2021-02-17 18:19:49 +00:00
Raman deep
4367114a2c Update .gitlab-ci.yml 2021-02-17 18:18:18 +00:00
Raman deep
311eb73524 Update .gitlab-ci.yml 2021-02-17 18:17:59 +00:00
Raman deep
cc4169e606 Update .gitlab-ci.yml 2021-02-17 18:17:04 +00:00
Raman deep
1eb16401d1 Update .gitlab-ci.yml 2021-02-17 18:15:27 +00:00
Raman deep
b4cd61fce1 Update .gitlab-ci.yml 2021-02-17 18:14:20 +00:00
Raman deep
0661f98401 Update .gitlab-ci.yml 2021-02-17 18:06:20 +00:00
Raman deep
46a6d34ee2 Update .gitlab-ci.yml 2021-02-17 17:47:34 +00:00
Raman deep
307f364be9 Update .gitlab-ci.yml 2021-02-17 17:40:10 +00:00
Raman deep
591bb08ad1 Update .gitlab-ci.yml 2021-02-17 17:34:14 +00:00
Raman deep
ca2f5f0e17 Update .gitlab-ci.yml 2021-02-17 17:31:47 +00:00
Raman deep
b97e9b7f58 Update .gitlab-ci.yml 2021-02-17 17:30:55 +00:00
Raman deep
306df95ad2 Update .gitlab-ci.yml 2021-02-17 16:14:34 +00:00
Raman deep
6eccef7b8b Update .gitlab-ci.yml 2021-02-17 16:10:34 +00:00
Raman deep
3d6685d360 Update .gitlab-ci.yml 2021-02-17 16:07:52 +00:00
Raman deep
eaf74de979 Update .gitlab-ci.yml 2021-01-31 18:25:15 +00:00
Raman deep
ea3dc78def Update .gitlab-ci.yml 2021-01-31 18:16:40 +00:00
Raman deep
416fc5c940 Update .gitlab-ci.yml 2021-01-31 18:03:14 +00:00
Raman deep
9c1d75df57 Update .gitlab-ci.yml 2021-01-31 18:02:50 +00:00
Raman deep
94c40b0bec Update .gitlab-ci.yml 2021-01-31 17:45:48 +00:00
Raman deep
6b33b3bda7 Update .gitlab-ci.yml 2021-01-31 17:37:30 +00:00
Raman deep
e213796b6a Update .gitlab-ci.yml 2021-01-31 17:34:04 +00:00
Raman deep
ca17445075 Update .gitlab-ci.yml 2021-01-31 17:27:09 +00:00
Raman deep
4685984be6 Update .gitlab-ci.yml 2021-01-31 17:08:03 +00:00
Raman deep
03bbb3ac68 Update .gitlab-ci.yml 2021-01-31 16:48:02 +00:00
Raman deep
0dd79fcc63 Update .gitlab-ci.yml 2021-01-31 14:22:33 +00:00
Raman deep
c38287d5b1 Update .gitlab-ci.yml 2021-01-31 14:18:09 +00:00
Raman deep
83fcdda9f6 Update .gitlab-ci.yml 2021-01-31 14:11:01 +00:00
Raman deep
ee1cc63d67 Update .gitlab-ci.yml 2021-01-31 14:10:18 +00:00
Raman deep
288e90d19b Update .gitlab-ci.yml 2021-01-31 14:07:20 +00:00
Raman deep
bb74bcd88f Update .gitlab-ci.yml 2021-01-31 14:01:15 +00:00
Raman deep
2b73023ea5 Update .gitlab-ci.yml 2021-01-30 05:51:14 +00:00
Raman deep
ceda32d254 Update .gitlab-ci.yml 2021-01-30 05:47:38 +00:00
Raman deep
1ec4e2d664 Update .gitlab-ci.yml 2021-01-30 05:41:02 +00:00
Raman deep
bab757388b Update .gitlab-ci.yml 2021-01-30 05:38:55 +00:00
Raman deep
43c335f944 Update .gitlab-ci.yml 2021-01-29 08:52:37 +00:00
Raman deep
c37b044b98 Update .gitlab-ci.yml 2021-01-29 08:48:01 +00:00
Raman deep
104e076f4c Update .gitlab-ci.yml 2021-01-29 08:28:23 +00:00
Raman deep
d04f1d990a Update .gitlab-ci.yml 2021-01-29 08:07:34 +00:00
Raman deep
ac9d2e053e Update .gitlab-ci.yml 2021-01-29 07:49:33 +00:00
Raman deep
43b5eea6de Update .gitlab-ci.yml 2021-01-29 07:34:48 +00:00
Raman deep
dedc6b169b Update .gitlab-ci.yml file 2021-01-28 19:54:38 +00:00
Raman deep
ab496a2300 Update .gitlab-ci.yml file 2021-01-28 19:54:33 +00:00
Raman deep
954ca843fc Update .gitlab-ci.yml 2021-01-28 19:49:39 +00:00
Raman deep
6cd0f3d7bf Update .gitlab-ci.yml 2021-01-28 19:41:32 +00:00
Raman deep
e40827a466 Update .gitlab-ci.yml 2021-01-28 19:16:11 +00:00
Raman deep
196bd680f7 Update .gitlab-ci.yml 2021-01-28 19:07:47 +00:00
Raman deep
25b512e6c7 Update .gitlab-ci.yml 2021-01-28 18:48:11 +00:00
Raman deep
3d41ad20c8 Update .gitlab-ci.yml 2021-01-28 18:27:32 +00:00
Raman deep
d126f52f9d Update .gitlab-ci.yml 2021-01-28 18:21:14 +00:00
Raman deep
3087197ccd Update .gitlab-ci.yml 2021-01-28 18:20:14 +00:00
Raman deep
cdd3690d9d Update .gitlab-ci.yml 2021-01-28 18:08:05 +00:00
Raman deep
0ceca45b67 Update .gitlab-ci.yml 2021-01-28 17:54:13 +00:00
Raman deep
a651c7ed84 Update .gitlab-ci.yml 2021-01-28 17:31:27 +00:00
developerraman
6a80fc19f0 Merge remote-tracking branch 'origin/master' 2021-01-28 22:59:02 +05:30
developerraman
0b523696c3 Espresso Test Check 2021-01-28 22:54:33 +05:30
Raman deep
b8eb32e7b3 Add .gitlab-ci.yml 2021-01-28 17:21:52 +00:00
Raman deep
bb00b599b3 Delete .gitlab-ci.yml 2021-01-28 16:59:40 +00:00
developerraman
719c0137fb Espresso Login Activity Test Cases 2021-01-28 17:46:04 +05:30
developerraman
ce49e907a2 Permission handling Library ,Crashlytics Library ,Espresso Library and Patient Details and Test Details Data added 2021-01-28 17:09:06 +05:30
developerraman
46feddd88f Permission handling Library ,Espresso and Validation Attributes Added 2021-01-28 16:39:46 +05:30
Ragini.N
f97f15309f Delete e_images_10.jpg 2021-01-27 10:55:54 +00:00
Ragini.N
7540512743 Upload New File(s) 2021-01-27 10:55:36 +00:00
36 changed files with 2569 additions and 136 deletions

View File

@@ -20,6 +20,11 @@ variables:
# when the script was last modified for latest compileSdkVersion, it was which is written down below # when the script was last modified for latest compileSdkVersion, it was which is written down below
ANDROID_SDK_TOOLS: "6514223" ANDROID_SDK_TOOLS: "6514223"
# Packages installation before running script
stages:
- build
- test
# Packages installation before running script # Packages installation before running script
before_script: before_script:
- apt-get --quiet update --yes - apt-get --quiet update --yes
@@ -54,25 +59,61 @@ before_script:
# Basic android and gradle stuff # Basic android and gradle stuff
# Check linting # Check linting
lintDebug: build_debug:
interruptible: true
stage: build
script:
- ./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint
# Make Project
assembleDebug:
interruptible: true
stage: build stage: build
script: script:
- ./gradlew assembleDebug - ./gradlew assembleDebug
- ./gradlew assembleDebugAndroidTest
artifacts: artifacts:
paths: paths:
- app/build/outputs/ - app/build/outputs/
# Run all tests, if any fails, interrupt the pipeline(fail it)
debugTests: .test_lab_template: &test_lab_template_def
interruptible: true
stage: test stage: test
script: before_script:
- ./gradlew -Pci --console=plain :app:testDebug # 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:
- 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
View File

@@ -1 +1 @@
Spin Tube App arrest_tb

6
.idea/compiler.xml generated Normal file
View 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
View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <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" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View File

@@ -3,6 +3,7 @@
<component name="RunConfigurationProducerService"> <component name="RunConfigurationProducerService">
<option name="ignoredProducers"> <option name="ignoredProducers">
<set> <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.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" /> <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" /> <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />

View File

@@ -1,13 +1,11 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
android { android {
compileSdkVersion 29 compileSdkVersion 29
buildToolsVersion "29.0.3" buildToolsVersion "29.0.3"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig { defaultConfig {
applicationId "in.sminnovations.arrest_tb" applicationId "in.sminnovations.arrest_tb"
@@ -15,6 +13,7 @@ android {
targetSdkVersion 29 targetSdkVersion 29
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }
@@ -25,6 +24,10 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
} }
} }
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
aaptOptions { aaptOptions {
noCompress "tflite" noCompress "tflite"
noCompress "lite" noCompress "lite"
@@ -54,6 +57,7 @@ dependencies {
implementation 'com.google.firebase:firebase-config:20.0.0' implementation 'com.google.firebase:firebase-config:20.0.0'
implementation 'com.google.firebase:firebase-auth:20.0.1' implementation 'com.google.firebase:firebase-auth:20.0.1'
implementation 'com.google.firebase:firebase-database:19.5.1' implementation 'com.google.firebase:firebase-database:19.5.1'
implementation 'com.google.firebase:firebase-storage:19.2.0' implementation 'com.google.firebase:firebase-storage:19.2.0'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
@@ -61,5 +65,16 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' 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'
} }

View File

@@ -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());
}
}

View File

@@ -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.
}
}

View File

@@ -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.
}
}

View File

@@ -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.
}

View File

@@ -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.
}
*/
}

View File

@@ -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.
}
}

View File

@@ -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();
}
}
}

View File

@@ -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.
}

View File

@@ -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;
}
}

View File

@@ -4,21 +4,19 @@
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application <application
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:requestLegacyExternalStorage="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<provider <provider
android:name="androidx.core.content.FileProvider" android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider" android:authorities="${applicationId}.fileprovider"
@@ -28,66 +26,75 @@
android:name="android.support.FILE_PROVIDER_PATHS" android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_path" /> android:resource="@xml/file_path" />
</provider> </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>
<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"
>
</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 <activity
android:name="com.theartofdev.edmodo.cropper.CropImageActivity" 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"></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" /> android:theme="@style/Base.Theme.AppCompat" />
</application> </application>

View File

@@ -1,2 +1,2 @@
0 negative 0 positive
1 positive 1 negative

Binary file not shown.

View File

@@ -40,6 +40,7 @@ import com.theartofdev.edmodo.cropper.CropImageView;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
@@ -332,12 +333,16 @@ public class AddImage extends NavigationTop {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
SimpleDateFormat currentDate = new SimpleDateFormat("MMM dd, yyyy"); 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()); saveCurrentTime = currentTime.format(calendar.getTime());
TestRandomKey = saveCurrentDate + saveCurrentTime+number; TestRandomKey = saveCurrentDate + saveCurrentTime+number;
TestRandomKey = TestRandomKey .replaceAll("[^A-Za-z0-9 ]","");
final StorageReference filePath1 =TestImagesRef.child(ImageUri1.getLastPathSegment() + TestRandomKey + ".jpg"); final StorageReference filePath1 =TestImagesRef.child(ImageUri1.getLastPathSegment() + TestRandomKey + ".jpg");

View File

@@ -1,5 +1,6 @@
package in.sminnovations.arrest_tb; package in.sminnovations.arrest_tb;
import android.Manifest;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.DatePickerDialog; import android.app.DatePickerDialog;
import android.content.Context; import android.content.Context;
@@ -9,7 +10,11 @@ import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Settings;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@@ -24,7 +29,22 @@ import android.widget.Toast;
import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat; 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.Calendar;
import java.util.Date;
import java.util.List;
public class PatientDetail extends NavigationTop implements AdapterView.OnItemSelectedListener { public class PatientDetail extends NavigationTop implements AdapterView.OnItemSelectedListener {
private Button next_act; private Button next_act;
@@ -33,6 +53,7 @@ public class PatientDetail extends NavigationTop implements AdapterView.OnItemSe
String gender; String gender;
private GpsTracker gpsTracker; private GpsTracker gpsTracker;
String lat,logi; String lat,logi;
int diff1=0;
@@ -51,7 +72,33 @@ public class PatientDetail extends NavigationTop implements AdapterView.OnItemSe
Age=findViewById(R.id.age); Age=findViewById(R.id.age);
NikshayId=findViewById(R.id.NikshayID); 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, ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.Gender, android.R.layout.simple_spinner_item); 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) { public void onDateSet(DatePicker datePicker, int year, int month, int day) {
month = month + 1; month = month + 1;
String date = month + "/" + day + "/" + year; String date = day + "-" + month + "-" + year;
mDisplayDate.setText(date); mDisplayDate.setText(date);
patientdob=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); // setContentView(R.layout.activity_patient_detail);
next_act=findViewById(R.id.next); next_act=findViewById(R.id.next);
next_act.setOnClickListener(new View.OnClickListener() { next_act.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@@ -102,10 +200,66 @@ public class PatientDetail extends NavigationTop implements AdapterView.OnItemSe
patientid = patient_ID.getText().toString(); patientid = patient_ID.getText().toString();
patientage = Age.getText().toString(); patientage = Age.getText().toString();
patientnikshayid = NikshayId.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(); 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 preferences = getSharedPreferences("PhoneBook", MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit(); SharedPreferences.Editor editor = preferences.edit();
@@ -196,6 +350,60 @@ public class PatientDetail extends NavigationTop implements AdapterView.OnItemSe
gpsTracker.showSettingsAlert(); 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();
}

View File

@@ -101,20 +101,46 @@ String numberwithcode;
else { else {
if (mobile.equals("") || name.equals("")) { if (mobile.equals("") || name.equals("")) {
Toast.makeText(Register.this, "please enter all the required fields", Toast.LENGTH_SHORT).show(); Toast.makeText(Register.this, "Please enter all the required fields", Toast.LENGTH_SHORT).show();
} else if (!Patterns.PHONE.matcher(mobile).matches()) { } else if (!Patterns.PHONE.matcher(mobile).matches()) {
editTextMobile.setError("Enter a valid Phone "); 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(); // Toast.makeText(Consumer_register.this, "Please Enter a valid email", Toast.LENGTH_SHORT).show();
} else { }
else if (mobile.length() <9 ) {
Toast.makeText(Register.this, "Enter a valid Phone", Toast.LENGTH_SHORT).show();
// Toast.makeText(Consumer_register.this, "Please Enter a valid email", Toast.LENGTH_SHORT).show();
}
else if (mobile.length() >=11 ) {
Toast.makeText(Register.this, "Enter a valid Phone", Toast.LENGTH_SHORT).show();
// Toast.makeText(Consumer_register.this, "Please Enter a valid email", Toast.LENGTH_SHORT).show();
}
else {
Query chekuser = FirebaseDatabase.getInstance().getReference("USERS").orderByChild("number").equalTo(mobile); Query chekuser = FirebaseDatabase.getInstance().getReference("USERS").orderByChild("number").equalTo(mobile);
chekuser.addListenerForSingleValueEvent(new ValueEventListener() { chekuser.addListenerForSingleValueEvent(new ValueEventListener() {
@Override @Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) { public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if (dataSnapshot.exists()) { if (dataSnapshot.exists()) {
editTextMobile.setError("User Already Exist "); Toast.makeText(Register.this, "User Already Exist", Toast.LENGTH_SHORT).show();
} else { } else {
@@ -125,10 +151,10 @@ String numberwithcode;
Log.e("main", "error " + numberwithcode); Log.e("main", "error " + numberwithcode);
if (mobile.equals("") || name.equals("")) { if (mobile.equals("") || name.equals("")) {
Toast.makeText(Register.this, "please enter all the required fields", Toast.LENGTH_SHORT).show(); Toast.makeText(Register.this, "Please enter all the required fields", Toast.LENGTH_SHORT).show();
} else if (!Patterns.PHONE.matcher(mobile).matches()) { } else if (!Patterns.PHONE.matcher(mobile).matches()) {
editTextMobile.setError("Enter a valid Phone "); editTextMobile.setError("Enter a valid Phone");
// Toast.makeText(Consumer_register.this, "Please Enter a valid email", Toast.LENGTH_SHORT).show(); // Toast.makeText(Consumer_register.this, "Please Enter a valid email", Toast.LENGTH_SHORT).show();
} else { } else {

View File

@@ -122,7 +122,7 @@ public class Report extends NavigationTop {
Intent intent=new Intent(Intent.ACTION_SEND); Intent intent=new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT,"Report"); intent.putExtra(Intent.EXTRA_TEXT,"Report");
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N) { 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); intent.putExtra(Intent.EXTRA_STREAM,path);
} }
else{ else{

View File

@@ -28,9 +28,14 @@ public class TensorFlowImageClassifier implements Classifier {
private static final int PIXEL_SIZE = 3; private static final int PIXEL_SIZE = 3;
private static final float THRESHOLD = 0.1f; 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 Interpreter interpreter;
private int inputSize; private int inputSize;
private List<String> labelList; private List<String> labelList;
private boolean quant;
private TensorFlowImageClassifier() { private TensorFlowImageClassifier() {
@@ -52,9 +57,13 @@ public class TensorFlowImageClassifier implements Classifier {
@Override @Override
public List<Recognition> recognizeImage(Bitmap bitmap) { public List<Recognition> recognizeImage(Bitmap bitmap) {
ByteBuffer byteBuffer = convertBitmapToByteBuffer(bitmap); ByteBuffer byteBuffer = convertBitmapToByteBuffer(bitmap);
/* ByteBuffer byteBuffer = convertBitmapToByteBuffer(bitmap);
byte[][] result = new byte[1][labelList.size()]; byte[][] result = new byte[1][labelList.size()];
interpreter.run(byteBuffer, result); 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 @Override
@@ -84,7 +93,8 @@ public class TensorFlowImageClassifier implements Classifier {
} }
private ByteBuffer convertBitmapToByteBuffer(Bitmap bitmap) { 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()); byteBuffer.order(ByteOrder.nativeOrder());
int[] intValues = new int[inputSize * inputSize]; int[] intValues = new int[inputSize * inputSize];
bitmap.getPixels(intValues, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight()); 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 i = 0; i < inputSize; ++i) {
for (int j = 0; j < inputSize; ++j) { for (int j = 0; j < inputSize; ++j) {
final int val = intValues[pixel++]; final int val = intValues[pixel++];
byteBuffer.put((byte) ((val >> 16) & 0xFF)); byteBuffer.putFloat((((val >> 16) & 0xFF)-IMAGE_MEAN)/IMAGE_STD);
byteBuffer.put((byte) ((val >> 8) & 0xFF)); byteBuffer.putFloat((((val >> 8) & 0xFF)-IMAGE_MEAN)/IMAGE_STD);
byteBuffer.put((byte) (val & 0xFF)); byteBuffer.putFloat((((val) & 0xFF)-IMAGE_MEAN)/IMAGE_STD);
} }
} }
return byteBuffer; return byteBuffer;
} }
@SuppressLint("DefaultLocale") @SuppressLint("DefaultLocale")
private List<Recognition> getSortedResult(byte[][] labelProbArray) { private List<Recognition> getSortedResultFloat(float[][] labelProbArray) {
PriorityQueue<Recognition> pq = PriorityQueue<Recognition> pq =
new PriorityQueue<>( new PriorityQueue<>(
@@ -114,7 +126,7 @@ public class TensorFlowImageClassifier implements Classifier {
}); });
for (int i = 0; i < labelList.size(); ++i) { for (int i = 0; i < labelList.size(); ++i) {
float confidence = (labelProbArray[0][i] & 0xff) / 255.0f; float confidence = labelProbArray[0][i];
if (confidence > THRESHOLD) { if (confidence > THRESHOLD) {
pq.add(new Recognition("" + i, pq.add(new Recognition("" + i,
labelList.size() > i ? labelList.get(i) : "unknown", labelList.size() > i ? labelList.get(i) : "unknown",

View File

@@ -1,15 +1,33 @@
package in.sminnovations.arrest_tb; package in.sminnovations.arrest_tb;
import android.Manifest;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences; 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.Bundle;
import android.os.Environment;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; 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.bumptech.glide.Glide;
import com.google.firebase.database.DataSnapshot; import com.google.firebase.database.DataSnapshot;
@@ -19,6 +37,8 @@ import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener; import com.google.firebase.database.ValueEventListener;
import java.io.File; import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
@@ -32,7 +52,9 @@ public class TestDetails extends NavigationTop {
String date,time,number; String date,time,number;
private String TestID = ""; private String TestID = "";
ImageButton shared ,dowbloadd;
File filePath=null;
@Override @Override
@@ -42,7 +64,10 @@ public class TestDetails extends NavigationTop {
.getSystemService(Context.LAYOUT_INFLATER_SERVICE); .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View contentView = inflater.inflate(R.layout.activity_spin__test, null, false); View contentView = inflater.inflate(R.layout.activity_spin__test, null, false);
draw.addView(contentView, 0); draw.addView(contentView, 0);
shared=findViewById(R.id.share);
dowbloadd=findViewById(R.id.downlaod);
patient_id=findViewById(R.id.patient_idr); patient_id=findViewById(R.id.patient_idr);
patient_dob=findViewById(R.id.patien_dobr); patient_dob=findViewById(R.id.patien_dobr);
patientnikshayid=findViewById(R.id.patient_nikshayidr); patientnikshayid=findViewById(R.id.patient_nikshayidr);
@@ -60,6 +85,7 @@ public class TestDetails extends NavigationTop {
validatyd=findViewById(R.id.patient_tubevisibler); validatyd=findViewById(R.id.patient_tubevisibler);
spintubeid=findViewById(R.id.patient_spintuber); spintubeid=findViewById(R.id.patient_spintuber);
nirtlab=findViewById(R.id.patient_nirtr); nirtlab=findViewById(R.id.patient_nirtr);
timed=findViewById(R.id.timer); timed=findViewById(R.id.timer);
resultd=findViewById(R.id.patient_resultr); resultd=findViewById(R.id.patient_resultr);
dated=findViewById(R.id.dater); dated=findViewById(R.id.dater);
@@ -74,6 +100,63 @@ public class TestDetails extends NavigationTop {
getTestDetails(TestID); 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) 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);
}
} }

View File

@@ -48,9 +48,36 @@ public class TestResult extends NavigationTop implements AdapterView.OnItemSelec
NIRTLabde = NIRTLabd.getText().toString(); NIRTLabde = NIRTLabd.getText().toString();
SPINTubeIDde = SPINTubeIDd.getText().toString(); SPINTubeIDde = SPINTubeIDd.getText().toString();
if (NIRTLabde.equals("") || SPINTubeIDde.equals("") || sampled.equals("")) { 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) if(ContextCompat.checkSelfPermission(TestResult.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED)
{ {

View File

@@ -32,7 +32,7 @@
android:textStyle="bold"> android:textStyle="bold">
</ImageView> </ImageView>
<TextView <!-- <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
@@ -43,6 +43,18 @@
android:textSize="@dimen/heading_size" android:textSize="@dimen/heading_size"
android:textStyle="bold"> 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> </TextView>
<View <View
android:layout_margin="20dp" android:layout_margin="20dp"

View File

@@ -6,6 +6,37 @@
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"> 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>

View File

@@ -73,7 +73,7 @@
<EditText <EditText
android:id="@+id/NIRTLab" android:id="@+id/NIRTLab"
android:layout_width="match_parent" android:layout_width="match_parent"
android:maxLength="7" android:maxLength="6"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"

View File

@@ -1,5 +1,5 @@
<resources> <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="open_navigation_drawer">Open navigation drawer</string>
<string name="close_navigation_drawer">Close navigation drawer</string> <string name="close_navigation_drawer">Close navigation drawer</string>
<string name="asteriskred"><font color='#cc0029'>*</font></string> <string name="asteriskred"><font color='#cc0029'>*</font></string>

View File

@@ -6,7 +6,10 @@ buildscript {
} }
dependencies { dependencies {
classpath "com.android.tools.build:gradle:4.0.1" 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 // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files

File diff suppressed because one or more lines are too long

View 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')

File diff suppressed because one or more lines are too long