Tabnine Logo
Instrumentation$ActivityMonitor.waitForActivityWithTimeout
Code IndexAdd Tabnine to your IDE (free)

How to use
waitForActivityWithTimeout
method
in
android.app.Instrumentation$ActivityMonitor

Best Java code snippets using android.app.Instrumentation$ActivityMonitor.waitForActivityWithTimeout (Showing top 10 results out of 315)

origin: RobotiumTech/robotium

void monitorActivities() {
  if(activityMonitor != null){
    Activity activity = activityMonitor.waitForActivityWithTimeout(2000L);
    if(activity != null){
      if (activitiesStoredInActivityStack.remove(activity.toString())){
        removeActivityFromStack(activity);
      }
      if(!activity.isFinishing()){
        addActivityToStack(activity);
      }
    }
  }
}
origin: RobotiumTech/robotium

/**
 * Waits for the given {@link Activity}.
 *
 * @param activityClass the class of the {@code Activity} to wait for
 * @param timeout the amount of time in milliseconds to wait
 * @return {@code true} if {@code Activity} appears before the timeout and {@code false} if it does not
 *
 */
public boolean waitForActivity(Class<? extends Activity> activityClass, int timeout){
  if(isActivityMatching(activityClass, activityUtils.getCurrentActivity(false, false))){
    return true;
  }
  
  boolean foundActivity = false;
  ActivityMonitor activityMonitor = getActivityMonitor();
  long currentTime = SystemClock.uptimeMillis();
  final long endTime = currentTime + timeout;
  while(currentTime < endTime){
    Activity currentActivity = activityMonitor.waitForActivityWithTimeout(endTime - currentTime);
    
    if(currentActivity != null && currentActivity.getClass().equals(activityClass)) {
      foundActivity = true;
      break;
    }        
    currentTime = SystemClock.uptimeMillis();
  }
  removeMonitor(activityMonitor);
  return foundActivity;
}

origin: RobotiumTech/robotium

/**
 * Waits for the given {@link Activity}.
 *
 * @param name the name of the {@code Activity} to wait for e.g. {@code "MyActivity"}
 * @param timeout the amount of time in milliseconds to wait
 * @return {@code true} if {@code Activity} appears before the timeout and {@code false} if it does not
 *
 */
public boolean waitForActivity(String name, int timeout){
  if(isActivityMatching(activityUtils.getCurrentActivity(false, false), name)){
    return true;
  }
  
  boolean foundActivity = false;
  ActivityMonitor activityMonitor = getActivityMonitor();
  long currentTime = SystemClock.uptimeMillis();
  final long endTime = currentTime + timeout;
  while(currentTime < endTime){
    Activity currentActivity = activityMonitor.waitForActivityWithTimeout(endTime - currentTime);
    
    if(isActivityMatching(currentActivity, name)){
      foundActivity = true;
      break;
    }    
    currentTime = SystemClock.uptimeMillis();
  }
  removeMonitor(activityMonitor);
  return foundActivity;
}

origin: com.jayway.android.robotium/robotium-solo

/**
 * Waits for the given {@link Activity}.
 *
 * @param activityClass the class of the {@code Activity} to wait for
 * @param timeout the amount of time in milliseconds to wait
 * @return {@code true} if {@code Activity} appears before the timeout and {@code false} if it does not
 *
 */
public boolean waitForActivity(Class<? extends Activity> activityClass, int timeout){
  if(isActivityMatching(activityClass, activityUtils.getCurrentActivity(false, false))){
    return true;
  }
  
  boolean foundActivity = false;
  ActivityMonitor activityMonitor = getActivityMonitor();
  long currentTime = SystemClock.uptimeMillis();
  final long endTime = currentTime + timeout;
  while(currentTime < endTime){
    Activity currentActivity = activityMonitor.waitForActivityWithTimeout(endTime - currentTime);
    
    if(currentActivity != null && currentActivity.getClass().equals(activityClass)) {
      foundActivity = true;
      break;
    }        
    currentTime = SystemClock.uptimeMillis();
  }
  removeMonitor(activityMonitor);
  return foundActivity;
}

origin: com.jayway.android.robotium/robotium-solo

/**
 * Waits for the given {@link Activity}.
 *
 * @param name the name of the {@code Activity} to wait for e.g. {@code "MyActivity"}
 * @param timeout the amount of time in milliseconds to wait
 * @return {@code true} if {@code Activity} appears before the timeout and {@code false} if it does not
 *
 */
public boolean waitForActivity(String name, int timeout){
  if(isActivityMatching(activityUtils.getCurrentActivity(false, false), name)){
    return true;
  }
  
  boolean foundActivity = false;
  ActivityMonitor activityMonitor = getActivityMonitor();
  long currentTime = SystemClock.uptimeMillis();
  final long endTime = currentTime + timeout;
  while(currentTime < endTime){
    Activity currentActivity = activityMonitor.waitForActivityWithTimeout(endTime - currentTime);
    
    if(isActivityMatching(currentActivity, name)){
      foundActivity = true;
      break;
    }    
    currentTime = SystemClock.uptimeMillis();
  }
  removeMonitor(activityMonitor);
  return foundActivity;
}

origin: stackoverflow.com

 public void testKillCreateLifeCycle() throws Throwable {
  Instrumentation.ActivityMonitor mainActivityMonitor = new Instrumentation.ActivityMonitor(MainActivity.class.getName(), null, false);
  getInstrumentation().addMonitor(mainActivityMonitor);

  final Activity activity = getActivity();
  mainActivityMonitor.waitForActivityWithTimeout(5000);

  navigateToFragment(activity);

  runTestOnUiThread(new Runnable() {
    @Override
    public void run() {
      activity.recreate();
    }
  });
  getInstrumentation().waitForIdleSync();

  Activity newActivity = mainActivityMonitor.getLastActivity();
  assertFragmentIsVisible((FragmentActivity) newActivity, getExpectedFragment());
}
origin: stackoverflow.com

 private Instrumentation.ActivityMonitor mBrowserActivityMonitor;

protected void setUp() throws Exception {
  super.setUp();

  mBrowserActivityMonitor = new Instrumentation.ActivityMonitor(Browser.class.getName(), null, false);
  getInstrumentation().addMonitor(mBrowserActivityMonitor);
  //...
}


public void testOpen()
{
  //...

  Activity activity = mBrowserActivityMonitor.waitForActivityWithTimeout(5 * 1000);
  assertNotNull("Activity was not started", activity);

  //...

}
origin: stackoverflow.com

Instrumentation.ActivityMonitor monitor = getInstrumentation()
   .addMonitor(Instrumentation.ActivityMonitor.class.getName(),
   null, false);
 // Wait for activity to fix inject error; Increase or decrease as needed
 monitor.waitForActivityWithTimeout(2000);
 // Should no longer fail
 TouchUtils.clickView(this, someView);
origin: com.jayway.android.robotium/robotium-solo

void monitorActivities() {
  if(activityMonitor != null){
    Activity activity = activityMonitor.waitForActivityWithTimeout(2000L);
    if(activity != null){
      if (activitiesStoredInActivityStack.remove(activity.toString())){
        removeActivityFromStack(activity);
      }
      if(!activity.isFinishing()){
        addActivityToStack(activity);
      }
    }
  }
}
origin: cattaka/AdapterToolbox

@SuppressWarnings("unchecked")
public static <T extends Activity> T monitorActivity(@NonNull Class<T> activityClass, int timeOut, @NonNull Runnable runnable) {
  Instrumentation.ActivityMonitor monitor = new Instrumentation.ActivityMonitor(activityClass.getCanonicalName(), null, false);
  try {
    InstrumentationRegistry.getInstrumentation().addMonitor(monitor);
    runnable.run();
    return (T) monitor.waitForActivityWithTimeout(timeOut);
  } finally {
    InstrumentationRegistry.getInstrumentation().removeMonitor(monitor);
  }
}
android.appInstrumentation$ActivityMonitorwaitForActivityWithTimeout

Popular methods of Instrumentation$ActivityMonitor

  • getLastActivity
  • <init>
  • getHits
  • waitForActivity

Popular in Java

  • Reactive rest calls using spring rest template
  • notifyDataSetChanged (ArrayAdapter)
  • startActivity (Activity)
  • getSupportFragmentManager (FragmentActivity)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • String (java.lang)
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now