use of android.test.suitebuilder.annotation.MediumTest in project platform_frameworks_base by android.
the class MemoryFileProviderTest method testRead.
// reads from a cross-process AssetFileDescriptor for a MemoryFile
@MediumTest
public void testRead() throws Exception {
ContentResolver resolver = getContext().getContentResolver();
Uri uri = Uri.parse("content://android.content.MemoryFileProvider/data/1/blob");
byte[] buf = new byte[MemoryFileProvider.TEST_BLOB.length];
InputStream in = resolver.openInputStream(uri);
assertNotNull(in);
int count = in.read(buf);
assertEquals(buf.length, count);
assertEquals(-1, in.read());
in.close();
assertTrue(Arrays.equals(MemoryFileProvider.TEST_BLOB, buf));
}
use of android.test.suitebuilder.annotation.MediumTest in project platform_frameworks_base by android.
the class LimitedLengthInputStreamTest method testConstructor_NegativeLength_Failure.
@MediumTest
public void testConstructor_NegativeLength_Failure() throws Exception {
try {
InputStream is = new LimitedLengthInputStream(mTestStream1, 0, -1);
fail("Should throw IOException on negative length");
} catch (IOException e) {
// success
}
}
use of android.test.suitebuilder.annotation.MediumTest in project platform_frameworks_base by android.
the class SettingsProviderTest method testParseProviderList.
@MediumTest
public void testParseProviderList() {
ContentResolver r = getContext().getContentResolver();
// We only accept "+value" and "-value"
// Test adding a value
Settings.Secure.putString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+test1");
assertTrue(Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED).contains("test1"));
// Test adding a second value
Settings.Secure.putString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+test2");
assertTrue(Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED).contains("test1"));
assertTrue(Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED).contains("test2"));
// Test adding a third value
Settings.Secure.putString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+test3");
assertTrue(Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED).contains("test1"));
assertTrue(Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED).contains("test2"));
assertTrue(Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED).contains("test3"));
// Test deleting the first value in a 3 item list
Settings.Secure.putString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "-test1");
assertFalse(Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED).contains("test1"));
// Test deleting the middle value in a 3 item list
Settings.Secure.putString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+test4");
assertTrue(Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED).contains("test2"));
assertTrue(Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED).contains("test3"));
assertTrue(Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED).contains("test4"));
Settings.Secure.putString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "-test3");
assertFalse(Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED).contains("test3"));
// Test deleting the last value in a 3 item list
Settings.Secure.putString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+test5");
assertTrue(Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED).contains("test2"));
assertTrue(Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED).contains("test4"));
assertTrue(Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED).contains("test5"));
Settings.Secure.putString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "-test5");
assertFalse(Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED).contains("test5"));
}
use of android.test.suitebuilder.annotation.MediumTest in project platform_frameworks_base by android.
the class SettingsProviderTest method testNameValueCache.
@MediumTest
public void testNameValueCache() {
ContentResolver r = getContext().getContentResolver();
Settings.Secure.putString(r, "test_service", "Value");
assertEquals("Value", Settings.Secure.getString(r, "test_service"));
// Make sure the value can be overwritten.
Settings.Secure.putString(r, "test_service", "New");
assertEquals("New", Settings.Secure.getString(r, "test_service"));
// Also that delete works.
assertEquals(1, r.delete(Settings.Secure.getUriFor("test_service"), null, null));
assertEquals(null, Settings.Secure.getString(r, "test_service"));
// Apps should not be able to use System settings.
try {
Settings.System.putString(r, "test_setting", "Value");
fail("IllegalArgumentException expected");
} catch (java.lang.IllegalArgumentException e) {
// expected
}
}
use of android.test.suitebuilder.annotation.MediumTest in project platform_frameworks_base by android.
the class SettingsProviderTest method testRowNumberContentUri.
@MediumTest
// Settings.Bookmarks uses a query format that's not supported now.
@Suppress
public void testRowNumberContentUri() {
ContentResolver r = getContext().getContentResolver();
// The bookmarks table (and everything else) uses standard row number content URIs.
Uri uri = Settings.Bookmarks.add(r, new Intent("TEST"), "Test Title", "Test Folder", '*', 123);
assertTrue(ContentUris.parseId(uri) > 0);
assertEquals("TEST", Settings.Bookmarks.getIntentForShortcut(r, '*').getAction());
ContentValues v = new ContentValues();
v.put(Settings.Bookmarks.INTENT, "#Intent;action=TOAST;end");
assertEquals(1, r.update(uri, v, null, null));
assertEquals("TOAST", Settings.Bookmarks.getIntentForShortcut(r, '*').getAction());
assertEquals(1, r.delete(uri, null, null));
assertEquals(null, Settings.Bookmarks.getIntentForShortcut(r, '*'));
}
Aggregations