| author | Da Risk <da_risk@geekorum.com> |
| Thu, 09 May 2019 16:06:10 -0700 | |
| changeset 134 | d7a3563591ae |
| parent 0 | app/src/test/java/com/geekorum/ttrss/SettingsActivityTest.kt@14443efede32 |
| child 137 | 5464f07a306c |
| permissions | -rw-r--r-- |
|
134
d7a3563591ae
Move SettingsActivity to settings package
Da Risk <da_risk@geekorum.com>
parents:
0
diff
changeset
|
1 |
/* |
| 0 | 2 |
* Geekttrss is a RSS feed reader application on the Android Platform. |
3 |
* |
|
4 |
* Copyright (C) 2017-2018 by Frederic-Charles Barthelery. |
|
5 |
* |
|
6 |
* This file is part of Geekttrss. |
|
7 |
* |
|
8 |
* Geekttrss is free software: you can redistribute it and/or modify |
|
9 |
* it under the terms of the GNU General Public License as published by |
|
10 |
* the Free Software Foundation, either version 3 of the License, or |
|
11 |
* (at your option) any later version. |
|
12 |
* |
|
13 |
* Geekttrss is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with Geekttrss. If not, see <http://www.gnu.org/licenses/>. |
|
20 |
*/ |
|
|
134
d7a3563591ae
Move SettingsActivity to settings package
Da Risk <da_risk@geekorum.com>
parents:
0
diff
changeset
|
21 |
package com.geekorum.ttrss.settings |
| 0 | 22 |
|
23 |
import android.content.Context |
|
24 |
import androidx.recyclerview.widget.RecyclerView |
|
25 |
import androidx.test.core.app.ApplicationProvider |
|
26 |
import androidx.test.espresso.Espresso.onView |
|
27 |
import androidx.test.espresso.action.ViewActions.click |
|
28 |
import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItem |
|
29 |
import androidx.test.espresso.intent.Intents |
|
30 |
import androidx.test.espresso.intent.rule.IntentsTestRule |
|
31 |
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant |
|
32 |
import androidx.test.espresso.matcher.ViewMatchers.withId |
|
33 |
import androidx.test.espresso.matcher.ViewMatchers.withText |
|
34 |
import androidx.test.ext.junit.runners.AndroidJUnit4 |
|
35 |
import androidx.test.ext.truth.content.IntentSubject |
|
|
134
d7a3563591ae
Move SettingsActivity to settings package
Da Risk <da_risk@geekorum.com>
parents:
0
diff
changeset
|
36 |
import com.geekorum.ttrss.R |
| 0 | 37 |
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity |
38 |
import com.google.common.truth.Truth.assertThat |
|
39 |
import org.junit.Rule |
|
40 |
import org.junit.runner.RunWith |
|
41 |
import kotlin.reflect.jvm.jvmName |
|
42 |
import kotlin.test.Test |
|
43 |
||
44 |
/* |
|
45 |
* For some reasons, when it's a Robolectric test the activity doesn't launch (or synchronization is bad) so we only check |
|
46 |
* if the correct intent is fired. See androidTest/com.geekorum.test.SettingsActivityTest for a more complete test. |
|
47 |
*/ |
|
48 |
@RunWith(AndroidJUnit4::class) |
|
49 |
class SettingsActivityTest {
|
|
50 |
||
51 |
@get:Rule |
|
52 |
val activityRule = IntentsTestRule(SettingsActivity::class.java) |
|
53 |
||
54 |
||
55 |
@Test |
|
56 |
fun testThatWeCanShowDependenciesOpenSourcesLicenses() {
|
|
57 |
// click on OSS licenses |
|
58 |
onView(withId(R.id.recycler_view)) |
|
59 |
.perform(actionOnItem<RecyclerView.ViewHolder>(hasDescendant(withText(R.string.oss_license_title)), |
|
60 |
click())) |
|
61 |
||
62 |
val intents = Intents.getIntents() |
|
63 |
assertThat(intents).hasSize(1) |
|
64 |
val intent = intents.first() |
|
65 |
||
66 |
val applicationContext = ApplicationProvider.getApplicationContext<Context>() |
|
67 |
IntentSubject.assertThat(intent).hasComponent(applicationContext.packageName, OssLicensesMenuActivity::class.jvmName) |
|
68 |
||
69 |
} |
|
70 |
} |