Skip to content
Permalink
Browse files
Changes in Xml files and Manifest // express testing in MainActivity
  • Loading branch information
dacost13 committed Sep 14, 2021
1 parent d26078d commit 4b4c33655e8d9c62a8f028a5adf337c4e2e5d960
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 20 deletions.
@@ -49,8 +49,14 @@ dependencies {
testImplementation 'org.mockito:mockito-core:1.10.19'
testImplementation 'androidx.test:core:1.0.0'
testImplementation "com.google.truth:truth:1.1.2"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test:rules:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.4.0'




implementation 'com.google.android.material:material:1.2.0'
@@ -0,0 +1,66 @@
package com.example.booksharing21;


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.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;

import androidx.test.ext.junit.rules.ActivityScenarioRule;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AndroidJUnit4.class)
@SmallTest
public class MainActivityExpress {


private static final String VALID_Email = "john.doe@outlook.com";

private static final String VALID_Password = "1234john";

@Rule
public ActivityScenarioRule<MainActivity> activityRule =
new ActivityScenarioRule<>(MainActivity.class);


// android developers https://developer.android.com/training/testing/espresso/basics
// checking users credentials

@Test
public void ValidCredentials() {
onView(withId(R.id.email)).perform(typeText(VALID_Email), closeSoftKeyboard());
onView(withId(R.id.password)).perform(typeText(VALID_Password),closeSoftKeyboard()); }
@Test
public void WrongEmail(){
onView(withId(R.id.email)).perform(typeText("john"),closeSoftKeyboard());
onView(withId(R.id.password)).perform(typeText(VALID_Password),closeSoftKeyboard()); }

@Test
public void WrongPassword(){
onView(withId(R.id.email)).perform(typeText(VALID_Email),closeSoftKeyboard());
onView(withId(R.id.password)).perform(typeText("doe"),closeSoftKeyboard()); }

@Test
public void NoCredentials(){
onView(withId(R.id.email)).perform(typeText(""),closeSoftKeyboard());
onView(withId(R.id.password)).perform(typeText(""),closeSoftKeyboard()); }


@Test
public void RegButton(){ onView(withId(R.id.reg)).perform(click()); }
@Test
public void logButton(){ onView(withId(R.id.log)).perform(click()).check(matches(isDisplayed())); }





}
@@ -29,8 +29,8 @@

<meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/map_key" />
<activity android:name=".BProfileActivity"></activity>
<activity android:name="MainActivity"></activity>
<activity android:name=".HomeActivity" />
<activity android:name=".MainActivity" />
<activity android:name=".RegisterActivity" />
<activity android:name=".SplashActivity">
<intent-filter>
@@ -231,7 +231,7 @@ public class RegisterActivity extends AppCompatActivity implements View.OnClickL

String username = editusername.getText().toString().trim();
if (username.isEmpty()) {
editusername.setError("Username is Required");
editusername.setError("Invalid Username");
editusername.requestFocus();
return Boolean.FALSE;
}else{
@@ -1,11 +1,11 @@
package com.example.booksharing21;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import androidx.appcompat.app.AppCompatActivity;

public class SplashActivity extends AppCompatActivity {

private static int SPLASH_TIME_OUT = 4000;
@@ -21,7 +21,7 @@ public class SplashActivity extends AppCompatActivity {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent homeIntent = new Intent(SplashActivity.this, com.example.booksharing21.MainActivity.class);
Intent homeIntent = new Intent(SplashActivity.this,MainActivity.class);
startActivity(homeIntent);
finish();
}
@@ -3,8 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".BProfileActivity">
android:layout_height="match_parent">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_height="wrap_content"
@@ -3,8 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
android:layout_height="match_parent">


<ImageView
@@ -15,12 +15,13 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/booksharinglogo" />
app:srcCompat="@drawable/booksharinglogo"
android:contentDescription="Logo" />

<EditText
android:id="@+id/username"
android:layout_width="280dp"
android:layout_height="42dp"
android:layout_height="48dp"
android:layout_marginStart="24dp"
android:layout_marginLeft="24dp"
android:layout_marginTop="176dp"
@@ -36,7 +37,7 @@
<EditText
android:id="@+id/password"
android:layout_width="280dp"
android:layout_height="42dp"
android:layout_height="48dp"
android:layout_marginStart="24dp"
android:layout_marginLeft="24dp"
android:layout_marginTop="240dp"
@@ -52,7 +53,7 @@
<EditText
android:id="@+id/password2"
android:layout_width="280dp"
android:layout_height="42dp"
android:layout_height="48dp"
android:layout_marginStart="24dp"
android:layout_marginLeft="24dp"
android:layout_marginTop="304dp"
@@ -68,7 +69,7 @@
<EditText
android:id="@+id/email"
android:layout_width="340dp"
android:layout_height="42dp"
android:layout_height="48dp"
android:layout_marginStart="24dp"
android:layout_marginLeft="24dp"
android:layout_marginTop="368dp"
@@ -83,7 +84,7 @@
<EditText
android:id="@+id/phone"
android:layout_width="340dp"
android:layout_height="42dp"
android:layout_height="48dp"
android:layout_marginStart="24dp"
android:layout_marginLeft="24dp"
android:layout_marginTop="432dp"
@@ -98,7 +99,7 @@
<EditText
android:id="@+id/address"
android:layout_width="340dp"
android:layout_height="42dp"
android:layout_height="48dp"
android:layout_marginStart="24dp"
android:layout_marginLeft="24dp"
android:layout_marginTop="496dp"
@@ -113,14 +114,14 @@
<Button
android:id="@+id/reg1"
android:layout_width="206dp"
android:layout_height="45dp"
android:layout_height="48dp"
android:layout_marginStart="96dp"
android:layout_marginLeft="96dp"
android:layout_marginTop="188dp"
android:background="@color/backgroundColor"
android:text="Register"

android:textColor="@color/textColor"
android:textColor="#37474F"
android:textSize="12sp"
android:theme="@style/AppTheme"
app:layout_constraintStart_toStartOf="parent"
@@ -6,9 +6,7 @@ import static org.junit.Assert.assertTrue;
import org.junit.Test;



// Register Testing

public class RegisterValidationTest {


0 comments on commit 4b4c336

Please sign in to comment.