FileDocCategorySizeDatePackage
ExportTestProvider.javaAPI DocAndroid 5.1 API5929Thu Mar 12 22:22:54 GMT 2015com.android.vcard.tests.testutils

ExportTestProvider

public class ExportTestProvider extends android.test.mock.MockContentProvider

Fields Summary
private final ArrayList
mContactEntryList
Constructors Summary
public ExportTestProvider(android.test.AndroidTestCase androidTestCase)

    
Methods Summary
public ContactEntrybuildInputEntry()

        ContactEntry contactEntry = new ContactEntry();
        mContactEntryList.add(contactEntry);
        return contactEntry;
    
public android.database.Cursorquery(android.net.Uri uri, java.lang.String[] projection, java.lang.String selection, java.lang.String[] selectionArgs, java.lang.String sortOrder)

        TestCase.assertTrue(VCardVerifier.CONTACTS_TEST_CONTENT_URI.equals(uri));
        // In this test, following arguments are not supported.
        TestCase.assertNull(selection);
        TestCase.assertNull(selectionArgs);
        TestCase.assertNull(sortOrder);

        return new MockCursor() {
            int mCurrentPosition = -1;

            @Override
            public int getCount() {
                return mContactEntryList.size();
            }

            @Override
            public boolean moveToFirst() {
                mCurrentPosition = 0;
                return true;
            }

            @Override
            public boolean moveToNext() {
                if (mCurrentPosition < mContactEntryList.size()) {
                    mCurrentPosition++;
                    return true;
                } else {
                    return false;
                }
            }

            @Override
            public boolean isBeforeFirst() {
                return mCurrentPosition < 0;
            }

            @Override
            public boolean isAfterLast() {
                return mCurrentPosition >= mContactEntryList.size();
            }

            @Override
            public int getColumnIndex(String columnName) {
                TestCase.assertEquals(Contacts._ID, columnName);
                return 0;
            }

            @Override
            public int getInt(int columnIndex) {
                TestCase.assertEquals(0, columnIndex);
                TestCase.assertTrue(mCurrentPosition >= 0
                        && mCurrentPosition < mContactEntryList.size());
                return mCurrentPosition;
            }

            @Override
            public String getString(int columnIndex) {
                return String.valueOf(getInt(columnIndex));
            }

            @Override
            public void close() {
            }
        };
    
public android.content.EntityIteratorqueryEntities(android.net.Uri uri, java.lang.String selection, java.lang.String[] selectionArgs, java.lang.String sortOrder)

An old method which had existed but was removed from ContentResolver.

We still keep using this method since we don't have a propeer way to know which value in the ContentValue corresponds to the entry in Contacts database.

        TestCase.assertTrue(uri != null);
        TestCase.assertTrue(ContentResolver.SCHEME_CONTENT.equals(uri.getScheme()));
        final String authority = uri.getAuthority();
        TestCase.assertTrue(RawContacts.CONTENT_URI.getAuthority().equals(authority));
        TestCase.assertTrue((Data.CONTACT_ID + "=?").equals(selection));
        TestCase.assertEquals(1, selectionArgs.length);
        final int id = Integer.parseInt(selectionArgs[0]);
        TestCase.assertTrue(id >= 0);
        TestCase.assertTrue(id < mContactEntryList.size());

        return new MockEntityIterator(mContactEntryList.get(id).getList());