summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJay Shrauner <shrauner@google.com>2015-08-29 11:34:25 -0700
committerJay Shrauner <shrauner@google.com>2015-08-29 11:50:25 -0700
commit3b1f640c9b2c0c98de0719af79fc02c022833883 (patch)
treed02a7a54475cbe7e5b28794259a1c85e982dba86 /tests
parent5c59ffa9423c49fe149719510dbc2bb3bed946fb (diff)
downloadandroid_packages_apps_ContactsCommon-3b1f640c9b2c0c98de0719af79fc02c022833883.tar.gz
android_packages_apps_ContactsCommon-3b1f640c9b2c0c98de0719af79fc02c022833883.tar.bz2
android_packages_apps_ContactsCommon-3b1f640c9b2c0c98de0719af79fc02c022833883.zip
Build fix
Use getInstrumentation().getTargetContext() to get test app context. Bug:23642167 Change-Id: I41d6ad5c2cdc2f0668d748b713ff899c8c56ebdc
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/contacts/common/model/account/AccountTypeTest.java7
-rw-r--r--tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java14
2 files changed, 11 insertions, 10 deletions
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 02f54463..8dc7df75 100644
--- a/tests/src/com/android/contacts/common/model/account/AccountTypeTest.java
+++ b/tests/src/com/android/contacts/common/model/account/AccountTypeTest.java
@@ -34,7 +34,7 @@ public class AccountTypeTest extends InstrumentationTestCase {
// In this test we use the test package itself as an external package.
final String packageName = getInstrumentation().getContext().getPackageName();
- final Context c = getContext();
+ final Context c = getInstrumentation().getTargetContext();
final String DEFAULT = "ABC";
// Package name null, resId -1, use the default
@@ -60,7 +60,7 @@ public class AccountTypeTest extends InstrumentationTestCase {
*/
public void testGetInviteContactActionLabel() {
final String packageName = getInstrumentation().getContext().getPackageName();
- final Context c = getContext();
+ final Context c = getInstrumentation().getTargetContext();
final int externalResID = R.string.test_string;
@@ -104,7 +104,8 @@ public class AccountTypeTest extends InstrumentationTestCase {
}
private int compareDisplayLabel(AccountType lhs, AccountType rhs) {
- return new AccountType.DisplayLabelComparator(getContext()).compare(lhs, rhs);
+ return new AccountType.DisplayLabelComparator(
+ getInstrumentation().getTargetContext()).compare(lhs, rhs);
}
private class AccountTypeForDisplayLabelTest extends AccountType {
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 60d9c4ab..932dddc0 100644
--- a/tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java
+++ b/tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java
@@ -47,7 +47,7 @@ import java.util.List;
@SmallTest
public class ExternalAccountTypeTest extends InstrumentationTestCase {
public void testResolveExternalResId() {
- final Context c = getContext();
+ final Context c = getInstrumentation().getTargetContext();
// In this test we use the test package itself as an external package.
final String packageName = getInstrumentation().getContext().getPackageName();
@@ -72,7 +72,7 @@ public class ExternalAccountTypeTest extends InstrumentationTestCase {
* Initialize with an invalid package name and see if type will be initialized, but empty.
*/
public void testNoPackage() {
- final ExternalAccountType type = new ExternalAccountType(getContext(),
+ final ExternalAccountType type = new ExternalAccountType(getInstrumentation().getTargetContext(),
"!!!no such package name!!!", false);
assertTrue(type.isInitialized());
}
@@ -81,7 +81,7 @@ public class ExternalAccountTypeTest extends InstrumentationTestCase {
* Initialize with the test package itself and see if EditSchema is correctly parsed.
*/
public void testEditSchema() {
- final ExternalAccountType type = new ExternalAccountType(getContext(),
+ final ExternalAccountType type = new ExternalAccountType(getInstrumentation().getTargetContext(),
getInstrumentation().getContext().getPackageName(), false);
assertTrue(type.isInitialized());
@@ -107,7 +107,7 @@ public class ExternalAccountTypeTest extends InstrumentationTestCase {
* {@link com.android.contacts.common.model.account.FallbackAccountType}.
*/
public void testEditSchema_fallback() {
- final ExternalAccountType type = new ExternalAccountType(getContext(),
+ final ExternalAccountType type = new ExternalAccountType(getInstrumentation().getTargetContext(),
getInstrumentation().getContext().getPackageName(), false,
getInstrumentation().getContext().getResources().getXml(R.xml.contacts_fallback)
);
@@ -117,7 +117,7 @@ public class ExternalAccountTypeTest extends InstrumentationTestCase {
// Create a fallback type with the same resource package name, and compare all the data
// kinds to its.
final AccountType reference = FallbackAccountType.createWithPackageNameForTest(
- getContext(), type.resourcePackageName);
+ getInstrumentation().getTargetContext(), type.resourcePackageName);
assertsDataKindEquals(reference.getSortedDataKinds(), type.getSortedDataKinds());
}
@@ -136,7 +136,7 @@ public class ExternalAccountTypeTest extends InstrumentationTestCase {
}
private void checkEditSchema_mustHaveChecks(int xmlResId, boolean expectInitialized) {
- final ExternalAccountType type = new ExternalAccountType(getContext(),
+ final ExternalAccountType type = new ExternalAccountType(getInstrumentation().getTargetContext(),
getInstrumentation().getContext().getPackageName(), false,
getInstrumentation().getContext().getResources().getXml(xmlResId)
);
@@ -148,7 +148,7 @@ public class ExternalAccountTypeTest extends InstrumentationTestCase {
* Initialize with "contacts_readonly.xml" and see if all data kinds are correctly registered.
*/
public void testReadOnlyDefinition() {
- final ExternalAccountType type = new ExternalAccountType(getContext(),
+ final ExternalAccountType type = new ExternalAccountType(getInstrumentation().getTargetContext(),
getInstrumentation().getContext().getPackageName(), false,
getInstrumentation().getContext().getResources().getXml(R.xml.contacts_readonly)
);