-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2962379
commit 6147bf8
Showing
3 changed files
with
210 additions
and
20 deletions.
There are no files selected for viewing
152 changes: 152 additions & 0 deletions
152
android/BOINC/app/src/androidTest/java/edu/berkeley/boinc/BOINCActivityTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
/* | ||
* This file is part of BOINC. | ||
* http://boinc.berkeley.edu | ||
* Copyright (C) 2020 University of California | ||
* | ||
* BOINC is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License | ||
* as published by the Free Software Foundation, | ||
* either version 3 of the License, or (at your option) any later version. | ||
* | ||
* BOINC is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with BOINC. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package edu.berkeley.boinc | ||
|
||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.action.ViewActions.click | ||
import androidx.test.espresso.assertion.ViewAssertions.matches | ||
import androidx.test.espresso.matcher.ViewMatchers.* | ||
import androidx.test.ext.junit.rules.ActivityScenarioRule | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.filters.LargeTest | ||
import org.hamcrest.Matchers.allOf | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@LargeTest | ||
@RunWith(AndroidJUnit4::class) | ||
class BOINCActivityTest { | ||
@Rule | ||
@JvmField | ||
var mActivityScenarioRule = ActivityScenarioRule(BOINCActivity::class.java) | ||
|
||
@Test | ||
fun boincActivityTest() { | ||
val appCompatImageButton = onView( | ||
allOf(withContentDescription("Navigate up"), | ||
childAtPosition( | ||
allOf(withId(R.id.action_bar), | ||
childAtPosition( | ||
withId(R.id.action_bar_container), | ||
0)), | ||
1), | ||
isDisplayed())) | ||
appCompatImageButton.perform(click()) | ||
|
||
val textView = onView( | ||
allOf(withId(R.id.title), withText("Tasks"), | ||
childAtPosition( | ||
allOf(withId(R.id.listitem), | ||
childAtPosition( | ||
withId(R.id.list_slidermenu), | ||
0)), | ||
1), | ||
isDisplayed())) | ||
textView.check(matches(withText("Tasks"))) | ||
|
||
val textView2 = onView( | ||
allOf(withId(R.id.title), withText("Notices"), | ||
childAtPosition( | ||
allOf(withId(R.id.listitem), | ||
childAtPosition( | ||
withId(R.id.list_slidermenu), | ||
1)), | ||
1), | ||
isDisplayed())) | ||
textView2.check(matches(withText("Notices"))) | ||
|
||
val textView3 = onView( | ||
allOf(withId(R.id.title), withText("Projects"), | ||
childAtPosition( | ||
allOf(withId(R.id.listitem), | ||
childAtPosition( | ||
withId(R.id.list_slidermenu), | ||
2)), | ||
1), | ||
isDisplayed())) | ||
textView3.check(matches(withText("Projects"))) | ||
|
||
val textView4 = onView( | ||
allOf(withId(R.id.title), withText("Add project"), | ||
childAtPosition( | ||
allOf(withId(R.id.listitem), | ||
childAtPosition( | ||
withId(R.id.list_slidermenu), | ||
3)), | ||
1), | ||
isDisplayed())) | ||
textView4.check(matches(withText("Add project"))) | ||
|
||
val textView5 = onView( | ||
allOf(withId(R.id.title), withText("Preferences"), | ||
childAtPosition( | ||
allOf(withId(R.id.listitem), | ||
childAtPosition( | ||
withId(R.id.list_slidermenu), | ||
4)), | ||
1), | ||
isDisplayed())) | ||
textView5.check(matches(withText("Preferences"))) | ||
|
||
val textView6 = onView( | ||
allOf(withId(R.id.title), withText("Help"), | ||
childAtPosition( | ||
allOf(withId(R.id.listitem), | ||
childAtPosition( | ||
withId(R.id.list_slidermenu), | ||
5)), | ||
1), | ||
isDisplayed())) | ||
textView6.check(matches(withText("Help"))) | ||
|
||
val textView7 = onView( | ||
allOf(withId(R.id.title), withText("Report Issue"), | ||
childAtPosition( | ||
allOf(withId(R.id.listitem), | ||
childAtPosition( | ||
withId(R.id.list_slidermenu), | ||
6)), | ||
1), | ||
isDisplayed())) | ||
textView7.check(matches(withText("Report Issue"))) | ||
|
||
val textView8 = onView( | ||
allOf(withId(R.id.title), withText("About"), | ||
childAtPosition( | ||
allOf(withId(R.id.listitem), | ||
childAtPosition( | ||
withId(R.id.list_slidermenu), | ||
7)), | ||
1), | ||
isDisplayed())) | ||
textView8.check(matches(withText("About"))) | ||
|
||
val textView9 = onView( | ||
allOf(withId(R.id.title), withText("Event Log"), | ||
childAtPosition( | ||
allOf(withId(R.id.listitem), | ||
childAtPosition( | ||
withId(R.id.list_slidermenu), | ||
8)), | ||
1), | ||
isDisplayed())) | ||
textView9.check(matches(withText("Event Log"))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
android/BOINC/app/src/androidTest/java/edu/berkeley/boinc/TestUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* This file is part of BOINC. | ||
* http://boinc.berkeley.edu | ||
* Copyright (C) 2020 University of California | ||
* | ||
* BOINC is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License | ||
* as published by the Free Software Foundation, | ||
* either version 3 of the License, or (at your option) any later version. | ||
* | ||
* BOINC is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with BOINC. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package edu.berkeley.boinc | ||
|
||
import android.view.View | ||
import android.view.ViewGroup | ||
import org.hamcrest.Description | ||
import org.hamcrest.Matcher | ||
import org.hamcrest.TypeSafeMatcher | ||
|
||
fun childAtPosition(parentMatcher: Matcher<View>, position: Int): Matcher<View> { | ||
return object : TypeSafeMatcher<View>() { | ||
override fun describeTo(description: Description) { | ||
description.appendText("Child at position $position in parent ") | ||
parentMatcher.describeTo(description) | ||
} | ||
|
||
public override fun matchesSafely(view: View): Boolean { | ||
val parent = view.parent | ||
return parent is ViewGroup && parentMatcher.matches(parent) | ||
&& view == parent.getChildAt(position) | ||
} | ||
} | ||
} |