|
0
|
1 |
/**
|
|
|
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 |
*/
|
|
|
21 |
package com.geekorum.ttrss
|
|
|
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
|
|
|
36 |
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity
|
|
|
37 |
import com.google.common.truth.Truth.assertThat
|
|
|
38 |
import org.junit.Rule
|
|
|
39 |
import org.junit.runner.RunWith
|
|
|
40 |
import kotlin.reflect.jvm.jvmName
|
|
|
41 |
import kotlin.test.Test
|
|
|
42 |
|
|
|
43 |
/*
|
|
|
44 |
* For some reasons, when it's a Robolectric test the activity doesn't launch (or synchronization is bad) so we only check
|
|
|
45 |
* if the correct intent is fired. See androidTest/com.geekorum.test.SettingsActivityTest for a more complete test.
|
|
|
46 |
*/
|
|
|
47 |
@RunWith(AndroidJUnit4::class)
|
|
|
48 |
class SettingsActivityTest {
|
|
|
49 |
|
|
|
50 |
@get:Rule
|
|
|
51 |
val activityRule = IntentsTestRule(SettingsActivity::class.java)
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
@Test
|
|
|
55 |
fun testThatWeCanShowDependenciesOpenSourcesLicenses() {
|
|
|
56 |
// click on OSS licenses
|
|
|
57 |
onView(withId(R.id.recycler_view))
|
|
|
58 |
.perform(actionOnItem<RecyclerView.ViewHolder>(hasDescendant(withText(R.string.oss_license_title)),
|
|
|
59 |
click()))
|
|
|
60 |
|
|
|
61 |
val intents = Intents.getIntents()
|
|
|
62 |
assertThat(intents).hasSize(1)
|
|
|
63 |
val intent = intents.first()
|
|
|
64 |
|
|
|
65 |
val applicationContext = ApplicationProvider.getApplicationContext<Context>()
|
|
|
66 |
IntentSubject.assertThat(intent).hasComponent(applicationContext.packageName, OssLicensesMenuActivity::class.jvmName)
|
|
|
67 |
|
|
|
68 |
}
|
|
|
69 |
}
|