diff options
author | Chiao Cheng <chiaocheng@google.com> | 2012-11-13 18:38:56 -0800 |
---|---|---|
committer | Chiao Cheng <chiaocheng@google.com> | 2012-11-13 18:38:56 -0800 |
commit | 428f008513d1591cc08fcfe2cf0c9237fb313241 (patch) | |
tree | 91d7e0ec7e18d839191f00046dc46627db51d95f /tests | |
parent | e776d0366d5bf2f93a0cd0f14e48804e564bccf2 (diff) | |
download | packages_apps_Contacts-428f008513d1591cc08fcfe2cf0c9237fb313241.tar.gz packages_apps_Contacts-428f008513d1591cc08fcfe2cf0c9237fb313241.tar.bz2 packages_apps_Contacts-428f008513d1591cc08fcfe2cf0c9237fb313241.zip |
Move dependencies of AccountTypeManager into ContactsCommon.
Moving dependencies in preparation to move AccountTypeManager.
Bug: 6993891
Change-Id: I804cdbe64b9b8111ed286037943d593e11dc4044
Diffstat (limited to 'tests')
34 files changed, 40 insertions, 1681 deletions
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml index a3dacbe87..7a7df01e8 100644 --- a/tests/AndroidManifest.xml +++ b/tests/AndroidManifest.xml @@ -103,18 +103,6 @@ android:resource="@xml/test_basic_authenticator" /> </service> - <service android:name=".testauth.TestSyncService$Basic" android:exported="true"> - <intent-filter> - <action android:name="android.content.SyncAdapter" /> - </intent-filter> - <meta-data - android:name="android.content.SyncAdapter" - android:resource="@xml/test_basic_syncadapter" /> - <meta-data - android:name="android.provider.CONTACTS_STRUCTURE" - android:resource="@xml/test_basic_contacts" /> - </service> - <service android:name=".QueryService" /> <service android:name=".PhoneNumberTestService" /> </application> diff --git a/tests/res/values/donottranslate_strings.xml b/tests/res/values/donottranslate_strings.xml index dc8bf2ff6..b3f3ee7da 100644 --- a/tests/res/values/donottranslate_strings.xml +++ b/tests/res/values/donottranslate_strings.xml @@ -17,7 +17,6 @@ <string name="contactsIntents">Contacts Intents</string> <string name="result">Result returned by activity</string> - <string name="test_string">TEST STRING</string> <string-array name="allIntents"> <!-- List modes --> diff --git a/tests/res/xml/contacts_fallback.xml b/tests/res/xml/contacts_fallback.xml deleted file mode 100644 index ae262eba7..000000000 --- a/tests/res/xml/contacts_fallback.xml +++ /dev/null @@ -1,96 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * 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. - */ ---> - -<!-- - contacts.xml to build "fallback account type" equivalent. - This is directly used in ExternalAccountTypeTest to test the parser. There's no sync adapter - that actually defined with this definition. ---> - -<ContactsAccountType - xmlns:android="http://schemas.android.com/apk/res/android" - > - <EditSchema - > - <DataKind kind="name" - maxOccurs="1" - supportsDisplayName="true" - supportsPrefix="true" - supportsMiddleName="true" - supportsSuffix="true" - supportsPhoneticFamilyName="true" - supportsPhoneticMiddleName="true" - supportsPhoneticGivenName="true" - > - </DataKind> - <DataKind kind="photo" maxOccurs="1" /> - <DataKind kind="phone" > - <Type type="mobile" /> - <Type type="home" /> - <Type type="work" /> - <Type type="fax_work" /> - <Type type="fax_home" /> - <Type type="pager" /> - <Type type="other" /> - <Type type="custom"/> - <Type type="callback" /> - <Type type="car" /> - <Type type="company_main" /> - <Type type="isdn" /> - <Type type="main" /> - <Type type="other_fax" /> - <Type type="radio" /> - <Type type="telex" /> - <Type type="tty_tdd" /> - <Type type="work_mobile"/> - <Type type="work_pager" /> - <Type type="assistant" /> - <Type type="mms" /> - </DataKind> - <DataKind kind="email" > - <Type type="home" /> - <Type type="work" /> - <Type type="other" /> - <Type type="mobile" /> - <Type type="custom" /> - </DataKind> - <DataKind kind="nickname" maxOccurs="1" /> - <DataKind kind="im" > - <Type type="aim" /> - <Type type="msn" /> - <Type type="yahoo" /> - <Type type="skype" /> - <Type type="qq" /> - <Type type="google_talk" /> - <Type type="icq" /> - <Type type="jabber" /> - <Type type="custom" /> - </DataKind> - <DataKind kind="postal" needsStructured="false" > - <Type type="home" /> - <Type type="work" /> - <Type type="other" /> - <Type type="custom" /> - </DataKind> - <DataKind kind="organization" maxOccurs="1" /> - <DataKind kind="website" /> - <DataKind kind="sip_address" maxOccurs="1" /> - <DataKind kind="note" maxOccurs="1" /> - </EditSchema> -</ContactsAccountType> diff --git a/tests/res/xml/contacts_readonly.xml b/tests/res/xml/contacts_readonly.xml deleted file mode 100644 index df8d9c06e..000000000 --- a/tests/res/xml/contacts_readonly.xml +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * 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. - */ ---> - -<!-- - Contacts.xml without EditSchema. ---> - -<ContactsAccountType - xmlns:android="http://schemas.android.com/apk/res/android" - > - <ContactsDataKind - android:icon="@drawable/android" - android:mimeType="vnd.android.cursor.item/a.b.c" - android:summaryColumn="data1" - android:detailColumn="data2" - android:detailSocialSummary="true" - > - </ContactsDataKind> - <ContactsDataKind - android:icon="@drawable/default_icon" - android:mimeType="vnd.android.cursor.item/d.e.f" - android:summaryColumn="data3" - android:detailColumn="data4" - android:detailSocialSummary="false" - > - </ContactsDataKind> - <ContactsDataKind - android:icon="@drawable/android" - android:mimeType="vnd.android.cursor.item/xyz" - android:summaryColumn="data5" - android:detailColumn="data6" - android:detailSocialSummary="true" - > - </ContactsDataKind> -</ContactsAccountType> diff --git a/tests/res/xml/iconset.xml b/tests/res/xml/iconset.xml index d1207e798..b9e419dd9 100644 --- a/tests/res/xml/iconset.xml +++ b/tests/res/xml/iconset.xml @@ -1,24 +1,25 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2009 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. ---> +<!-- + ~ Copyright (C) 2012 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 + --> <icon-set xmlns:android="http://schemas.android.com/apk/res/android"> <icon-default android:icon="@drawable/default_icon" /> - <icon android:mimeType="vnd.android.cursor.item/phone" + <icon android:mimeType="vnd.android.cursor.item/phone" android:icon="@drawable/phone_icon" /> -</icon-set>
\ No newline at end of file +</icon-set> diff --git a/tests/res/xml/missing_contacts_base.xml b/tests/res/xml/missing_contacts_base.xml deleted file mode 100644 index 2c9aa6dbc..000000000 --- a/tests/res/xml/missing_contacts_base.xml +++ /dev/null @@ -1,39 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * 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. - */ ---> - -<!-- XML for must-have checks. Base definition, which is valid. --> - -<ContactsAccountType - xmlns:android="http://schemas.android.com/apk/res/android" - > - <EditSchema> - <DataKind kind="name" - maxOccurs="1" - supportsDisplayName="true" - supportsPrefix="true" - supportsMiddleName="true" - supportsSuffix="true" - supportsPhoneticFamilyName="true" - supportsPhoneticMiddleName="true" - supportsPhoneticGivenName="true" - > - </DataKind> - <DataKind kind="photo" maxOccurs="1" /> - </EditSchema> -</ContactsAccountType> diff --git a/tests/res/xml/missing_contacts_name.xml b/tests/res/xml/missing_contacts_name.xml deleted file mode 100644 index 1ac26be33..000000000 --- a/tests/res/xml/missing_contacts_name.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * 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. - */ ---> - -<!-- XML for must-have checks. Missing "name" kind. --> - -<ContactsAccountType - xmlns:android="http://schemas.android.com/apk/res/android" - > - <EditSchema> - <DataKind kind="photo" maxOccurs="1" /> - </EditSchema> -</ContactsAccountType> diff --git a/tests/res/xml/missing_contacts_name_attr1.xml b/tests/res/xml/missing_contacts_name_attr1.xml deleted file mode 100644 index b7b0f191a..000000000 --- a/tests/res/xml/missing_contacts_name_attr1.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * 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. - */ ---> - -<!-- XML for must-have checks. Missing one of the "support*" attributes". --> - -<ContactsAccountType - xmlns:android="http://schemas.android.com/apk/res/android" - > - <EditSchema> - <DataKind kind="name" - maxOccurs="1" - supportsPrefix="true" - supportsMiddleName="true" - supportsSuffix="true" - supportsPhoneticFamilyName="true" - supportsPhoneticMiddleName="true" - supportsPhoneticGivenName="true" - /> - <DataKind kind="photo" maxOccurs="1" /> - </EditSchema> -</ContactsAccountType> diff --git a/tests/res/xml/missing_contacts_name_attr2.xml b/tests/res/xml/missing_contacts_name_attr2.xml deleted file mode 100644 index 41be9e879..000000000 --- a/tests/res/xml/missing_contacts_name_attr2.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * 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. - */ ---> - -<!-- XML for must-have checks. Missing one of the "support*" attributes". --> - -<ContactsAccountType - xmlns:android="http://schemas.android.com/apk/res/android" - > - <EditSchema> - <DataKind kind="name" - maxOccurs="1" - supportsDisplayName="true" - supportsMiddleName="true" - supportsSuffix="true" - supportsPhoneticFamilyName="true" - supportsPhoneticMiddleName="true" - supportsPhoneticGivenName="true" - /> - <DataKind kind="photo" maxOccurs="1" /> - </EditSchema> -</ContactsAccountType> diff --git a/tests/res/xml/missing_contacts_name_attr3.xml b/tests/res/xml/missing_contacts_name_attr3.xml deleted file mode 100644 index e639a7678..000000000 --- a/tests/res/xml/missing_contacts_name_attr3.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * 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. - */ ---> - -<!-- XML for must-have checks. Missing one of the "support*" attributes". --> - -<ContactsAccountType - xmlns:android="http://schemas.android.com/apk/res/android" - > - <EditSchema> - <DataKind kind="name" - maxOccurs="1" - supportsDisplayName="true" - supportsPrefix="true" - supportsSuffix="true" - supportsPhoneticFamilyName="true" - supportsPhoneticMiddleName="true" - supportsPhoneticGivenName="true" - /> - <DataKind kind="photo" maxOccurs="1" /> - </EditSchema> -</ContactsAccountType> diff --git a/tests/res/xml/missing_contacts_name_attr4.xml b/tests/res/xml/missing_contacts_name_attr4.xml deleted file mode 100644 index b42cdcd93..000000000 --- a/tests/res/xml/missing_contacts_name_attr4.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * 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. - */ ---> - -<!-- XML for must-have checks. Missing one of the "support*" attributes". --> - -<ContactsAccountType - xmlns:android="http://schemas.android.com/apk/res/android" - > - <EditSchema> - <DataKind kind="name" - maxOccurs="1" - supportsDisplayName="true" - supportsPrefix="true" - supportsMiddleName="true" - supportsPhoneticFamilyName="true" - supportsPhoneticMiddleName="true" - supportsPhoneticGivenName="true" - /> - <DataKind kind="photo" maxOccurs="1" /> - </EditSchema> -</ContactsAccountType> diff --git a/tests/res/xml/missing_contacts_name_attr5.xml b/tests/res/xml/missing_contacts_name_attr5.xml deleted file mode 100644 index 3778d2f69..000000000 --- a/tests/res/xml/missing_contacts_name_attr5.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * 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. - */ ---> - -<!-- XML for must-have checks. Missing one of the "support*" attributes". --> - -<ContactsAccountType - xmlns:android="http://schemas.android.com/apk/res/android" - > - <EditSchema> - <DataKind kind="name" - maxOccurs="1" - supportsDisplayName="true" - supportsPrefix="true" - supportsMiddleName="true" - supportsSuffix="true" - supportsPhoneticMiddleName="true" - supportsPhoneticGivenName="true" - /> - <DataKind kind="photo" maxOccurs="1" /> - </EditSchema> -</ContactsAccountType> diff --git a/tests/res/xml/missing_contacts_name_attr6.xml b/tests/res/xml/missing_contacts_name_attr6.xml deleted file mode 100644 index b3a34114c..000000000 --- a/tests/res/xml/missing_contacts_name_attr6.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * 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. - */ ---> - -<!-- XML for must-have checks. Missing one of the "support*" attributes". --> - -<ContactsAccountType - xmlns:android="http://schemas.android.com/apk/res/android" - > - <EditSchema> - <DataKind kind="name" - maxOccurs="1" - supportsDisplayName="true" - supportsPrefix="true" - supportsMiddleName="true" - supportsSuffix="true" - supportsPhoneticFamilyName="true" - supportsPhoneticGivenName="true" - /> - <DataKind kind="photo" maxOccurs="1" /> - </EditSchema> -</ContactsAccountType> diff --git a/tests/res/xml/missing_contacts_name_attr7.xml b/tests/res/xml/missing_contacts_name_attr7.xml deleted file mode 100644 index c87e4f176..000000000 --- a/tests/res/xml/missing_contacts_name_attr7.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * 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. - */ ---> - -<!-- XML for must-have checks. Missing one of the "support*" attributes". --> - -<ContactsAccountType - xmlns:android="http://schemas.android.com/apk/res/android" - > - <EditSchema> - <DataKind kind="name" - maxOccurs="1" - supportsDisplayName="true" - supportsPrefix="true" - supportsMiddleName="true" - supportsSuffix="true" - supportsPhoneticFamilyName="true" - supportsPhoneticMiddleName="true" - /> - <DataKind kind="photo" maxOccurs="1" /> - </EditSchema> -</ContactsAccountType> diff --git a/tests/res/xml/missing_contacts_photo.xml b/tests/res/xml/missing_contacts_photo.xml deleted file mode 100644 index 87f4fc692..000000000 --- a/tests/res/xml/missing_contacts_photo.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * 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. - */ ---> - -<!-- XML for must-have checks. Missing "photo" kind. --> - -<ContactsAccountType - xmlns:android="http://schemas.android.com/apk/res/android" - > - <EditSchema> - <DataKind kind="name" - maxOccurs="1" - supportsDisplayName="true" - supportsPrefix="true" - supportsMiddleName="true" - supportsSuffix="true" - supportsPhoneticFamilyName="true" - supportsPhoneticMiddleName="true" - supportsPhoneticGivenName="true" - > - </DataKind> - </EditSchema> -</ContactsAccountType> diff --git a/tests/res/xml/test_basic_contacts.xml b/tests/res/xml/test_basic_contacts.xml deleted file mode 100644 index 0047204f7..000000000 --- a/tests/res/xml/test_basic_contacts.xml +++ /dev/null @@ -1,283 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * 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. - */ ---> - -<ContactsAccountType - xmlns:android="http://schemas.android.com/apk/res/android" - > - <EditSchema - > - <!-- - Name: - - maxOccurs must be 1 - - No types. - - - Currently all the supportsXxx attributes must be true, but here's the plan for the - future: - (There's some hardcoded assumptions in the contact editor, which is one reason - for the above restriction) - - - "Family name" and "Given name" must be supported. - - All sync adapters must support structured name. "display name only" is not - supported. - -> Supporting this would require relatively large changes to - the contact editor. - - - Fields are decided from the attributes: - StructuredName.DISPLAY_NAME if supportsDisplayName == true - StructuredName.PREFIX if supportsPrefix == true - StructuredName.FAMILY_NAME (always) - StructuredName.MIDDLE_NAME if supportsPrefix == true - StructuredName.GIVEN_NAME (always) - StructuredName.SUFFIX if supportsSuffix == true - StructuredName.PHONETIC_FAMILY_NAME if supportsPhoneticFamilyName == true - StructuredName.PHONETIC_MIDDLE_NAME if supportsPhoneticMiddleName == true - StructuredName.PHONETIC_GIVEN_NAME if supportsPhoneticGivenName == true - - - DataKind.PSEUDO_MIME_TYPE_DISPLAY_NAME is always added. - - DataKind.PSEUDO_MIME_TYPE_PHONETIC_NAME is added - if any of supportsPhoneticXxx == true - --> - <!-- Fallback/Google definition. Supports all. --> - <DataKind kind="name" - maxOccurs="1" - supportsDisplayName="true" - supportsPrefix="true" - supportsMiddleName="true" - supportsSuffix="true" - supportsPhoneticFamilyName="true" - supportsPhoneticMiddleName="true" - supportsPhoneticGivenName="true" - > - </DataKind> - - <!-- Exchange definition. No display-name, no phonetic-middle. - <DataKind kind="name" - supportsDisplayName="false" - supportsPrefix="true" - supportsMiddleName="true" - supportsSuffix="true" - supportsPhoneticFamilyName="true" - supportsPhoneticMiddleName="false" - supportsPhoneticGivenName ="true" - > - </DataKind> - --> - - <!-- - Photo: - - maxOccurs must be 1 - - No types. - --> - <DataKind kind="photo" maxOccurs="1" /> - - <!-- - Phone definition. - - "is secondary?" is inferred from type. - --> - <!-- Fallback, Google definition. --> - <DataKind kind="phone" > - <!-- Note: Google type doesn't have obsolete ones --> - <Type type="mobile" /> - <Type type="home" /> - <Type type="work" /> - <Type type="fax_work" /> - <Type type="fax_home" /> - <Type type="pager" /> - <Type type="other" /> - <Type type="custom"/> - <Type type="callback" /> - <Type type="car" /> - <Type type="company_main" /> - <Type type="isdn" /> - <Type type="main" /> - <Type type="other_fax" /> - <Type type="radio" /> - <Type type="telex" /> - <Type type="tty_tdd" /> - <Type type="work_mobile"/> - <Type type="work_pager" /> - <Type type="assistant" /> - <Type type="mms" /> - </DataKind> - - <!-- Exchange definition. - <DataKind kind="phone" > - <Type type="home" maxOccurs="2" /> - <Type type="mobile" maxOccurs="1" /> - <Type type="work" maxOccurs="2" /> - <Type type="fax_work" maxOccurs="1" /> - <Type type="fax_home" maxOccurs="1" /> - <Type type="pager" maxOccurs="1" /> - <Type type="car" maxOccurs="1" /> - <Type type="company_main" maxOccurs="1" /> - <Type type="mms" maxOccurs="1" /> - <Type type="radio" maxOccurs="1" /> - <Type type="assistant" maxOccurs="1" /> - </DataKind> - --> - - <!-- - Email - --> - <!-- Fallback/Google definition. --> - <DataKind kind="email" > - <!-- Note: Google type doesn't have obsolete ones --> - <Type type="home" /> - <Type type="work" /> - <Type type="other" /> - <Type type="mobile" /> - <Type type="custom" /> - </DataKind> - - <!-- - Exchange definition. - - Same definition as "fallback" except for maxOccurs=3 - <DataKind kind="email" maxOccurs="3" > - <Type type="home" /> - <Type type="work" /> - <Type type="other" /> - <Type type="mobile" /> - <Type type="custom" /> - </DataKind> - --> - - <!-- - Nickname - - maxOccurs must be 1 - - No types. - --> - <DataKind kind="nickname" maxOccurs="1" /> - - <!-- - Im: - - The TYPE column always stores Im.TYPE_OTHER (defaultValues is always set) - - The user-selected type is stored in Im.PROTOCOL - --> - <!-- Fallback, Google definition. --> - <DataKind kind="im" > - <Type type="aim" /> - <Type type="msn" /> - <Type type="yahoo" /> - <Type type="skype" /> - <Type type="qq" /> - <Type type="google_talk" /> - <Type type="icq" /> - <Type type="jabber" /> - <Type type="custom" /> - </DataKind> - - <!-- Exchange definition. - <DataKind kind="im" maxOccurs="3" > - <Type type="aim" /> - <Type type="msn" /> - <Type type="yahoo" /> - <Type type="skype" /> - <Type type="qq" /> - <Type type="google_talk" /> - <Type type="icq" /> - <Type type="jabber" /> - <Type type="custom" /> - </DataKind> - --> - - <!-- - Postal address. - --> - <!-- Fallback/Google definition. Not structured. --> - <DataKind kind="postal" needsStructured="false" > - <Type type="home" /> - <Type type="work" /> - <Type type="other" /> - <Type type="custom" /> - </DataKind> - - <!-- Exchange definition. Structured. - <DataKind kind="postal" needsStructured="true" > - <Type type="work" /> - <Type type="home" /> - <Type type="other" /> - </DataKind> - --> - - <!-- - Organization: - - Fields are fixed: COMPANY, TITLE - - maxOccurs must be 1 - - No types. - --> - <DataKind kind="organization" maxOccurs="1" /> - - <!-- - Website: - - No types. - --> - <DataKind kind="website" /> - - <!-- - Below kinds have nothing configurable. - - No types are supported. - - maxOccurs must be 1 - --> - <DataKind kind="sip_address" maxOccurs="1" /> - <DataKind kind="note" maxOccurs="1" /> - - <!-- - Google/Exchange supports it, but fallback doesn't. - <DataKind kind="group_membership" maxOccurs="1" /> - --> - - <!-- - Event - --> - <DataKind kind="event" dateWithTime="false"> - <Type type="birthday" maxOccurs="1" yearOptional="true" /> - <Type type="anniversary" /> - <Type type="other" /> - <Type type="custom" /> - </DataKind> - - <!-- - Exchange definition. dateWithTime is needed only for Exchange. - <DataKind kind="event" dateWithTime="true"> - <Type type="birthday" maxOccurs="1" /> - </DataKind> - --> - - <!-- - Relationship - --> - <DataKind kind="relationship" > - <Type type="assistant" /> - <Type type="brother" /> - <Type type="child" /> - <Type type="domestic_partner" /> - <Type type="father" /> - <Type type="friend" /> - <Type type="manager" /> - <Type type="mother" /> - <Type type="parent" /> - <Type type="partner" /> - <Type type="referred_by" /> - <Type type="relative" /> - <Type type="sister" /> - <Type type="spouse" /> - <Type type="custom" /> - </DataKind> - </EditSchema> -</ContactsAccountType> diff --git a/tests/res/xml/test_basic_syncadapter.xml b/tests/res/xml/test_basic_syncadapter.xml deleted file mode 100644 index fecc0eb16..000000000 --- a/tests/res/xml/test_basic_syncadapter.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * 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. - */ ---> - -<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android" - android:contentAuthority="com.android.contacts" - android:accountType="com.android.contacts.tests.authtest.basic" - android:supportsUploading="true" - android:userVisible="true" -/> diff --git a/tests/src/com/android/contacts/RawContactDeltaListTests.java b/tests/src/com/android/contacts/RawContactDeltaListTests.java index 07e9dd644..ef7667b30 100644 --- a/tests/src/com/android/contacts/RawContactDeltaListTests.java +++ b/tests/src/com/android/contacts/RawContactDeltaListTests.java @@ -40,7 +40,7 @@ import com.android.contacts.model.RawContactDelta; import com.android.contacts.model.RawContactDelta.ValuesDelta; import com.android.contacts.model.RawContactDeltaList; import com.android.contacts.model.RawContactModifier; -import com.android.contacts.model.account.AccountType; +import com.android.contacts.common.model.account.AccountType; import com.google.common.collect.Lists; import java.lang.reflect.Field; diff --git a/tests/src/com/android/contacts/RawContactModifierTests.java b/tests/src/com/android/contacts/RawContactModifierTests.java index 497bede9a..bb0945b0f 100644 --- a/tests/src/com/android/contacts/RawContactModifierTests.java +++ b/tests/src/com/android/contacts/RawContactModifierTests.java @@ -44,11 +44,11 @@ import com.android.contacts.model.RawContactDelta; import com.android.contacts.model.RawContactDelta.ValuesDelta; import com.android.contacts.model.RawContactDeltaList; import com.android.contacts.model.RawContactModifier; -import com.android.contacts.model.account.AccountType; -import com.android.contacts.model.account.AccountType.EditType; -import com.android.contacts.model.account.ExchangeAccountType; -import com.android.contacts.model.account.GoogleAccountType; -import com.android.contacts.model.dataitem.DataKind; +import com.android.contacts.common.model.account.AccountType; +import com.android.contacts.common.model.account.AccountType.EditType; +import com.android.contacts.common.model.account.ExchangeAccountType; +import com.android.contacts.common.model.account.GoogleAccountType; +import com.android.contacts.common.model.dataitem.DataKind; import com.android.contacts.common.test.mocks.ContactsMockContext; import com.android.contacts.tests.mocks.MockAccountTypeManager; import com.android.contacts.common.test.mocks.MockContentProvider; diff --git a/tests/src/com/android/contacts/activities/PeopleActivityTest.java b/tests/src/com/android/contacts/activities/PeopleActivityTest.java index 644c0a586..2fb1040f2 100644 --- a/tests/src/com/android/contacts/activities/PeopleActivityTest.java +++ b/tests/src/com/android/contacts/activities/PeopleActivityTest.java @@ -42,9 +42,9 @@ import com.android.contacts.detail.ContactDetailFragment; import com.android.contacts.interactions.TestLoaderManager; import com.android.contacts.list.ContactBrowseListFragment; import com.android.contacts.model.AccountTypeManager; -import com.android.contacts.model.account.AccountType; -import com.android.contacts.model.account.AccountWithDataSet; -import com.android.contacts.model.account.BaseAccountType; +import com.android.contacts.common.model.account.AccountType; +import com.android.contacts.common.model.account.AccountWithDataSet; +import com.android.contacts.common.model.account.BaseAccountType; import com.android.contacts.test.InjectedServices; import com.android.contacts.tests.mocks.MockAccountTypeManager; import com.android.contacts.tests.mocks.MockContactPhotoManager; diff --git a/tests/src/com/android/contacts/editor/ContactEditorUtilsTest.java b/tests/src/com/android/contacts/editor/ContactEditorUtilsTest.java index 9f2d49b6e..0d38c9595 100644 --- a/tests/src/com/android/contacts/editor/ContactEditorUtilsTest.java +++ b/tests/src/com/android/contacts/editor/ContactEditorUtilsTest.java @@ -20,8 +20,8 @@ import android.test.AndroidTestCase; import android.test.MoreAsserts; import android.test.suitebuilder.annotation.SmallTest; -import com.android.contacts.model.account.AccountType; -import com.android.contacts.model.account.AccountWithDataSet; +import com.android.contacts.common.model.account.AccountType; +import com.android.contacts.common.model.account.AccountWithDataSet; import com.android.contacts.tests.mocks.MockAccountTypeManager; import com.google.common.collect.Sets; diff --git a/tests/src/com/android/contacts/interactions/ContactDeletionInteractionTest.java b/tests/src/com/android/contacts/interactions/ContactDeletionInteractionTest.java index bf4e24b20..a89ddc96d 100644 --- a/tests/src/com/android/contacts/interactions/ContactDeletionInteractionTest.java +++ b/tests/src/com/android/contacts/interactions/ContactDeletionInteractionTest.java @@ -32,8 +32,8 @@ import com.android.contacts.common.test.mocks.ContactsMockContext; import com.android.contacts.common.test.mocks.MockContentProvider; import com.android.contacts.common.test.mocks.MockContentProvider.Query; import com.android.contacts.model.AccountTypeManager; -import com.android.contacts.model.account.AccountType; -import com.android.contacts.model.account.BaseAccountType; +import com.android.contacts.common.model.account.AccountType; +import com.android.contacts.common.model.account.BaseAccountType; import com.android.contacts.test.InjectedServices; import com.android.contacts.tests.mocks.MockAccountTypeManager; diff --git a/tests/src/com/android/contacts/model/AccountTypeManagerTest.java b/tests/src/com/android/contacts/model/AccountTypeManagerTest.java index c8db85ea6..8cc4e1245 100644 --- a/tests/src/com/android/contacts/model/AccountTypeManagerTest.java +++ b/tests/src/com/android/contacts/model/AccountTypeManagerTest.java @@ -20,9 +20,9 @@ import android.content.Context; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; -import com.android.contacts.model.account.AccountType; -import com.android.contacts.model.account.AccountTypeWithDataSet; -import com.android.contacts.model.account.AccountWithDataSet; +import com.android.contacts.common.model.account.AccountType; +import com.android.contacts.common.model.account.AccountTypeWithDataSet; +import com.android.contacts.common.model.account.AccountWithDataSet; import com.google.common.collect.Lists; import com.google.common.collect.Maps; diff --git a/tests/src/com/android/contacts/model/AccountWithDataSetTest.java b/tests/src/com/android/contacts/model/AccountWithDataSetTest.java deleted file mode 100644 index 1818c38c8..000000000 --- a/tests/src/com/android/contacts/model/AccountWithDataSetTest.java +++ /dev/null @@ -1,123 +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.contacts.model; - -import android.os.Bundle; -import android.test.AndroidTestCase; -import android.test.MoreAsserts; -import android.test.suitebuilder.annotation.SmallTest; - -import com.android.contacts.model.account.AccountWithDataSet; -import com.google.common.collect.Lists; - -import java.util.List; - -/** - * Test case for {@link AccountWithDataSet}. - * - * adb shell am instrument -w -e class com.android.contacts.model.AccountWithDataSetTest \ - com.android.contacts.tests/android.test.InstrumentationTestRunner - */ -@SmallTest -public class AccountWithDataSetTest extends AndroidTestCase { - public void testStringifyAndUnstringify() { - AccountWithDataSet a1 = new AccountWithDataSet("name1", "typeA", null); - AccountWithDataSet a2 = new AccountWithDataSet("name2", "typeB", null); - AccountWithDataSet a3 = new AccountWithDataSet("name3", "typeB", "dataset"); - - // stringify() & unstringify - AccountWithDataSet a1r = AccountWithDataSet.unstringify(a1.stringify()); - AccountWithDataSet a2r = AccountWithDataSet.unstringify(a2.stringify()); - AccountWithDataSet a3r = AccountWithDataSet.unstringify(a3.stringify()); - - assertEquals(a1, a1r); - assertEquals(a2, a2r); - assertEquals(a3, a3r); - - MoreAsserts.assertNotEqual(a1, a2r); - MoreAsserts.assertNotEqual(a1, a3r); - - MoreAsserts.assertNotEqual(a2, a1r); - MoreAsserts.assertNotEqual(a2, a3r); - - MoreAsserts.assertNotEqual(a3, a1r); - MoreAsserts.assertNotEqual(a3, a2r); - } - - public void testStringifyListAndUnstringify() { - AccountWithDataSet a1 = new AccountWithDataSet("name1", "typeA", null); - AccountWithDataSet a2 = new AccountWithDataSet("name2", "typeB", null); - AccountWithDataSet a3 = new AccountWithDataSet("name3", "typeB", "dataset"); - - // Empty list - assertEquals(0, stringifyListAndUnstringify().size()); - - // 1 element - final List<AccountWithDataSet> listA = stringifyListAndUnstringify(a1); - assertEquals(1, listA.size()); - assertEquals(a1, listA.get(0)); - - // 2 elements - final List<AccountWithDataSet> listB = stringifyListAndUnstringify(a2, a1); - assertEquals(2, listB.size()); - assertEquals(a2, listB.get(0)); - assertEquals(a1, listB.get(1)); - - // 3 elements - final List<AccountWithDataSet> listC = stringifyListAndUnstringify(a3, a2, a1); - assertEquals(3, listC.size()); - assertEquals(a3, listC.get(0)); - assertEquals(a2, listC.get(1)); - assertEquals(a1, listC.get(2)); - } - - private static List<AccountWithDataSet> stringifyListAndUnstringify( - AccountWithDataSet... accounts) { - - List<AccountWithDataSet> list = Lists.newArrayList(accounts); - return AccountWithDataSet.unstringifyList(AccountWithDataSet.stringifyList(list)); - } - - public void testParcelable() { - AccountWithDataSet a1 = new AccountWithDataSet("name1", "typeA", null); - AccountWithDataSet a2 = new AccountWithDataSet("name2", "typeB", null); - AccountWithDataSet a3 = new AccountWithDataSet("name3", "typeB", "dataset"); - - // Parcel them & unpercel. - final Bundle b = new Bundle(); - b.putParcelable("a1", a1); - b.putParcelable("a2", a2); - b.putParcelable("a3", a3); - - AccountWithDataSet a1r = b.getParcelable("a1"); - AccountWithDataSet a2r = b.getParcelable("a2"); - AccountWithDataSet a3r = b.getParcelable("a3"); - - assertEquals(a1, a1r); - assertEquals(a2, a2r); - assertEquals(a3, a3r); - - MoreAsserts.assertNotEqual(a1, a2r); - MoreAsserts.assertNotEqual(a1, a3r); - - MoreAsserts.assertNotEqual(a2, a1r); - MoreAsserts.assertNotEqual(a2, a3r); - - MoreAsserts.assertNotEqual(a3, a1r); - MoreAsserts.assertNotEqual(a3, a2r); - } -} diff --git a/tests/src/com/android/contacts/model/ContactLoaderTest.java b/tests/src/com/android/contacts/model/ContactLoaderTest.java index 2876e2a2b..c87ede833 100644 --- a/tests/src/com/android/contacts/model/ContactLoaderTest.java +++ b/tests/src/com/android/contacts/model/ContactLoaderTest.java @@ -30,9 +30,9 @@ import android.test.suitebuilder.annotation.LargeTest; import com.android.contacts.common.test.mocks.ContactsMockContext; import com.android.contacts.common.test.mocks.MockContentProvider; -import com.android.contacts.model.account.AccountType; -import com.android.contacts.model.account.AccountWithDataSet; -import com.android.contacts.model.account.BaseAccountType; +import com.android.contacts.common.model.account.AccountType; +import com.android.contacts.common.model.account.AccountWithDataSet; +import com.android.contacts.common.model.account.BaseAccountType; import com.android.contacts.test.InjectedServices; import com.android.contacts.tests.mocks.MockAccountTypeManager; diff --git a/tests/src/com/android/contacts/model/account/AccountTypeTest.java b/tests/src/com/android/contacts/model/account/AccountTypeTest.java deleted file mode 100644 index 3276011df..000000000 --- a/tests/src/com/android/contacts/model/account/AccountTypeTest.java +++ /dev/null @@ -1,133 +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.contacts.model.account; - -import android.content.Context; -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.SmallTest; - -import com.android.contacts.model.account.AccountType; -import com.android.contacts.tests.R; - -/** - * Test case for {@link AccountType}. - * - * adb shell am instrument -w -e class com.android.contacts.model.AccountTypeTest \ - com.android.contacts.tests/android.test.InstrumentationTestRunner - */ -@SmallTest -public class AccountTypeTest extends AndroidTestCase { - public void testGetResourceText() { - // In this test we use the test package itself as an external package. - final String packageName = getTestContext().getPackageName(); - - final Context c = getContext(); - final String DEFAULT = "ABC"; - - // Package name null, resId -1, use the default - assertEquals(DEFAULT, AccountType.getResourceText(c, null, -1, DEFAULT)); - - // Resource ID -1, use the default - assertEquals(DEFAULT, AccountType.getResourceText(c, packageName, -1, DEFAULT)); - - // Load from an external package. (here, we use this test package itself) - final int externalResID = R.string.test_string; - assertEquals(getTestContext().getString(externalResID), - AccountType.getResourceText(c, packageName, externalResID, DEFAULT)); - - // Load from the contacts package itself. - final int internalResId = com.android.contacts.R.string.people; - assertEquals(c.getString(internalResId), - AccountType.getResourceText(c, null, internalResId, DEFAULT)); - } - - /** - * Verify if {@link AccountType#getInviteContactActionLabel} correctly gets the resource ID - * from {@link AccountType#getInviteContactActionResId} - */ - public void testGetInviteContactActionLabel() { - final String packageName = getTestContext().getPackageName(); - final Context c = getContext(); - - final int externalResID = R.string.test_string; - - AccountType accountType = new AccountType() { - { - resourcePackageName = packageName; - syncAdapterPackageName = packageName; - } - @Override protected int getInviteContactActionResId() { - return externalResID; - } - - @Override public boolean isGroupMembershipEditable() { - return false; - } - - @Override public boolean areContactsWritable() { - return false; - } - }; - - assertEquals(getTestContext().getString(externalResID), - accountType.getInviteContactActionLabel(c)); - } - - public void testDisplayLabelComparator() { - final AccountTypeForDisplayLabelTest EMPTY = new AccountTypeForDisplayLabelTest(""); - final AccountTypeForDisplayLabelTest NULL = new AccountTypeForDisplayLabelTest(null); - final AccountTypeForDisplayLabelTest AA = new AccountTypeForDisplayLabelTest("aa"); - final AccountTypeForDisplayLabelTest BBB = new AccountTypeForDisplayLabelTest("bbb"); - final AccountTypeForDisplayLabelTest C = new AccountTypeForDisplayLabelTest("c"); - - assertTrue(compareDisplayLabel(AA, BBB) < 0); - assertTrue(compareDisplayLabel(BBB, C) < 0); - assertTrue(compareDisplayLabel(AA, C) < 0); - assertTrue(compareDisplayLabel(AA, AA) == 0); - assertTrue(compareDisplayLabel(BBB, AA) > 0); - - assertTrue(compareDisplayLabel(EMPTY, AA) < 0); - assertTrue(compareDisplayLabel(EMPTY, NULL) == 0); - } - - private int compareDisplayLabel(AccountType lhs, AccountType rhs) { - return new AccountType.DisplayLabelComparator(getContext()).compare(lhs, rhs); - } - - private class AccountTypeForDisplayLabelTest extends AccountType { - private final String mDisplayLabel; - - public AccountTypeForDisplayLabelTest(String displayLabel) { - mDisplayLabel = displayLabel; - } - - @Override - public CharSequence getDisplayLabel(Context context) { - return mDisplayLabel; - } - - @Override - public boolean isGroupMembershipEditable() { - return false; - } - - @Override - public boolean areContactsWritable() { - return false; - } - } -} diff --git a/tests/src/com/android/contacts/model/account/ExternalAccountTypeTest.java b/tests/src/com/android/contacts/model/account/ExternalAccountTypeTest.java deleted file mode 100644 index 6eb3bd73d..000000000 --- a/tests/src/com/android/contacts/model/account/ExternalAccountTypeTest.java +++ /dev/null @@ -1,247 +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.contacts.model.account; - -import android.content.Context; -import android.provider.ContactsContract.CommonDataKinds.Email; -import android.provider.ContactsContract.CommonDataKinds.Event; -import android.provider.ContactsContract.CommonDataKinds.Im; -import android.provider.ContactsContract.CommonDataKinds.Note; -import android.provider.ContactsContract.CommonDataKinds.Organization; -import android.provider.ContactsContract.CommonDataKinds.Photo; -import android.provider.ContactsContract.CommonDataKinds.Relation; -import android.provider.ContactsContract.CommonDataKinds.SipAddress; -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.suitebuilder.annotation.SmallTest; - -import com.android.contacts.model.dataitem.DataKind; -import com.android.contacts.tests.R; -import com.google.common.base.Objects; - -import java.util.List; - -/** - * Test case for {@link ExternalAccountType}. - * - * adb shell am instrument -w -e class com.android.contacts.model.ExternalAccountTypeTest \ - com.android.contacts.tests/android.test.InstrumentationTestRunner - */ -@SmallTest -public class ExternalAccountTypeTest extends AndroidTestCase { - 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(); - - // Resource name empty. - assertEquals(-1, ExternalAccountType.resolveExternalResId(c, null, packageName, "")); - assertEquals(-1, ExternalAccountType.resolveExternalResId(c, "", packageName, "")); - - // Name doesn't begin with '@' - assertEquals(-1, ExternalAccountType.resolveExternalResId(c, "x", packageName, "")); - - // Invalid resource name - assertEquals(-1, ExternalAccountType.resolveExternalResId(c, "@", packageName, "")); - assertEquals(-1, ExternalAccountType.resolveExternalResId(c, "@a", packageName, "")); - assertEquals(-1, ExternalAccountType.resolveExternalResId(c, "@a/b", packageName, "")); - - // Valid resource name - assertEquals(R.string.test_string, ExternalAccountType.resolveExternalResId(c, - "@string/test_string", packageName, "")); - } - - /** - * Initialize with an invalid package name and see if type type will *not* be initialized. - */ - public void testNoPackage() { - final ExternalAccountType type = new ExternalAccountType(getContext(), - "!!!no such package name!!!", false); - assertFalse(type.isInitialized()); - } - - /** - * Initialize with the name of an existing package, which has no contacts.xml metadata. - */ - public void testNoMetadata() { - // Use the main application package, which does exist, but has no contacts.xml in it. - String packageName = getContext().getPackageName(); - final ExternalAccountType type = new ExternalAccountType(getContext(), - packageName, false); - assertTrue(type.isInitialized()); - } - - /** - * Initialize with the test package itself and see if EditSchema is correctly parsed. - */ - public void testEditSchema() { - final ExternalAccountType type = new ExternalAccountType(getContext(), - getTestContext().getPackageName(), false); - - assertTrue(type.isInitialized()); - - // Let's just check if the DataKinds are registered. - assertNotNull(type.getKindForMimetype(StructuredName.CONTENT_ITEM_TYPE)); - assertNotNull(type.getKindForMimetype(DataKind.PSEUDO_MIME_TYPE_DISPLAY_NAME)); - assertNotNull(type.getKindForMimetype(DataKind.PSEUDO_MIME_TYPE_PHONETIC_NAME)); - assertNotNull(type.getKindForMimetype(Email.CONTENT_ITEM_TYPE)); - assertNotNull(type.getKindForMimetype(StructuredPostal.CONTENT_ITEM_TYPE)); - assertNotNull(type.getKindForMimetype(Im.CONTENT_ITEM_TYPE)); - assertNotNull(type.getKindForMimetype(Organization.CONTENT_ITEM_TYPE)); - assertNotNull(type.getKindForMimetype(Photo.CONTENT_ITEM_TYPE)); - assertNotNull(type.getKindForMimetype(Note.CONTENT_ITEM_TYPE)); - assertNotNull(type.getKindForMimetype(Website.CONTENT_ITEM_TYPE)); - assertNotNull(type.getKindForMimetype(SipAddress.CONTENT_ITEM_TYPE)); - assertNotNull(type.getKindForMimetype(Event.CONTENT_ITEM_TYPE)); - assertNotNull(type.getKindForMimetype(Relation.CONTENT_ITEM_TYPE)); - } - - /** - * Initialize with "contacts_fallback.xml" and compare the DataKinds to those of - * {@link FallbackAccountType}. - */ - public void testEditSchema_fallback() { - final ExternalAccountType type = new ExternalAccountType(getContext(), - getTestContext().getPackageName(), false, - getTestContext().getResources().getXml(R.xml.contacts_fallback) - ); - - assertTrue(type.isInitialized()); - - // 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); - - assertsDataKindEquals(reference.getSortedDataKinds(), type.getSortedDataKinds()); - } - - public void testEditSchema_mustHaveChecks() { - checkEditSchema_mustHaveChecks(R.xml.missing_contacts_base, true); - checkEditSchema_mustHaveChecks(R.xml.missing_contacts_photo, false); - checkEditSchema_mustHaveChecks(R.xml.missing_contacts_name, false); - checkEditSchema_mustHaveChecks(R.xml.missing_contacts_name_attr1, false); - checkEditSchema_mustHaveChecks(R.xml.missing_contacts_name_attr2, false); - checkEditSchema_mustHaveChecks(R.xml.missing_contacts_name_attr3, false); - checkEditSchema_mustHaveChecks(R.xml.missing_contacts_name_attr4, false); - checkEditSchema_mustHaveChecks(R.xml.missing_contacts_name_attr5, false); - checkEditSchema_mustHaveChecks(R.xml.missing_contacts_name_attr6, false); - checkEditSchema_mustHaveChecks(R.xml.missing_contacts_name_attr7, false); - } - - private void checkEditSchema_mustHaveChecks(int xmlResId, boolean expectInitialized) { - final ExternalAccountType type = new ExternalAccountType(getContext(), - getTestContext().getPackageName(), false, - getTestContext().getResources().getXml(xmlResId) - ); - - assertEquals(expectInitialized, type.isInitialized()); - } - - /** - * Initialize with "contacts_readonly.xml" and see if all data kinds are correctly registered. - */ - public void testReadOnlyDefinition() { - final ExternalAccountType type = new ExternalAccountType(getContext(), - getTestContext().getPackageName(), false, - getTestContext().getResources().getXml(R.xml.contacts_readonly) - ); - assertTrue(type.isInitialized()); - - // Shouldn't have a "null" mimetype. - assertTrue(type.getKindForMimetype(null) == null); - - // 3 kinds are defined in XML and 4 are added by default. - assertEquals(4 + 3, type.getSortedDataKinds().size()); - - // Check for the default kinds. - assertNotNull(type.getKindForMimetype(StructuredName.CONTENT_ITEM_TYPE)); - assertNotNull(type.getKindForMimetype(DataKind.PSEUDO_MIME_TYPE_DISPLAY_NAME)); - assertNotNull(type.getKindForMimetype(DataKind.PSEUDO_MIME_TYPE_PHONETIC_NAME)); - assertNotNull(type.getKindForMimetype(Photo.CONTENT_ITEM_TYPE)); - - // Check for type specific kinds. - DataKind kind = type.getKindForMimetype("vnd.android.cursor.item/a.b.c"); - assertNotNull(kind); - // No check for icon -- we actually just ignore it. - assertEquals("data1", ((BaseAccountType.SimpleInflater) kind.actionHeader) - .getColumnNameForTest()); - assertEquals("data2", ((BaseAccountType.SimpleInflater) kind.actionBody) - .getColumnNameForTest()); - assertEquals(true, kind.actionBodySocial); - - kind = type.getKindForMimetype("vnd.android.cursor.item/d.e.f"); - assertNotNull(kind); - assertEquals("data3", ((BaseAccountType.SimpleInflater) kind.actionHeader) - .getColumnNameForTest()); - assertEquals("data4", ((BaseAccountType.SimpleInflater) kind.actionBody) - .getColumnNameForTest()); - assertEquals(false, kind.actionBodySocial); - - kind = type.getKindForMimetype("vnd.android.cursor.item/xyz"); - assertNotNull(kind); - assertEquals("data5", ((BaseAccountType.SimpleInflater) kind.actionHeader) - .getColumnNameForTest()); - assertEquals("data6", ((BaseAccountType.SimpleInflater) kind.actionBody) - .getColumnNameForTest()); - assertEquals(true, kind.actionBodySocial); - } - - private static void assertsDataKindEquals(List<DataKind> expectedKinds, - List<DataKind> actualKinds) { - final int count = Math.max(actualKinds.size(), expectedKinds.size()); - for (int i = 0; i < count; i++) { - String actual = actualKinds.size() > i ? actualKinds.get(i).toString() : "(n/a)"; - String expected = expectedKinds.size() > i ? expectedKinds.get(i).toString() : "(n/a)"; - - // Because assertEquals()'s output is not very friendly when comparing two similar - // strings, we manually do the check. - if (!Objects.equal(actual, expected)) { - final int commonPrefixEnd = findCommonPrefixEnd(actual, expected); - fail("Kind #" + i - + "\n[Actual]\n" + insertMarkerAt(actual, commonPrefixEnd) - + "\n[Expected]\n" + insertMarkerAt(expected, commonPrefixEnd)); - } - } - } - - private static int findCommonPrefixEnd(String s1, String s2) { - int i = 0; - for (;;) { - final boolean s1End = (s1.length() <= i); - final boolean s2End = (s2.length() <= i); - if (s1End || s2End) { - return i; - } - if (s1.charAt(i) != s2.charAt(i)) { - return i; - } - i++; - } - } - - private static String insertMarkerAt(String s, int position) { - final String MARKER = "***"; - if (position > s.length()) { - return s + MARKER; - } else { - return new StringBuilder(s).insert(position, MARKER).toString(); - } - } -} diff --git a/tests/src/com/android/contacts/tests/mocks/MockAccountTypeManager.java b/tests/src/com/android/contacts/tests/mocks/MockAccountTypeManager.java index ce16743a0..31eff5271 100644 --- a/tests/src/com/android/contacts/tests/mocks/MockAccountTypeManager.java +++ b/tests/src/com/android/contacts/tests/mocks/MockAccountTypeManager.java @@ -16,9 +16,9 @@ package com.android.contacts.tests.mocks; import com.android.contacts.model.AccountTypeManager; -import com.android.contacts.model.account.AccountType; -import com.android.contacts.model.account.AccountTypeWithDataSet; -import com.android.contacts.model.account.AccountWithDataSet; +import com.android.contacts.common.model.account.AccountType; +import com.android.contacts.common.model.account.AccountTypeWithDataSet; +import com.android.contacts.common.model.account.AccountWithDataSet; import com.google.common.base.Objects; import com.google.common.collect.Lists; import com.google.common.collect.Maps; diff --git a/tests/src/com/android/contacts/tests/streamitems/StreamItemPopulatorActivity.java b/tests/src/com/android/contacts/tests/streamitems/StreamItemPopulatorActivity.java index 20229d298..9132e4002 100644 --- a/tests/src/com/android/contacts/tests/streamitems/StreamItemPopulatorActivity.java +++ b/tests/src/com/android/contacts/tests/streamitems/StreamItemPopulatorActivity.java @@ -32,7 +32,7 @@ import android.view.View; import android.widget.Button; import android.widget.Toast; -import com.android.contacts.model.account.GoogleAccountType; +import com.android.contacts.common.model.account.GoogleAccountType; import com.android.contacts.tests.R; import com.google.common.collect.Lists; diff --git a/tests/src/com/android/contacts/tests/testauth/TestAuthenticationService.java b/tests/src/com/android/contacts/tests/testauth/TestAuthenticationService.java deleted file mode 100644 index 84f3f0f80..000000000 --- a/tests/src/com/android/contacts/tests/testauth/TestAuthenticationService.java +++ /dev/null @@ -1,47 +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.contacts.tests.testauth; - -import android.app.Service; -import android.content.Intent; -import android.os.IBinder; -import android.util.Log; - -public abstract class TestAuthenticationService extends Service { - - private TestAuthenticator mAuthenticator; - - @Override - public void onCreate() { - Log.v(TestauthConstants.LOG_TAG, this + " Service started."); - mAuthenticator = new TestAuthenticator(this); - } - - @Override - public void onDestroy() { - Log.v(TestauthConstants.LOG_TAG, this + " Service stopped."); - } - - @Override - public IBinder onBind(Intent intent) { - Log.v(TestauthConstants.LOG_TAG, this + " getBinder() intent=" + intent); - return mAuthenticator.getIBinder(); - } - - public static class Basic extends TestAuthenticationService { - } -} diff --git a/tests/src/com/android/contacts/tests/testauth/TestAuthenticator.java b/tests/src/com/android/contacts/tests/testauth/TestAuthenticator.java deleted file mode 100644 index 97e2e4d18..000000000 --- a/tests/src/com/android/contacts/tests/testauth/TestAuthenticator.java +++ /dev/null @@ -1,131 +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.contacts.tests.testauth; - -import android.accounts.AbstractAccountAuthenticator; -import android.accounts.Account; -import android.accounts.AccountAuthenticatorResponse; -import android.accounts.AccountManager; -import android.content.Context; -import android.content.SharedPreferences; -import android.os.Bundle; -import android.preference.PreferenceManager; -import android.util.Log; - -/** - * Simple authenticator. It has no "login" dialogs/activities. When you add a new account, it'll - * just create a new account with a unique name. - */ -class TestAuthenticator extends AbstractAccountAuthenticator { - private static final String PASSWORD = "xxx"; // any string will do. - - // To remember the last user-ID. - private static final String PREF_KEY_LAST_USER_ID = "TestAuthenticator.PREF_KEY_LAST_USER_ID"; - - private final Context mContext; - - public TestAuthenticator(Context context) { - super(context); - mContext = context.getApplicationContext(); - } - - /** - * @return a new, unique username. - */ - private String newUniqueUserName() { - final SharedPreferences prefs = - PreferenceManager.getDefaultSharedPreferences(mContext); - final int nextId = prefs.getInt(PREF_KEY_LAST_USER_ID, 0) + 1; - prefs.edit().putInt(PREF_KEY_LAST_USER_ID, nextId).apply(); - - return "User-" + nextId; - } - - /** - * Create a new account with the name generated by {@link #newUniqueUserName()}. - */ - @Override - public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, - String authTokenType, String[] requiredFeatures, Bundle options) { - Log.v(TestauthConstants.LOG_TAG, "addAccount() type=" + accountType); - final Bundle bundle = new Bundle(); - - final Account account = new Account(newUniqueUserName(), accountType); - - // Create an account. - AccountManager.get(mContext).addAccountExplicitly(account, PASSWORD, null); - - // And return it. - bundle.putString(AccountManager.KEY_ACCOUNT_NAME, account.name); - bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type); - return bundle; - } - - /** - * Just return the user name as the authtoken. - */ - @Override - public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, - String authTokenType, Bundle loginOptions) { - Log.v(TestauthConstants.LOG_TAG, "getAuthToken() account=" + account); - final Bundle bundle = new Bundle(); - bundle.putString(AccountManager.KEY_ACCOUNT_NAME, account.name); - bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type); - bundle.putString(AccountManager.KEY_AUTHTOKEN, account.name); - - return bundle; - } - - @Override - public Bundle confirmCredentials( - AccountAuthenticatorResponse response, Account account, Bundle options) { - Log.v(TestauthConstants.LOG_TAG, "confirmCredentials()"); - return null; - } - - @Override - public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) { - Log.v(TestauthConstants.LOG_TAG, "editProperties()"); - throw new UnsupportedOperationException(); - } - - @Override - public String getAuthTokenLabel(String authTokenType) { - // null means we don't support multiple authToken types - Log.v(TestauthConstants.LOG_TAG, "getAuthTokenLabel()"); - return null; - } - - @Override - public Bundle hasFeatures( - AccountAuthenticatorResponse response, Account account, String[] features) { - // This call is used to query whether the Authenticator supports - // specific features. We don't expect to get called, so we always - // return false (no) for any queries. - Log.v(TestauthConstants.LOG_TAG, "hasFeatures()"); - final Bundle result = new Bundle(); - result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, false); - return result; - } - - @Override - public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, - String authTokenType, Bundle loginOptions) { - Log.v(TestauthConstants.LOG_TAG, "updateCredentials()"); - return null; - } -} diff --git a/tests/src/com/android/contacts/tests/testauth/TestSyncAdapter.java b/tests/src/com/android/contacts/tests/testauth/TestSyncAdapter.java deleted file mode 100644 index 9e6fbf8a2..000000000 --- a/tests/src/com/android/contacts/tests/testauth/TestSyncAdapter.java +++ /dev/null @@ -1,68 +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.contacts.tests.testauth; - -import android.accounts.Account; -import android.accounts.AccountManager; -import android.content.AbstractThreadedSyncAdapter; -import android.content.ContentProviderClient; -import android.content.ContentResolver; -import android.content.ContentValues; -import android.content.Context; -import android.content.SyncResult; -import android.os.Bundle; -import android.provider.ContactsContract.RawContacts; -import android.util.Log; - -/** - * Simple (minimal) sync adapter. - * - */ -public class TestSyncAdapter extends AbstractThreadedSyncAdapter { - private final AccountManager mAccountManager; - - private final Context mContext; - - public TestSyncAdapter(Context context, boolean autoInitialize) { - super(context, autoInitialize); - mContext = context.getApplicationContext(); - mAccountManager = AccountManager.get(mContext); - } - - /** - * Doesn't actually sync, but sweep up all existing local-only contacts. - */ - @Override - public void onPerformSync(Account account, Bundle extras, String authority, - ContentProviderClient provider, SyncResult syncResult) { - Log.v(TestauthConstants.LOG_TAG, "TestSyncAdapter.onPerformSync() account=" + account); - - // First, claim all local-only contacts, if any. - ContentResolver cr = mContext.getContentResolver(); - ContentValues values = new ContentValues(); - values.put(RawContacts.ACCOUNT_NAME, account.name); - values.put(RawContacts.ACCOUNT_TYPE, account.type); - final int count = cr.update(RawContacts.CONTENT_URI, values, - RawContacts.ACCOUNT_NAME + " IS NULL AND " + RawContacts.ACCOUNT_TYPE + " IS NULL", - null); - if (count > 0) { - Log.v(TestauthConstants.LOG_TAG, "Claimed " + count + " local raw contacts"); - } - - // TODO: Clear isDirty flag - // TODO: Remove isDeleted raw contacts - } -} diff --git a/tests/src/com/android/contacts/tests/testauth/TestSyncService.java b/tests/src/com/android/contacts/tests/testauth/TestSyncService.java deleted file mode 100644 index 99287771c..000000000 --- a/tests/src/com/android/contacts/tests/testauth/TestSyncService.java +++ /dev/null @@ -1,40 +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.contacts.tests.testauth; - -import android.app.Service; -import android.content.Intent; -import android.os.IBinder; - -public abstract class TestSyncService extends Service { - - private static TestSyncAdapter sSyncAdapter; - - @Override - public void onCreate() { - if (sSyncAdapter == null) { - sSyncAdapter = new TestSyncAdapter(getApplicationContext(), true); - } - } - - @Override - public IBinder onBind(Intent intent) { - return sSyncAdapter.getSyncAdapterBinder(); - } - - public static class Basic extends TestSyncService { - } -} diff --git a/tests/src/com/android/contacts/tests/testauth/TestauthConstants.java b/tests/src/com/android/contacts/tests/testauth/TestauthConstants.java deleted file mode 100644 index 717ed354a..000000000 --- a/tests/src/com/android/contacts/tests/testauth/TestauthConstants.java +++ /dev/null @@ -1,21 +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.contacts.tests.testauth; - -class TestauthConstants { - public static final String LOG_TAG = "Testauth"; -} |