Skip to content
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
1 change: 1 addition & 0 deletions .idea/.name

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

47 changes: 47 additions & 0 deletions .idea/androidTestResultsUserPreferences.xml

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

17 changes: 0 additions & 17 deletions .idea/deploymentTargetDropDown.xml

This file was deleted.

13 changes: 10 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}

android {
Expand Down Expand Up @@ -32,18 +33,24 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'com.google.firebase:firebase-auth:21.1.0'
testImplementation 'junit:junit:4.+'
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.4.0'
androidTestImplementation 'org.mockito:mockito-core:2.+'

testImplementation 'androidx.test:core:1.4.0'
testImplementation 'androidx.test.ext:junit:1.1.3'
testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric'
testImplementation 'junit:junit:4.+'
testImplementation 'org.robolectric:robolectric:4.8'

testImplementation 'androidx.test.espresso:espresso-intents:3.4.0'
testImplementation 'androidx.test.ext:truth:1.4.0'
testImplementation "org.mockito:mockito-core:3.5.0"


}
39 changes: 39 additions & 0 deletions app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"project_info": {
"project_number": "97756466887",
"project_id": "lab3-23376",
"storage_bucket": "lab3-23376.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:97756466887:android:bd9a3b28cbcab2d40278e2",
"android_client_info": {
"package_name": "com.example.testAndroid"
}
},
"oauth_client": [
{
"client_id": "97756466887-men8n7vp3sb52lhmtgc9cl9mu0v17h6n.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyA60VFxjN__i_RhzdGsf9Zk0LRU6ANK5I0"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "97756466887-men8n7vp3sb52lhmtgc9cl9mu0v17h6n.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}
59 changes: 56 additions & 3 deletions app/src/androidTest/java/com/example/Lab3/EspressoMainTest.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.example.Lab3;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;

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

import androidx.test.espresso.NoMatchingViewException;
import androidx.test.espresso.action.ViewActions;
import androidx.test.espresso.matcher.ViewMatchers;
import androidx.test.ext.junit.rules.ActivityScenarioRule;
Expand All @@ -18,6 +22,7 @@
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.isClickable;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
Expand All @@ -26,17 +31,65 @@
@RunWith(AndroidJUnit4.class)
@SmallTest
public class EspressoMainTest {


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


@Test
public void listGoesOverTheFold() {
public void IsTimerOn() {
onView(withId(R.id.time)).check(matches(isDisplayed()));
}

@Test
public void listGoesOverTheFold2() {
onView(withId(R.id.time)).check(matches(isDisplayed()));
public void IsYesButtonVisible(){
for (int i=0; i<10; i++){
onView(withId(R.id.yes_btn)).perform(click());
}
onView(withId(R.id.points)).check(matches(withText("10")));

}

@Test
public void IsNoButtonVisible(){
onView(withId(R.id.no_btn)).check(matches(isClickable()));

for (int i=0; i<10; i++){
onView(withId(R.id.no_btn)).perform(click());
}
onView(withId(R.id.points)).check(matches(withText("0")));

}

@Test
public void IsQuestionVisible() {
onView(withId(R.id.roolsView))
.check(matches(isDisplayed()))
.check(matches(withText("Чи співпадає назва кольору ліворуч з кольором текста праворуч?")));
}

@Test
public void IsGameEndsInMinute() throws InterruptedException {
int clickCount = 5;
for (int i = 0; i < clickCount; i++){
onView(withId(R.id.yes_btn)).perform(click());
}
onView(withId(R.id.points)).check(matches(withText("5")));
Thread.sleep(55 * 1000);
int TIMEOUT = 10 * 1000;
int CONDITION_CHECK_INTERVAL = 100;

long startTime = System.currentTimeMillis();
try {
while(System.currentTimeMillis() - startTime < TIMEOUT) {
onView(withId(R.id.roolsView)).check(matches(isDisplayed()));
Thread.sleep(CONDITION_CHECK_INTERVAL);
}
} catch (NoMatchingViewException e){
onView(withId(R.id.result_string)).check(matches(withText("Ваш результат:")));
onView(withId(R.id.result)).check(matches(withText("5")));
}
}
}
114 changes: 114 additions & 0 deletions app/src/androidTest/java/com/example/Lab3/LoginTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package com.example.Lab3;

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.assertion.ViewAssertions.matches;
import static androidx.test.espresso.intent.Intents.intended;
import static androidx.test.espresso.intent.Intents.intending;
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent;
import static androidx.test.espresso.intent.matcher.IntentMatchers.toPackage;
import static androidx.test.espresso.matcher.RootMatchers.withDecorView;
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 android.app.Activity;
import android.app.Instrumentation;
import android.content.Intent;
import android.os.IBinder;
import android.view.View;
import android.view.WindowManager;

import androidx.test.core.app.ActivityScenario;
import androidx.test.espresso.Root;
import androidx.test.espresso.action.TypeTextAction;
import androidx.test.espresso.intent.Intents;
import androidx.test.ext.junit.rules.ActivityScenarioRule;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;

import org.hamcrest.Matchers;
import org.hamcrest.TypeSafeMatcher;
import org.junit.After;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;

import org.hamcrest.Description;


@RunWith(AndroidJUnit4.class)
@SmallTest
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class LoginTest {
private View decorView;
@Rule
public ActivityScenarioRule<LoginActivity> activityRule =
new ActivityScenarioRule<>(LoginActivity.class);

@Test
public void IsEmailFieldVisible() {
onView(withId(R.id.username)).check(matches(isDisplayed()));
}
@Test
public void IsPasswordFieldVisible() {
onView(withId(R.id.password)).check(matches(isDisplayed()));
}


@Before
public void intentInit(){
Intents.init();
}

@Test
public void TryRightLogin() throws InterruptedException {
onView(withId(R.id.username)).perform(new TypeTextAction("test@gmail.com"), closeSoftKeyboard());
onView(withId(R.id.password)).perform(new TypeTextAction("123456"), closeSoftKeyboard());
// onView(withId(R.id.password)).perform(closeSoftKeyboard());
Thread.sleep(250);
onView(withId(R.id.loginButton)).perform(click());

Intent i = new Intent();
Instrumentation.ActivityResult result = new Instrumentation.ActivityResult(Activity.RESULT_OK, i);
intending(toPackage(StartActivity.class.getName()));


}

@After
public void intentRelease(){
Intents.release();
}

@Test
public void TryWrongLogin() throws InterruptedException {
onView(withId(R.id.username)).perform(new TypeTextAction("test1@gmail.com"), closeSoftKeyboard());
onView(withId(R.id.password)).perform(new TypeTextAction("123456"), closeSoftKeyboard());
Thread.sleep(250);
onView(withId(R.id.loginButton)).perform(click());


onView(withText("Authentication failed."))
.inRoot(new ToastMatcher())// Here we use decorView
.check(matches(isDisplayed()));


// onView(withText("Authentication failed."))
// .inRoot(withDecorView(Matchers.is(decorView)))// Here we use decorView
// .check(matches(isDisplayed()));


// onView(withId(R.id.checklogin)).check(matches(withText("False")));



}



}
Loading