Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nirja debta #131

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

174 changes: 95 additions & 79 deletions app/app.iml

Large diffs are not rendered by default.

20 changes: 13 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ android {
storePassword ''
}
}
compileSdkVersion 23
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.avjindersinghsekhon.minimaltodo"
minSdkVersion 16
targetSdkVersion 23
targetSdkVersion 28
versionCode 3
versionName "1.2"
testInstrumentationRunner = 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
Expand All @@ -33,14 +34,19 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.gms:play-services-analytics:7.8.0'
implementation 'com.google.android.gms:play-services-analytics:17.0.0'
implementation 'uk.co.chrisjenx:calligraphy:2.1.0'
implementation 'com.github.ganfra:material-spinner:1.1.0'
implementation 'com.wdullaer:materialdatetimepicker:1.5.1'
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation 'com.github.ganfra:material-spinner:1.1.0'
implementation 'com.android.support:recyclerview-v7:23.1.0'
implementation 'com.android.support:design:23.1.0'
implementation 'com.android.support:appcompat-v7:23.1.0'
implementation 'com.android.support:support-v13:23.1.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha07'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package com.example.avjindersinghsekhon.minimaltodo.Main;


import androidx.test.espresso.Espresso;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;

import com.example.avjindersinghsekhon.minimaltodo.R;

import org.junit.Before;
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.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;

@RunWith(AndroidJUnit4.class)


public class MainActivityTest_Nirja {
@Rule
public ActivityTestRule mActivityRule = new ActivityTestRule(MainActivity.class);

@Before
public void setUp() {
Espresso.closeSoftKeyboard();
onView(withId(R.id.addToDoItemFAB))
// to check whether the plus button is visible to the user or not
.check(matches(isDisplayed()))
.perform(click());
}

//Neeraja what's this test for? I don't think we need to test the constext of the App.
// @Test
// public void useAppContext() throws Exception {
// // Context of the app under test.
// Context appContext = InstrumentationRegistry.getTargetContext();
//
// assertEquals("com.example.avjindersinghsekhon.minimaltodo",
// appContext.getPackageName());
// }


@Test
public void activityLaunch() {
// to check whether the user able to click the button or not
// then check whether after clicking the plus button First screen switches to second screen
onView(withId(R.id.userToDoEditText)).check(matches(isDisplayed()));
// Is editing text is visible or not
onView(withId(R.id.userToDoDescription)).check(matches(isDisplayed()));
//is description text is visible or not
onView(withId(R.id.userToDoRemindMeTextView)).check(matches(isDisplayed()));
// Remind me text is visible or not
onView(withId(R.id.copyclipboard)).check(matches(isDisplayed()));
// copy to clipboard
onView(withId(R.id.makeToDoFloatingActionButton)).check(matches(isDisplayed()));
//arrow button
onView(withId(R.id.toDoHasDateSwitchCompat)).check(matches(isDisplayed()));
//slider
}

@Test
public void textInputOutput() {
onView(withId(R.id.userToDoEditText)).perform(
typeText("This is a test."));
onView(withId(R.id.userToDoDescription)).perform(
typeText("This is also a test."));

onView(withId(R.id.makeToDoFloatingActionButton)).perform(click());

// This is will cause the test to fail because
// this is not a reliable way to test data in a RecyclerView
//We need to use the Espresso API for a RecyclerView in order to check the data on RecyclerView
onView(withId(R.id.toDoListItemTextview)).check(
matches(withText("This is a test.")));
}

}


Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package com.example.avjindersinghsekhon.minimaltodo.Main;


import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;

import androidx.test.espresso.ViewInteraction;
import androidx.test.filters.LargeTest;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;

import com.example.avjindersinghsekhon.minimaltodo.R;

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.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withClassName;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.is;

@LargeTest
@RunWith(AndroidJUnit4.class)
public class Save {

@Rule
public ActivityTestRule<MainActivity> mActivityTestRule = new ActivityTestRule<>(MainActivity.class);

@Test
public void mainActivityTest() {
// 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();
}

ViewInteraction floatingActionButton = onView(
allOf(withId(R.id.addToDoItemFAB),
childAtPosition(
allOf(withId(R.id.myCoordinatorLayout),
childAtPosition(
withId(R.id.myParentLayout),
0)),
2),
isDisplayed()));
floatingActionButton.perform(click());

// Added a sleep statement to match the app's execution delay.
// The recommended way to handle such scenarios is to use Espresso idling resources:
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}

ViewInteraction appCompatEditText = onView(
allOf(withId(R.id.userToDoEditText),
childAtPosition(
childAtPosition(
withId(R.id.toDoCustomTextInput),
0),
0),
isDisplayed()));
appCompatEditText.perform(replaceText("Title"), closeSoftKeyboard());

ViewInteraction appCompatEditText2 = onView(
allOf(withId(R.id.userToDoDescription),
childAtPosition(
childAtPosition(
withId(R.id.toDoCustomTextInput01),
0),
0),
isDisplayed()));
appCompatEditText2.perform(replaceText("Description Test"), closeSoftKeyboard());

ViewInteraction floatingActionButton2 = onView(
allOf(withId(R.id.makeToDoFloatingActionButton),
childAtPosition(
childAtPosition(
withClassName(is("android.widget.LinearLayout")),
1),
1),
isDisplayed()));
floatingActionButton2.perform(click());

}

private static Matcher<View> childAtPosition(
final Matcher<View> parentMatcher, final int position) {

return new TypeSafeMatcher<View>() {
@Override
public void describeTo(Description description) {
description.appendText("Child at position " + position + " in parent ");
parentMatcher.describeTo(description);
}

@Override
public boolean matchesSafely(View view) {
ViewParent parent = view.getParent();
return parent instanceof ViewGroup && parentMatcher.matches(parent)
&& view.equals(((ViewGroup) parent).getChildAt(position));
}
};
}
}
Loading