-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from bohdanlailo/feature/SR-033
SR-033 Write additional tests [LB,MH]
- Loading branch information
Showing
11 changed files
with
174 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
app/src/androidTest/java/at/team30/setroute/FeedbackTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package at.team30.setroute | ||
|
||
import android.Manifest | ||
import android.widget.EditText | ||
import androidx.test.espresso.Espresso | ||
import androidx.test.espresso.action.ViewActions | ||
import androidx.test.espresso.matcher.ViewMatchers | ||
import at.team30.setroute.R | ||
import at.team30.setroute.infrastructure.DependencyInjection | ||
import at.team30.setroute.infrastructure.IRoutesRepository | ||
import at.team30.setroute.ui.MainActivity | ||
import dagger.hilt.android.testing.HiltAndroidRule | ||
import dagger.hilt.android.testing.HiltAndroidTest | ||
import dagger.hilt.android.testing.UninstallModules | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import javax.inject.Inject | ||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.action.ViewActions.* | ||
import androidx.test.espresso.assertion.ViewAssertions.matches | ||
import androidx.test.espresso.matcher.ViewMatchers.* | ||
import androidx.test.ext.junit.rules.ActivityScenarioRule | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.rule.GrantPermissionRule | ||
import org.hamcrest.Matchers.not | ||
|
||
@UninstallModules(DependencyInjection::class) | ||
@HiltAndroidTest | ||
class FeedbackTest { | ||
|
||
@get:Rule(order = 0) | ||
var hiltRule = HiltAndroidRule(this) | ||
|
||
@get:Rule(order = 1) | ||
val activityRule = ActivityScenarioRule(MainActivity::class.java) | ||
|
||
@get:Rule(order = 2) | ||
val runtimePermissionRule: GrantPermissionRule = GrantPermissionRule.grant(Manifest.permission.ACCESS_FINE_LOCATION) | ||
|
||
@Inject | ||
lateinit var routesRepository: IRoutesRepository | ||
|
||
@Before | ||
fun init() { | ||
hiltRule.inject() | ||
} | ||
|
||
@Test | ||
fun feedbackButtonDisabledWithoutText() { | ||
onView(withId(R.id.settingsFragment)).perform(click()) | ||
onView(withId(R.id.feedback_text_field)).perform(clearText()) | ||
onView(withId(R.id.submit_feedback_button)).check(matches(not(isEnabled()))) | ||
} | ||
|
||
@Test | ||
fun feedbackButtonDisabledWithLongText() { | ||
onView(withId(R.id.settingsFragment)).perform(click()) | ||
onView(withId(R.id.feedback_text_field)).perform(clearText(), typeText("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea")) | ||
onView(withId(R.id.submit_feedback_button)).check(matches(not(isEnabled()))) | ||
} | ||
|
||
@Test | ||
fun feedbackButtonEnabled() { | ||
onView(withId(R.id.settingsFragment)).perform(click()) | ||
onView(withId(R.id.feedback_text_field)).perform(clearText(), typeText("Feedback")) | ||
onView(withId(R.id.submit_feedback_button)).check(matches(isEnabled())) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<vector android:height="24dp" android:tint="#FFFFFF" | ||
<vector android:height="24dp" android:tint="@color/secondaryColor" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M19,9h-1.56C17.79,8.41 18,7.73 18,7c0,-2.21 -1.79,-4 -4,-4c-0.34,0 -0.66,0.05 -0.98,0.13C12.2,2.45 11.16,2.02 10,2.02c-1.89,0 -3.51,1.11 -4.27,2.71C4.15,5.26 3,6.74 3,8.5c0,1.86 1.28,3.41 3,3.86L6,21h11v-2h2c1.1,0 2,-0.9 2,-2v-6C21,9.9 20.1,9 19,9zM7,10.5c-1.1,0 -2,-0.9 -2,-2c0,-0.85 0.55,-1.6 1.37,-1.88l0.8,-0.27l0.36,-0.76C8,4.62 8.94,4.02 10,4.02c0.79,0 1.39,0.35 1.74,0.65l0.78,0.65c0,0 0.64,-0.32 1.47,-0.32c1.1,0 2,0.9 2,2c0,0 -3,0 -3,0C9.67,7 9.15,10.5 7,10.5zM19,17h-2v-6h2V17z"/> | ||
<path android:fillColor="@color/secondaryColor" android:pathData="M19,9h-1.56C17.79,8.41 18,7.73 18,7c0,-2.21 -1.79,-4 -4,-4c-0.34,0 -0.66,0.05 -0.98,0.13C12.2,2.45 11.16,2.02 10,2.02c-1.89,0 -3.51,1.11 -4.27,2.71C4.15,5.26 3,6.74 3,8.5c0,1.86 1.28,3.41 3,3.86L6,21h11v-2h2c1.1,0 2,-0.9 2,-2v-6C21,9.9 20.1,9 19,9zM7,10.5c-1.1,0 -2,-0.9 -2,-2c0,-0.85 0.55,-1.6 1.37,-1.88l0.8,-0.27l0.36,-0.76C8,4.62 8.94,4.02 10,4.02c0.79,0 1.39,0.35 1.74,0.65l0.78,0.65c0,0 0.64,-0.32 1.47,-0.32c1.1,0 2,0.9 2,2c0,0 -3,0 -3,0C9.67,7 9.15,10.5 7,10.5zM19,17h-2v-6h2V17z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<vector android:height="24dp" android:tint="#FFFFFF" | ||
<vector android:height="24dp" android:tint="@color/secondaryColor" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M20,3L4,3v10c0,2.21 1.79,4 4,4h6c2.21,0 4,-1.79 4,-4v-3h2c1.11,0 2,-0.9 2,-2L22,5c0,-1.11 -0.89,-2 -2,-2zM20,8h-2L18,5h2v3zM4,19h16v2L4,21z"/> | ||
<path android:fillColor="@color/secondaryColor" android:pathData="M20,3L4,3v10c0,2.21 1.79,4 4,4h6c2.21,0 4,-1.79 4,-4v-3h2c1.11,0 2,-0.9 2,-2L22,5c0,-1.11 -0.89,-2 -2,-2zM20,8h-2L18,5h2v3zM4,19h16v2L4,21z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<vector android:height="24dp" android:tint="#FFFFFF" | ||
<vector android:height="24dp" android:tint="@color/secondaryColor" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M22.17,9.17c0,-3.87 -3.13,-7 -7,-7s-7,3.13 -7,7c0,3.47 2.52,6.34 5.83,6.89V20H6v-3h1v-4c0,-0.55 -0.45,-1 -1,-1H3c-0.55,0 -1,0.45 -1,1v4h1v5h16v-2h-3v-3.88c3.47,-0.41 6.17,-3.36 6.17,-6.95zM4.5,11c0.83,0 1.5,-0.67 1.5,-1.5S5.33,8 4.5,8 3,8.67 3,9.5 3.67,11 4.5,11z"/> | ||
<path android:fillColor="@color/secondaryColor" android:pathData="M22.17,9.17c0,-3.87 -3.13,-7 -7,-7s-7,3.13 -7,7c0,3.47 2.52,6.34 5.83,6.89V20H6v-3h1v-4c0,-0.55 -0.45,-1 -1,-1H3c-0.55,0 -1,0.45 -1,1v4h1v5h16v-2h-3v-3.88c3.47,-0.41 6.17,-3.36 6.17,-6.95zM4.5,11c0.83,0 1.5,-0.67 1.5,-1.5S5.33,8 4.5,8 3,8.67 3,9.5 3.67,11 4.5,11z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<vector android:height="24dp" android:tint="#FFFFFF" | ||
<vector android:height="24dp" android:tint="@color/secondaryColor" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M4.5,9.5m-2.5,0a2.5,2.5 0,1 1,5 0a2.5,2.5 0,1 1,-5 0"/> | ||
<path android:fillColor="@android:color/white" android:pathData="M9,5.5m-2.5,0a2.5,2.5 0,1 1,5 0a2.5,2.5 0,1 1,-5 0"/> | ||
<path android:fillColor="@android:color/white" android:pathData="M15,5.5m-2.5,0a2.5,2.5 0,1 1,5 0a2.5,2.5 0,1 1,-5 0"/> | ||
<path android:fillColor="@android:color/white" android:pathData="M19.5,9.5m-2.5,0a2.5,2.5 0,1 1,5 0a2.5,2.5 0,1 1,-5 0"/> | ||
<path android:fillColor="@android:color/white" android:pathData="M17.34,14.86c-0.87,-1.02 -1.6,-1.89 -2.48,-2.91 -0.46,-0.54 -1.05,-1.08 -1.75,-1.32 -0.11,-0.04 -0.22,-0.07 -0.33,-0.09 -0.25,-0.04 -0.52,-0.04 -0.78,-0.04s-0.53,0 -0.79,0.05c-0.11,0.02 -0.22,0.05 -0.33,0.09 -0.7,0.24 -1.28,0.78 -1.75,1.32 -0.87,1.02 -1.6,1.89 -2.48,2.91 -1.31,1.31 -2.92,2.76 -2.62,4.79 0.29,1.02 1.02,2.03 2.33,2.32 0.73,0.15 3.06,-0.44 5.54,-0.44h0.18c2.48,0 4.81,0.58 5.54,0.44 1.31,-0.29 2.04,-1.31 2.33,-2.32 0.31,-2.04 -1.3,-3.49 -2.61,-4.8z"/> | ||
<path android:fillColor="@color/secondaryColor" android:pathData="M4.5,9.5m-2.5,0a2.5,2.5 0,1 1,5 0a2.5,2.5 0,1 1,-5 0"/> | ||
<path android:fillColor="@color/secondaryColor" android:pathData="M9,5.5m-2.5,0a2.5,2.5 0,1 1,5 0a2.5,2.5 0,1 1,-5 0"/> | ||
<path android:fillColor="@color/secondaryColor" android:pathData="M15,5.5m-2.5,0a2.5,2.5 0,1 1,5 0a2.5,2.5 0,1 1,-5 0"/> | ||
<path android:fillColor="@color/secondaryColor" android:pathData="M19.5,9.5m-2.5,0a2.5,2.5 0,1 1,5 0a2.5,2.5 0,1 1,-5 0"/> | ||
<path android:fillColor="@color/secondaryColor" android:pathData="M17.34,14.86c-0.87,-1.02 -1.6,-1.89 -2.48,-2.91 -0.46,-0.54 -1.05,-1.08 -1.75,-1.32 -0.11,-0.04 -0.22,-0.07 -0.33,-0.09 -0.25,-0.04 -0.52,-0.04 -0.78,-0.04s-0.53,0 -0.79,0.05c-0.11,0.02 -0.22,0.05 -0.33,0.09 -0.7,0.24 -1.28,0.78 -1.75,1.32 -0.87,1.02 -1.6,1.89 -2.48,2.91 -1.31,1.31 -2.92,2.76 -2.62,4.79 0.29,1.02 1.02,2.03 2.33,2.32 0.73,0.15 3.06,-0.44 5.54,-0.44h0.18c2.48,0 4.81,0.58 5.54,0.44 1.31,-0.29 2.04,-1.31 2.33,-2.32 0.31,-2.04 -1.3,-3.49 -2.61,-4.8z"/> | ||
</vector> |
4 changes: 2 additions & 2 deletions
4
app/src/main/res/drawable/ic_baseline_romantic_walk_white.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<vector android:height="24dp" android:tint="#FFFFFF" | ||
<vector android:height="24dp" android:tint="@color/secondaryColor" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z"/> | ||
<path android:fillColor="@color/secondaryColor" android:pathData="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<vector android:height="24dp" android:tint="#FFFFFF" | ||
<vector android:height="24dp" android:tint="@color/secondaryColor" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M4,10h3v7h-3z"/> | ||
<path android:fillColor="@android:color/white" android:pathData="M10.5,10h3v7h-3z"/> | ||
<path android:fillColor="@android:color/white" android:pathData="M2,19h20v3h-20z"/> | ||
<path android:fillColor="@android:color/white" android:pathData="M17,10h3v7h-3z"/> | ||
<path android:fillColor="@android:color/white" android:pathData="M12,1l-10,5l0,2l20,0l0,-2z"/> | ||
<path android:fillColor="@color/secondaryColor" android:pathData="M4,10h3v7h-3z"/> | ||
<path android:fillColor="@color/secondaryColor" android:pathData="M10.5,10h3v7h-3z"/> | ||
<path android:fillColor="@color/secondaryColor" android:pathData="M2,19h20v3h-20z"/> | ||
<path android:fillColor="@color/secondaryColor" android:pathData="M17,10h3v7h-3z"/> | ||
<path android:fillColor="@color/secondaryColor" android:pathData="M12,1l-10,5l0,2l20,0l0,-2z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<vector android:height="24dp" android:tint="#FFFFFF" | ||
<vector android:height="24dp" android:tint="@color/secondaryColor" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M20.57,14.86L22,13.43 20.57,12 17,15.57 8.43,7 12,3.43 10.57,2 9.14,3.43 7.71,2 5.57,4.14 4.14,2.71 2.71,4.14l1.43,1.43L2,7.71l1.43,1.43L2,10.57 3.43,12 7,8.43 15.57,17 12,20.57 13.43,22l1.43,-1.43L16.29,22l2.14,-2.14 1.43,1.43 1.43,-1.43 -1.43,-1.43L22,16.29z"/> | ||
<path android:fillColor="@color/secondaryColor" android:pathData="M20.57,14.86L22,13.43 20.57,12 17,15.57 8.43,7 12,3.43 10.57,2 9.14,3.43 7.71,2 5.57,4.14 4.14,2.71 2.71,4.14l1.43,1.43L2,7.71l1.43,1.43L2,10.57 3.43,12 7,8.43 15.57,17 12,20.57 13.43,22l1.43,-1.43L16.29,22l2.14,-2.14 1.43,1.43 1.43,-1.43 -1.43,-1.43L22,16.29z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package at.team30.setroute | ||
|
||
import android.widget.EditText | ||
import at.team30.setroute.Helper.EmailHelper | ||
import com.dumbster.smtp.SimpleSmtpServer | ||
import kotlinx.coroutines.runBlocking | ||
import org.junit.Assert | ||
import org.junit.Before | ||
import org.junit.Ignore | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.junit.runners.JUnit4 | ||
import java.lang.IllegalArgumentException | ||
|
||
@RunWith(JUnit4::class) | ||
class EmailTest { | ||
|
||
lateinit var emailHelper : EmailHelper | ||
lateinit var smtpServer : SimpleSmtpServer | ||
var port = 666 | ||
|
||
@Test(expected = IllegalArgumentException::class) | ||
fun initIllegalArgumentsNoUsername() { | ||
EmailHelper( | ||
authenticate = true, | ||
userName = null | ||
) | ||
} | ||
|
||
@Test(expected = IllegalArgumentException::class) | ||
fun initIllegalArgumentsNoPassword() { | ||
EmailHelper( | ||
authenticate = true, | ||
userName = "Max Musterman", | ||
password = null | ||
) | ||
} | ||
|
||
|
||
|
||
@Test | ||
fun createEmailHelperWithoutAuthentication() { | ||
EmailHelper( | ||
authenticate = false, | ||
userName = "Max Musterman", | ||
password = null | ||
) | ||
} | ||
|
||
@Before | ||
fun setUpTest() { | ||
smtpServer = SimpleSmtpServer(port) | ||
} | ||
|
||
@Test | ||
@Ignore | ||
fun emailReceived() { | ||
var text = "Very best feedback." | ||
var receiver = "[email protected]" | ||
var subject = "Very important issue" | ||
|
||
emailHelper = EmailHelper( | ||
smtpHost = "localhost", | ||
smtpPort = port, | ||
enableStartTtls = false, | ||
userName = null, | ||
password = null, | ||
sender = "[email protected]", | ||
authenticate = false | ||
) | ||
|
||
runBlocking { | ||
emailHelper.sendEmail(text, receiver, subject) | ||
} | ||
Assert.assertEquals(1, smtpServer.receivedEmailSize) | ||
} | ||
|
||
} |