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
2 changes: 1 addition & 1 deletion .idea/misc.xml

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

24 changes: 14 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ android {
}
}

compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}

dependencies {
Expand All @@ -42,16 +52,10 @@ dependencies {
androidTestImplementation "androidx.test:core:$androidx_test"
androidTestImplementation "androidx.test.ext:junit-ktx:$androidx_test"

// androidx.fragment
def fragment_version = "1.2.0-rc01" // must use for new factory stuff
debugImplementation "androidx.fragment:fragment-testing:$fragment_version"
implementation "androidx.fragment:fragment:$fragment_version"


//glide
def glide_version = "4.9.0"
implementation "com.github.bumptech.glide:glide:$glide_version"
annotationProcessor "com.github.bumptech.glide:compiler:$glide_version"
// material dialogs
def matieral_dialogs_version = "3.3.0"
implementation "com.afollestad.material-dialogs:core:$matieral_dialogs_version"
implementation "com.afollestad.material-dialogs:input:$matieral_dialogs_version"

}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.codingwithmitch.espressouitestexamples

import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.typeText
import androidx.test.espresso.assertion.ViewAssertions.doesNotExist
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.*
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import org.junit.Test

import org.junit.runner.RunWith

@RunWith(AndroidJUnit4ClassRunner::class)
class MainActivityTest{


@Test
fun test_showDialog_captureNameInput() {

// GIVEN
val activityScenario = ActivityScenario.launch(MainActivity::class.java)
val NAME = "Mitch"

// Execute and Verify
onView(withId(R.id.button_launch_dialog)).perform(click())

onView(withText(R.string.text_enter_name)).check(matches(isDisplayed()))

onView(withText(R.string.text_ok)).perform(click())

// make sure dialog is still visible (can't click ok without entering a name)
onView(withText(R.string.text_enter_name)).check(matches(isDisplayed()))

// enter a name
onView(withId(R.id.md_input_message)).perform(typeText(NAME))

onView(withText(R.string.text_ok)).perform(click())

// make sure dialog is gone
onView(withText(R.string.text_enter_name)).check(doesNotExist())

onView(withId(R.id.text_name)).check(matches(withText(NAME)))
}
}












This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.codingwithmitch.espressouitestexamples">

<uses-permission android:name="android.permission.INTERNET"/>

<application
android:allowBackup="false"
Expand All @@ -11,7 +10,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ui.movie.MainActivity">
<activity android:name="MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.codingwithmitch.espressouitestexamples

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.input.input
import kotlinx.android.synthetic.main.activity_main.*


class MainActivity : AppCompatActivity(){

private val TAG: String = "AppDebug"


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

button_launch_dialog.setOnClickListener {
showDialog()
}

}

private fun showDialog(){
MaterialDialog(this)
.show {
input (
waitForPositiveButton = true,
allowEmpty = false
){ dialog, name ->
setNameToTextView(name.toString())
}
title(R.string.text_enter_name)
positiveButton(R.string.text_ok)
}
}

private fun setNameToTextView(name: String){
text_name.text = name
}

}















This file was deleted.

This file was deleted.

Loading