OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * Content provider for testing content URLs. | 6 * Content provider for testing content URLs. |
7 */ | 7 */ |
8 | 8 |
9 package org.chromium.chrome.test; | 9 package org.chromium.chrome.test; |
10 | 10 |
11 import android.content.ContentProvider; | 11 import android.content.ContentProvider; |
12 import android.content.ContentValues; | 12 import android.content.ContentValues; |
13 import android.content.Context; | 13 import android.content.Context; |
14 import android.database.AbstractCursor; | 14 import android.database.AbstractCursor; |
15 import android.database.Cursor; | 15 import android.database.Cursor; |
16 import android.net.Uri; | 16 import android.net.Uri; |
17 import android.os.ParcelFileDescriptor; | 17 import android.os.ParcelFileDescriptor; |
18 import android.util.Log; | 18 import android.util.Log; |
19 | 19 |
| 20 import org.chromium.base.annotations.MainDex; |
| 21 |
20 import java.io.File; | 22 import java.io.File; |
21 import java.io.FileNotFoundException; | 23 import java.io.FileNotFoundException; |
22 import java.io.IOException; | 24 import java.io.IOException; |
23 import java.net.URLConnection; | 25 import java.net.URLConnection; |
24 import java.util.HashMap; | 26 import java.util.HashMap; |
25 import java.util.Map; | 27 import java.util.Map; |
26 | 28 |
27 /** | 29 /** |
28 * Content provider for testing content:// urls. | 30 * Content provider for testing content:// urls. |
29 * Note: if you move this class, make sure you have also updated AndroidManifest
.xml | 31 * Note: if you move this class, make sure you have also updated AndroidManifest
.xml |
(...skipping 10 matching lines...) Expand all Loading... |
40 * requires declaring a sharedUserId between the Chrome apk and ChromePublicTest
Apk and | 42 * requires declaring a sharedUserId between the Chrome apk and ChromePublicTest
Apk and |
41 * then setting the target process for ContentProvider for the instrumentation t
arget package. | 43 * then setting the target process for ContentProvider for the instrumentation t
arget package. |
42 * android:process="{{manifest_package}}" | 44 * android:process="{{manifest_package}}" |
43 * | 45 * |
44 * Note that modifying the application manifest file could be problematic as Chr
ome has | 46 * Note that modifying the application manifest file could be problematic as Chr
ome has |
45 * side by side channels. | 47 * side by side channels. |
46 * | 48 * |
47 * The second one is moving the TestContentProvider to the ChromeTestSuport apk.
This | 49 * The second one is moving the TestContentProvider to the ChromeTestSuport apk.
This |
48 * seems a lot better path than above. | 50 * seems a lot better path than above. |
49 */ | 51 */ |
| 52 @MainDex |
50 public class TestContentProvider extends ContentProvider { | 53 public class TestContentProvider extends ContentProvider { |
51 private static final String ANDROID_DATA_FILE_PATH = "android/"; | 54 private static final String ANDROID_DATA_FILE_PATH = "android/"; |
52 private static final String AUTHORITY = "org.chromium.chrome.test.TestConten
tProvider"; | 55 private static final String AUTHORITY = "org.chromium.chrome.test.TestConten
tProvider"; |
53 private static final String CONTENT_SCHEME = "content://"; | 56 private static final String CONTENT_SCHEME = "content://"; |
54 private static final String GET_RESOURCE_REQUEST_COUNT = "get_resource_reque
st_count"; | 57 private static final String GET_RESOURCE_REQUEST_COUNT = "get_resource_reque
st_count"; |
55 private static final String RESET_RESOURCE_REQUEST_COUNTS = "reset_resource_
request_counts"; | 58 private static final String RESET_RESOURCE_REQUEST_COUNTS = "reset_resource_
request_counts"; |
56 private static final String SET_DATA_PATH = "set_data_path"; | 59 private static final String SET_DATA_PATH = "set_data_path"; |
57 private static final String TAG = "TestContentProvider"; | 60 private static final String TAG = "TestContentProvider"; |
58 private enum ColumnIndex { | 61 private enum ColumnIndex { |
59 RESOURCE_REQUEST_COUNT_COLUMN, | 62 RESOURCE_REQUEST_COUNT_COLUMN, |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 ? mResourceRequestCount.get(resource) : 0); | 233 ? mResourceRequestCount.get(resource) : 0); |
231 } else if (RESET_RESOURCE_REQUEST_COUNTS.equals(action)) { | 234 } else if (RESET_RESOURCE_REQUEST_COUNTS.equals(action)) { |
232 mResourceRequestCount = new HashMap<String, Integer>(); | 235 mResourceRequestCount = new HashMap<String, Integer>(); |
233 } else if (SET_DATA_PATH.equals(action)) { | 236 } else if (SET_DATA_PATH.equals(action)) { |
234 mDataFilePath = resource; | 237 mDataFilePath = resource; |
235 } | 238 } |
236 return null; | 239 return null; |
237 } | 240 } |
238 } | 241 } |
239 } | 242 } |
OLD | NEW |