forked from odk-x/services
-
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.
additional improvements to waits in tests (odk-x#299)
* additional improvements to waits in tests * add onIdle and clean up imports * add dismiss system dialogs * add additional fixes * attempt to use orchestrator * add base class for tests requiring files and improve reporting * additional fixes * move away from activity rule and other fixes * remove orchestration and add warmup test * add new ignores * add an ignore * add additional waits
- Loading branch information
Showing
61 changed files
with
572 additions
and
353 deletions.
There are no files selected for viewing
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
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
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
35 changes: 35 additions & 0 deletions
35
services_app/src/androidTest/java/org/opendatakit/BaseFileTest.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,35 @@ | ||
package org.opendatakit; | ||
|
||
import android.Manifest; | ||
import android.app.Application; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
|
||
import androidx.test.core.app.ApplicationProvider; | ||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.rule.GrantPermissionRule; | ||
|
||
import org.junit.Rule; | ||
import org.opendatakit.utilities.RuntimePermissionUtils; | ||
|
||
public abstract class BaseFileTest { | ||
@Rule | ||
public GrantPermissionRule writeRuntimePermissionRule = GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE); | ||
@Rule | ||
public GrantPermissionRule readtimePermissionRule = GrantPermissionRule.grant(Manifest.permission.READ_EXTERNAL_STORAGE); | ||
|
||
|
||
protected void verifyReady() { | ||
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); | ||
|
||
Application app = ApplicationProvider.getApplicationContext(); | ||
boolean permissions = RuntimePermissionUtils.checkPackageAllPermission(context, app.getPackageName(), | ||
Manifest.permission.READ_EXTERNAL_STORAGE, | ||
Manifest.permission.WRITE_EXTERNAL_STORAGE | ||
); | ||
if (!permissions) { | ||
throw new RuntimeException("FILE PERMISSIONS MISSING"); | ||
} | ||
} | ||
} |
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
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
32 changes: 32 additions & 0 deletions
32
services_app/src/androidTest/java/org/opendatakit/WarmUpTest.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,32 @@ | ||
package org.opendatakit; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import android.content.Intent; | ||
|
||
import androidx.test.espresso.Espresso; | ||
|
||
import org.junit.Test; | ||
import org.opendatakit.consts.IntentConsts; | ||
import org.opendatakit.services.MainActivity; | ||
|
||
public class WarmUpTest extends BaseUITest<MainActivity> { | ||
|
||
@Test | ||
public void warmUpTest() { | ||
Espresso.onIdle(); | ||
assertTrue(true); | ||
} | ||
|
||
@Override | ||
protected void setUpPostLaunch() { | ||
// do nothing | ||
} | ||
|
||
@Override | ||
protected Intent getLaunchIntent() { | ||
Intent intent = new Intent(getContext(), MainActivity.class); | ||
intent.putExtra(IntentConsts.INTENT_KEY_APP_NAME, APP_NAME); | ||
return intent; | ||
} | ||
} |
Oops, something went wrong.