|
17 | 17 | */ |
18 | 18 | package com.vrem.wifianalyzer |
19 | 19 |
|
20 | | -import androidx.recyclerview.widget.RecyclerView |
21 | | -import androidx.test.espresso.Espresso.onView |
22 | 20 | import androidx.test.espresso.Espresso.pressBack |
23 | | -import androidx.test.espresso.assertion.ViewAssertions.matches |
24 | | -import androidx.test.espresso.contrib.RecyclerViewActions |
25 | | -import androidx.test.espresso.matcher.ViewMatchers.hasDescendant |
26 | | -import androidx.test.espresso.matcher.ViewMatchers.isDisplayed |
27 | | -import androidx.test.espresso.matcher.ViewMatchers.withId |
28 | | -import androidx.test.espresso.matcher.ViewMatchers.withText |
29 | 21 |
|
30 | 22 | internal class SettingsInstrumentedTest : Runnable { |
31 | 23 | override fun run() { |
32 | 24 | selectMenuItem(10, "Settings") |
33 | | - verifyVisibleSettings() |
34 | | - verifyScrollableSettings() |
| 25 | + verifySettings() |
35 | 26 | pressBack() |
36 | 27 | } |
37 | 28 |
|
38 | | - private fun verifyVisibleSettings() { |
39 | | - onView(withText("Scan Interval")).check(matches(isDisplayed())) |
40 | | - onView(withText("Sort Access Points By")).check(matches(isDisplayed())) |
41 | | - onView(withText("Group Access Points By")).check(matches(isDisplayed())) |
42 | | - onView(withText("Connection Display")).check(matches(isDisplayed())) |
43 | | - onView(withText("Access Point Display")).check(matches(isDisplayed())) |
44 | | - onView(withText("Graph Maximum Signal Strength")).check(matches(isDisplayed())) |
45 | | - onView(withText("Channel Graph Legend Display")).check(matches(isDisplayed())) |
46 | | - onView(withText("Time Graph Legend Display")).check(matches(isDisplayed())) |
47 | | - } |
48 | | - |
49 | | - private fun verifyScrollableSettings() { |
50 | | - scrollToAndVerify("Theme") |
51 | | - scrollToAndVerify("Keep screen on") |
52 | | - scrollToAndVerify("Country") |
53 | | - scrollToAndVerify("Language") |
54 | | - scrollToAndVerify("Reset") |
55 | | - } |
56 | | - |
57 | | - private fun scrollToAndVerify(text: String) { |
58 | | - onView(withId(androidx.preference.R.id.recycler_view)) |
59 | | - .perform(RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(hasDescendant(withText(text)))) |
60 | | - onView(withText(text)).check(matches(isDisplayed())) |
| 29 | + private fun verifySettings() { |
| 30 | + listOf( |
| 31 | + "Scan Interval", |
| 32 | + "Sort Access Points By", |
| 33 | + "Group Access Points By", |
| 34 | + "Connection Display", |
| 35 | + "Access Point Display", |
| 36 | + "Graph Maximum Signal Strength", |
| 37 | + "Channel Graph Legend Display", |
| 38 | + "Time Graph Legend Display", |
| 39 | + "Theme", |
| 40 | + "Keep screen on", |
| 41 | + "Country", |
| 42 | + "Language", |
| 43 | + "Reset", |
| 44 | + ).forEach { scrollToAndVerify(it) } |
61 | 45 | } |
62 | 46 | } |
0 commit comments