Search in sources :

Example 16 with OperationInfo

use of com.android.calendar.AsyncQueryServiceHelper.OperationInfo in project Etar-Calendar by Etar-Group.

the class AsyncQueryServiceTest method testCancel_multipleCancels.

@LargeTest
public void testCancel_multipleCancels() throws Exception {
    int index = 0;
    OperationInfo[] work = new OperationInfo[5];
    work[index++] = generateWork(MIN_DELAY * 2);
    work[index++] = generateWork(0);
    work[index++] = generateWork(MIN_DELAY);
    work[index++] = generateWork(0);
    work[index] = generateWork(MIN_DELAY * 3);
    // Not part of the expected as it will be canceled
    OperationInfo[] expected = new OperationInfo[3];
    // delay = 0
    expected[0] = work[1];
    // delay = 0
    expected[1] = work[3];
    // delay = MIN_DELAY
    expected[2] = work[2];
    TestAsyncQueryService aqs = new TestAsyncQueryService(buildTestContext(expected), expected);
    startWork(aqs, work);
    // delay = 3
    Operation lastOne = aqs.getLastCancelableOperation();
    assertTrue("3) delay=3 is not last", work[4].equivalent(lastOne));
    assertEquals("Can't cancel delay 2", 1, aqs.cancelOperation(work[0].token));
    assertEquals("Delay 2 should be gone", 0, aqs.cancelOperation(work[0].token));
    assertEquals("Can't cancel delay 3", 1, aqs.cancelOperation(work[4].token));
    assertEquals("Delay 3 should be gone", 0, aqs.cancelOperation(work[4].token));
    Log.d(TAG, "testCancel_multipleCancels Waiting >>>>>>>>>>>");
    assertEquals("Not all operations were executed.", expected.length, aqs.waitForCompletion(BASE_TEST_WAIT_TIME));
    Log.d(TAG, "testCancel_multipleCancels Done <<<<<<<<<<<<<<");
}
Also used : OperationInfo(com.android.calendar.AsyncQueryServiceHelper.OperationInfo) ContentProviderOperation(android.content.ContentProviderOperation) Operation(com.android.calendar.AsyncQueryService.Operation) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Aggregations

OperationInfo (com.android.calendar.AsyncQueryServiceHelper.OperationInfo)16 SmallTest (android.test.suitebuilder.annotation.SmallTest)5 ContentProviderOperation (android.content.ContentProviderOperation)4 LargeTest (android.test.suitebuilder.annotation.LargeTest)3 Operation (com.android.calendar.AsyncQueryService.Operation)3 ContentProviderResult (android.content.ContentProviderResult)2 ContentValues (android.content.ContentValues)2 Smoke (android.test.suitebuilder.annotation.Smoke)1