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

Commit cea3c914 authored by Flavio Lerda's avatar Flavio Lerda
Browse files

Fix tests that require the screen to be on.

Acquire the wake lock as the tests needs the screen to be on.
Previously the test blocked until I pressed the power button on the
device, unless the device was already on or set to keep the screen on
while plugged in.

Change-Id: I61ccbcc1b18bb954128c832b67efddd23dae5f08
parent e7d15fb4
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.contacts.list;
import com.android.contacts.activities.PeopleActivity;
import com.android.contacts.format.SpannedTestUtils;
import com.android.contacts.format.TestTextWithHighlightingFactory;
import com.android.contacts.util.IntegrationTestUtils;

import android.database.Cursor;
import android.database.MatrixCursor;
@@ -40,10 +41,26 @@ public class ContactListItemViewTest extends ActivityInstrumentationTestCase2<Pe
    /** The HTML code used to mark the end of the highlighted part. */
    private static final String END = "</font>";

    private IntegrationTestUtils mUtils;

    public ContactListItemViewTest() {
        super(PeopleActivity.class);
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        // This test requires that the screen be turned on.
        mUtils = new IntegrationTestUtils(getInstrumentation());
        mUtils.acquireScreenWakeLock(getInstrumentation().getTargetContext());
    }

    @Override
    protected void tearDown() throws Exception {
        mUtils.releaseScreenWakeLock();
        super.tearDown();
    }

    public void testShowDisplayName_Simple() {
        Cursor cursor = createCursor("John Doe", "Doe John");
        ContactListItemView view = createView();