本文整理匯總了Java中android.support.test.rule.ActivityTestRule.launchActivity方法的典型用法代碼示例。如果您正苦於以下問題:Java ActivityTestRule.launchActivity方法的具體用法?Java ActivityTestRule.launchActivity怎麽用?Java ActivityTestRule.launchActivity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.test.rule.ActivityTestRule
的用法示例。
在下文中一共展示了ActivityTestRule.launchActivity方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testReposActivityFragments
import android.support.test.rule.ActivityTestRule; //導入方法依賴的package包/類
@Test
public void testReposActivityFragments() {
ActivityTestRule rule = new ActivityTestRule<>(ReposActivity.class, true, false);
shelfTestUtils.setupBook("book-one", "Preface\n\n* Note");
shelfTestUtils.setupRepo("file:/");
shelfTestUtils.setupRepo("dropbox:/orgzly");
rule.launchActivity(null);
// List of repos
fragmentTest(rule, false, withId(R.id.fragment_repos_flipper));
// Directory repo
onListItem(1).perform(click());
fragmentTest(rule, false, withId(R.id.fragment_repo_directory_container));
pressBack();
// Dropbox repo
onListItem(0).perform(click());
fragmentTest(rule, false, withId(R.id.fragment_repo_dropbox_container));
}
示例2: Disconnect
import android.support.test.rule.ActivityTestRule; //導入方法依賴的package包/類
public static void Disconnect(ActivityTestRule<SnippetListActivity> snippetListActivityTestRule) {
SnippetListActivity snippetListActivity = snippetListActivityTestRule.launchActivity(null);
openActionBarOverflowOrOptionsMenu(InstrumentationRegistry.getTargetContext());
// Espresso can't find menu items by id. We'll use the text property.
onView(withText(R.string.disconnect_menu_item))
.perform(click());
intended(allOf(
hasComponent(hasShortClassName(".SignInActivity")),
toPackage("com.microsoft.graph.snippets")
));
snippetListActivity.finish();
}
示例3: getSnippetsIndexes
import android.support.test.rule.ActivityTestRule; //導入方法依賴的package包/類
public static List<Integer> getSnippetsIndexes(ActivityTestRule<SnippetListActivity> snippetListActivityRule) {
SnippetListActivity snippetListActivity = snippetListActivityRule.launchActivity(null);
ListAdapter listAdapter = getListAdapter(snippetListActivity);
int numItems = listAdapter.getCount();
List<Integer> snippetIndexes = new ArrayList<>();
// Get the index of items in the adapter that
// are actual snippets and not categories, which don't have a Url
for (int i = 0; i < numItems; i++) {
if(((AbstractSnippet)listAdapter.getItem(i)).getUrl() != null) {
snippetIndexes.add(i);
}
}
snippetListActivity.finish();
return snippetIndexes;
}
示例4: bringToFront
import android.support.test.rule.ActivityTestRule; //導入方法依賴的package包/類
/**
* Brings activity to foreground, if it is already launched, or launches it.
*
* @param rule activity rule for the activity to operate on.
* @param <T> activity class.
*/
public static <T extends Activity> void bringToFront(final ActivityTestRule<T> rule) {
final T runningActivity = rule.getActivity();
if (runningActivity == null) {
rule.launchActivity(null);
} else {
// TODO(dotdoom): launch using runningActivity.getIntent()? E.g. to preserve username
// and save roundtrip to login window.
final Intent intent = new Intent(runningActivity, runningActivity.getClass());
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
runningActivity.startActivity(intent);
}
}
示例5: launchDatePickerInFragmentActivity
import android.support.test.rule.ActivityTestRule; //導入方法依賴的package包/類
private void launchDatePickerInFragmentActivity(List<ActivityTheme> activityThemeList, final Class<DatePickerInFragmentActivity> clazz){
for(DatePickerMode datePickerMode : DatePickerMode.values()){
for(int i = 0; i < 2; i++){
boolean isCalendarViewShown = i == 0;
for(int j = 0; j < 2; j++){
boolean isSpinnersShown = j == 0;
for(ActivityTheme activityTheme : activityThemeList){
if(datePickerMode == DatePickerMode.Calendar && activityTheme == ActivityTheme.Theme_Black){
continue;
}
final Intent intent = MainActivity.createIntent(activityTestRule.getActivity(),
clazz,
datePickerMode.layout,
isCalendarViewShown,
isSpinnersShown,
activityTheme.theme);
ActivityTestRule<DatePickerInFragmentActivity> rule = new ActivityTestRule<>(clazz, false);
String fileName = String.format("%s_%s_%s_%s_%s_%s_%s.png",
clazz.getSimpleName(),
datePickerMode.name(),
"isCalendarViewShown",
isCalendarViewShown,
"isSpinnersShown",
isSpinnersShown,
activityTheme.name());
Log.d(clazz.getSimpleName(), fileName);
rule.launchActivity(intent);
takeScreenshot(rule.getActivity(), fileName);
}
}
}
}
}
示例6: launchDatePickerInAppCompatActivity
import android.support.test.rule.ActivityTestRule; //導入方法依賴的package包/類
private void launchDatePickerInAppCompatActivity(List<ActivityTheme> activityThemeList, final Class<DatePickerInAppCompatActivity> clazz){
for(DatePickerMode datePickerMode : DatePickerMode.values()){
for(int i = 0; i < 2; i++){
boolean isCalendarViewShown = i == 0;
for(int j = 0; j < 2; j++){
boolean isSpinnersShown = j == 0;
for(ActivityTheme activityTheme : activityThemeList){
if(datePickerMode == DatePickerMode.Calendar && activityTheme == ActivityTheme.Theme_Black){
continue;
}
final Intent intent = MainActivity.createIntent(activityTestRule.getActivity(),
clazz,
datePickerMode.layout,
isCalendarViewShown,
isSpinnersShown,
activityTheme.theme);
ActivityTestRule<DatePickerInAppCompatActivity> rule = new ActivityTestRule<>(clazz, false);
String fileName = String.format("%s_%s_%s_%s_%s_%s_%s.png",
clazz.getSimpleName(),
datePickerMode.name(),
"isCalendarViewShown",
isCalendarViewShown,
"isSpinnersShown",
isSpinnersShown,
activityTheme.name());
Log.d(clazz.getSimpleName(), fileName);
rule.launchActivity(intent);
takeScreenshot(rule.getActivity(), fileName);
}
}
}
}
}
示例7: launchActivity
import android.support.test.rule.ActivityTestRule; //導入方法依賴的package包/類
protected void launchActivity(final ActivityTestRule activityTestRule, final Bundle extras) {
final Intent intent = new Intent();
intent.putExtras(extras);
activityTestRule.launchActivity(intent);
}
示例8: AzureADSignIn
import android.support.test.rule.ActivityTestRule; //導入方法依賴的package包/類
public static void AzureADSignIn(String username, String password, ActivityTestRule<SignInActivity> signInActivityTestRule) throws InterruptedException {
SignInActivity signInActivity = signInActivityTestRule.launchActivity(null);
onView(withId(R.id.o365_signin)).perform(click());
try {
onWebView()
.withElement(findElement(Locator.ID, USER_ID_TEXT_ELEMENT))
.perform(clearElement())
// Enter text into the input element
.perform(DriverAtoms.webKeys(username))
// Set focus on the username input text
// The form validates the username when this field loses focus
.perform(webClick())
.withElement(findElement(Locator.ID, PASSWORD_TEXT_ELEMENT))
// Now we force focus on this element to make
// the username element to lose focus and validate
.perform(webClick())
.perform(clearElement())
// Enter text into the input element
.perform(DriverAtoms.webKeys(password));
Thread.sleep(2000, 0);
onWebView()
.withElement(findElement(Locator.ID, SIGN_IN_BUTTON_ELEMENT))
.perform(webClick());
} catch (NoMatchingViewException ex) {
// If user is already logged in, the flow will go directly to SnippetListActivity
} finally {
Thread.sleep(2000, 0);
}
// Finally, verify that SnippetListActivity is on top
intended(allOf(
hasComponent(hasShortClassName(".SnippetListActivity")),
toPackage("com.microsoft.graph.snippets")
));
signInActivity.finish();
}
示例9: launchPopularMovies
import android.support.test.rule.ActivityTestRule; //導入方法依賴的package包/類
public PopularMoviesRobot launchPopularMovies(ActivityTestRule<PopularMoviesActivity> rule) {
rule.launchActivity(null);
return this;
}
示例10: launchDetailsScreen
import android.support.test.rule.ActivityTestRule; //導入方法依賴的package包/類
public PosterDetailsRobot launchDetailsScreen(long movieId, ActivityTestRule<MovieDetailsActivity> testRule) {
testRule.launchActivity(MovieDetailsActivity.createIntentFor(movieId, InstrumentationRegistry.getInstrumentation()
.getTargetContext()
.getApplicationContext()));
return new PosterDetailsRobot();
}
示例11: getItemsCount
import android.support.test.rule.ActivityTestRule; //導入方法依賴的package包/類
private int getItemsCount(ActivityTestRule<SnippetListActivity> snippetListActivityRule){
SnippetListActivity snippetListActivity = snippetListActivityRule.launchActivity(null);
ListAdapter listAdapter = getListAdapter(snippetListActivity);
int numItems = listAdapter.getCount();
snippetListActivity.finish();
return numItems;
}