Skip to content

Commit

Permalink
Added UpdateProjectTest
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 committed May 5, 2021
1 parent 5a07db2 commit e4fc43b
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.odk.collect.android.feature.projects

import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.pressBack
import androidx.test.espresso.matcher.ViewMatchers
import org.junit.Rule
import org.junit.Test
import org.junit.rules.RuleChain
import org.odk.collect.android.support.CollectTestRule
import org.odk.collect.android.support.TestRuleChain

class UpdateProjectTest {

val rule = CollectTestRule()

@get:Rule
var chain: RuleChain = TestRuleChain
.chain()
.around(rule)

@Test
fun updateProjectTest() {
rule.mainMenu()
.assertProjectIcon("D", "#3e9fcc")
.openProjectSettingsDialog()
.assertCurrentProject("Demo project")
.clickAdminSettings()
.setProjectName("Project X")
.setProjectIcon("X")
.setProjectColor("#cccccc")

onView(ViewMatchers.isRoot()).perform(pressBack())

rule.mainMenu()
.assertProjectIcon("X", "#cccccc")
.openProjectSettingsDialog()
.assertCurrentProject("Project X")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,25 @@ public QRCodePage clickConfigureQR() {
clickOnString(R.string.configure_via_qr_code);
return new QRCodePage(rule).assertOnPage();
}

public AdminSettingsPage setProjectName(String projectName) {
clickOnString(R.string.project_name);
inputText(projectName);
clickOKOnDialog();
return this;
}

public AdminSettingsPage setProjectIcon(String projectIcon) {
clickOnString(R.string.project_icon);
inputText(projectIcon);
clickOKOnDialog();
return this;
}

public AdminSettingsPage setProjectColor(String projectColor) {
clickOnString(R.string.project_color);
inputText(projectColor);
clickOKOnDialog();
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,13 @@ public T addText(String existingText, String text) {

public T inputText(String text) {
onView(withClassName(endsWith("EditText"))).perform(replaceText(text));
closeSoftKeyboard();
return (T) this;
}

public T inputText(int hint, String text) {
onView(withHint(getTranslatedString(hint))).perform(replaceText(text));
closeSoftKeyboard();
return (T) this;
}

Expand Down

0 comments on commit e4fc43b

Please sign in to comment.