forked from getodk/collect
-
Notifications
You must be signed in to change notification settings - Fork 0
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
d932897
commit c45f65a
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
..._app/src/androidTest/java/org/odk/collect/android/storage/StorageMigrationBannerTest.java
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,36 @@ | ||
package org.odk.collect.android.storage; | ||
|
||
import androidx.test.rule.ActivityTestRule; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.odk.collect.android.activities.MainMenuActivity; | ||
import org.odk.collect.android.support.StorageMigrationNotPerformedRule; | ||
import org.odk.collect.android.support.pages.MainMenuPage; | ||
|
||
public class StorageMigrationBannerTest { | ||
|
||
@Rule | ||
public ActivityTestRule<MainMenuActivity> main = new ActivityTestRule<>(MainMenuActivity.class); | ||
|
||
@Rule | ||
public StorageMigrationNotPerformedRule storageMigrationNotPerformedRule = new StorageMigrationNotPerformedRule(); | ||
|
||
@Test | ||
public void when_storageMigrationNotPerformed_should_bannerBeVisible() { | ||
new MainMenuPage(main) | ||
.assertStorageMigrationBannerIsDisplayed() | ||
.rotateToLandscape(new MainMenuPage(main)) | ||
.assertStorageMigrationBannerIsDisplayed() | ||
.rotateToPortrait(new MainMenuPage(main)) | ||
.assertStorageMigrationBannerIsDisplayed() | ||
.reopenApp() | ||
.assertStorageMigrationBannerIsDisplayed(); | ||
} | ||
|
||
@Test | ||
public void when_learMoreButtonClicked_should_storageMigrationDialogAppear() { | ||
new MainMenuPage(main) | ||
.clickLearnMoreButton(); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...rc/androidTest/java/org/odk/collect/android/support/StorageMigrationNotPerformedRule.java
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,29 @@ | ||
package org.odk.collect.android.support; | ||
|
||
import org.junit.rules.TestRule; | ||
import org.junit.runner.Description; | ||
import org.junit.runners.model.Statement; | ||
import org.odk.collect.android.storage.StorageStateProvider; | ||
|
||
public class StorageMigrationNotPerformedRule implements TestRule { | ||
|
||
@Override | ||
public Statement apply(Statement base, Description description) { | ||
return new StorageMigrationNotPerformedRuleStatement(base); | ||
} | ||
|
||
private class StorageMigrationNotPerformedRuleStatement extends Statement { | ||
|
||
private final Statement base; | ||
|
||
StorageMigrationNotPerformedRuleStatement(Statement base) { | ||
this.base = base; | ||
} | ||
|
||
@Override | ||
public void evaluate() throws Throwable { | ||
new StorageStateProvider().disableUsingScopedStorage(); | ||
base.evaluate(); | ||
} | ||
} | ||
} |
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
27 changes: 27 additions & 0 deletions
27
...rc/androidTest/java/org/odk/collect/android/support/pages/StorageMigrationDialogPage.java
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,27 @@ | ||
package org.odk.collect.android.support.pages; | ||
|
||
import androidx.test.rule.ActivityTestRule; | ||
|
||
import org.odk.collect.android.R; | ||
|
||
import static androidx.test.espresso.Espresso.onView; | ||
import static androidx.test.espresso.action.ViewActions.click; | ||
import static androidx.test.espresso.matcher.ViewMatchers.withId; | ||
|
||
public class StorageMigrationDialogPage<D extends Page<D>> extends Page<StorageMigrationDialogPage<D>> { | ||
|
||
public StorageMigrationDialogPage(ActivityTestRule rule) { | ||
super(rule); | ||
} | ||
|
||
@Override | ||
public StorageMigrationDialogPage<D> assertOnPage() { | ||
checkIsStringDisplayed(R.string.storage_migration_dialog_title); | ||
return this; | ||
} | ||
|
||
public MainMenuPage clickMigrate() { | ||
onView(withId(R.id.migrateButton)).perform(click()); | ||
return new MainMenuPage(rule).assertOnPage(); | ||
} | ||
} |