-
Notifications
You must be signed in to change notification settings - Fork 54
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
99b3fd2
commit 3a8d3dc
Showing
7 changed files
with
67 additions
and
81 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
29 changes: 15 additions & 14 deletions
29
...Test/kotlin/universe/constellation/orion/viewer/test/framework/InstrumentationTestCase.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 |
---|---|---|
@@ -1,29 +1,30 @@ | ||
package universe.constellation.orion.viewer.test.framework | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import androidx.test.rule.ActivityTestRule | ||
import androidx.test.ext.junit.rules.activityScenarioRule | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.rule.GrantPermissionRule | ||
import org.junit.Rule | ||
import universe.constellation.orion.viewer.Controller | ||
import universe.constellation.orion.viewer.OrionViewerActivity | ||
import universe.constellation.orion.viewer.prefs.GlobalOptions | ||
import universe.constellation.orion.viewer.prefs.OrionApplication | ||
|
||
|
||
abstract class InstrumentationTestCase : TestUtil { | ||
abstract class InstrumentationTestCase(intent: Intent, private val showTapHelp: Boolean = false) : TestUtil { | ||
|
||
@get:Rule | ||
val mRuntimePermissionRule: GrantPermissionRule = GrantPermissionRule.grant(android.Manifest.permission.WRITE_EXTERNAL_STORAGE, android.Manifest.permission.READ_EXTERNAL_STORAGE) | ||
|
||
@get:Rule | ||
val mActivityRule: ActivityTestRule<OrionViewerActivity> = ActivityTestRule(OrionViewerActivity::class.java, true, false) | ||
|
||
val activity: OrionViewerActivity | ||
get() = mActivityRule.activity | ||
|
||
fun getController() : Controller = mActivityRule.activity.controller!! | ||
|
||
fun startActivityWithBook(intent: Intent) { | ||
mActivityRule.launchActivity(intent) | ||
activity.orionContext.isTesting = true | ||
var activityScenarioRule = activityScenarioRule<OrionViewerActivity>(intent.apply { | ||
if (showTapHelp) { | ||
putExtra(GlobalOptions.SHOW_TAP_HELP, true) | ||
} else { | ||
putExtra(GlobalOptions.SHOW_TAP_HELP, false) | ||
} | ||
}) | ||
|
||
val globalOptions by lazy { | ||
(InstrumentationRegistry.getInstrumentation().targetContext.applicationContext as OrionApplication).options | ||
} | ||
} |
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