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
46 changes: 0 additions & 46 deletions .github/workflows/build-apk.yml

This file was deleted.

6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ dependencies {
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.code.gson:gson:2.8.7'

// OKHTTP
implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2'
implementation 'com.squareup.okhttp3:okhttp'
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.2'
implementation 'com.squareup.okhttp3:okhttp-tls:5.0.0-alpha.2'

// TESTS
Expand All @@ -136,7 +136,7 @@ dependencies {
androidTestImplementation 'androidx.test:core:1.3.0'
testImplementation 'androidx.test:core:1.3.0'
testImplementation 'androidx.arch.core:core-testing:2.1.0'
testImplementation 'org.mockito:mockito-core:3.9.0'
testImplementation 'org.mockito:mockito-core:3.11.2'
androidTestImplementation('com.android.support.test.espresso:espresso-contrib:3.0.2') {
exclude group: 'com.android.support', module: 'appcompat'
exclude module: 'support-annotations'
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.5.10"
ext.kotlin_version = '1.5.20'
repositories {
google()
mavenCentral()
Expand Down
191 changes: 191 additions & 0 deletions tests/CleanerFullTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
package com.sweven.blockcovid

import android.view.View
import android.view.ViewGroup
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.closeSoftKeyboard
import androidx.test.espresso.action.ViewActions.replaceText
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
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.Matchers.allOf
import org.hamcrest.TypeSafeMatcher
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@LargeTest
@RunWith(AndroidJUnit4::class)
class CleanerFullTest {

@Rule
@JvmField
var mActivityTestRule = ActivityTestRule(StartActivity::class.java)

@Test
fun cleanerFullRun() {
val textInputEditText = onView(
allOf(
withId(R.id.username),
isDisplayed()
)
)
textInputEditText.perform(replaceText("cleaner"), closeSoftKeyboard())

val textInputEditText2 = onView(
allOf(
withId(R.id.password),
isDisplayed()
)
)
textInputEditText2.perform(replaceText("password"), closeSoftKeyboard())

val extendedFloatingActionButton = onView(
allOf(
withId(R.id.login_button),
childAtPosition(
allOf(
withId(R.id.container),
childAtPosition(
withId(android.R.id.content),
0
)
),
2
),
isDisplayed()
)
)
extendedFloatingActionButton.perform(click())

Thread.sleep(500)

val extendedFloatingActionButton1 = onView(
allOf(
withId(R.id.refresh_button),
childAtPosition(
childAtPosition(
withId(R.id.nav_host_fragment_cleaner),
0
),
2
),
isDisplayed()
)
)
extendedFloatingActionButton1.perform(click())

Thread.sleep(500)

val actionMenuItemView = onView(
allOf(
withId(R.id.navigation_login),
childAtPosition(
childAtPosition(
withId(R.id.action_bar),
1
),
0
),
isDisplayed()
)
)
actionMenuItemView.perform(click())

val materialButton = onView(
allOf(
withId(R.id.change_password_button),
childAtPosition(
childAtPosition(
withId(R.id.nav_host_fragment_cleaner),
0
),
1
),
isDisplayed()
)
)
materialButton.perform(click())

val textInputEditText3 = onView(
allOf(
withId(R.id.edit_old_password),
isDisplayed()
)
)
textInputEditText3.perform(replaceText("password"), closeSoftKeyboard())

val textInputEditText4 = onView(
allOf(
withId(R.id.edit_new_password),
isDisplayed()
)
)
textInputEditText4.perform(replaceText("password"), closeSoftKeyboard())

val textInputEditText5 = onView(
allOf(
withId(R.id.edit_repeat_password),
isDisplayed()
)
)
textInputEditText5.perform(replaceText("password"), closeSoftKeyboard())

val extendedFloatingActionButton3 = onView(
allOf(
withId(R.id.change_password_button),
childAtPosition(
childAtPosition(
withId(R.id.nav_host_fragment_cleaner),
0
),
3
),
isDisplayed()
)
)
extendedFloatingActionButton3.perform(click())

Thread.sleep(500)

val materialButton2 = onView(
allOf(
withId(R.id.logout_button), withText("Logout"),
childAtPosition(
childAtPosition(
withId(R.id.nav_host_fragment_cleaner),
0
),
2
),
isDisplayed()
)
)
materialButton2.perform(click())
}

private fun childAtPosition(
parentMatcher: Matcher<View>,
position: Int
): Matcher<View> {

return object : TypeSafeMatcher<View>() {
override fun describeTo(description: Description) {
description.appendText("Child at position $position in parent ")
parentMatcher.describeTo(description)
}

public override fun matchesSafely(view: View): Boolean {
val parent = view.parent
return parent is ViewGroup && parentMatcher.matches(parent) &&
view == parent.getChildAt(position)
}
}
}
}
Loading