Fix broken tests and remove dead code

Change-Id: I3ae31c604c86641622f997915dc7d86bf2c662a2
This commit is contained in:
Tony Mantler 2014-03-18 13:57:11 -07:00
parent 571a96c755
commit 452744474a
4 changed files with 6 additions and 43 deletions

View File

@ -66,26 +66,6 @@ public class UiUtilities {
}
}
/** Generics version of {@link Activity#findViewById} */
@SuppressWarnings("unchecked")
public static <T extends View> T getViewOrNull(Activity parent, int viewId) {
return (T) parent.findViewById(viewId);
}
/** Generics version of {@link View#findViewById} */
@SuppressWarnings("unchecked")
public static <T extends View> T getViewOrNull(View parent, int viewId) {
return (T) parent.findViewById(viewId);
}
/**
* Same as {@link Activity#findViewById}, but crashes if there's no view.
*/
@SuppressWarnings("unchecked")
public static <T extends View> T getView(Activity parent, int viewId) {
return (T) checkView(parent.findViewById(viewId));
}
/**
* Same as {@link View#findViewById}, but crashes if there's no view.
*/

View File

@ -68,27 +68,6 @@ public class UiUtilitiesTests extends AndroidTestCase {
assertEquals(moreThan999, UiUtilities.getMessageCountForUi(c, 1001, false));
}
public void testGetView() {
// Test for getView(Activity, int)
DummyActivity a = new DummyActivity();
DummyView v = new DummyView(getContext());
a.mDummyViewId = 10;
a.mDummyView = v;
assertEquals(v, UiUtilities.getView(a, 10));
try {
assertEquals(v, UiUtilities.getView(a, 11));
fail();
} catch (IllegalArgumentException expected) {
}
// TODO Test for getView(View, int)?
// Unfortunately View.findViewById is final, so can't use the same approach.
// Also it's a huge pain to set up an actual, nested views in unit tests, so let's leave
// it for now.
}
public void brokentestSetVisibilitySafe() {
{
DummyView v = new DummyView(getContext());

View File

@ -22,6 +22,7 @@ import android.test.ActivityInstrumentationTestCase2;
import android.test.UiThreadTest;
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.Suppress;
import android.view.View;
import android.widget.EditText;
import com.android.email.R;
@ -64,7 +65,8 @@ public class AccountSetupIncomingTests extends
}
private boolean isNextButtonEnabled() {
return mActivity.mNextButton.isEnabled();
final View nextButton = mActivity.findViewById(R.id.next);
return nextButton.isEnabled();
}
/**

View File

@ -21,6 +21,7 @@ import android.content.Intent;
import android.test.ActivityInstrumentationTestCase2;
import android.test.UiThreadTest;
import android.test.suitebuilder.annotation.MediumTest;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
@ -63,7 +64,8 @@ public class AccountSetupOutgoingTests extends
}
private boolean isNextButtonEnabled() {
return mActivity.mNextButton.isEnabled();
final View nextButton = mActivity.findViewById(R.id.next);
return nextButton.isEnabled();
}
/**