Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 348bdb87 authored by Kai Wang's avatar Kai Wang Committed by Gerrit Code Review
Browse files

Merge "Bluetooth PbapParserTest"

parents 3d34c439 a43ccfaa
Loading
Loading
Loading
Loading
+17 −8
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@ import android.test.AndroidTestCase;


import java.io.IOException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStream;
import java.util.TimeZone;


import org.junit.Before;
import org.junit.Before;
import org.junit.Test;
import org.junit.Test;
@@ -81,11 +82,10 @@ public class PbapParserTest extends AndroidTestCase {
        processor.setResults(pbapVCardList.getList());
        processor.setResults(pbapVCardList.getList());


        // Verify that these entries aren't in the call log to start.
        // Verify that these entries aren't in the call log to start.
        // EST is default Time Zone
        assertFalse(verifyCallLog("555-0002", "1483232460000", "3"));
        assertFalse(verifyCallLog("555-0002", "1483250460000", "3"));
        // Finish processing the data and verify entries were added to the call log.
        // Finish processing the data and verify entries were added to the call log.
        processor.onPullComplete();
        processor.onPullComplete();
        assertTrue(verifyCallLog("555-0002", "1483250460000", "3"));
        assertTrue(verifyCallLog("555-0002", "1483232460000", "3"));
    }
    }


    // testUnknownCall should parse two calls with no phone number.
    // testUnknownCall should parse two calls with no phone number.
@@ -102,14 +102,13 @@ public class PbapParserTest extends AndroidTestCase {
        processor.setResults(pbapVCardList.getList());
        processor.setResults(pbapVCardList.getList());


        // Verify that these entries aren't in the call log to start.
        // Verify that these entries aren't in the call log to start.
        // EST is default Time Zone
        assertFalse(verifyCallLog("", "1483232520000", "3"));
        assertFalse(verifyCallLog("", "1483250520000", "3"));
        assertFalse(verifyCallLog("", "1483232580000", "3"));
        assertFalse(verifyCallLog("", "1483250580000", "3"));


        // Finish processing the data and verify entries were added to the call log.
        // Finish processing the data and verify entries were added to the call log.
        processor.onPullComplete();
        processor.onPullComplete();
        assertTrue(verifyCallLog("", "1483250520000", "3"));
        assertTrue(verifyCallLog("", "1483232520000", "3"));
        assertTrue(verifyCallLog("", "1483250580000", "3"));
        assertTrue(verifyCallLog("", "1483232580000", "3"));
    }
    }


    // Find Entries in call log with type matching number and date.
    // Find Entries in call log with type matching number and date.
@@ -118,6 +117,9 @@ public class PbapParserTest extends AndroidTestCase {
        String[] query = new String[] {Calls.NUMBER, Calls.DATE, Calls.TYPE};
        String[] query = new String[] {Calls.NUMBER, Calls.DATE, Calls.TYPE};
        Cursor cursor = mContext.getContentResolver().query(Calls.CONTENT_URI, query,
        Cursor cursor = mContext.getContentResolver().query(Calls.CONTENT_URI, query,
                Calls.TYPE + "= " + type, null, Calls.DATE + ", " + Calls.NUMBER);
                Calls.TYPE + "= " + type, null, Calls.DATE + ", " + Calls.NUMBER);
        if (date != null) {
            date = adjDate(date);
        }
        if (cursor != null) {
        if (cursor != null) {
            while (cursor.moveToNext()) {
            while (cursor.moveToNext()) {
                String foundNumber = cursor.getString(cursor.getColumnIndex(Calls.NUMBER));
                String foundNumber = cursor.getString(cursor.getColumnIndex(Calls.NUMBER));
@@ -131,4 +133,11 @@ public class PbapParserTest extends AndroidTestCase {
        }
        }
        return false;
        return false;
    }
    }

    // Get time zone from device and adjust date to the device's time zone.
    String adjDate(String date) {
        TimeZone tz = TimeZone.getDefault();
        long dt = Long.valueOf(date) - tz.getRawOffset();
        return Long.toString(dt);
    }
}
}