Skip to content

Commit 7caf73f

Browse files
authored
Fix compilation errors while trying to run instrumentation tests. (commons-app#3850)
1 parent dea629c commit 7caf73f

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

app/src/androidTest/java/fr/free/nrw/commons/AboutActivityTest.kt

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import androidx.test.espresso.matcher.ViewMatchers
1414
import androidx.test.espresso.matcher.ViewMatchers.withText
1515
import androidx.test.rule.ActivityTestRule
1616
import androidx.test.runner.AndroidJUnit4
17-
import fr.free.nrw.commons.utils.ConfigUtils
17+
import fr.free.nrw.commons.utils.ConfigUtils.getVersionNameWithSha
1818
import org.hamcrest.CoreMatchers
1919
import org.junit.Before
2020
import org.junit.Rule
@@ -36,7 +36,9 @@ class AboutActivityTest {
3636
@Test
3737
fun testBuildNumber() {
3838
Espresso.onView(ViewMatchers.withId(R.id.about_version))
39-
.check(ViewAssertions.matches(withText(ConfigUtils.getVersionNameWithSha(getApplicationContext()))))
39+
.check(ViewAssertions.matches(
40+
withText(getApplicationContext<CommonsApplication>().getVersionNameWithSha())
41+
))
4042
}
4143

4244
@Test

app/src/androidTest/java/fr/free/nrw/commons/UploadTest.kt

+10-10
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import androidx.test.rule.ActivityTestRule
2626
import androidx.test.rule.GrantPermissionRule
2727
import androidx.test.runner.AndroidJUnit4
2828
import fr.free.nrw.commons.auth.LoginActivity
29-
import fr.free.nrw.commons.upload.DescriptionsAdapter
29+
import fr.free.nrw.commons.upload.UploadMediaDetailAdapter
3030
import fr.free.nrw.commons.util.MyViewAction
3131
import fr.free.nrw.commons.utils.ConfigUtils
3232
import org.hamcrest.core.AllOf.allOf
@@ -78,7 +78,7 @@ class UploadTest {
7878

7979
@Test
8080
fun testUploadWithDescription() {
81-
if (!ConfigUtils.isBetaFlavour()) {
81+
if (!ConfigUtils.isBetaFlavour) {
8282
throw Error("This test should only be run in Beta!")
8383
}
8484

@@ -96,7 +96,7 @@ class UploadTest {
9696
// Try to dismiss the error, if there is one (probably about duplicate files on Commons)
9797
dismissWarning("Yes")
9898

99-
onView(allOf<View>(isDisplayed(), withId(R.id.et_title)))
99+
onView(allOf<View>(isDisplayed(), withId(R.id.tv_title)))
100100
.perform(replaceText(commonsFileName))
101101

102102
onView(allOf<View>(isDisplayed(), withId(R.id.description_item_edit_text)))
@@ -150,7 +150,7 @@ class UploadTest {
150150

151151
@Test
152152
fun testUploadWithoutDescription() {
153-
if (!ConfigUtils.isBetaFlavour()) {
153+
if (!ConfigUtils.isBetaFlavour) {
154154
throw Error("This test should only be run in Beta!")
155155
}
156156

@@ -168,7 +168,7 @@ class UploadTest {
168168
// Try to dismiss the error, if there is one (probably about duplicate files on Commons)
169169
dismissWarning("Yes")
170170

171-
onView(allOf<View>(isDisplayed(), withId(R.id.et_title)))
171+
onView(allOf<View>(isDisplayed(), withId(R.id.tv_title)))
172172
.perform(replaceText(commonsFileName))
173173

174174
onView(allOf(isDisplayed(), withId(R.id.btn_next)))
@@ -209,7 +209,7 @@ class UploadTest {
209209

210210
@Test
211211
fun testUploadWithMultilingualDescription() {
212-
if (!ConfigUtils.isBetaFlavour()) {
212+
if (!ConfigUtils.isBetaFlavour) {
213213
throw Error("This test should only be run in Beta!")
214214
}
215215

@@ -227,25 +227,25 @@ class UploadTest {
227227
// Try to dismiss the error, if there is one (probably about duplicate files on Commons)
228228
dismissWarningDialog()
229229

230-
onView(allOf<View>(isDisplayed(), withId(R.id.et_title)))
230+
onView(allOf<View>(isDisplayed(), withId(R.id.tv_title)))
231231
.perform(replaceText(commonsFileName))
232232

233233
onView(withId(R.id.rv_descriptions)).perform(
234234
RecyclerViewActions
235-
.actionOnItemAtPosition<DescriptionsAdapter.ViewHolder>(0,
235+
.actionOnItemAtPosition<UploadMediaDetailAdapter.ViewHolder>(0,
236236
MyViewAction.typeTextInChildViewWithId(R.id.description_item_edit_text, "Test description")))
237237

238238
onView(withId(R.id.btn_add_description))
239239
.perform(click())
240240

241241
onView(withId(R.id.rv_descriptions)).perform(
242242
RecyclerViewActions
243-
.actionOnItemAtPosition<DescriptionsAdapter.ViewHolder>(1,
243+
.actionOnItemAtPosition<UploadMediaDetailAdapter.ViewHolder>(1,
244244
MyViewAction.selectSpinnerItemInChildViewWithId(R.id.spinner_description_languages, 2)))
245245

246246
onView(withId(R.id.rv_descriptions)).perform(
247247
RecyclerViewActions
248-
.actionOnItemAtPosition<DescriptionsAdapter.ViewHolder>(1,
248+
.actionOnItemAtPosition<UploadMediaDetailAdapter.ViewHolder>(1,
249249
MyViewAction.typeTextInChildViewWithId(R.id.description_item_edit_text, "Description")))
250250

251251
onView(allOf(isDisplayed(), withId(R.id.btn_next)))

app/src/androidTest/java/fr/free/nrw/commons/WelcomeActivityTest.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@ class WelcomeActivityTest {
2323

2424
@Test
2525
fun ifBetaShowsSkipButton() {
26-
if (ConfigUtils.isBetaFlavour()) {
26+
if (ConfigUtils.isBetaFlavour) {
2727
onView(withId(R.id.finishTutorialButton))
2828
.check(matches(isDisplayed()))
2929
}
3030
}
3131

3232
@Test
3333
fun ifProdHidesSkipButton() {
34-
if (!ConfigUtils.isBetaFlavour()) {
34+
if (!ConfigUtils.isBetaFlavour) {
3535
onView(withId(R.id.finishTutorialButton))
3636
.check(matches(not(isDisplayed())))
3737
}
3838
}
3939

4040
@Test
4141
fun testBetaSkipButton() {
42-
if (ConfigUtils.isBetaFlavour()) {
42+
if (ConfigUtils.isBetaFlavour) {
4343
onView(withId(R.id.finishTutorialButton))
4444
.perform(ViewActions.click())
4545
assert(activityRule.activity.isDestroyed)

0 commit comments

Comments
 (0)