From fb0a934ad90f1855787563eb80f2c8fff7f640ac Mon Sep 17 00:00:00 2001 From: Chiao Cheng Date: Fri, 13 Sep 2013 17:27:42 -0700 Subject: Follow up on build break to fix unit tests. Change-Id: I82b7fa50601f6dad60038fd1b9c5f0aad2f374f5 --- .../android/dialer/PhoneCallDetailsHelperTest.java | 10 +++--- .../dialer/calllog/CallLogListItemHelperTest.java | 5 +-- .../dialer/calllog/TestPhoneNumberHelper.java | 33 -------------------- .../calllog/TestPhoneNumberUtilsWrapper.java | 36 ++++++++++++++++++++++ 4 files changed, 43 insertions(+), 41 deletions(-) delete mode 100644 tests/src/com/android/dialer/calllog/TestPhoneNumberHelper.java create mode 100644 tests/src/com/android/dialer/calllog/TestPhoneNumberUtilsWrapper.java (limited to 'tests/src') diff --git a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java index 05c59a77f..6a9817f26 100644 --- a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java +++ b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java @@ -26,8 +26,7 @@ import android.view.View; import android.widget.TextView; import com.android.dialer.calllog.CallTypeHelper; -import com.android.dialer.calllog.PhoneNumberHelper; -import com.android.dialer.calllog.TestPhoneNumberHelper; +import com.android.dialer.calllog.TestPhoneNumberUtilsWrapper; import com.android.dialer.util.LocaleTestUtils; import java.util.GregorianCalendar; @@ -58,7 +57,6 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { /** The views to fill. */ private PhoneCallDetailsViews mViews; private TextView mNameView; - private PhoneNumberHelper mPhoneNumberHelper; private LocaleTestUtils mLocaleTestUtils; @Override @@ -67,8 +65,9 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { Context context = getContext(); Resources resources = context.getResources(); CallTypeHelper callTypeHelper = new CallTypeHelper(resources); - mPhoneNumberHelper = new TestPhoneNumberHelper(resources, TEST_VOICEMAIL_NUMBER); - mHelper = new PhoneCallDetailsHelper(resources, callTypeHelper, mPhoneNumberHelper); + final TestPhoneNumberUtilsWrapper phoneUtils = new TestPhoneNumberUtilsWrapper( + TEST_VOICEMAIL_NUMBER); + mHelper = new PhoneCallDetailsHelper(resources, callTypeHelper, phoneUtils); mHelper.setCurrentTimeForTest( new GregorianCalendar(2011, 5, 4, 13, 0, 0).getTimeInMillis()); mViews = PhoneCallDetailsViews.createForTest(context); @@ -83,7 +82,6 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { mNameView = null; mViews = null; mHelper = null; - mPhoneNumberHelper = null; super.tearDown(); } diff --git a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java index 1b793bc65..bb940edca 100644 --- a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java +++ b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java @@ -57,9 +57,10 @@ public class CallLogListItemHelperTest extends AndroidTestCase { Context context = getContext(); Resources resources = context.getResources(); CallTypeHelper callTypeHelper = new CallTypeHelper(resources); - mPhoneNumberHelper = new TestPhoneNumberHelper(resources, TEST_VOICEMAIL_NUMBER); + final TestPhoneNumberUtilsWrapper phoneUtils = new TestPhoneNumberUtilsWrapper( + TEST_VOICEMAIL_NUMBER); PhoneCallDetailsHelper phoneCallDetailsHelper = new PhoneCallDetailsHelper( - resources, callTypeHelper, mPhoneNumberHelper); + resources, callTypeHelper, phoneUtils); mHelper = new CallLogListItemHelper(phoneCallDetailsHelper, mPhoneNumberHelper, resources); mViews = CallLogListItemViews.createForTest(context); } diff --git a/tests/src/com/android/dialer/calllog/TestPhoneNumberHelper.java b/tests/src/com/android/dialer/calllog/TestPhoneNumberHelper.java deleted file mode 100644 index 2671a7151..000000000 --- a/tests/src/com/android/dialer/calllog/TestPhoneNumberHelper.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2011 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.calllog; - -import android.content.res.Resources; - -/** - * Modified version of {@link PhoneNumberHelper} to be used in tests that allows injecting the - * voicemail number. - */ -public final class TestPhoneNumberHelper extends PhoneNumberHelper { - private CharSequence mVoicemailNumber; - - public TestPhoneNumberHelper(Resources resources, CharSequence voicemailNumber) { - super(resources); - mVoicemailNumber = voicemailNumber; - } - -} diff --git a/tests/src/com/android/dialer/calllog/TestPhoneNumberUtilsWrapper.java b/tests/src/com/android/dialer/calllog/TestPhoneNumberUtilsWrapper.java new file mode 100644 index 000000000..0dbd91479 --- /dev/null +++ b/tests/src/com/android/dialer/calllog/TestPhoneNumberUtilsWrapper.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2013 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.calllog; + +import android.content.res.Resources; + +/** + * Modified version of {@link com.android.dialer.calllog.PhoneNumberHelper} to be used in tests + * that allows injecting the voicemail number. + */ +public final class TestPhoneNumberUtilsWrapper extends PhoneNumberUtilsWrapper { + private CharSequence mVoicemailNumber; + + public TestPhoneNumberUtilsWrapper(CharSequence voicemailNumber) { + mVoicemailNumber = voicemailNumber; + } + + @Override + public boolean isVoicemailNumber(CharSequence number) { + return mVoicemailNumber.equals(number); + } +} -- cgit v1.2.3