summaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/providers/contacts/ContactsMockResources.java
diff options
context:
space:
mode:
authorDaniel Lehmann <lehmannd@google.com>2011-08-14 15:53:42 -0700
committerDaniel Lehmann <lehmannd@google.com>2011-08-14 15:53:42 -0700
commit0bf6b318e3c994294d4a885f57906debd4a0e64e (patch)
treedc730be21876e5179d97c98f3ecf292d2ba61a93 /tests/src/com/android/providers/contacts/ContactsMockResources.java
parent0e272967c6c6662d8a6eed80650dad0369aac085 (diff)
downloadpackages_providers_ContactsProvider-0bf6b318e3c994294d4a885f57906debd4a0e64e.zip
packages_providers_ContactsProvider-0bf6b318e3c994294d4a885f57906debd4a0e64e.tar.gz
packages_providers_ContactsProvider-0bf6b318e3c994294d4a885f57906debd4a0e64e.tar.bz2
Several DB changes as requested by ES
- Switch from resource ids to names to prevent breakage on package upgrade Bug:5135277 - Add SYNC1...SYNC4 columns to StreamItems and StreamItemPhotos Bug:5119385 - Remove ACTION, ACTION_URI from Groups, StreamItems and StreamItemPhotos (this reduces db size and prevents click intercepting) Bug:5135808 - Add some raw-contact fields to the StreamItem and StreamItemPhotos query Bug:5134081 Doing those changes in one block to prevent too many db upgrade steps Bug:5135277 Change-Id: I1d1661c9a507d9efd4ef334fe21481097e820b7c
Diffstat (limited to 'tests/src/com/android/providers/contacts/ContactsMockResources.java')
-rw-r--r--tests/src/com/android/providers/contacts/ContactsMockResources.java68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/src/com/android/providers/contacts/ContactsMockResources.java b/tests/src/com/android/providers/contacts/ContactsMockResources.java
new file mode 100644
index 0000000..d1ec817
--- /dev/null
+++ b/tests/src/com/android/providers/contacts/ContactsMockResources.java
@@ -0,0 +1,68 @@
+/*
+ * 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.providers.contacts;
+
+import com.google.common.collect.Maps;
+
+import android.content.res.Resources.NotFoundException;
+import android.test.mock.MockResources;
+
+import java.util.Map;
+
+final class ContactsMockResources extends MockResources {
+ private Map<Integer, String> mPackages = Maps.newHashMap();
+ private Map<Integer, String> mTypes = Maps.newHashMap();
+ private Map<Integer, String> mEntries = Maps.newHashMap();
+
+ public void addResource(int resId, String packageName, String typeName, String entryName) {
+ mPackages.put(resId, packageName);
+ mTypes.put(resId, typeName);
+ mEntries.put(resId, entryName);
+ }
+
+ @Override
+ public String getResourceName(int resId) throws NotFoundException {
+ if (!mPackages.containsKey(resId)) {
+ throw new NotFoundException("Resource " + resId + " not found");
+ }
+ return mPackages.get(resId) + ":" + mTypes.get(resId) + "/" + mEntries.get(resId);
+ }
+
+ @Override
+ public String getResourcePackageName(int resId) throws NotFoundException {
+ if (!mPackages.containsKey(resId)) {
+ throw new NotFoundException("Resource " + resId + " not found");
+ }
+ return mPackages.get(resId);
+ }
+
+ @Override
+ public String getResourceTypeName(int resId) throws NotFoundException {
+ if (!mPackages.containsKey(resId)) {
+ throw new NotFoundException("Resource " + resId + " not found");
+ }
+ return mTypes.get(resId);
+ }
+
+ @Override
+ public String getResourceEntryName(int resId) throws NotFoundException {
+ if (!mPackages.containsKey(resId)) {
+ throw new NotFoundException("Resource " + resId + " not found");
+ }
+ return mEntries.get(resId);
+ }
+} \ No newline at end of file