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

Commit 449c7772 authored by Hugo Hudson's avatar Hugo Hudson Committed by Android (Google) Code Review
Browse files

Merge "Fixing up the tests."

parents 0680020c e86b753c
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.contacts;


import com.android.contacts.model.AccountTypeManager;
import com.android.contacts.model.AccountTypeManager;
import com.android.contacts.model.AccountWithDataSet;
import com.android.contacts.model.AccountWithDataSet;
import com.android.contacts.test.NeededForTesting;
import com.android.i18n.phonenumbers.PhoneNumberUtil;
import com.android.i18n.phonenumbers.PhoneNumberUtil;


import android.content.Context;
import android.content.Context;
@@ -91,6 +92,7 @@ public class ContactsUtils {
    /**
    /**
     * Returns true if two objects are considered equal.  Two null references are equal here.
     * Returns true if two objects are considered equal.  Two null references are equal here.
     */
     */
    @NeededForTesting
    public static boolean areObjectsEqual(Object a, Object b) {
    public static boolean areObjectsEqual(Object a, Object b) {
        return a == b || (a != null && a.equals(b));
        return a == b || (a != null && a.equals(b));
    }
    }
+0 −7
Original line number Original line Diff line number Diff line
@@ -20,9 +20,6 @@ import com.android.contacts.widget.TextWithHighlighting;
import com.android.contacts.widget.TextWithHighlightingFactory;
import com.android.contacts.widget.TextWithHighlightingFactory;


import android.database.CharArrayBuffer;
import android.database.CharArrayBuffer;
import android.graphics.Typeface;
import android.provider.ContactsContract;
import android.text.Spannable;
import android.widget.TextView;
import android.widget.TextView;


/**
/**
@@ -50,10 +47,6 @@ public final class DisplayNameFormatter {
        return mAlternateNameBuffer;
        return mAlternateNameBuffer;
    }
    }


    public void setTextWithHighlightingFactory(TextWithHighlightingFactory factory) {
        mTextWithHighlightingFactory = factory;
    }

    public void setUnknownNameText(CharSequence unknownNameText) {
    public void setUnknownNameText(CharSequence unknownNameText) {
        mUnknownNameText = unknownNameText;
        mUnknownNameText = unknownNameText;
    }
    }
+0 −5
Original line number Original line Diff line number Diff line
@@ -21,7 +21,6 @@ import com.android.contacts.ContactStatusUtil;
import com.android.contacts.R;
import com.android.contacts.R;
import com.android.contacts.format.DisplayNameFormatter;
import com.android.contacts.format.DisplayNameFormatter;
import com.android.contacts.format.PrefixHighlighter;
import com.android.contacts.format.PrefixHighlighter;
import com.android.contacts.widget.TextWithHighlightingFactory;


import android.content.Context;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.ColorStateList;
@@ -279,10 +278,6 @@ public class ContactListItemView extends ViewGroup
        mCallButtonClickListener = callButtonClickListener;
        mCallButtonClickListener = callButtonClickListener;
    }
    }


    public void setTextWithHighlightingFactory(TextWithHighlightingFactory factory) {
        mDisplayNameFormatter.setTextWithHighlightingFactory(factory);
    }

    public void setUnknownNameText(CharSequence unknownNameText) {
    public void setUnknownNameText(CharSequence unknownNameText) {
        mDisplayNameFormatter.setUnknownNameText(unknownNameText);
        mDisplayNameFormatter.setUnknownNameText(unknownNameText);
    }
    }
+0 −14
Original line number Original line Diff line number Diff line
@@ -125,20 +125,6 @@ public class DisplayNameFormatterTest extends AndroidTestCase {
        SpannedTestUtils.checkHtmlText("unknown", mView);
        SpannedTestUtils.checkHtmlText("unknown", mView);
    }
    }


    public void testSetDisplayName_Highlighting() {
        mDisplayNameFormatter.setTextWithHighlightingFactory(new TestTextWithHighlightingFactory());
        setNames("John Doe", "Sue Anne");
        setDisplayNameWithHighlighting();
        SpannedTestUtils.checkHtmlText("<i>John Doe</i> <i>Sue Anne</i>", mView);
    }

    public void testSetDisplayName_HighlightingAndBoldFirstName() {
        mDisplayNameFormatter.setTextWithHighlightingFactory(new TestTextWithHighlightingFactory());
        setNames("John Doe", "Doe John");
        setDisplayNameWithHighlighting();
        SpannedTestUtils.checkHtmlText("<i>John Doe</i> <i>Doe John</i>", mView);
    }

    /**
    /**
     * Sets the name and alternate name on the formatter.
     * Sets the name and alternate name on the formatter.
     *
     *
+1 −14
Original line number Original line Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.contacts.list;


import com.android.contacts.activities.PeopleActivity;
import com.android.contacts.activities.PeopleActivity;
import com.android.contacts.format.SpannedTestUtils;
import com.android.contacts.format.SpannedTestUtils;
import com.android.contacts.format.TestTextWithHighlightingFactory;
import com.android.contacts.util.IntegrationTestUtils;
import com.android.contacts.util.IntegrationTestUtils;


import android.database.Cursor;
import android.database.Cursor;
@@ -37,7 +36,7 @@ import android.widget.TextView;
@LargeTest
@LargeTest
public class ContactListItemViewTest extends ActivityInstrumentationTestCase2<PeopleActivity> {
public class ContactListItemViewTest extends ActivityInstrumentationTestCase2<PeopleActivity> {
    /** The HTML code used to mark the start of the highlighted part. */
    /** The HTML code used to mark the start of the highlighted part. */
    private static final String START = "<font color =\"#729a27\">";
    private static final String START = "<font color =\"#99cc00\">";
    /** The HTML code used to mark the end of the highlighted part. */
    /** The HTML code used to mark the end of the highlighted part. */
    private static final String END = "</font>";
    private static final String END = "</font>";


@@ -106,18 +105,6 @@ public class ContactListItemViewTest extends ActivityInstrumentationTestCase2<Pe
                view.getNameTextView());
                view.getNameTextView());
    }
    }


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

        view.setTextWithHighlightingFactory(new TestTextWithHighlightingFactory());
        view.showDisplayName(cursor, 0, 1, true,
                ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY);

        SpannedTestUtils.checkHtmlText("<i>John Doe</i> <i>Doe John</i>",
                view.getNameTextView());
    }

    public void testSetSnippet_Prefix() {
    public void testSetSnippet_Prefix() {
        ContactListItemView view = createView();
        ContactListItemView view = createView();
        view.setHighlightedPrefix("TEST".toCharArray());
        view.setHighlightedPrefix("TEST".toCharArray());