Unbundled build fixes for tests
Build tests against current SDK. Make local copy of LaunchPerformanceBase.
Use android-support-test instead of android.test.runner. Use public APIs
for querying ContentProviderOperation type.
Bug:23642167
Change-Id: Id9798146801b1676b222bdd4d9240371f70c41d2
(cherry picked from commit b3a146cc554df8c9965c79af32f2b56fbce01ba0)
diff --git a/Android.mk b/Android.mk
index 52e1873..7bcfa61 100644
--- a/Android.mk
+++ b/Android.mk
@@ -41,6 +41,8 @@
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
+LOCAL_SDK_VERSION := current
+
include $(BUILD_PACKAGE)
# Use the following include to make our test apk.
diff --git a/TestCommon/Android.mk b/TestCommon/Android.mk
index c24a25b..b85584d 100644
--- a/TestCommon/Android.mk
+++ b/TestCommon/Android.mk
@@ -22,9 +22,12 @@
# vm as the packages to be tested. Otherwise you will get error
# "Class ref in pre-verified class resolved to unexpected implementation"
# when running the unit tests.
-LOCAL_JAVA_LIBRARIES := guava android.test.runner
+LOCAL_JAVA_LIBRARIES := guava android-support-test
LOCAL_INSTRUMENTATION_FOR := com.android.contacts.common
LOCAL_MODULE := com.android.contacts.common.test
+
+LOCAL_SDK_VERSION := current
+
include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/TestCommon/src/com/android/contacts/common/test/LaunchPerformanceBase.java b/TestCommon/src/com/android/contacts/common/test/LaunchPerformanceBase.java
new file mode 100644
index 0000000..a2ebde3
--- /dev/null
+++ b/TestCommon/src/com/android/contacts/common/test/LaunchPerformanceBase.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2007 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.contacts.common.test;
+
+import android.app.Instrumentation;
+import android.content.Intent;
+import android.os.Bundle;
+
+
+/**
+ * Base class for all launch performance Instrumentation classes.
+ */
+public class LaunchPerformanceBase extends Instrumentation {
+
+ public static final String LOG_TAG = "Launch Performance";
+
+ protected Bundle mResults;
+ protected Intent mIntent;
+
+ public LaunchPerformanceBase() {
+ mResults = new Bundle();
+ mIntent = new Intent(Intent.ACTION_MAIN);
+ mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ setAutomaticPerformanceSnapshots();
+ }
+
+ /**
+ * Launches intent, and waits for idle before returning.
+ *
+ * @hide
+ */
+ protected void LaunchApp() {
+ startActivitySync(mIntent);
+ waitForIdleSync();
+ }
+}
diff --git a/tests/Android.mk b/tests/Android.mk
index d18e2a6..32bb06a 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -4,8 +4,9 @@
# We only want this apk build for tests.
LOCAL_MODULE_TAGS := tests
-LOCAL_JAVA_LIBRARIES := android.test.runner
-LOCAL_STATIC_JAVA_LIBRARIES := com.android.contacts.common.test
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android-support-test \
+ com.android.contacts.common.test
# Include all test java files.
LOCAL_SRC_FILES := $(call all-java-files-under, src)
@@ -14,4 +15,6 @@
LOCAL_INSTRUMENTATION_FOR := com.android.contacts.common
+LOCAL_SDK_VERSION := current
+
include $(BUILD_PACKAGE)
diff --git a/tests/src/com/android/contacts/common/RawContactDeltaListTests.java b/tests/src/com/android/contacts/common/RawContactDeltaListTests.java
index 7f05e69..ebbddab 100644
--- a/tests/src/com/android/contacts/common/RawContactDeltaListTests.java
+++ b/tests/src/com/android/contacts/common/RawContactDeltaListTests.java
@@ -16,11 +16,6 @@
package com.android.contacts.common;
-import static android.content.ContentProviderOperation.TYPE_ASSERT;
-import static android.content.ContentProviderOperation.TYPE_DELETE;
-import static android.content.ContentProviderOperation.TYPE_INSERT;
-import static android.content.ContentProviderOperation.TYPE_UPDATE;
-
import android.content.ContentProviderOperation;
import android.content.ContentValues;
import android.content.Context;
@@ -56,6 +51,12 @@
public class RawContactDeltaListTests extends AndroidTestCase {
public static final String TAG = RawContactDeltaListTests.class.getSimpleName();
+ // From android.content.ContentProviderOperation
+ public static final int TYPE_INSERT = 1;
+ public static final int TYPE_UPDATE = 2;
+ public static final int TYPE_DELETE = 3;
+ public static final int TYPE_ASSERT = 4;
+
private static final long CONTACT_FIRST = 1;
private static final long CONTACT_SECOND = 2;
@@ -195,11 +196,11 @@
assertEquals("Unexpected uri", expected.getUri(), found.getUri());
- final String expectedType = getStringForType(expected.getType());
- final String foundType = getStringForType(found.getType());
+ final String expectedType = getTypeString(expected);
+ final String foundType = getTypeString(found);
assertEquals("Unexpected type", expectedType, foundType);
- if (expected.getType() == TYPE_DELETE) continue;
+ if (expected.isDelete()) continue;
try {
final ContentValues expectedValues = getValues(expected);
@@ -217,14 +218,17 @@
}
}
- static String getStringForType(int type) {
- switch (type) {
- case TYPE_ASSERT: return "TYPE_ASSERT";
- case TYPE_INSERT: return "TYPE_INSERT";
- case TYPE_UPDATE: return "TYPE_UPDATE";
- case TYPE_DELETE: return "TYPE_DELETE";
- default: return Integer.toString(type);
+ static String getTypeString(ContentProviderOperation op) {
+ if (op.isAssertQuery()) {
+ return "TYPE_ASSERT";
+ } else if (op.isInsert()) {
+ return "TYPE_INSERT";
+ } else if (op.isUpdate()) {
+ return "TYPE_UPDATE";
+ } else if (op.isDelete()) {
+ return "TYPE_DELETE";
}
+ return "TYPE_UNKNOWN";
}
static ContentProviderOperation buildAssertVersion(long version) {
@@ -294,7 +298,7 @@
int updateCount = 0;
for (ContentProviderOperation oper : diff) {
if (AggregationExceptions.CONTENT_URI.equals(oper.getUri())
- && oper.getType() == ContentProviderOperation.TYPE_UPDATE) {
+ && oper.isUpdate()) {
updateCount++;
}
}
diff --git a/tests/src/com/android/contacts/common/RawContactDeltaTests.java b/tests/src/com/android/contacts/common/RawContactDeltaTests.java
index 8fc3052..3597524 100644
--- a/tests/src/com/android/contacts/common/RawContactDeltaTests.java
+++ b/tests/src/com/android/contacts/common/RawContactDeltaTests.java
@@ -16,11 +16,6 @@
package com.android.contacts.common;
-import static android.content.ContentProviderOperation.TYPE_ASSERT;
-import static android.content.ContentProviderOperation.TYPE_DELETE;
-import static android.content.ContentProviderOperation.TYPE_INSERT;
-import static android.content.ContentProviderOperation.TYPE_UPDATE;
-
import android.content.ContentProviderOperation;
import android.content.ContentProviderOperation.Builder;
import android.content.ContentValues;
@@ -153,8 +148,8 @@
// Should produce a delete action
final Builder builder = values.buildDiff(Data.CONTENT_URI);
- final int type = builder.build().getType();
- assertEquals("Didn't produce delete action", TYPE_DELETE, type);
+ final boolean isDelete = builder.build().isDelete();
+ assertTrue("Didn't produce delete action", isDelete);
}
/**
@@ -191,21 +186,21 @@
assertEquals("Unexpected operations", 4, diff.size());
{
final ContentProviderOperation oper = diff.get(0);
- assertEquals("Expected version enforcement", TYPE_ASSERT, oper.getType());
+ assertTrue("Expected version enforcement", oper.isAssertQuery());
}
{
final ContentProviderOperation oper = diff.get(1);
- assertEquals("Expected aggregation mode change", TYPE_UPDATE, oper.getType());
+ assertTrue("Expected aggregation mode change", oper.isUpdate());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
{
final ContentProviderOperation oper = diff.get(2);
- assertEquals("Incorrect type", TYPE_INSERT, oper.getType());
+ assertTrue("Incorrect type", oper.isInsert());
assertEquals("Incorrect target", Data.CONTENT_URI, oper.getUri());
}
{
final ContentProviderOperation oper = diff.get(3);
- assertEquals("Expected aggregation mode change", TYPE_UPDATE, oper.getType());
+ assertTrue("Expected aggregation mode change", oper.isUpdate());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
}
@@ -231,26 +226,26 @@
assertEquals("Unexpected operations", 5, diff.size());
{
final ContentProviderOperation oper = diff.get(0);
- assertEquals("Expected version enforcement", TYPE_ASSERT, oper.getType());
+ assertTrue("Expected version enforcement", oper.isAssertQuery());
}
{
final ContentProviderOperation oper = diff.get(1);
- assertEquals("Expected aggregation mode change", TYPE_UPDATE, oper.getType());
+ assertTrue("Expected aggregation mode change", oper.isUpdate());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
{
final ContentProviderOperation oper = diff.get(2);
- assertEquals("Incorrect type", TYPE_UPDATE, oper.getType());
+ assertTrue("Incorrect type", oper.isUpdate());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
{
final ContentProviderOperation oper = diff.get(3);
- assertEquals("Incorrect type", TYPE_INSERT, oper.getType());
+ assertTrue("Incorrect type", oper.isInsert());
assertEquals("Incorrect target", Data.CONTENT_URI, oper.getUri());
}
{
final ContentProviderOperation oper = diff.get(4);
- assertEquals("Expected aggregation mode change", TYPE_UPDATE, oper.getType());
+ assertTrue("Expected aggregation mode change", oper.isUpdate());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
}
@@ -270,21 +265,21 @@
assertEquals("Unexpected operations", 4, diff.size());
{
final ContentProviderOperation oper = diff.get(0);
- assertEquals("Expected version enforcement", TYPE_ASSERT, oper.getType());
+ assertTrue("Expected version enforcement", oper.isAssertQuery());
}
{
final ContentProviderOperation oper = diff.get(1);
- assertEquals("Expected aggregation mode change", TYPE_UPDATE, oper.getType());
+ assertTrue("Expected aggregation mode change", oper.isUpdate());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
{
final ContentProviderOperation oper = diff.get(2);
- assertEquals("Incorrect type", TYPE_UPDATE, oper.getType());
+ assertTrue("Incorrect type", oper.isUpdate());
assertEquals("Incorrect target", Data.CONTENT_URI, oper.getUri());
}
{
final ContentProviderOperation oper = diff.get(3);
- assertEquals("Expected aggregation mode change", TYPE_UPDATE, oper.getType());
+ assertTrue("Expected aggregation mode change", oper.isUpdate());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
}
@@ -303,11 +298,11 @@
assertEquals("Unexpected operations", 2, diff.size());
{
final ContentProviderOperation oper = diff.get(0);
- assertEquals("Expected version enforcement", TYPE_ASSERT, oper.getType());
+ assertTrue("Expected version enforcement", oper.isAssertQuery());
}
{
final ContentProviderOperation oper = diff.get(1);
- assertEquals("Incorrect type", TYPE_DELETE, oper.getType());
+ assertTrue("Incorrect type", oper.isDelete());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
}
@@ -328,7 +323,7 @@
assertEquals("Unexpected operations", 2, diff.size());
{
final ContentProviderOperation oper = diff.get(0);
- assertEquals("Incorrect type", TYPE_INSERT, oper.getType());
+ assertTrue("Incorrect type", oper.isInsert());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
}
@@ -356,12 +351,12 @@
assertEquals("Unexpected operations", 3, diff.size());
{
final ContentProviderOperation oper = diff.get(0);
- assertEquals("Incorrect type", TYPE_INSERT, oper.getType());
+ assertTrue("Incorrect type", oper.isInsert());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
{
final ContentProviderOperation oper = diff.get(1);
- assertEquals("Incorrect type", TYPE_INSERT, oper.getType());
+ assertTrue("Incorrect type", oper.isInsert());
assertEquals("Incorrect target", Data.CONTENT_URI, oper.getUri());
}
diff --git a/tests/src/com/android/contacts/common/RawContactModifierTests.java b/tests/src/com/android/contacts/common/RawContactModifierTests.java
index 2e972cf..e025691 100644
--- a/tests/src/com/android/contacts/common/RawContactModifierTests.java
+++ b/tests/src/com/android/contacts/common/RawContactModifierTests.java
@@ -16,10 +16,6 @@
package com.android.contacts.common;
-import static android.content.ContentProviderOperation.TYPE_DELETE;
-import static android.content.ContentProviderOperation.TYPE_INSERT;
-import static android.content.ContentProviderOperation.TYPE_UPDATE;
-
import android.content.ContentProviderOperation;
import android.content.ContentValues;
import android.net.Uri;
@@ -65,6 +61,9 @@
public class RawContactModifierTests extends AndroidTestCase {
public static final String TAG = "EntityModifierTests";
+ // From android.content.ContentProviderOperation
+ public static final int TYPE_INSERT = 1;
+
public static final long VER_FIRST = 100;
private static final long TEST_ID = 4;
@@ -356,17 +355,17 @@
assertEquals("Unexpected operations", 3, diff.size());
{
final ContentProviderOperation oper = diff.get(0);
- assertEquals("Expected aggregation mode change", TYPE_UPDATE, oper.getType());
+ assertTrue("Expected aggregation mode change", oper.isUpdate());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
{
final ContentProviderOperation oper = diff.get(1);
- assertEquals("Incorrect type", TYPE_INSERT, oper.getType());
+ assertTrue("Incorrect type", oper.isInsert());
assertEquals("Incorrect target", Data.CONTENT_URI, oper.getUri());
}
{
final ContentProviderOperation oper = diff.get(2);
- assertEquals("Expected aggregation mode change", TYPE_UPDATE, oper.getType());
+ assertTrue("Expected aggregation mode change", oper.isUpdate());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
@@ -377,7 +376,7 @@
assertEquals("Unexpected operations", 1, diff.size());
{
final ContentProviderOperation oper = diff.get(0);
- assertEquals("Incorrect type", TYPE_DELETE, oper.getType());
+ assertTrue("Incorrect type", oper.isDelete());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
}
@@ -487,17 +486,17 @@
assertEquals("Unexpected operations", 3, diff.size());
{
final ContentProviderOperation oper = diff.get(0);
- assertEquals("Expected aggregation mode change", TYPE_UPDATE, oper.getType());
+ assertTrue("Expected aggregation mode change", oper.isUpdate());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
{
final ContentProviderOperation oper = diff.get(1);
- assertEquals("Incorrect type", TYPE_UPDATE, oper.getType());
+ assertTrue("Incorrect type", oper.isUpdate());
assertEquals("Incorrect target", Data.CONTENT_URI, oper.getUri());
}
{
final ContentProviderOperation oper = diff.get(2);
- assertEquals("Expected aggregation mode change", TYPE_UPDATE, oper.getType());
+ assertTrue("Expected aggregation mode change", oper.isUpdate());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
@@ -508,7 +507,7 @@
assertEquals("Unexpected operations", 1, diff.size());
{
final ContentProviderOperation oper = diff.get(0);
- assertEquals("Incorrect type", TYPE_DELETE, oper.getType());
+ assertTrue("Incorrect type", oper.isDelete());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
}
@@ -531,7 +530,7 @@
assertEquals("Unexpected operations", 2, diff.size());
{
final ContentProviderOperation oper = diff.get(0);
- assertEquals("Incorrect type", TYPE_INSERT, oper.getType());
+ assertTrue("Incorrect type", oper.isInsert());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
@@ -560,12 +559,12 @@
assertEquals("Unexpected operations", 3, diff.size());
{
final ContentProviderOperation oper = diff.get(0);
- assertEquals("Incorrect type", TYPE_INSERT, oper.getType());
+ assertTrue("Incorrect type", oper.isInsert());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
{
final ContentProviderOperation oper = diff.get(1);
- assertEquals("Incorrect type", TYPE_INSERT, oper.getType());
+ assertTrue("Incorrect type", oper.isInsert());
assertEquals("Incorrect target", Data.CONTENT_URI, oper.getUri());
}
@@ -612,17 +611,17 @@
assertEquals("Unexpected operations", 3, diff.size());
{
final ContentProviderOperation oper = diff.get(0);
- assertEquals("Expected aggregation mode change", TYPE_UPDATE, oper.getType());
+ assertTrue("Expected aggregation mode change", oper.isUpdate());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
{
final ContentProviderOperation oper = diff.get(1);
- assertEquals("Incorrect type", TYPE_UPDATE, oper.getType());
+ assertTrue("Incorrect type", oper.isUpdate());
assertEquals("Incorrect target", Data.CONTENT_URI, oper.getUri());
}
{
final ContentProviderOperation oper = diff.get(2);
- assertEquals("Expected aggregation mode change", TYPE_UPDATE, oper.getType());
+ assertTrue("Expected aggregation mode change", oper.isUpdate());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
@@ -633,17 +632,17 @@
assertEquals("Unexpected operations", 3, diff.size());
{
final ContentProviderOperation oper = diff.get(0);
- assertEquals("Expected aggregation mode change", TYPE_UPDATE, oper.getType());
+ assertTrue("Expected aggregation mode change", oper.isUpdate());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
{
final ContentProviderOperation oper = diff.get(1);
- assertEquals("Incorrect type", TYPE_DELETE, oper.getType());
+ assertTrue("Incorrect type", oper.isDelete());
assertEquals("Incorrect target", Data.CONTENT_URI, oper.getUri());
}
{
final ContentProviderOperation oper = diff.get(2);
- assertEquals("Expected aggregation mode change", TYPE_UPDATE, oper.getType());
+ assertTrue("Expected aggregation mode change", oper.isUpdate());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
}
@@ -678,17 +677,17 @@
assertEquals("Unexpected operations", 3, diff.size());
{
final ContentProviderOperation oper = diff.get(0);
- assertEquals("Expected aggregation mode change", TYPE_UPDATE, oper.getType());
+ assertTrue("Expected aggregation mode change", oper.isUpdate());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
{
final ContentProviderOperation oper = diff.get(1);
- assertEquals("Incorrect type", TYPE_UPDATE, oper.getType());
+ assertTrue("Incorrect type", oper.isUpdate());
assertEquals("Incorrect target", Data.CONTENT_URI, oper.getUri());
}
{
final ContentProviderOperation oper = diff.get(2);
- assertEquals("Expected aggregation mode change", TYPE_UPDATE, oper.getType());
+ assertTrue("Expected aggregation mode change", oper.isUpdate());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
@@ -699,7 +698,7 @@
assertEquals("Unexpected operations", 1, diff.size());
{
final ContentProviderOperation oper = diff.get(0);
- assertEquals("Incorrect type", TYPE_DELETE, oper.getType());
+ assertTrue("Incorrect type", oper.isDelete());
assertEquals("Incorrect target", RawContacts.CONTENT_URI, oper.getUri());
}
}
diff --git a/tests/src/com/android/contacts/common/model/ValuesDeltaTests.java b/tests/src/com/android/contacts/common/model/ValuesDeltaTests.java
index ca828dc..c5297a9 100644
--- a/tests/src/com/android/contacts/common/model/ValuesDeltaTests.java
+++ b/tests/src/com/android/contacts/common/model/ValuesDeltaTests.java
@@ -16,9 +16,6 @@
package com.android.contacts.common.model;
-import static android.content.ContentProviderOperation.TYPE_INSERT;
-import static android.content.ContentProviderOperation.TYPE_UPDATE;
-
import android.content.ContentProviderOperation.Builder;
import android.content.ContentValues;
import android.provider.ContactsContract.CommonDataKinds.Phone;
@@ -48,8 +45,8 @@
// Should produce an insert action
final Builder builder = values.buildDiff(Data.CONTENT_URI);
- final int type = builder.build().getType();
- assertEquals("Didn't produce insert action", TYPE_INSERT, type);
+ final boolean isInsert = builder.build().isInsert();
+ assertTrue("Didn't produce insert action", isInsert);
}
/**
@@ -79,7 +76,7 @@
// Should produce an update action
final Builder builder = values.buildDiff(Data.CONTENT_URI);
- final int type = builder.build().getType();
- assertEquals("Didn't produce update action", TYPE_UPDATE, type);
+ final boolean isUpdate = builder.build().isUpdate();
+ assertTrue("Didn't produce update action", isUpdate);
}
}
diff --git a/tests/src/com/android/contacts/common/model/account/AccountTypeTest.java b/tests/src/com/android/contacts/common/model/account/AccountTypeTest.java
index 4374ad3..02f5446 100644
--- a/tests/src/com/android/contacts/common/model/account/AccountTypeTest.java
+++ b/tests/src/com/android/contacts/common/model/account/AccountTypeTest.java
@@ -17,7 +17,7 @@
package com.android.contacts.common.model.account;
import android.content.Context;
-import android.test.AndroidTestCase;
+import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import com.android.contacts.common.unittest.R;
@@ -29,10 +29,10 @@
com.android.contacts.tests/android.test.InstrumentationTestRunner
*/
@SmallTest
-public class AccountTypeTest extends AndroidTestCase {
+public class AccountTypeTest extends InstrumentationTestCase {
public void testGetResourceText() {
// In this test we use the test package itself as an external package.
- final String packageName = getTestContext().getPackageName();
+ final String packageName = getInstrumentation().getContext().getPackageName();
final Context c = getContext();
final String DEFAULT = "ABC";
@@ -45,7 +45,7 @@
// Load from an external package. (here, we use this test package itself)
final int externalResID = R.string.test_string;
- assertEquals(getTestContext().getString(externalResID),
+ assertEquals(getInstrumentation().getContext().getString(externalResID),
AccountType.getResourceText(c, packageName, externalResID, DEFAULT));
// Load from the contacts package itself.
@@ -59,7 +59,7 @@
* from {@link AccountType#getInviteContactActionResId}
*/
public void testGetInviteContactActionLabel() {
- final String packageName = getTestContext().getPackageName();
+ final String packageName = getInstrumentation().getContext().getPackageName();
final Context c = getContext();
final int externalResID = R.string.test_string;
@@ -82,7 +82,7 @@
}
};
- assertEquals(getTestContext().getString(externalResID),
+ assertEquals(getInstrumentation().getContext().getString(externalResID),
accountType.getInviteContactActionLabel(c));
}
diff --git a/tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java b/tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java
index d508e0f..60d9c4a 100644
--- a/tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java
+++ b/tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java
@@ -28,7 +28,7 @@
import android.provider.ContactsContract.CommonDataKinds.StructuredName;
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
import android.provider.ContactsContract.CommonDataKinds.Website;
-import android.test.AndroidTestCase;
+import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import android.util.Log;
@@ -45,11 +45,11 @@
com.android.contacts.tests/android.test.InstrumentationTestRunner
*/
@SmallTest
-public class ExternalAccountTypeTest extends AndroidTestCase {
+public class ExternalAccountTypeTest extends InstrumentationTestCase {
public void testResolveExternalResId() {
final Context c = getContext();
// In this test we use the test package itself as an external package.
- final String packageName = getTestContext().getPackageName();
+ final String packageName = getInstrumentation().getContext().getPackageName();
// Resource name empty.
assertEquals(-1, ExternalAccountType.resolveExternalResId(c, null, packageName, ""));
@@ -82,7 +82,7 @@
*/
public void testEditSchema() {
final ExternalAccountType type = new ExternalAccountType(getContext(),
- getTestContext().getPackageName(), false);
+ getInstrumentation().getContext().getPackageName(), false);
assertTrue(type.isInitialized());
@@ -108,8 +108,8 @@
*/
public void testEditSchema_fallback() {
final ExternalAccountType type = new ExternalAccountType(getContext(),
- getTestContext().getPackageName(), false,
- getTestContext().getResources().getXml(R.xml.contacts_fallback)
+ getInstrumentation().getContext().getPackageName(), false,
+ getInstrumentation().getContext().getResources().getXml(R.xml.contacts_fallback)
);
assertTrue(type.isInitialized());
@@ -137,8 +137,8 @@
private void checkEditSchema_mustHaveChecks(int xmlResId, boolean expectInitialized) {
final ExternalAccountType type = new ExternalAccountType(getContext(),
- getTestContext().getPackageName(), false,
- getTestContext().getResources().getXml(xmlResId)
+ getInstrumentation().getContext().getPackageName(), false,
+ getInstrumentation().getContext().getResources().getXml(xmlResId)
);
assertEquals(expectInitialized, type.isInitialized());
@@ -149,8 +149,8 @@
*/
public void testReadOnlyDefinition() {
final ExternalAccountType type = new ExternalAccountType(getContext(),
- getTestContext().getPackageName(), false,
- getTestContext().getResources().getXml(R.xml.contacts_readonly)
+ getInstrumentation().getContext().getPackageName(), false,
+ getInstrumentation().getContext().getResources().getXml(R.xml.contacts_readonly)
);
assertTrue(type.isInitialized());