|
| 1 | +/* |
| 2 | + * This file is part of BOINC. |
| 3 | + * http://boinc.berkeley.edu |
| 4 | + * Copyright (C) 2020 University of California |
| 5 | + * |
| 6 | + * BOINC is free software; you can redistribute it and/or modify it |
| 7 | + * under the terms of the GNU Lesser General Public License |
| 8 | + * as published by the Free Software Foundation, |
| 9 | + * either version 3 of the License, or (at your option) any later version. |
| 10 | + * |
| 11 | + * BOINC is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 14 | + * See the GNU Lesser General Public License for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU Lesser General Public License |
| 17 | + * along with BOINC. If not, see <http://www.gnu.org/licenses/>. |
| 18 | + */ |
| 19 | +package edu.berkeley.boinc |
| 20 | + |
| 21 | +import androidx.test.espresso.Espresso.onView |
| 22 | +import androidx.test.espresso.action.ViewActions.click |
| 23 | +import androidx.test.espresso.assertion.ViewAssertions.matches |
| 24 | +import androidx.test.espresso.matcher.ViewMatchers.* |
| 25 | +import androidx.test.ext.junit.rules.ActivityScenarioRule |
| 26 | +import androidx.test.ext.junit.runners.AndroidJUnit4 |
| 27 | +import androidx.test.filters.LargeTest |
| 28 | +import org.hamcrest.Matchers.allOf |
| 29 | +import org.junit.Rule |
| 30 | +import org.junit.Test |
| 31 | +import org.junit.runner.RunWith |
| 32 | + |
| 33 | +@LargeTest |
| 34 | +@RunWith(AndroidJUnit4::class) |
| 35 | +class BOINCActivityTest { |
| 36 | + @Rule |
| 37 | + @JvmField |
| 38 | + var mActivityScenarioRule = ActivityScenarioRule(BOINCActivity::class.java) |
| 39 | + |
| 40 | + @Test |
| 41 | + fun boincActivityTest() { |
| 42 | + val appCompatImageButton = onView( |
| 43 | + allOf(withContentDescription("Navigate up"), |
| 44 | + childAtPosition( |
| 45 | + allOf(withId(R.id.action_bar), |
| 46 | + childAtPosition( |
| 47 | + withId(R.id.action_bar_container), |
| 48 | + 0)), |
| 49 | + 1), |
| 50 | + isDisplayed())) |
| 51 | + appCompatImageButton.perform(click()) |
| 52 | + |
| 53 | + val textView = onView( |
| 54 | + allOf(withId(R.id.title), withText("Tasks"), |
| 55 | + childAtPosition( |
| 56 | + allOf(withId(R.id.listitem), |
| 57 | + childAtPosition( |
| 58 | + withId(R.id.list_slidermenu), |
| 59 | + 0)), |
| 60 | + 1), |
| 61 | + isDisplayed())) |
| 62 | + textView.check(matches(withText("Tasks"))) |
| 63 | + |
| 64 | + val textView2 = onView( |
| 65 | + allOf(withId(R.id.title), withText("Notices"), |
| 66 | + childAtPosition( |
| 67 | + allOf(withId(R.id.listitem), |
| 68 | + childAtPosition( |
| 69 | + withId(R.id.list_slidermenu), |
| 70 | + 1)), |
| 71 | + 1), |
| 72 | + isDisplayed())) |
| 73 | + textView2.check(matches(withText("Notices"))) |
| 74 | + |
| 75 | + val textView3 = onView( |
| 76 | + allOf(withId(R.id.title), withText("Projects"), |
| 77 | + childAtPosition( |
| 78 | + allOf(withId(R.id.listitem), |
| 79 | + childAtPosition( |
| 80 | + withId(R.id.list_slidermenu), |
| 81 | + 2)), |
| 82 | + 1), |
| 83 | + isDisplayed())) |
| 84 | + textView3.check(matches(withText("Projects"))) |
| 85 | + |
| 86 | + val textView4 = onView( |
| 87 | + allOf(withId(R.id.title), withText("Add project"), |
| 88 | + childAtPosition( |
| 89 | + allOf(withId(R.id.listitem), |
| 90 | + childAtPosition( |
| 91 | + withId(R.id.list_slidermenu), |
| 92 | + 3)), |
| 93 | + 1), |
| 94 | + isDisplayed())) |
| 95 | + textView4.check(matches(withText("Add project"))) |
| 96 | + |
| 97 | + val textView5 = onView( |
| 98 | + allOf(withId(R.id.title), withText("Preferences"), |
| 99 | + childAtPosition( |
| 100 | + allOf(withId(R.id.listitem), |
| 101 | + childAtPosition( |
| 102 | + withId(R.id.list_slidermenu), |
| 103 | + 4)), |
| 104 | + 1), |
| 105 | + isDisplayed())) |
| 106 | + textView5.check(matches(withText("Preferences"))) |
| 107 | + |
| 108 | + val textView6 = onView( |
| 109 | + allOf(withId(R.id.title), withText("Help"), |
| 110 | + childAtPosition( |
| 111 | + allOf(withId(R.id.listitem), |
| 112 | + childAtPosition( |
| 113 | + withId(R.id.list_slidermenu), |
| 114 | + 5)), |
| 115 | + 1), |
| 116 | + isDisplayed())) |
| 117 | + textView6.check(matches(withText("Help"))) |
| 118 | + |
| 119 | + val textView7 = onView( |
| 120 | + allOf(withId(R.id.title), withText("Report Issue"), |
| 121 | + childAtPosition( |
| 122 | + allOf(withId(R.id.listitem), |
| 123 | + childAtPosition( |
| 124 | + withId(R.id.list_slidermenu), |
| 125 | + 6)), |
| 126 | + 1), |
| 127 | + isDisplayed())) |
| 128 | + textView7.check(matches(withText("Report Issue"))) |
| 129 | + |
| 130 | + val textView8 = onView( |
| 131 | + allOf(withId(R.id.title), withText("About"), |
| 132 | + childAtPosition( |
| 133 | + allOf(withId(R.id.listitem), |
| 134 | + childAtPosition( |
| 135 | + withId(R.id.list_slidermenu), |
| 136 | + 7)), |
| 137 | + 1), |
| 138 | + isDisplayed())) |
| 139 | + textView8.check(matches(withText("About"))) |
| 140 | + |
| 141 | + val textView9 = onView( |
| 142 | + allOf(withId(R.id.title), withText("Event Log"), |
| 143 | + childAtPosition( |
| 144 | + allOf(withId(R.id.listitem), |
| 145 | + childAtPosition( |
| 146 | + withId(R.id.list_slidermenu), |
| 147 | + 8)), |
| 148 | + 1), |
| 149 | + isDisplayed())) |
| 150 | + textView9.check(matches(withText("Event Log"))) |
| 151 | + } |
| 152 | +} |
0 commit comments