Search in sources :

Example 31 with FlakyTest

use of android.test.FlakyTest in project AntennaPod by AntennaPod.

the class DBCleanupTests method testPerformAutoCleanupShouldNotDeleteBecauseInQueue_withFeedsWithNoMedia.

/**
     * Reproduces a bug where DBTasks.performAutoCleanup(android.content.Context) would use the ID of the FeedItem in the
     * call to DBWriter.deleteFeedMediaOfItem instead of the ID of the FeedMedia. This would cause the wrong item to be deleted.
     * @throws IOException
     */
@FlakyTest(tolerance = 3)
public void testPerformAutoCleanupShouldNotDeleteBecauseInQueue_withFeedsWithNoMedia() throws IOException {
    // add feed with no enclosures so that item ID != media ID
    saveFeedlist(1, 10, false);
    // add candidate for performAutoCleanup
    List<Feed> feeds = saveFeedlist(1, 1, true);
    FeedMedia m = feeds.get(0).getItems().get(0).getMedia();
    m.setDownloaded(true);
    m.setFile_url("file");
    PodDBAdapter adapter = PodDBAdapter.getInstance();
    adapter.open();
    adapter.setMedia(m);
    adapter.close();
    testPerformAutoCleanupShouldNotDeleteBecauseInQueue();
}
Also used : PodDBAdapter(de.danoeh.antennapod.core.storage.PodDBAdapter) FeedMedia(de.danoeh.antennapod.core.feed.FeedMedia) Feed(de.danoeh.antennapod.core.feed.Feed) FlakyTest(android.test.FlakyTest)

Example 32 with FlakyTest

use of android.test.FlakyTest in project android_frameworks_base by crdroidandroid.

the class AutoCompleteTextViewCallbacks method testPopupLeaveSelection.

/** Test that arrow-up out of the popup calls the onNothingSelected callback */
@FlakyTest(tolerance = 3)
public void testPopupLeaveSelection() {
    final AutoCompleteTextViewSimple theActivity = getActivity();
    AutoCompleteTextView textView = theActivity.getTextView();
    final Instrumentation instrumentation = getInstrumentation();
    // focus and type
    textView.requestFocus();
    instrumentation.waitForIdleSync();
    sendKeys("A");
    instrumentation.waitForIdleSync();
    // move down into the popup
    sendKeys("DPAD_DOWN");
    instrumentation.waitForIdleSync();
    textView.post(new Runnable() {

        public void run() {
            // prepare to move down into the popup
            theActivity.resetItemListeners();
        }
    });
    sendKeys("DPAD_UP");
    instrumentation.waitForIdleSync();
    // now check for selection callbacks.
    assertFalse("onItemClick should not be called", theActivity.mItemClickCalled);
    assertFalse("onItemSelected should not be called", theActivity.mItemSelectedCalled);
    assertTrue("onNothingSelected should be called", theActivity.mNothingSelectedCalled);
}
Also used : Instrumentation(android.app.Instrumentation) FlakyTest(android.test.FlakyTest)

Example 33 with FlakyTest

use of android.test.FlakyTest in project android_frameworks_base by crdroidandroid.

the class AutoCompleteTextViewCallbacks method testPopupEnterSelection.

/** Test that arrow-down into the popup calls the onSelected callback. */
@FlakyTest(tolerance = 3)
public void testPopupEnterSelection() throws Exception {
    final AutoCompleteTextViewSimple theActivity = getActivity();
    AutoCompleteTextView textView = theActivity.getTextView();
    final Instrumentation instrumentation = getInstrumentation();
    // focus and type
    textView.requestFocus();
    instrumentation.waitForIdleSync();
    sendKeys("A");
    textView.post(new Runnable() {

        public void run() {
            // prepare to move down into the popup
            theActivity.resetItemListeners();
        }
    });
    sendKeys("DPAD_DOWN");
    instrumentation.waitForIdleSync();
    // give UI time to settle
    Thread.sleep(WAIT_TIME);
    // now check for selection callbacks.
    assertFalse("onItemClick should not be called", theActivity.mItemClickCalled);
    assertTrue("onItemSelected should be called", theActivity.mItemSelectedCalled);
    assertEquals("onItemSelected position", 0, theActivity.mItemSelectedPosition);
    assertFalse("onNothingSelected should not be called", theActivity.mNothingSelectedCalled);
    textView.post(new Runnable() {

        public void run() {
            // try one more time - should move from 0 to 1
            theActivity.resetItemListeners();
        }
    });
    sendKeys("DPAD_DOWN");
    instrumentation.waitForIdleSync();
    // give UI time to settle
    Thread.sleep(WAIT_TIME);
    // now check for selection callbacks.
    assertFalse("onItemClick should not be called", theActivity.mItemClickCalled);
    assertTrue("onItemSelected should be called", theActivity.mItemSelectedCalled);
    assertEquals("onItemSelected position", 1, theActivity.mItemSelectedPosition);
    assertFalse("onNothingSelected should not be called", theActivity.mNothingSelectedCalled);
}
Also used : Instrumentation(android.app.Instrumentation) FlakyTest(android.test.FlakyTest)

Example 34 with FlakyTest

use of android.test.FlakyTest in project android_frameworks_base by crdroidandroid.

the class AutoCompleteTextViewPopup method testPopupGetListSelection.

/** Test that we can look at the selection as we move around */
@FlakyTest(tolerance = 3)
public void testPopupGetListSelection() throws Throwable {
    AutoCompleteTextViewSimple theActivity = getActivity();
    final AutoCompleteTextView textView = theActivity.getTextView();
    final Instrumentation instrumentation = getInstrumentation();
    // focus and type
    textView.requestFocus();
    instrumentation.waitForIdleSync();
    sendKeys("A");
    // No initial selection
    waitAssertListSelection(textView, ListView.INVALID_POSITION);
    // check for selection position as expected
    sendKeys("DPAD_DOWN");
    waitAssertListSelection("move selection to (0)", textView, 0);
    // Repeat for one more movement
    sendKeys("DPAD_DOWN");
    waitAssertListSelection("move selection to (1)", textView, 1);
    // TODO: FlakyTest repeat runs will not currently call setUp, clear state
    clearText(textView);
}
Also used : Instrumentation(android.app.Instrumentation) FlakyTest(android.test.FlakyTest)

Example 35 with FlakyTest

use of android.test.FlakyTest in project android_frameworks_base by crdroidandroid.

the class BroadcastTest method testReceiveSticky.

// Marking flaky until http://b/issue?id=1191337 is resolved
@FlakyTest(tolerance = 2)
public void testReceiveSticky() throws Exception {
    Intent intent = new Intent(LaunchpadActivity.BROADCAST_STICKY1, null);
    intent.putExtra("test", LaunchpadActivity.DATA_1);
    ActivityManagerNative.broadcastStickyIntent(intent, null, UserHandle.myUserId());
    runLaunchpad(LaunchpadActivity.BROADCAST_STICKY1);
}
Also used : Intent(android.content.Intent) FlakyTest(android.test.FlakyTest)

Aggregations

FlakyTest (android.test.FlakyTest)78 Instrumentation (android.app.Instrumentation)49 Intent (android.content.Intent)13 FeedItem (de.danoeh.antennapod.core.feed.FeedItem)11 Feed (de.danoeh.antennapod.core.feed.Feed)9 ArrayList (java.util.ArrayList)7 File (java.io.File)6 LargeTest (android.test.suitebuilder.annotation.LargeTest)3 UiObject (com.android.uiautomator.core.UiObject)2 UiSelector (com.android.uiautomator.core.UiSelector)2 FeedMedia (de.danoeh.antennapod.core.feed.FeedMedia)2 PlayerStatus (de.danoeh.antennapod.core.service.playback.PlayerStatus)2 PodDBAdapter (de.danoeh.antennapod.core.storage.PodDBAdapter)2 Date (java.util.Date)2 Uri (android.net.Uri)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 AppLink (bolts.AppLink)1 FacebookAppLinkResolver (com.facebook.applinks.FacebookAppLinkResolver)1 SdkSuppress (com.google.android.apps.common.testing.testrunner.annotations.SdkSuppress)1