-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
72 additions
and
75 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
48 changes: 0 additions & 48 deletions
48
...-title/app/src/androidTest/java/com/sqisland/espresso/toolbar_title/MainActivityTest.java
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
...ar-title/app/src/androidTest/java/com/sqisland/espresso/toolbar_title/MainActivityTest.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,47 @@ | ||
package com.sqisland.espresso.toolbar_title | ||
|
||
import android.support.test.InstrumentationRegistry | ||
import android.support.test.espresso.Espresso.onView | ||
import android.support.test.espresso.ViewInteraction | ||
import android.support.test.espresso.assertion.ViewAssertions.matches | ||
import android.support.test.espresso.matcher.BoundedMatcher | ||
import android.support.test.espresso.matcher.ViewMatchers.isAssignableFrom | ||
import android.support.test.rule.ActivityTestRule | ||
import android.support.test.runner.AndroidJUnit4 | ||
import android.support.v7.widget.Toolbar | ||
import org.hamcrest.Description | ||
import org.hamcrest.Matcher | ||
import org.hamcrest.core.Is.`is` | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class MainActivityTest { | ||
@get:Rule | ||
val activityRule = ActivityTestRule(MainActivity::class.java) | ||
|
||
@Test | ||
fun toolbarTitle() { | ||
val title = InstrumentationRegistry.getTargetContext().getString(R.string.my_title) | ||
matchToolbarTitle(title) | ||
} | ||
|
||
private fun matchToolbarTitle(title: CharSequence): ViewInteraction { | ||
return onView(isAssignableFrom(Toolbar::class.java)) | ||
.check(matches(withToolbarTitle(`is`(title)))) | ||
} | ||
|
||
private fun withToolbarTitle(textMatcher: Matcher<CharSequence>): Matcher<Any> { | ||
return object : BoundedMatcher<Any, Toolbar>(Toolbar::class.java) { | ||
public override fun matchesSafely(toolbar: Toolbar): Boolean { | ||
return textMatcher.matches(toolbar.title) | ||
} | ||
|
||
override fun describeTo(description: Description) { | ||
description.appendText("with toolbar title: ") | ||
textMatcher.describeTo(description) | ||
} | ||
} | ||
} | ||
} |
12 changes: 0 additions & 12 deletions
12
toolbar-title/app/src/main/java/com/sqisland/espresso/toolbar_title/MainActivity.java
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
toolbar-title/app/src/main/java/com/sqisland/espresso/toolbar_title/MainActivity.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,11 @@ | ||
package com.sqisland.espresso.toolbar_title | ||
|
||
import android.os.Bundle | ||
import android.support.v7.app.AppCompatActivity | ||
|
||
class MainActivity : AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setTitle(R.string.my_title) | ||
} | ||
} |
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