Skip to content

Commit 952d4f5

Browse files
Merge pull request #8 from stepstone-tech/remove-depreciations-after-bumping-agp-to-v7
Remove depreciations and align to the newest libraries up-to-date on 09.2021
2 parents cb3767a + 2230bd4 commit 952d4f5

File tree

7 files changed

+34
-26
lines changed

7 files changed

+34
-26
lines changed

app/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
3-
apply plugin: 'kotlin-android-extensions'
43
apply from: '../ktlint.gradle'
54

65
android {
@@ -20,6 +19,9 @@ android {
2019
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2120
}
2221
}
22+
buildFeatures {
23+
viewBinding true
24+
}
2325
testOptions {
2426
execution 'ANDROIDX_TEST_ORCHESTRATOR'
2527
animationsDisabled = true
Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,34 @@
11
package com.stepstone.xrunner.sample
22

3+
import androidx.lifecycle.Lifecycle
4+
import androidx.test.core.app.ActivityScenario
35
import androidx.test.espresso.Espresso.onView
46
import androidx.test.espresso.action.ViewActions.click
57
import androidx.test.espresso.assertion.ViewAssertions.matches
68
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
79
import androidx.test.espresso.matcher.ViewMatchers.withId
810
import androidx.test.espresso.matcher.ViewMatchers.withText
911
import androidx.test.ext.junit.runners.AndroidJUnit4
10-
import androidx.test.rule.ActivityTestRule
1112
import org.hamcrest.Matchers.not
13+
import org.junit.*
1214
import org.junit.Assert.assertTrue
13-
import org.junit.Ignore
14-
import org.junit.Rule
15-
import org.junit.Test
1615
import org.junit.runner.RunWith
1716

1817
@RunWith(AndroidJUnit4::class)
1918
class MainActivityTest {
2019

21-
@get:Rule
22-
val rule = ActivityTestRule(MainActivity::class.java)
20+
private lateinit var scenario: ActivityScenario<MainActivity>
21+
22+
@Before
23+
fun launch() {
24+
scenario = ActivityScenario.launch(MainActivity::class.java).also {
25+
it.moveToState(Lifecycle.State.RESUMED)
26+
}
27+
}
2328

2429
@Test
2530
fun dummy_text_should_be_hidden_by_default() {
26-
onView(withId(R.id.dummy_text_view)).check(matches(not(isDisplayed())))
31+
onView(withId(R.id.dummyTextView)).check(matches(not(isDisplayed())))
2732
}
2833

2934
@Test
@@ -38,11 +43,16 @@ class MainActivityTest {
3843
onView(withId(R.id.fab)).perform(click())
3944

4045
// then
41-
onView(withId(R.id.dummy_text_view)).check(matches(withText("XRunner")))
46+
onView(withId(R.id.dummyTextView)).check(matches(withText("XRunner")))
4247
}
4348

4449
@Test
4550
fun failing_test() {
4651
assertTrue(false)
4752
}
53+
54+
@After
55+
fun cleanup() {
56+
scenario.close()
57+
}
4858
}

app/src/main/java/com/stepstone/xrunner/sample/MainActivity.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@ package com.stepstone.xrunner.sample
33
import android.os.Bundle
44
import androidx.appcompat.app.AppCompatActivity
55
import android.view.View
6-
import kotlinx.android.synthetic.main.activity_main.fab
7-
import kotlinx.android.synthetic.main.activity_main.toolbar
8-
import kotlinx.android.synthetic.main.content_main.dummy_text_view
6+
import com.stepstone.xrunner.sample.databinding.ActivityMainBinding
97

108
class MainActivity : AppCompatActivity() {
119

1210
override fun onCreate(savedInstanceState: Bundle?) {
1311
super.onCreate(savedInstanceState)
14-
setContentView(R.layout.activity_main)
15-
setSupportActionBar(toolbar)
12+
val binding = ActivityMainBinding.inflate(layoutInflater)
13+
setContentView(binding.root)
14+
setSupportActionBar(binding.toolbar)
1615

17-
fab.setOnClickListener {
18-
dummy_text_view.visibility = View.VISIBLE
16+
binding.fab.setOnClickListener {
17+
binding.content.dummyTextView.visibility = View.VISIBLE
1918
}
2019
supportActionBar?.setDisplayHomeAsUpEnabled(true)
2120
}

app/src/main/res/layout/activity_main.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
</com.google.android.material.appbar.AppBarLayout>
2222

23-
<include layout="@layout/content_main" />
23+
<include layout="@layout/content_main"
24+
android:id="@+id/content"/>
2425

2526
<com.google.android.material.floatingactionbutton.FloatingActionButton
2627
android:id="@+id/fab"

app/src/main/res/layout/content_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
tools:showIn="@layout/activity_main">
1010

1111
<TextView
12-
android:id="@+id/dummy_text_view"
12+
android:id="@+id/dummyTextView"
1313
android:layout_width="wrap_content"
1414
android:layout_height="wrap_content"
1515
android:layout_marginStart="8dp"

build.gradle

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22

33
buildscript {
44
ext.KOTLIN_VERSION = '1.5.21'
5-
ext.ANDROID_GRADLE_PLUGIN_VERSION = '7.0.1'
5+
ext.ANDROID_GRADLE_PLUGIN_VERSION = '7.0.2'
66
ext.DOKKA_VERSION = '1.5.0'
77
repositories {
88
google()
9-
maven {
10-
url 'https://dl.bintray.com/kotlin/kotlin-eap'
11-
}
129
mavenCentral()
1310
}
1411
dependencies {
@@ -39,9 +36,9 @@ configure(allprojects) {
3936
TEST_EXT_VERSION = '1.1.3'
4037
TEST_ORCHESTRATOR_VERSION = '1.4.0'
4138
ESPRESSO_VERSION = '3.4.0'
42-
APPCOMPAT_VERSION = '1.1.0'
43-
MATERIAL_VERSION = '1.1.0'
44-
CONSTRAINT_VERSION = '1.1.3'
39+
APPCOMPAT_VERSION = '1.3.1'
40+
MATERIAL_VERSION = '1.4.0'
41+
CONSTRAINT_VERSION = '2.1.1'
4542
}
4643
}
4744

gradle.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@ org.gradle.jvmargs=-Xmx1536m
1414
# Kotlin code style for this project: "official" or "obsolete":
1515
kotlin.code.style=official
1616
android.useAndroidX=true
17-
android.enableJetifier=true

0 commit comments

Comments
 (0)