summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/values/strings.xml5
-rw-r--r--src/com/android/dialer/PhoneCallDetailsHelper.java5
-rw-r--r--src/com/android/dialer/calllog/PhoneNumberDisplayHelper.java12
-rw-r--r--src/com/android/dialer/dialpad/DialpadFragment.java10
-rw-r--r--tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java8
-rw-r--r--tests/src/com/android/dialer/calllog/CallLogFragmentTest.java22
-rw-r--r--tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java5
-rw-r--r--tests/src/com/android/dialer/calllog/TestPhoneNumberUtilsWrapper.java2
-rw-r--r--tests/src/com/android/dialer/dialpad/DialpadFragmentTest.java6
-rw-r--r--tests/src/com/android/dialer/interactions/PhoneNumberInteractionTest.java25
10 files changed, 62 insertions, 38 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 33d552725..b04eddd8d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -456,8 +456,9 @@
<!-- String describing the icon used to start a voice search -->
<string name="description_start_voice_search">Start voice search</string>
- <!-- The string used to represent an unknown location for a phone number in the call log [CHAR LIMIT=3] -->
- <string name="call_log_empty_gecode">\u0020</string>
+ <!-- The string used to represent an unknown location for a phone number in the call log
+ Do not translate. -->
+ <string name="call_log_empty_geocode"></string>
<!-- Menu item used to call a contact, containing the number of the contact to call -->
<string name="menu_callNumber">Call <xliff:g id="number">%s</xliff:g></string>
diff --git a/src/com/android/dialer/PhoneCallDetailsHelper.java b/src/com/android/dialer/PhoneCallDetailsHelper.java
index af0a5257e..2a4a1425c 100644
--- a/src/com/android/dialer/PhoneCallDetailsHelper.java
+++ b/src/com/android/dialer/PhoneCallDetailsHelper.java
@@ -63,8 +63,8 @@ public class PhoneCallDetailsHelper {
PhoneNumberUtilsWrapper phoneUtils) {
mResources = resources;
mCallTypeHelper = callTypeHelper;
- mPhoneNumberHelper = new PhoneNumberDisplayHelper(resources);
mPhoneNumberUtilsWrapper = phoneUtils;
+ mPhoneNumberHelper = new PhoneNumberDisplayHelper(mPhoneNumberUtilsWrapper, resources);
}
/** Fills the call details views with content. */
@@ -122,7 +122,7 @@ public class PhoneCallDetailsHelper {
nameText = displayNumber;
if (TextUtils.isEmpty(details.geocode)
|| mPhoneNumberUtilsWrapper.isVoicemailNumber(details.number)) {
- numberText = mResources.getString(R.string.call_log_empty_gecode);
+ numberText = mResources.getString(R.string.call_log_empty_geocode);
} else {
numberText = details.geocode;
}
@@ -137,7 +137,6 @@ public class PhoneCallDetailsHelper {
}
views.nameView.setText(nameText);
-
views.labelView.setText(labelText);
views.labelView.setVisibility(TextUtils.isEmpty(labelText) ? View.GONE : View.VISIBLE);
}
diff --git a/src/com/android/dialer/calllog/PhoneNumberDisplayHelper.java b/src/com/android/dialer/calllog/PhoneNumberDisplayHelper.java
index 81f3ca1e5..5d7ce7ea9 100644
--- a/src/com/android/dialer/calllog/PhoneNumberDisplayHelper.java
+++ b/src/com/android/dialer/calllog/PhoneNumberDisplayHelper.java
@@ -18,8 +18,8 @@ package com.android.dialer.calllog;
import android.content.res.Resources;
import android.provider.CallLog.Calls;
-import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
+import android.util.Log;
import com.android.dialer.R;
@@ -27,10 +27,17 @@ import com.android.dialer.R;
* Helper for formatting and managing the display of phone numbers.
*/
public class PhoneNumberDisplayHelper {
+ private final PhoneNumberUtilsWrapper mPhoneNumberUtils;
private final Resources mResources;
public PhoneNumberDisplayHelper(Resources resources) {
mResources = resources;
+ mPhoneNumberUtils = new PhoneNumberUtilsWrapper();
+ }
+
+ public PhoneNumberDisplayHelper(PhoneNumberUtilsWrapper phoneNumberUtils, Resources resources) {
+ mPhoneNumberUtils = phoneNumberUtils;
+ mResources = resources;
}
/* package */ CharSequence getDisplayName(CharSequence number, int presentation) {
@@ -43,7 +50,7 @@ public class PhoneNumberDisplayHelper {
if (presentation == Calls.PRESENTATION_PAYPHONE) {
return mResources.getString(R.string.payphone);
}
- if (new PhoneNumberUtilsWrapper().isVoicemailNumber(number)) {
+ if (mPhoneNumberUtils.isVoicemailNumber(number)) {
return mResources.getString(R.string.voicemail);
}
if (PhoneNumberUtilsWrapper.isLegacyUnknownNumbers(number)) {
@@ -62,7 +69,6 @@ public class PhoneNumberDisplayHelper {
int presentation, CharSequence formattedNumber) {
final CharSequence displayName = getDisplayName(number, presentation);
-
if (!TextUtils.isEmpty(displayName)) {
return displayName;
}
diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java
index 72214dc1c..91f2bda76 100644
--- a/src/com/android/dialer/dialpad/DialpadFragment.java
+++ b/src/com/android/dialer/dialpad/DialpadFragment.java
@@ -1558,9 +1558,9 @@ public class DialpadFragment extends Fragment
* or Wait character (;).
*/
private void updateDialString(char newDigit) {
- if(newDigit != WAIT && newDigit != PAUSE) {
- Log.wtf(TAG, "Not expected for anything other than PAUSE & WAIT");
- return;
+ if (newDigit != WAIT && newDigit != PAUSE) {
+ throw new IllegalArgumentException(
+ "Not expected for anything other than PAUSE & WAIT");
}
int selectionStart;
@@ -1640,8 +1640,8 @@ public class DialpadFragment extends Fragment
/* package */ static boolean canAddDigit(CharSequence digits, int start, int end,
char newDigit) {
if(newDigit != WAIT && newDigit != PAUSE) {
- Log.wtf(TAG, "Should not be called for anything other than PAUSE & WAIT");
- return false;
+ throw new IllegalArgumentException(
+ "Should not be called for anything other than PAUSE & WAIT");
}
// False if no selection, or selection is reversed (end < start)
diff --git a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java
index 6a9817f26..6f5a98658 100644
--- a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java
+++ b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java
@@ -51,6 +51,8 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
private static final String TEST_COUNTRY_ISO = "US";
/** The geocoded location used in the tests. */
private static final String TEST_GEOCODE = "United States";
+ /** Empty geocode label */
+ private static final String EMPTY_GEOCODE = "";
/** The object under test. */
private PhoneCallDetailsHelper mHelper;
@@ -183,18 +185,18 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
public void testSetPhoneCallDetails_NoGeocode() {
setPhoneCallDetailsWithNumberAndGeocode("+14125555555", "1-412-555-5555", null);
assertNameEquals("1-412-555-5555"); // The phone number is shown as the name.
- assertLabelEquals("-"); // The empty geocode is shown as the label.
+ assertLabelEquals(EMPTY_GEOCODE); // The empty geocode is shown as the label.
}
public void testSetPhoneCallDetails_EmptyGeocode() {
setPhoneCallDetailsWithNumberAndGeocode("+14125555555", "1-412-555-5555", "");
assertNameEquals("1-412-555-5555"); // The phone number is shown as the name.
- assertLabelEquals("-"); // The empty geocode is shown as the label.
+ assertLabelEquals(EMPTY_GEOCODE); // The empty geocode is shown as the label.
}
public void testSetPhoneCallDetails_NoGeocodeForVoicemail() {
setPhoneCallDetailsWithNumberAndGeocode(TEST_VOICEMAIL_NUMBER, "", "United States");
- assertLabelEquals("-"); // The empty geocode is shown as the label.
+ assertLabelEquals(EMPTY_GEOCODE); // The empty geocode is shown as the label.
}
public void testSetPhoneCallDetails_Highlighted() {
diff --git a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java
index 7ceec8f08..4ccdaaf33 100644
--- a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java
+++ b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java
@@ -70,6 +70,8 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
/** The formatted version of {@link #TEST_NUMBER}. */
private static final String TEST_FORMATTED_NUMBER = "1 212-555-1000";
+ private static final String TEST_DEFAULT_CUSTOM_LABEL = "myLabel";
+
/** The activity in which we are hosting the fragment. */
private FragmentTestActivity mActivity;
private CallLogFragment mFragment;
@@ -218,8 +220,10 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
@MediumTest
public void testBindView_WithCachedName() {
mCursor.moveToFirst();
+ // provide a default custom label instead of an empty string, which corresponds to
+ // {@value com.android.dialer.calllog.ContactInfo#GEOCODE_AS_LABEL}
insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE,
- "John Doe", Phone.TYPE_HOME, "");
+ "John Doe", Phone.TYPE_HOME, TEST_DEFAULT_CUSTOM_LABEL);
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
mAdapter.bindStandAloneView(view, getActivity(), mCursor);
@@ -232,20 +236,22 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
public void testBindView_UriNumber() {
mCursor.moveToFirst();
insertWithCachedValues("sip:johndoe@gmail.com", NOW, 0, Calls.INCOMING_TYPE,
- "John Doe", Phone.TYPE_HOME, "");
+ "John Doe", Phone.TYPE_HOME, TEST_DEFAULT_CUSTOM_LABEL);
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
mAdapter.bindStandAloneView(view, getActivity(), mCursor);
CallLogListItemViews views = (CallLogListItemViews) view.getTag();
assertNameIs(views, "John Doe");
- assertLabel(views, "sip:johndoe@gmail.com", null);
+ assertLabel(views, "sip:johndoe@gmail.com", "sip:johndoe@gmail.com");
}
@MediumTest
public void testBindView_HomeLabel() {
mCursor.moveToFirst();
+ // provide a default custom label instead of an empty string, which corresponds to
+ // {@value com.android.dialer.calllog.ContactInfo#GEOCODE_AS_LABEL}
insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE,
- "John Doe", Phone.TYPE_HOME, "");
+ "John Doe", Phone.TYPE_HOME, TEST_DEFAULT_CUSTOM_LABEL);
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
mAdapter.bindStandAloneView(view, getActivity(), mCursor);
@@ -257,8 +263,10 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
@MediumTest
public void testBindView_WorkLabel() {
mCursor.moveToFirst();
+ // provide a default custom label instead of an empty string, which corresponds to
+ // {@link com.android.dialer.calllog.ContactInfo#GEOCODE_AS_LABEL}
insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE,
- "John Doe", Phone.TYPE_WORK, "");
+ "John Doe", Phone.TYPE_WORK, TEST_DEFAULT_CUSTOM_LABEL);
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
mAdapter.bindStandAloneView(view, getActivity(), mCursor);
@@ -607,7 +615,9 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
privateOrUnknownOrVm[2] = true;
} else {
int inout = mRnd.nextBoolean() ? Calls.OUTGOING_TYPE : Calls.INCOMING_TYPE;
- String number = new Formatter().format("1800123%04d", i).toString();
+ final Formatter formatter = new Formatter();
+ String number = formatter.format("1800123%04d", i).toString();
+ formatter.close();
insert(number, Calls.PRESENTATION_ALLOWED, NOW, RAND_DURATION, inout);
}
}
diff --git a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java
index 662afa0ca..a10dec908 100644
--- a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java
+++ b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java
@@ -50,6 +50,7 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
/** The views used in the tests. */
private CallLogListItemViews mViews;
private PhoneNumberDisplayHelper mPhoneNumberHelper;
+ private PhoneNumberDisplayHelper mPhoneNumberDisplayHelper;
@Override
protected void setUp() throws Exception {
@@ -61,7 +62,9 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
TEST_VOICEMAIL_NUMBER);
PhoneCallDetailsHelper phoneCallDetailsHelper = new PhoneCallDetailsHelper(
resources, callTypeHelper, phoneUtils);
- mHelper = new CallLogListItemHelper(phoneCallDetailsHelper, mPhoneNumberHelper, resources);
+ mPhoneNumberDisplayHelper = new PhoneNumberDisplayHelper(resources);
+ mHelper = new CallLogListItemHelper(phoneCallDetailsHelper, mPhoneNumberDisplayHelper,
+ resources);
mViews = CallLogListItemViews.createForTest(context);
}
diff --git a/tests/src/com/android/dialer/calllog/TestPhoneNumberUtilsWrapper.java b/tests/src/com/android/dialer/calllog/TestPhoneNumberUtilsWrapper.java
index 95f3cc12e..7266d8890 100644
--- a/tests/src/com/android/dialer/calllog/TestPhoneNumberUtilsWrapper.java
+++ b/tests/src/com/android/dialer/calllog/TestPhoneNumberUtilsWrapper.java
@@ -16,8 +16,6 @@
package com.android.dialer.calllog;
-import android.content.res.Resources;
-
/**
* Modified version of {@link com.android.dialer.calllog.PhoneNumberDisplayHelper} to be used in tests
* that allows injecting the voicemail number.
diff --git a/tests/src/com/android/dialer/dialpad/DialpadFragmentTest.java b/tests/src/com/android/dialer/dialpad/DialpadFragmentTest.java
index a123e745e..6f18fe69a 100644
--- a/tests/src/com/android/dialer/dialpad/DialpadFragmentTest.java
+++ b/tests/src/com/android/dialer/dialpad/DialpadFragmentTest.java
@@ -34,7 +34,11 @@ public class DialpadFragmentTest extends TestCase {
public void testCanAddDigit_InvalidCharacter() {
// only handles wait/pause
- assertFalse(DialpadFragment.canAddDigit("123", 1, 1, '5'));
+ try {
+ DialpadFragment.canAddDigit("123", 1, 1, '5');
+ fail("Calling canAddDigit with invalid character should throw an exception");
+ } catch (IllegalArgumentException e) {
+ }
}
public void testCanAddDigit_BadOrNoSelection() {
diff --git a/tests/src/com/android/dialer/interactions/PhoneNumberInteractionTest.java b/tests/src/com/android/dialer/interactions/PhoneNumberInteractionTest.java
index f86675e57..fbc64cd64 100644
--- a/tests/src/com/android/dialer/interactions/PhoneNumberInteractionTest.java
+++ b/tests/src/com/android/dialer/interactions/PhoneNumberInteractionTest.java
@@ -91,7 +91,7 @@ public class PhoneNumberInteractionTest extends InstrumentationTestCase {
Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, 13);
expectQuery(contactUri)
.returnRow(1, "123", 0, null, null, Phone.TYPE_HOME, null,
- Phone.CONTENT_ITEM_TYPE);
+ Phone.CONTENT_ITEM_TYPE, 13);
TestPhoneNumberInteraction interaction = new TestPhoneNumberInteraction(
mContext, ContactDisplayUtils.INTERACTION_SMS, null);
@@ -110,7 +110,7 @@ public class PhoneNumberInteractionTest extends InstrumentationTestCase {
Uri dataUri = ContentUris.withAppendedId(Data.CONTENT_URI, 1);
expectQuery(dataUri, true /* isDataUri */ )
.returnRow(1, "987", 0, null, null, Phone.TYPE_HOME, null,
- Phone.CONTENT_ITEM_TYPE);
+ Phone.CONTENT_ITEM_TYPE, 1);
TestPhoneNumberInteraction interaction = new TestPhoneNumberInteraction(
mContext, ContactDisplayUtils.INTERACTION_SMS, null);
@@ -128,10 +128,10 @@ public class PhoneNumberInteractionTest extends InstrumentationTestCase {
public void testSendSmsWhenThereIsPrimaryNumber() {
Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, 13);
expectQuery(contactUri)
- .returnRow(
- 1, "123", 0, null, null, Phone.TYPE_HOME, null, Phone.CONTENT_ITEM_TYPE)
- .returnRow(
- 2, "456", 1, null, null, Phone.TYPE_HOME, null, Phone.CONTENT_ITEM_TYPE);
+ .returnRow(1, "123", 0, null, null, Phone.TYPE_HOME, null,
+ Phone.CONTENT_ITEM_TYPE, 13)
+ .returnRow(2, "456", 1, null, null, Phone.TYPE_HOME, null,
+ Phone.CONTENT_ITEM_TYPE, 13);
TestPhoneNumberInteraction interaction = new TestPhoneNumberInteraction(
mContext, ContactDisplayUtils.INTERACTION_SMS, null);
@@ -170,9 +170,9 @@ public class PhoneNumberInteractionTest extends InstrumentationTestCase {
Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, 13);
expectQuery(contactUri)
.returnRow(1, "123", 0, null, null, Phone.TYPE_HOME, null,
- Phone.CONTENT_ITEM_TYPE)
+ Phone.CONTENT_ITEM_TYPE, 13)
.returnRow(2, "123", 0, null, null, Phone.TYPE_WORK, null,
- Phone.CONTENT_ITEM_TYPE);
+ Phone.CONTENT_ITEM_TYPE, 13);
TestPhoneNumberInteraction interaction = new TestPhoneNumberInteraction(
mContext, ContactDisplayUtils.INTERACTION_CALL, null);
@@ -191,7 +191,7 @@ public class PhoneNumberInteractionTest extends InstrumentationTestCase {
Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, 13);
expectQuery(contactUri)
.returnRow(1, "example@example.com", 0, null, null, Phone.TYPE_HOME, null,
- SipAddress.CONTENT_ITEM_TYPE);
+ SipAddress.CONTENT_ITEM_TYPE, 13);
TestPhoneNumberInteraction interaction = new TestPhoneNumberInteraction(
mContext, ContactDisplayUtils.INTERACTION_CALL, null);
@@ -209,9 +209,9 @@ public class PhoneNumberInteractionTest extends InstrumentationTestCase {
Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, 13);
expectQuery(contactUri)
.returnRow(1, "123", 0, "account", null, Phone.TYPE_HOME, "label",
- Phone.CONTENT_ITEM_TYPE)
+ Phone.CONTENT_ITEM_TYPE, 13)
.returnRow(2, "456", 0, null, null, Phone.TYPE_WORK, null,
- Phone.CONTENT_ITEM_TYPE);
+ Phone.CONTENT_ITEM_TYPE, 13);
TestPhoneNumberInteraction interaction = new TestPhoneNumberInteraction(
mContext, ContactDisplayUtils.INTERACTION_CALL, null);
@@ -252,7 +252,8 @@ public class PhoneNumberInteractionTest extends InstrumentationTestCase {
RawContacts.DATA_SET,
Phone.TYPE,
Phone.LABEL,
- Phone.MIMETYPE)
+ Phone.MIMETYPE,
+ Phone.CONTACT_ID)
.withSelection("mimetype IN ('vnd.android.cursor.item/phone_v2',"
+ " 'vnd.android.cursor.item/sip_address') AND data1 NOT NULL");
}