Search in sources :

Example 11 with OperationInfo

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

the class AsyncQueryService method startDelete.

/**
     * This method begins an asynchronous delete. When the delete operation is
     * done {@link #onDeleteComplete} is called.
     *
     * @param token A token passed into {@link #onDeleteComplete} to identify
     *            the delete operation.
     * @param cookie An object that gets passed into {@link #onDeleteComplete}
     * @param uri the Uri passed to the delete operation.
     * @param selection A filter declaring which rows to delete, formatted as an
     *            SQL WHERE clause (excluding the WHERE itself). Passing null
     *            will delete all rows for the given URI.
     * @param selectionArgs You may include ?s in selection, which will be
     *            replaced by the values from selectionArgs, in the order that
     *            they appear in the selection. The values will be bound as
     *            Strings.
     * @param delayMillis delay in executing the operation. This operation will
     *            execute before the delayed time when another operation is
     *            added. Useful for implementing single level undo.
     */
public void startDelete(int token, Object cookie, Uri uri, String selection, String[] selectionArgs, long delayMillis) {
    OperationInfo info = new OperationInfo();
    info.op = Operation.EVENT_ARG_DELETE;
    info.resolver = mContext.getContentResolver();
    info.handler = mHandler;
    info.token = token;
    info.cookie = cookie;
    info.uri = uri;
    info.selection = selection;
    info.selectionArgs = selectionArgs;
    info.delayMillis = delayMillis;
    AsyncQueryServiceHelper.queueOperation(mContext, info);
}
Also used : OperationInfo(com.android.calendar.AsyncQueryServiceHelper.OperationInfo)

Example 12 with OperationInfo

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

the class AsyncQueryServiceTest method generateWork.

private OperationInfo generateWork(long delayMillis) {
    OperationInfo work = new OperationInfo();
    work.op = Operation.EVENT_ARG_DELETE;
    work.token = ++mId;
    work.cookie = 100 + work.token;
    work.uri = Uri.parse(AUTHORITY_URI + "blah");
    work.selection = TEST_SELECTION;
    work.selectionArgs = TEST_SELECTION_ARGS;
    work.delayMillis = delayMillis;
    work.result = 1000 + work.token;
    return work;
}
Also used : OperationInfo(com.android.calendar.AsyncQueryServiceHelper.OperationInfo)

Example 13 with OperationInfo

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

the class AsyncQueryServiceTest method testCancel_simpleCancelLastTest.

@LargeTest
public void testCancel_simpleCancelLastTest() 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 toBeCancelled1 = work[index];
    OperationInfo[] expected = generateSortedWork(work, work.length - 1);
    TestAsyncQueryService aqs = new TestAsyncQueryService(buildTestContext(expected), expected);
    startWork(aqs, work);
    Operation lastOne = aqs.getLastCancelableOperation();
    // Log.d(TAG, "lastOne = " + lastOne.toString());
    // Log.d(TAG, "toBeCancelled1 = " + toBeCancelled1.toString());
    assertTrue("1) delay=3 is not last", toBeCancelled1.equivalent(lastOne));
    assertEquals("Can't cancel delay 3", 1, aqs.cancelOperation(lastOne.token));
    Log.d(TAG, "testCancel_simpleCancelLastTest Waiting >>>>>>>>>>>");
    assertEquals("Not all operations were executed.", expected.length, aqs.waitForCompletion(BASE_TEST_WAIT_TIME));
    Log.d(TAG, "testCancel_simpleCancelLastTest 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)

Example 14 with OperationInfo

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

the class AsyncQueryServiceTest method testUpdate.

@SmallTest
public void testUpdate() throws Exception {
    int index = 0;
    final OperationInfo[] work = new OperationInfo[1];
    work[index] = new OperationInfo();
    work[index].op = Operation.EVENT_ARG_UPDATE;
    work[index].token = ++mId;
    work[index].cookie = ++mId;
    work[index].uri = Uri.parse(AUTHORITY_URI + ++mId);
    work[index].values = new ContentValues();
    work[index].values.put("key", ++mId);
    work[index].selection = TEST_SELECTION;
    work[index].selectionArgs = TEST_SELECTION_ARGS;
    work[index].delayMillis = 0;
    work[index].result = ++mId;
    TestAsyncQueryService aqs = new TestAsyncQueryService(buildTestContext(work), work);
    aqs.startUpdate(work[index].token, work[index].cookie, work[index].uri, work[index].values, work[index].selection, work[index].selectionArgs, work[index].delayMillis);
    Log.d(TAG, "testUpdate Waiting >>>>>>>>>>>");
    assertEquals("Not all operations were executed.", work.length, aqs.waitForCompletion(BASE_TEST_WAIT_TIME));
    Log.d(TAG, "testUpdate Done <<<<<<<<<<<<<<");
}
Also used : OperationInfo(com.android.calendar.AsyncQueryServiceHelper.OperationInfo) ContentValues(android.content.ContentValues) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 15 with OperationInfo

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

the class AsyncQueryServiceTest method testQuery.

@Smoke
@SmallTest
public void testQuery() throws Exception {
    int index = 0;
    final OperationInfo[] work = new OperationInfo[1];
    work[index] = new OperationInfo();
    work[index].op = Operation.EVENT_ARG_QUERY;
    work[index].token = ++mId;
    work[index].cookie = ++mId;
    work[index].uri = Uri.parse(AUTHORITY_URI + "blah");
    work[index].projection = TEST_PROJECTION;
    work[index].selection = TEST_SELECTION;
    work[index].selectionArgs = TEST_SELECTION_ARGS;
    work[index].orderBy = "order";
    work[index].delayMillis = 0;
    work[index].result = new TestCursor();
    TestAsyncQueryService aqs = new TestAsyncQueryService(buildTestContext(work), work);
    aqs.startQuery(work[index].token, work[index].cookie, work[index].uri, work[index].projection, work[index].selection, work[index].selectionArgs, work[index].orderBy);
    Log.d(TAG, "testQuery Waiting >>>>>>>>>>>");
    assertEquals("Not all operations were executed.", work.length, aqs.waitForCompletion(BASE_TEST_WAIT_TIME));
    Log.d(TAG, "testQuery Done <<<<<<<<<<<<<<");
}
Also used : OperationInfo(com.android.calendar.AsyncQueryServiceHelper.OperationInfo) SmallTest(android.test.suitebuilder.annotation.SmallTest) Smoke(android.test.suitebuilder.annotation.Smoke)

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