summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/res/layout/fill_call_log_test.xml151
-rw-r--r--tests/res/values/donottranslate_strings.xml15
-rw-r--r--tests/src/com/android/dialer/CallDetailActivityTest.java1
-rw-r--r--tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java29
-rw-r--r--tests/src/com/android/dialer/calllog/CallLogAdapterTest.java4
-rw-r--r--tests/src/com/android/dialer/calllog/CallLogFragmentTest.java67
-rw-r--r--tests/src/com/android/dialer/calllog/CallLogGroupBuilderTest.java10
-rw-r--r--tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java118
-rw-r--r--tests/src/com/android/dialer/database/SmartDialPrefixTest.java21
-rw-r--r--tests/src/com/android/dialer/dialpad/SmartDialNameMatcherTest.java1
-rw-r--r--tests/src/com/android/dialer/list/PhoneFavoritesTileAdapterTest.java69
-rw-r--r--tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java178
-rw-r--r--tests/src/com/android/dialer/widget/ActionBarControllerTest.java181
13 files changed, 608 insertions, 237 deletions
diff --git a/tests/res/layout/fill_call_log_test.xml b/tests/res/layout/fill_call_log_test.xml
index 704b9c66e..9b89e4a55 100644
--- a/tests/res/layout/fill_call_log_test.xml
+++ b/tests/res/layout/fill_call_log_test.xml
@@ -20,7 +20,7 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:gravity="center_horizontal"
+ android:gravity="left"
>
<TextView
android:layout_width="match_parent"
@@ -53,4 +53,153 @@
android:indeterminate="false"
android:visibility="gone"
/>
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/add_custom_entry"
+ />
+ <RadioGroup
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+ <RadioButton
+ android:id="@+id/call_type_incoming"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/call_type_incoming" />
+ <RadioButton
+ android:id="@+id/call_type_missed"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/call_type_missed" />
+ <RadioButton
+ android:id="@+id/call_type_outgoing"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/call_type_outgoing" />
+ </RadioGroup>
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="left"
+ >
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/call_date"
+ />
+ <TextView
+ android:id="@+id/call_date"
+ android:paddingStart="16dp"
+ android:layout_width="120dp"
+ android:layout_height="wrap_content"
+ />
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/edit"
+ android:onClick="showDatePickerDialog" />
+ </LinearLayout>
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="left"
+ >
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/call_time"
+ />
+ <TextView
+ android:id="@+id/call_time"
+ android:paddingStart="16dp"
+ android:layout_width="120dp"
+ android:layout_height="wrap_content"
+ />
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/edit"
+ android:onClick="showTimePickerDialog" />
+ </LinearLayout>
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/call_presentation"
+ />
+ <RadioGroup
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+ <RadioButton
+ android:id="@+id/presentation_allowed"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/presentation_allowed"
+ android:textSize="9sp" />
+ <RadioButton
+ android:id="@+id/presentation_restricted"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/presentation_restricted"
+ android:textSize="9sp" />
+ <RadioButton
+ android:id="@+id/presentation_unknown"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/presentation_unknown"
+ android:textSize="9sp" />
+ <RadioButton
+ android:id="@+id/presentation_payphone"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/presentation_payphone"
+ android:textSize="9sp" />
+ </RadioGroup>
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="left"
+ >
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/number"
+ />
+ <EditText
+ android:id="@+id/phone_number"
+ android:layout_width="180dp"
+ android:layout_height="wrap_content"
+ android:inputType="phone"
+ />
+ </LinearLayout>
+ <Button
+ android:id="@+id/add_custom"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/addToCallLogButton"
+ android:onClick="addManualEntry"
+ />
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="left"
+ >
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/delta_after_add"
+ />
+ <EditText
+ android:id="@+id/delta_after_add"
+ android:layout_width="90dp"
+ android:layout_height="wrap_content"
+ android:text="-1"
+ android:inputType="number"
+ />
+ </LinearLayout>
</LinearLayout>
diff --git a/tests/res/values/donottranslate_strings.xml b/tests/res/values/donottranslate_strings.xml
index ceba5ea96..25c3a5a71 100644
--- a/tests/res/values/donottranslate_strings.xml
+++ b/tests/res/values/donottranslate_strings.xml
@@ -37,5 +37,18 @@
<string name="numberOfCallLogEntries">Number of call log entries to add:</string>
<string name="addedLogEntriesToast">Added %1$d call log entries.</string>
<string name="noLogEntriesToast">No entries in the call log yet. Need at least one record for the template. Or use random numbers.</string>
-
+ <string name="add_custom_entry">Add custom call log entry:</string>
+ <string name="call_type_incoming">Incoming</string>
+ <string name="call_type_missed">Missed</string>
+ <string name="call_type_outgoing">Outgoing</string>
+ <string name="call_date">Call date</string>
+ <string name="call_time">Call time</string>
+ <string name="edit">Edit</string>
+ <string name="number">Number</string>
+ <string name="call_presentation">Presentation</string>
+ <string name="presentation_allowed">Allowed</string>
+ <string name="presentation_restricted">Restricted</string>
+ <string name="presentation_unknown">Unknown</string>
+ <string name="presentation_payphone">Payphone</string>
+ <string name="delta_after_add">Offset call time after add (min): </string>
</resources>
diff --git a/tests/src/com/android/dialer/CallDetailActivityTest.java b/tests/src/com/android/dialer/CallDetailActivityTest.java
index 1ad17c4f4..1e16fe427 100644
--- a/tests/src/com/android/dialer/CallDetailActivityTest.java
+++ b/tests/src/com/android/dialer/CallDetailActivityTest.java
@@ -219,7 +219,6 @@ public class CallDetailActivityTest extends ActivityInstrumentationTestCase2<Cal
mFakeAsyncTaskExecutor.runTask(PREPARE_MEDIA_PLAYER);
mTestUtils.clickButton(mActivityUnderTest, R.id.playback_speakerphone);
mTestUtils.clickButton(mActivityUnderTest, R.id.playback_start_stop);
- mTestUtils.clickButton(mActivityUnderTest, R.id.call_and_sms_main_action);
Thread.sleep(2000);
// TODO: Suppressed the test for now, because I'm looking for an easy way to say "the audio
// is not playing at this point", and I can't find it without doing dirty things.
diff --git a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java
index 9b7d9de13..679335e57 100644
--- a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java
+++ b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java
@@ -111,9 +111,7 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
public void testSetPhoneCallDetails_Normal() {
setPhoneCallDetailsWithNumber("14125551212",
Calls.PRESENTATION_ALLOWED, "1-412-555-1212");
- assertEquals("Yesterday", mViews.callTypeAndDate.getText().toString());
- assertEqualsHtml("<font color='#33b5e5'><b>Yesterday</b></font>",
- mViews.callTypeAndDate.getText());
+ assertTrue(mViews.callLocationAndDate.getText().toString().contains("Yesterday"));
}
/** Asserts that a char sequence is actually a Spanned corresponding to the expected HTML. */
@@ -252,12 +250,12 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
/** Asserts that the label text field contains the given string value. */
private void assertLabelEquals(String text) {
- assertEquals(text, mViews.labelView.getText().toString());
+ assertTrue(mViews.callLocationAndDate.getText().toString().contains(text));
}
/** Asserts that the date text field contains the given string value. */
private void assertDateEquals(String text) {
- assertEquals(text, mViews.callTypeAndDate.getText().toString());
+ assertTrue(mViews.callLocationAndDate.getText().toString().contains(text));
}
/** Asserts that the call type contains the images with the given drawables. */
@@ -268,7 +266,7 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
assertEquals(id, mViews.callTypeIcons.getCallType(index));
}
assertEquals(View.VISIBLE, mViews.callTypeIcons.getVisibility());
- assertEquals("Yesterday", mViews.callTypeAndDate.getText().toString());
+ assertTrue(mViews.callLocationAndDate.getText().toString().contains("Yesterday"));
}
/**
@@ -282,7 +280,8 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
assertEquals(id, mViews.callTypeIcons.getCallType(index));
}
assertEquals(View.VISIBLE, mViews.callTypeIcons.getVisibility());
- assertEquals(overflowText + " Yesterday", mViews.callTypeAndDate.getText().toString());
+ assertTrue(mViews.callLocationAndDate.getText().toString().contains(overflowText));
+ assertTrue(mViews.callLocationAndDate.getText().toString().contains("Yesterday"));
}
/** Sets the phone call details with default values and the given number. */
@@ -291,8 +290,8 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
mHelper.setPhoneCallDetails(mViews,
new PhoneCallDetails(number, presentation, formattedNumber,
TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{ Calls.VOICEMAIL_TYPE }, TEST_DATE, TEST_DURATION),
- true);
+ new int[]{ Calls.VOICEMAIL_TYPE }, TEST_DATE, TEST_DURATION)
+ );
}
/** Sets the phone call details with default values and the given number. */
@@ -301,8 +300,8 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
mHelper.setPhoneCallDetails(mViews,
new PhoneCallDetails(number, Calls.PRESENTATION_ALLOWED,
formattedNumber, TEST_COUNTRY_ISO, geocodedLocation,
- new int[]{ Calls.VOICEMAIL_TYPE }, TEST_DATE, TEST_DURATION),
- true);
+ new int[]{ Calls.VOICEMAIL_TYPE }, TEST_DATE, TEST_DURATION)
+ );
}
/** Sets the phone call details with default values and the given date. */
@@ -310,8 +309,8 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
mHelper.setPhoneCallDetails(mViews,
new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{ Calls.INCOMING_TYPE }, date, TEST_DURATION),
- false);
+ new int[]{ Calls.INCOMING_TYPE }, date, TEST_DURATION)
+ );
}
/** Sets the phone call details with default values and the given call types using icons. */
@@ -319,8 +318,8 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
mHelper.setPhoneCallDetails(mViews,
new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
- callTypes, TEST_DATE, TEST_DURATION),
- false);
+ callTypes, TEST_DATE, TEST_DURATION)
+ );
}
private void setCallDetailsHeaderWithNumber(String number, int presentation) {
diff --git a/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java b/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java
index 12cdb2b99..f3679d4ed 100644
--- a/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java
+++ b/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java
@@ -68,7 +68,7 @@ public class CallLogAdapterTest extends AndroidTestCase {
mCursor = new MatrixCursor(CallLogQuery._PROJECTION);
mCursor.moveToFirst();
// The views into which to store the data.
- mView = new View(getContext());
+ mView = new CallLogListItemView(getContext());
mView.setTag(CallLogListItemViews.createForTest(getContext()));
}
@@ -212,7 +212,7 @@ public class CallLogAdapterTest extends AndroidTestCase {
public TestCallLogAdapter(Context context, CallFetcher callFetcher,
ContactInfoHelper contactInfoHelper) {
- super(context, callFetcher, contactInfoHelper, false, false);
+ super(context, callFetcher, contactInfoHelper, null, false);
}
@Override
diff --git a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java
index 49d32e5cb..964d8a299 100644
--- a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java
+++ b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java
@@ -20,6 +20,7 @@ import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.ComponentName;
import android.content.ContentUris;
+import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.database.MatrixCursor;
@@ -34,6 +35,7 @@ import android.telephony.TelephonyManager;
import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.MediumTest;
+import android.util.Log;
import android.view.View;
import android.widget.FrameLayout;
@@ -89,11 +91,6 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
private Random mRnd;
- // References to the icons bitmaps used to build the list are stored in a
- // map mIcons. The keys to retrieve the icons are:
- // Calls.INCOMING_TYPE, Calls.OUTGOING_TYPE and Calls.MISSED_TYPE.
- private HashMap<Integer, Bitmap> mCallTypeIcons;
-
// An item in the call list. All the methods performing checks use it.
private CallLogListItemViews mItem;
// The list of views representing the data in the DB. View are in
@@ -121,7 +118,9 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
// Wait for the fragment to be loaded.
getInstrumentation().waitForIdleSync();
- mVoicemail = TelephonyManager.getDefault().getVoiceMailNumber();
+ final TelephonyManager telephonyManager =
+ (TelephonyManager) mActivity.getSystemService(Context.TELEPHONY_SERVICE);
+ mVoicemail = telephonyManager.getVoiceMailNumber();
mAdapter = mFragment.getAdapter();
// Do not process requests for details during tests. This would start a background thread,
// which makes the tests flaky.
@@ -129,7 +128,6 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
mAdapter.stopRequestProcessing();
mParentView = new FrameLayout(mActivity);
mCursor = new MatrixCursor(CallLogQuery._PROJECTION);
- buildIconMap();
}
/**
@@ -171,7 +169,6 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
insertPrivate(NOW, 0);
View view = mAdapter.newGroupView(getActivity(), mParentView);
mAdapter.bindGroupView(view, getActivity(), mCursor, 3, false);
- assertNotNull(view.findViewById(R.id.secondary_action_icon));
}
@MediumTest
@@ -179,8 +176,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
mCursor.moveToFirst();
insertPrivate(NOW, 0);
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
- mAdapter.bindStandAloneView(view, getActivity(), mCursor);
- assertNotNull(view.findViewById(R.id.secondary_action_icon));
+ mAdapter.bindViewForTest(view, getActivity(), mCursor);
}
@MediumTest
@@ -189,7 +185,6 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
insertPrivate(NOW, 0);
View view = mAdapter.newChildView(getActivity(), mParentView);
mAdapter.bindChildView(view, getActivity(), mCursor);
- assertNotNull(view.findViewById(R.id.secondary_action_icon));
}
@MediumTest
@@ -197,7 +192,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
mCursor.moveToFirst();
insert(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0, Calls.INCOMING_TYPE);
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
- mAdapter.bindStandAloneView(view, getActivity(), mCursor);
+ mAdapter.bindViewForTest(view, getActivity(), mCursor);
CallLogListItemViews views = (CallLogListItemViews) view.getTag();
assertNameIs(views, TEST_NUMBER);
@@ -211,7 +206,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
values[CallLogQuery.CACHED_FORMATTED_NUMBER] = TEST_FORMATTED_NUMBER;
insertValues(values);
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
- mAdapter.bindStandAloneView(view, getActivity(), mCursor);
+ mAdapter.bindViewForTest(view, getActivity(), mCursor);
CallLogListItemViews views = (CallLogListItemViews) view.getTag();
assertNameIs(views, TEST_FORMATTED_NUMBER);
@@ -225,7 +220,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE,
"John Doe", Phone.TYPE_HOME, TEST_DEFAULT_CUSTOM_LABEL);
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
- mAdapter.bindStandAloneView(view, getActivity(), mCursor);
+ mAdapter.bindViewForTest(view, getActivity(), mCursor);
CallLogListItemViews views = (CallLogListItemViews) view.getTag();
assertNameIs(views, "John Doe");
@@ -238,7 +233,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
insertWithCachedValues("sip:johndoe@gmail.com", NOW, 0, Calls.INCOMING_TYPE,
"John Doe", Phone.TYPE_HOME, TEST_DEFAULT_CUSTOM_LABEL);
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
- mAdapter.bindStandAloneView(view, getActivity(), mCursor);
+ mAdapter.bindViewForTest(view, getActivity(), mCursor);
CallLogListItemViews views = (CallLogListItemViews) view.getTag();
assertNameIs(views, "John Doe");
@@ -253,7 +248,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE,
"John Doe", Phone.TYPE_HOME, TEST_DEFAULT_CUSTOM_LABEL);
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
- mAdapter.bindStandAloneView(view, getActivity(), mCursor);
+ mAdapter.bindViewForTest(view, getActivity(), mCursor);
CallLogListItemViews views = (CallLogListItemViews) view.getTag();
assertNameIs(views, "John Doe");
@@ -268,7 +263,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE,
"John Doe", Phone.TYPE_WORK, TEST_DEFAULT_CUSTOM_LABEL);
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
- mAdapter.bindStandAloneView(view, getActivity(), mCursor);
+ mAdapter.bindViewForTest(view, getActivity(), mCursor);
CallLogListItemViews views = (CallLogListItemViews) view.getTag();
assertNameIs(views, "John Doe");
@@ -282,7 +277,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE,
"John Doe", Phone.TYPE_CUSTOM, numberLabel);
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
- mAdapter.bindStandAloneView(view, getActivity(), mCursor);
+ mAdapter.bindViewForTest(view, getActivity(), mCursor);
CallLogListItemViews views = (CallLogListItemViews) view.getTag();
assertNameIs(views, "John Doe");
@@ -295,7 +290,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE,
"John Doe", Phone.TYPE_HOME, "");
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
- mAdapter.bindStandAloneView(view, getActivity(), mCursor);
+ mAdapter.bindViewForTest(view, getActivity(), mCursor);
CallLogListItemViews views = (CallLogListItemViews) view.getTag();
assertTrue(views.quickContactView.isEnabled());
@@ -306,7 +301,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
mCursor.moveToFirst();
insert(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0, Calls.INCOMING_TYPE);
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
- mAdapter.bindStandAloneView(view, getActivity(), mCursor);
+ mAdapter.bindViewForTest(view, getActivity(), mCursor);
CallLogListItemViews views = (CallLogListItemViews) view.getTag();
assertFalse(views.quickContactView.isEnabled());
@@ -317,7 +312,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
mCursor.moveToFirst();
insert(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0, Calls.INCOMING_TYPE);
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
- mAdapter.bindStandAloneView(view, getActivity(), mCursor);
+ mAdapter.bindViewForTest(view, getActivity(), mCursor);
CallLogListItemViews views = (CallLogListItemViews) view.getTag();
@@ -325,7 +320,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
// {@link com.android.dialer.calllog.CallLogAdapter#bindView} method. If it is possible
// to place a call to the phone number, a call intent will have been created for the
// primaryActionView.
- IntentProvider intentProvider = (IntentProvider) views.primaryActionView.getTag();
+ IntentProvider intentProvider = (IntentProvider) views.callBackButtonView.getTag();
Intent intent = intentProvider.getIntent(mActivity);
// Starts a call.
assertEquals(Intent.ACTION_CALL_PRIVILEGED, intent.getAction());
@@ -338,10 +333,10 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
mCursor.moveToFirst();
insertVoicemail(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0);
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
- mAdapter.bindStandAloneView(view, getActivity(), mCursor);
+ mAdapter.bindViewForTest(view, getActivity(), mCursor);
CallLogListItemViews views = (CallLogListItemViews) view.getTag();
- IntentProvider intentProvider = (IntentProvider) views.secondaryActionButtonView.getTag();
+ IntentProvider intentProvider = (IntentProvider) views.voicemailButtonView.getTag();
Intent intent = intentProvider.getIntent(mActivity);
// Starts the call detail activity.
assertEquals(new ComponentName(mActivity, CallDetailActivity.class),
@@ -381,12 +376,12 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
if (presentation == Calls.PRESENTATION_RESTRICTED ||
presentation == Calls.PRESENTATION_UNKNOWN) {
//If number is not callable, the primary action view should have a null tag.
- assertNull(mItem.primaryActionView.getTag());
+ assertNull(mItem.callBackButtonView.getTag());
} else {
//If the number is callable, the primary action view should have a non-null tag.
- assertNotNull(mItem.primaryActionView.getTag());
+ assertNotNull(mItem.callBackButtonView.getTag());
- IntentProvider intentProvider = (IntentProvider)mItem.primaryActionView.getTag();
+ IntentProvider intentProvider = (IntentProvider)mItem.callBackButtonView.getTag();
Intent callIntent = intentProvider.getIntent(mActivity);
//The intent should be to make the call
@@ -411,17 +406,6 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
return d.getBitmap();
}
- /**
- * Fetch all the icons we need in tests from the contacts app and store them in a map.
- */
- private void buildIconMap() {
- mCallTypeIcons = new HashMap<Integer, Bitmap>(3);
-
- mCallTypeIcons.put(Calls.INCOMING_TYPE, getBitmap("ic_call_incoming_holo_dark"));
- mCallTypeIcons.put(Calls.MISSED_TYPE, getBitmap("ic_call_missed_holo_dark"));
- mCallTypeIcons.put(Calls.OUTGOING_TYPE, getBitmap("ic_call_outgoing_holo_dark"));
- }
-
//
// HELPERS to build/update the call entries (views) from the DB.
//
@@ -438,7 +422,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
if (null == mList[i]) {
mList[i] = mAdapter.newStandAloneView(mActivity, mParentView);
}
- mAdapter.bindStandAloneView(mList[i], mActivity, mCursor);
+ mAdapter.bindViewForTest(mList[i], mActivity, mCursor);
mCursor.moveToPrevious();
i++;
}
@@ -647,10 +631,9 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
/** Asserts that the label text view contains the given text. */
private void assertLabel(CallLogListItemViews views, CharSequence number,
CharSequence label) {
- assertEquals(label == null ? View.GONE : View.VISIBLE,
- views.phoneCallDetailsViews.labelView.getVisibility());
if (label != null) {
- assertEquals(label, views.phoneCallDetailsViews.labelView.getText().toString());
+ assertTrue(views.phoneCallDetailsViews.callLocationAndDate.getText().toString()
+ .contains(label));
}
}
}
diff --git a/tests/src/com/android/dialer/calllog/CallLogGroupBuilderTest.java b/tests/src/com/android/dialer/calllog/CallLogGroupBuilderTest.java
index cef717f00..891f0686f 100644
--- a/tests/src/com/android/dialer/calllog/CallLogGroupBuilderTest.java
+++ b/tests/src/com/android/dialer/calllog/CallLogGroupBuilderTest.java
@@ -297,5 +297,15 @@ public class CallLogGroupBuilderTest extends AndroidTestCase {
public void addGroup(int cursorPosition, int size, boolean expanded) {
groups.add(new GroupSpec(cursorPosition, size, expanded));
}
+
+ @Override
+ public void setDayGroup(long rowId, int dayGroup) {
+ //No-op
+ }
+
+ @Override
+ public void clearDayGroups() {
+ //No-op
+ }
}
}
diff --git a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java
index 7e4736e35..96eefbc5d 100644
--- a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java
+++ b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java
@@ -81,13 +81,7 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
public void testSetPhoneCallDetails() {
setPhoneCallDetailsWithNumber("12125551234", Calls.PRESENTATION_ALLOWED,
"1-212-555-1234");
- assertEquals(View.VISIBLE, mViews.secondaryActionButtonView.getVisibility());
- }
-
- public void testSetPhoneCallDetailsInFavorites() {
- setPhoneCallDetailsWithNumberInFavorites("12125551234", Calls.PRESENTATION_ALLOWED,
- "1-212-555-1234");
- assertNoCallIntent();
+ assertEquals(View.VISIBLE, mViews.callBackButtonView.getVisibility());
}
public void testSetPhoneCallDetails_Unknown() {
@@ -95,73 +89,36 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
assertNoCallIntent();
}
- public void testSetPhoneCallDetailsInFavorites_Unknown() {
- setPhoneCallDetailsWithNumberInFavorites("", Calls.PRESENTATION_UNKNOWN, "");
- assertNoCallIntent();
- }
-
public void testSetPhoneCallDetails_Private() {
setPhoneCallDetailsWithNumber("", Calls.PRESENTATION_RESTRICTED, "");
assertNoCallIntent();
}
- public void testSetPhoneCallDetailsInFavorites_Private() {
- setPhoneCallDetailsWithNumberInFavorites("", Calls.PRESENTATION_RESTRICTED, "");
- assertNoCallIntent();
- }
-
public void testSetPhoneCallDetails_Payphone() {
setPhoneCallDetailsWithNumber("", Calls.PRESENTATION_PAYPHONE, "");
assertNoCallIntent();
}
- public void testSetPhoneCallDetailsInFavorites_Payphone() {
- setPhoneCallDetailsWithNumberInFavorites("", Calls.PRESENTATION_PAYPHONE, "");
- assertNoCallIntent();
- }
-
public void testSetPhoneCallDetails_VoicemailNumber() {
setPhoneCallDetailsWithNumber(TEST_VOICEMAIL_NUMBER,
Calls.PRESENTATION_ALLOWED, TEST_VOICEMAIL_NUMBER);
- assertEquals(View.VISIBLE, mViews.secondaryActionButtonView.getVisibility());
+ assertEquals(View.VISIBLE, mViews.voicemailButtonView.getVisibility());
}
public void testSetPhoneCallDetails_ReadVoicemail() {
setPhoneCallDetailsWithTypes(Calls.VOICEMAIL_TYPE);
- assertEquals(View.VISIBLE, mViews.secondaryActionButtonView.getVisibility());
+ assertEquals(View.VISIBLE, mViews.voicemailButtonView.getVisibility());
}
public void testSetPhoneCallDetails_UnreadVoicemail() {
setUnreadPhoneCallDetailsWithTypes(Calls.VOICEMAIL_TYPE);
- assertEquals(View.VISIBLE, mViews.secondaryActionButtonView.getVisibility());
+ assertEquals(View.VISIBLE, mViews.voicemailButtonView.getVisibility());
}
public void testSetPhoneCallDetails_VoicemailFromUnknown() {
setPhoneCallDetailsWithNumberAndType("", Calls.PRESENTATION_UNKNOWN,
"", Calls.VOICEMAIL_TYPE);
- assertEquals(View.VISIBLE, mViews.secondaryActionButtonView.getVisibility());
- }
-
- public void testSetPhoneCallDetailsInFavorites_VoicemailNumber() {
- setPhoneCallDetailsWithNumberInFavorites(TEST_VOICEMAIL_NUMBER,
- Calls.PRESENTATION_ALLOWED, TEST_VOICEMAIL_NUMBER);
- assertNoCallIntent();
- }
-
- public void testSetPhoneCallDetailsInFavorites_ReadVoicemail() {
- setPhoneCallDetailsWithTypesInFavorites(Calls.VOICEMAIL_TYPE);
- assertEquals(View.VISIBLE, mViews.secondaryActionButtonView.getVisibility());
- }
-
- public void testSetPhoneCallDetailsInFavorites_UnreadVoicemail() {
- setUnreadPhoneCallDetailsWithTypesInFavorites(Calls.VOICEMAIL_TYPE);
- assertEquals(View.VISIBLE, mViews.secondaryActionButtonView.getVisibility());
- }
-
- public void testSetPhoneCallDetailsInFavorites_VoicemailFromUnknown() {
- setPhoneCallDetailsWithNumberAndTypeInFavorites("", Calls.PRESENTATION_UNKNOWN,
- "", Calls.VOICEMAIL_TYPE);
- assertEquals(View.VISIBLE, mViews.secondaryActionButtonView.getVisibility());
+ assertEquals(View.VISIBLE, mViews.voicemailButtonView.getVisibility());
}
/**
@@ -172,7 +129,7 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
PhoneCallDetails details = new PhoneCallDetails("", Calls.PRESENTATION_UNKNOWN, "",
TEST_COUNTRY_ISO, TEST_GEOCODE,
new int[]{Calls.INCOMING_TYPE}, TEST_DATE, TEST_DURATION);
- assertEquals(R.string.description_unknown_answered_call,
+ assertEquals(R.string.description_incoming_answered_call,
mHelper.getCallDescriptionStringID(details));
}
@@ -184,7 +141,7 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
PhoneCallDetails details = new PhoneCallDetails("", Calls.PRESENTATION_UNKNOWN, "",
TEST_COUNTRY_ISO, TEST_GEOCODE,
new int[]{Calls.MISSED_TYPE}, TEST_DATE, TEST_DURATION);
- assertEquals(R.string.description_unknown_missed_call,
+ assertEquals(R.string.description_incoming_missed_call,
mHelper.getCallDescriptionStringID(details));
}
@@ -196,7 +153,7 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
PhoneCallDetails details = new PhoneCallDetails("", Calls.PRESENTATION_UNKNOWN, "",
TEST_COUNTRY_ISO, TEST_GEOCODE,
new int[]{Calls.VOICEMAIL_TYPE}, TEST_DATE, TEST_DURATION);
- assertEquals(R.string.description_unknown_missed_call,
+ assertEquals(R.string.description_incoming_missed_call,
mHelper.getCallDescriptionStringID(details));
}
@@ -209,7 +166,7 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
TEST_FORMATTED_NUMBER,
TEST_COUNTRY_ISO, TEST_GEOCODE,
new int[]{Calls.INCOMING_TYPE}, TEST_DATE, TEST_DURATION);
- assertEquals(R.string.description_return_answered_call,
+ assertEquals(R.string.description_incoming_answered_call,
mHelper.getCallDescriptionStringID(details));
}
@@ -222,7 +179,7 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
TEST_FORMATTED_NUMBER,
TEST_COUNTRY_ISO, TEST_GEOCODE,
new int[]{Calls.MISSED_TYPE}, TEST_DATE, TEST_DURATION);
- assertEquals(R.string.description_return_missed_call,
+ assertEquals(R.string.description_incoming_missed_call,
mHelper.getCallDescriptionStringID(details));
}
@@ -235,7 +192,7 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
TEST_FORMATTED_NUMBER,
TEST_COUNTRY_ISO, TEST_GEOCODE,
new int[]{Calls.VOICEMAIL_TYPE}, TEST_DATE, TEST_DURATION);
- assertEquals(R.string.description_return_missed_call,
+ assertEquals(R.string.description_incoming_missed_call,
mHelper.getCallDescriptionStringID(details));
}
@@ -249,7 +206,7 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
TEST_FORMATTED_NUMBER,
TEST_COUNTRY_ISO, TEST_GEOCODE,
new int[]{Calls.OUTGOING_TYPE}, TEST_DATE, TEST_DURATION);
- assertEquals(R.string.description_call_last,
+ assertEquals(R.string.description_outgoing_call,
mHelper.getCallDescriptionStringID(details));
}
@@ -263,7 +220,7 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
TEST_FORMATTED_NUMBER,
TEST_COUNTRY_ISO, TEST_GEOCODE,
new int[]{Calls.OUTGOING_TYPE, Calls.OUTGOING_TYPE}, TEST_DATE, TEST_DURATION);
- assertEquals(R.string.description_call_last_multiple,
+ assertEquals(R.string.description_outgoing_call,
mHelper.getCallDescriptionStringID(details));
}
@@ -370,31 +327,14 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
formattedNumber, Calls.INCOMING_TYPE);
}
- /** Sets the details of a phone call in the favorite screen using the specified phone number. */
- private void setPhoneCallDetailsWithNumberInFavorites(String number,
- int presentation, String formattedNumber) {
- setPhoneCallDetailsWithNumberAndTypeInFavorites(number, presentation,
- formattedNumber, Calls.INCOMING_TYPE);
- }
-
/** Sets the details of a phone call using the specified phone number. */
private void setPhoneCallDetailsWithNumberAndType(String number,
int presentation, String formattedNumber, int callType) {
mHelper.setPhoneCallDetails(mViews,
new PhoneCallDetails(number, presentation, formattedNumber,
TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{ callType }, TEST_DATE, TEST_DURATION),
- false, false);
- }
-
- /** Sets the details of a phone call in the favorite screen using the specified phone number. */
- private void setPhoneCallDetailsWithNumberAndTypeInFavorites(String number,
- int presentation, String formattedNumber, int callType) {
- mHelper.setPhoneCallDetails(mViews,
- new PhoneCallDetails(number, presentation, formattedNumber,
- TEST_COUNTRY_ISO, TEST_GEOCODE,
- new int[]{ callType }, TEST_DATE, TEST_DURATION),
- false, true);
+ new int[]{ callType }, TEST_DATE, TEST_DURATION)
+ );
}
/** Sets the details of a phone call using the specified call type. */
@@ -402,17 +342,8 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
mHelper.setPhoneCallDetails(mViews,
new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
- types, TEST_DATE, TEST_DURATION),
- false, false);
- }
-
- /** Sets the details of a phone call in the favorite screen using the specified call type. */
- private void setPhoneCallDetailsWithTypesInFavorites(int... types) {
- mHelper.setPhoneCallDetails(mViews,
- new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
- TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
- types, TEST_DATE, TEST_DURATION),
- false, true);
+ types, TEST_DATE, TEST_DURATION)
+ );
}
/** Sets the details of an unread phone call using the specified call type. */
@@ -420,18 +351,7 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
mHelper.setPhoneCallDetails(mViews,
new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
- types, TEST_DATE, TEST_DURATION),
- true, false);
- }
-
- /** Sets the details of an unread phone call in the favorite screen using the specified call
- * type.
- */
- private void setUnreadPhoneCallDetailsWithTypesInFavorites(int... types) {
- mHelper.setPhoneCallDetails(mViews,
- new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
- TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
- types, TEST_DATE, TEST_DURATION),
- true, true);
+ types, TEST_DATE, TEST_DURATION)
+ );
}
}
diff --git a/tests/src/com/android/dialer/database/SmartDialPrefixTest.java b/tests/src/com/android/dialer/database/SmartDialPrefixTest.java
index 23bda7cb2..9cb842e56 100644
--- a/tests/src/com/android/dialer/database/SmartDialPrefixTest.java
+++ b/tests/src/com/android/dialer/database/SmartDialPrefixTest.java
@@ -21,6 +21,8 @@ import android.database.sqlite.SQLiteDatabase;
import android.test.suitebuilder.annotation.SmallTest;
import android.test.suitebuilder.annotation.Suppress;
import android.test.AndroidTestCase;
+import android.text.TextUtils;
+import android.util.Log;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data;
@@ -31,16 +33,13 @@ import com.android.dialer.dialpad.SmartDialNameMatcher;
import com.android.dialer.dialpad.SmartDialPrefix;
import java.lang.Exception;
-import java.lang.FindBugsSuppressWarnings;
import java.lang.Override;
import java.lang.String;
import java.util.ArrayList;
-import junit.framework.TestCase;
-
/**
* To run this test, use the command:
- * adb shell am instrument -w -e class com.android.dialer.dialpad.SmartDialPrefixTest /
+ * adb shell am instrument -w -e class com.android.dialer.database.SmartDialPrefixTest /
* com.android.dialer.tests/android.test.InstrumentationTestRunner
*/
@SmallTest
@@ -80,6 +79,7 @@ public class SmartDialPrefixTest extends AndroidTestCase {
assertTrue(SmartDialPrefix.isCountryNanp("vi"));
}
+ @Override
protected void setUp() {
mTestHelper = DialerDatabaseHelper.getNewInstanceForTest(getContext());
}
@@ -136,8 +136,8 @@ public class SmartDialPrefixTest extends AndroidTestCase {
private ContactNumber constructNewContactWithDummyIds(MatrixCursor contactCursor,
MatrixCursor nameCursor, String number, int id, String displayName) {
- return constructNewContact(contactCursor, nameCursor, id, number, 0, "", displayName, 0, 0,
- 0, 0, 0, 0, 0);
+ return constructNewContact(contactCursor, nameCursor, id, number, id, String.valueOf(id),
+ displayName, 0, 0, 0, 0, 0, 0, 0);
}
private ContactNumber constructNewContact(MatrixCursor contactCursor, MatrixCursor nameCursor,
@@ -147,6 +147,12 @@ public class SmartDialPrefixTest extends AndroidTestCase {
assertNotNull(contactCursor);
assertNotNull(nameCursor);
+ if (TextUtils.isEmpty(number)) {
+ // Add a dummy number, otherwise DialerDatabaseHelper simply ignores the entire
+ // row if the number is empty
+ number = "0";
+ }
+
contactCursor.addRow(new Object[]{id, "", "", number, contactId, lookupKey, displayName,
photoId, lastTimeUsed, timesUsed, starred, isSuperPrimary, inVisibleGroup,
isPrimary});
@@ -294,7 +300,8 @@ public class SmartDialPrefixTest extends AndroidTestCase {
// 6543 doesn't match
assertFalse(getLooseMatchesFromDb("6543").contains(martinjuniorharry));
- assertEquals(7, mTestHelper.countPrefixTableRows(db));
+ // 7 actual rows, + 1 for the dummy number we added
+ assertEquals(8, mTestHelper.countPrefixTableRows(db));
}
public void testPutForInitialMatchesForLongTokenNames() {
diff --git a/tests/src/com/android/dialer/dialpad/SmartDialNameMatcherTest.java b/tests/src/com/android/dialer/dialpad/SmartDialNameMatcherTest.java
index 1e578eee7..c1365f5cf 100644
--- a/tests/src/com/android/dialer/dialpad/SmartDialNameMatcherTest.java
+++ b/tests/src/com/android/dialer/dialpad/SmartDialNameMatcherTest.java
@@ -198,6 +198,7 @@ public class SmartDialNameMatcherTest extends TestCase {
}
public void testMatches_NumberNANP() {
+ SmartDialPrefix.setUserInNanpRegion(true);
// An 11 digit number prefixed with 1 should be matched by the 10 digit number, as well as
// the 7 digit number (without area code)
checkMatchesNumber("1-510-333-7596", "5103337596", true, true, 2, 14);
diff --git a/tests/src/com/android/dialer/list/PhoneFavoritesTileAdapterTest.java b/tests/src/com/android/dialer/list/PhoneFavoritesTileAdapterTest.java
index 7a2076d8e..c2069bda7 100644
--- a/tests/src/com/android/dialer/list/PhoneFavoritesTileAdapterTest.java
+++ b/tests/src/com/android/dialer/list/PhoneFavoritesTileAdapterTest.java
@@ -53,75 +53,6 @@ public class PhoneFavoritesTileAdapterTest extends AndroidTestCase {
}
- public void testGetRowIndex_NoRowLimit() {
- mAdapter = getAdapterForTest(2, PhoneFavoritesTileAdapter.NO_ROW_LIMIT);
- assertEquals(0, mAdapter.getRowCount(0));
- assertEquals(1, mAdapter.getRowCount(1));
- assertEquals(1, mAdapter.getRowCount(2));
- assertEquals(2, mAdapter.getRowCount(4));
- assertEquals(4, mAdapter.getRowCount(7));
- assertEquals(100, mAdapter.getRowCount(199));
-
- mAdapter = getAdapterForTest(5, PhoneFavoritesTileAdapter.NO_ROW_LIMIT);
- assertEquals(0, mAdapter.getRowCount(0));
- assertEquals(1, mAdapter.getRowCount(1));
- assertEquals(1, mAdapter.getRowCount(3));
- assertEquals(1, mAdapter.getRowCount(5));
- assertEquals(2, mAdapter.getRowCount(7));
- assertEquals(2, mAdapter.getRowCount(10));
- assertEquals(40, mAdapter.getRowCount(199));
- }
-
- public void testGetItemId_NoRowLimit() {
- mAdapter = getAdapterForTest(2, PhoneFavoritesTileAdapter.NO_ROW_LIMIT);
- assertEquals(0, mAdapter.getItemId(0));
- assertEquals(1, mAdapter.getItemId(1));
- assertEquals(5, mAdapter.getItemId(5));
- assertEquals(10, mAdapter.getItemId(10));
- }
-
- public void testGetAdjustedItemId_NoRowLimit() {
- mAdapter = getAdapterForTest(2, PhoneFavoritesTileAdapter.NO_ROW_LIMIT);
- assertEquals(0, mAdapter.getAdjustedItemId(0));
- assertEquals(1, mAdapter.getAdjustedItemId(1));
- assertEquals(5, mAdapter.getAdjustedItemId(5));
- assertEquals(10, mAdapter.getAdjustedItemId(10));
- }
-
- public void testGetItem_NoRowLimit() {
- mAdapter = getAdapterForTest(2, PhoneFavoritesTileAdapter.NO_ROW_LIMIT);
- mAdapter.setContactCursor(getCursorForTest(5, 5));
-
- final ArrayList<ContactEntry> row1 = new ArrayList<ContactEntry> ();
- row1.add(getTestContactEntry(0, true));
- row1.add(getTestContactEntry(1, true));
- assertContactEntryRowsEqual(row1, mAdapter.getItem(0));
-
- final ArrayList<ContactEntry> row3 = new ArrayList<ContactEntry> ();
- row3.add(getTestContactEntry(4, true));
- row3.add(getTestContactEntry(5, false));
- assertContactEntryRowsEqual(row3, mAdapter.getItem(2));
-
- final ArrayList<ContactEntry> row5 = new ArrayList<ContactEntry> ();
- row5.add(getTestContactEntry(8, false));
- row5.add(getTestContactEntry(9, false));
- assertContactEntryRowsEqual(row5, mAdapter.getItem(4));
- }
-
- /**
- * Ensures that PhoneFavoritesTileAdapter returns true for hasStableIds. This is needed for
- * animation purposes.
- */
- public void testHasStableIds() {
- mAdapter = new PhoneFavoritesTileAdapter(getContext(), null, null, 2, 2);
- assertTrue(mAdapter.hasStableIds());
- }
-
- private PhoneFavoritesTileAdapter getAdapterForTest(int numCols, int numRows) {
- return new PhoneFavoritesTileAdapter(getContext(), null,
- sOnDataSetChangedForAnimationListener, numCols, numRows);
- }
-
/**
* Returns a cursor containing starred and frequent contacts for test purposes.
*
diff --git a/tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java b/tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java
index b1b8e2f05..1e5c25742 100644
--- a/tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java
+++ b/tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java
@@ -17,7 +17,11 @@
package com.android.dialer.tests.calllog;
import android.app.Activity;
+import android.app.DatePickerDialog;
+import android.app.Dialog;
+import android.app.DialogFragment;
import android.app.LoaderManager;
+import android.app.TimePickerDialog;
import android.content.ContentProviderClient;
import android.content.ContentValues;
import android.content.CursorLoader;
@@ -27,16 +31,22 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.os.RemoteException;
import android.provider.CallLog.Calls;
+import android.text.format.DateFormat;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
+import android.widget.DatePicker;
+import android.widget.EditText;
import android.widget.ProgressBar;
+import android.widget.RadioButton;
import android.widget.TextView;
+import android.widget.TimePicker;
import android.widget.Toast;
import com.android.dialer.tests.R;
+import java.util.Calendar;
import java.util.Random;
/**
@@ -56,6 +66,23 @@ public class FillCallLogTestActivity extends Activity {
private Button mAddButton;
private ProgressBar mProgressBar;
private CheckBox mUseRandomNumbers;
+ private RadioButton mCallTypeIncoming;
+ private RadioButton mCallTypeMissed;
+ private RadioButton mCallTypeOutgoing;
+ private RadioButton mPresentationAllowed;
+ private RadioButton mPresentationRestricted;
+ private RadioButton mPresentationUnknown;
+ private RadioButton mPresentationPayphone;
+ private TextView mCallDate;
+ private TextView mCallTime;
+ private TextView mPhoneNumber;
+ private EditText mOffset;
+
+ private int mCallTimeHour;
+ private int mCallTimeMinute;
+ private int mCallDateYear;
+ private int mCallDateMonth;
+ private int mCallDateDay;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -88,6 +115,28 @@ public class FillCallLogTestActivity extends Activity {
mProgressBar.setVisibility(View.VISIBLE);
}
});
+
+ mCallTypeIncoming = (RadioButton) findViewById(R.id.call_type_incoming);
+ mCallTypeMissed = (RadioButton) findViewById(R.id.call_type_missed);
+ mCallTypeOutgoing = (RadioButton) findViewById(R.id.call_type_outgoing);
+ mPresentationAllowed = (RadioButton) findViewById(R.id.presentation_allowed);
+ mPresentationPayphone = (RadioButton) findViewById(R.id.presentation_payphone);
+ mPresentationUnknown = (RadioButton) findViewById(R.id.presentation_unknown);
+ mPresentationRestricted = (RadioButton) findViewById(R.id.presentation_restricted);
+ mCallTime = (TextView) findViewById(R.id.call_time);
+ mCallDate = (TextView) findViewById(R.id.call_date);
+ mPhoneNumber = (TextView) findViewById(R.id.phone_number);
+ mOffset = (EditText) findViewById(R.id.delta_after_add);
+
+ // Use the current time as the default values for the picker
+ final Calendar c = Calendar.getInstance();
+ mCallTimeHour = c.get(Calendar.HOUR_OF_DAY);
+ mCallTimeMinute = c.get(Calendar.MINUTE);
+ mCallDateYear = c.get(Calendar.YEAR);
+ mCallDateMonth = c.get(Calendar.MONTH);
+ mCallDateDay = c.get(Calendar.DAY_OF_MONTH);
+ setDisplayDate();
+ setDisplayTime();
}
/**
@@ -306,4 +355,133 @@ public class FillCallLogTestActivity extends Activity {
public void updateCount(Integer count) {
mProgressBar.setProgress(count);
}
+
+ /**
+ * Determines the call type for a manually entered call.
+ *
+ * @return Call type.
+ */
+ private int getManualCallType() {
+ if (mCallTypeIncoming.isChecked()) {
+ return Calls.INCOMING_TYPE;
+ } else if (mCallTypeOutgoing.isChecked()) {
+ return Calls.OUTGOING_TYPE;
+ } else {
+ return Calls.MISSED_TYPE;
+ }
+ }
+
+ /**
+ * Determines the presentation for a manually entered call.
+ *
+ * @return Presentation.
+ */
+ private int getManualPresentation() {
+ if (mPresentationAllowed.isChecked()) {
+ return Calls.PRESENTATION_ALLOWED;
+ } else if (mPresentationPayphone.isChecked()) {
+ return Calls.PRESENTATION_PAYPHONE;
+ } else if (mPresentationRestricted.isChecked()) {
+ return Calls.PRESENTATION_RESTRICTED;
+ } else {
+ return Calls.PRESENTATION_UNKNOWN;
+ }
+ }
+
+ /**
+ * Shows a time picker dialog, storing the results in the time field.
+ */
+ public void showTimePickerDialog(View v) {
+ DialogFragment newFragment = new TimePickerFragment();
+ newFragment.show(getFragmentManager(),"timePicker");
+ }
+
+ /**
+ * Helper class to display time picker and store the hour/minute.
+ */
+ public class TimePickerFragment extends DialogFragment
+ implements TimePickerDialog.OnTimeSetListener {
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ // Create a new instance of TimePickerDialog and return it
+ return new TimePickerDialog(getActivity(), this, mCallTimeHour, mCallTimeMinute,
+ DateFormat.is24HourFormat(getActivity()));
+ }
+
+ public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
+ mCallTimeHour = hourOfDay;
+ mCallTimeMinute = minute;
+ setDisplayTime();
+ }
+ }
+
+ /**
+ * Sets the call time TextView to the current selected time.
+ */
+ private void setDisplayTime() {
+ mCallTime.setText(String.format("%02d:%02d", mCallTimeHour, mCallTimeMinute));
+ }
+
+ /**
+ * Sets the call date Textview to the current selected date
+ */
+ private void setDisplayDate() {
+ mCallDate.setText(String.format("%04d-%02d-%02d", mCallDateYear, mCallDateMonth,
+ mCallDateDay));
+ }
+
+ /**
+ * Shows a date picker dialog.
+ */
+ public void showDatePickerDialog(View v) {
+ DialogFragment newFragment = new DatePickerFragment();
+ newFragment.show(getFragmentManager(),"datePicker");
+ }
+
+ /**
+ * Helper class to show a date picker.
+ */
+ public class DatePickerFragment extends DialogFragment
+ implements DatePickerDialog.OnDateSetListener {
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ // Create a new instance of DatePickerDialog and return it
+ return new DatePickerDialog(getActivity(), this, mCallDateYear, mCallDateMonth,
+ mCallDateDay);
+ }
+
+ public void onDateSet(DatePicker view, int year, int month, int day) {
+ mCallDateYear = year;
+ mCallDateMonth = month;
+ mCallDateDay = day;
+ setDisplayDate();
+ }
+ }
+
+ /**
+ * OnClick handler for the button that adds a manual call log entry to the call log.
+ *
+ * @param v Calling view.
+ */
+ public void addManualEntry(View v) {
+ Calendar dateTime = Calendar.getInstance();
+ dateTime.set(mCallDateYear, mCallDateMonth, mCallDateDay, mCallTimeHour, mCallTimeMinute);
+
+ Calls.addCall(null, this, mPhoneNumber.getText().toString(), getManualPresentation(),
+ getManualCallType(), dateTime.getTimeInMillis(), RNG.nextInt(60 * 60));
+
+ // Subtract offset from the call date/time and store as new date/time
+ int offset = Integer.parseInt(mOffset.getText().toString());
+
+ dateTime.add(Calendar.MINUTE, offset);
+ mCallDateYear = dateTime.get(Calendar.YEAR);
+ mCallDateMonth = dateTime.get(Calendar.MONTH);
+ mCallDateDay = dateTime.get(Calendar.DAY_OF_MONTH);
+ mCallTimeHour = dateTime.get(Calendar.HOUR_OF_DAY);
+ mCallTimeMinute = dateTime.get(Calendar.MINUTE);
+ setDisplayDate();
+ setDisplayTime();
+ }
}
diff --git a/tests/src/com/android/dialer/widget/ActionBarControllerTest.java b/tests/src/com/android/dialer/widget/ActionBarControllerTest.java
new file mode 100644
index 000000000..c67ea35aa
--- /dev/null
+++ b/tests/src/com/android/dialer/widget/ActionBarControllerTest.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dialer.widget;
+
+import android.content.Context;
+import android.test.InstrumentationTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import com.android.dialer.widget.ActionBarController.ActivityUi;
+
+@SmallTest
+public class ActionBarControllerTest extends InstrumentationTestCase {
+
+ private static final int ACTION_BAR_HEIGHT = 100;
+ private ActionBarController mActionBarController;
+ private SearchEditTextLayout mSearchBox;
+ private MockActivityUi mActivityUi;
+
+ private class MockActivityUi implements ActivityUi {
+ boolean isInSearchUi;
+ boolean hasSearchQuery;
+ boolean shouldShowActionBar;
+ int actionBarHideOffset;
+
+ @Override
+ public boolean isInSearchUi() {
+ return isInSearchUi;
+ }
+
+ @Override
+ public boolean hasSearchQuery() {
+ return hasSearchQuery;
+ }
+
+ @Override
+ public boolean shouldShowActionBar() {
+ return shouldShowActionBar;
+ }
+
+ @Override
+ public int getActionBarHeight() {
+ return ACTION_BAR_HEIGHT;
+ }
+
+ @Override
+ public int getActionBarHideOffset() {
+ return actionBarHideOffset;
+ }
+
+ @Override
+ public void setActionBarHideOffset(int hideOffset) {
+ actionBarHideOffset = hideOffset;
+ }
+ }
+
+ /**
+ * Mock version of the searchbox, that updates its state immediately instead of animating
+ */
+ private class MockSearchBox extends SearchEditTextLayout {
+
+ public MockSearchBox(Context context) {
+ super(context, null);
+ }
+
+ @Override
+ public void expand(boolean animate, boolean requestFocus) {
+ mIsExpanded = true;
+ }
+
+ @Override
+ public void collapse(boolean animate) {
+ mIsExpanded = false;
+ }
+ }
+
+ @Override
+ protected void setUp() {
+ mActivityUi = new MockActivityUi();
+ mSearchBox = new MockSearchBox(this.getInstrumentation().getContext());
+ mActionBarController = new ActionBarController(mActivityUi, mSearchBox);
+ }
+
+ // Tapping the search box should only do something when the activity is not in the search UI
+ public void testSearchBoxTapped() {
+ mSearchBox.collapse(false);
+ mActivityUi.isInSearchUi = false;
+ mActionBarController.onSearchBoxTapped();
+ assertActionBarState(true, false, false);
+
+ // Collapse the search box manually again. This time tapping on the search box should not
+ // expand the search box because isInSearchUi is not true.
+ mSearchBox.collapse(false);
+ mActivityUi.isInSearchUi = true;
+ mActionBarController.onSearchBoxTapped();
+ assertActionBarState(false, false, false);
+ }
+
+ // The search box should always end up being faded in and collapsed. If necessary, it should
+ // be slid down or up depending on what the state of the action bar was before that.
+ public void testOnSearchUiExited() {
+ // ActionBar shown previously before entering searchUI
+ mSearchBox.expand(true, false);
+ mSearchBox.setVisible(false);
+ mActivityUi.shouldShowActionBar = true;
+ mActionBarController.onSearchUiExited();
+ assertActionBarState(false, false, false);
+
+ // ActionBar slid up previously before entering searchUI
+ mSearchBox.collapse(false);
+ mSearchBox.setVisible(false);
+ mActivityUi.shouldShowActionBar = false;
+ mActionBarController.onSearchUiExited();
+ assertActionBarState(false, false, true);
+ }
+
+ // Depending on what state the UI was in previously, sliding the dialpad down can mean either
+ // displaying the expanded search box by sliding it down, displaying the unexpanded search box,
+ // or nothing at all.
+ public void testOnDialpadDown() {
+ // No search query typed in the dialpad and action bar was showing before
+ mActivityUi.shouldShowActionBar = true;
+ mActivityUi.isInSearchUi = true;
+ mSearchBox.setVisible(false);
+ mActionBarController.onDialpadDown();
+ assertActionBarState(false, false, false);
+
+ // No search query typed in the dialpad, but action bar was not showing before
+ mActionBarController.slideActionBarUp(false);
+ mActivityUi.shouldShowActionBar = false;
+ mSearchBox.setVisible(false);
+ mActionBarController.onDialpadDown();
+ assertActionBarState(false, false, true);
+
+ // Something typed in the dialpad - so remain in search UI and slide the expanded search
+ // box down
+ mActionBarController.slideActionBarUp(false);
+ mActivityUi.shouldShowActionBar = true;
+ mActivityUi.hasSearchQuery= true;
+ mSearchBox.setVisible(false);
+ mSearchBox.expand(false, false);
+ mActionBarController.onDialpadDown();
+ assertActionBarState(true, false, false);
+ }
+
+ // Sliding the dialpad up should fade out the search box if we weren't already in search, or
+ // slide up the search box otherwise
+ public void testOnDialpadUp() {
+ mActivityUi.isInSearchUi = false;
+ mActionBarController.onDialpadUp();
+ assertActionBarState(false, true, false);
+
+ // In Search UI, with expanded search box and something currently typed in the search box
+ mActivityUi.isInSearchUi = true;
+ mActivityUi.hasSearchQuery = true;
+ mSearchBox.expand(true, false);
+ mSearchBox.setVisible(true);
+ mActionBarController.slideActionBarUp(false);
+ mActionBarController.onDialpadUp();
+ assertActionBarState(true, false, true);
+ }
+
+ private void assertActionBarState(boolean isExpanded, boolean isFadedOut, boolean isSlidUp) {
+ assertEquals(isExpanded, mSearchBox.isExpanded());
+ assertEquals(isFadedOut, mSearchBox.isFadedOut());
+ assertEquals(isSlidUp, mActionBarController.getIsActionBarSlidUp());
+ }
+}