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

Commit f93b2a4e authored by kai's avatar kai
Browse files

Bluetooth Unit Test

use Mockito to mock Adapterservice and adjust time zone

Bug: 64694242
Test: 1 runtest bluetooth
Change-Id: Ie1c1d47df2d3862eb63c660f6e2cd12afa97e724
Merged-In: I4c4627bf28450254726472908527a7cb27738cea
(cherry picked from commit 4c311930)
parent 6436b202
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ public class HeadsetClientServiceTest extends AndroidTestCase {
        assertTrue(mService != null);

        // At this point Adapter Service should have started
        AdapterService inst = AdapterService.getAdapterService();
        AdapterService inst = mock(AdapterService.class);
        assertTrue(inst != null);

        // Try getting the Bluetooth adapter
+2 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ import java.util.ArrayList;
import com.android.bluetooth.btservice.AdapterService;

import static org.mockito.Mockito.*;

import org.mockito.ArgumentCaptor;

public class HeadsetClientStateMachineTest extends AndroidTestCase {
@@ -25,7 +26,7 @@ public class HeadsetClientStateMachineTest extends AndroidTestCase {

    @Override
    protected void setUp() throws Exception {
        AdapterService inst = AdapterService.getAdapterService();
        AdapterService inst = mock(AdapterService.class);
        assertTrue(inst != null);
        mAdapter = BluetoothAdapter.getDefaultAdapter();
    }
+8 −7
Original line number Diff line number Diff line
@@ -81,11 +81,11 @@ public class PbapParserTest extends AndroidTestCase {
        processor.setResults(pbapVCardList.getList());

        // Verify that these entries aren't in the call log to start.
        assertFalse(verifyCallLog("555-0002", "1483232460000", "3"));

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

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

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

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

    // Find Entries in call log with type matching number and date.