| author | Da Risk <da_risk@geekorum.com> |
| Fri, 05 Jul 2019 14:00:53 -0700 | |
| changeset 354 | 14a679b8ce11 |
| parent 137 | 5464f07a306c |
| child 611 | 91b8d76c03cd |
| 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 |
* |
|
|
137
5464f07a306c
Update copyright headers for 2019
Da Risk <da_risk@geekorum.com>
parents:
134
diff
changeset
|
4 |
* Copyright (C) 2017-2019 by Frederic-Charles Barthelery. |
| 0 | 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 |
|
|
354
14a679b8ce11
app: target sdk 29 (android Q)
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
41 |
import org.robolectric.annotation.Config |
| 0 | 42 |
import kotlin.reflect.jvm.jvmName |
43 |
import kotlin.test.Test |
|
44 |
||
45 |
/* |
|
46 |
* For some reasons, when it's a Robolectric test the activity doesn't launch (or synchronization is bad) so we only check |
|
47 |
* if the correct intent is fired. See androidTest/com.geekorum.test.SettingsActivityTest for a more complete test. |
|
48 |
*/ |
|
49 |
@RunWith(AndroidJUnit4::class) |
|
|
354
14a679b8ce11
app: target sdk 29 (android Q)
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
50 |
@Config(sdk = [28]) // for now we don't do robolectric on sdk 29 (needs to run on java9) |
| 0 | 51 |
class SettingsActivityTest {
|
52 |
||
53 |
@get:Rule |
|
54 |
val activityRule = IntentsTestRule(SettingsActivity::class.java) |
|
55 |
||
56 |
||
57 |
@Test |
|
58 |
fun testThatWeCanShowDependenciesOpenSourcesLicenses() {
|
|
59 |
// click on OSS licenses |
|
60 |
onView(withId(R.id.recycler_view)) |
|
61 |
.perform(actionOnItem<RecyclerView.ViewHolder>(hasDescendant(withText(R.string.oss_license_title)), |
|
62 |
click())) |
|
63 |
||
64 |
val intents = Intents.getIntents() |
|
65 |
assertThat(intents).hasSize(1) |
|
66 |
val intent = intents.first() |
|
67 |
||
68 |
val applicationContext = ApplicationProvider.getApplicationContext<Context>() |
|
69 |
IntentSubject.assertThat(intent).hasComponent(applicationContext.packageName, OssLicensesMenuActivity::class.jvmName) |
|
70 |
||
71 |
} |
|
72 |
} |