Search in sources :

Example 51 with MediumTest

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));
}
Also used : InputStream(java.io.InputStream) Uri(android.net.Uri) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 52 with MediumTest

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
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 53 with MediumTest

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"));
}
Also used : ContentResolver(android.content.ContentResolver) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 54 with MediumTest

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
    }
}
Also used : ContentResolver(android.content.ContentResolver) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 55 with MediumTest

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, '*'));
}
Also used : ContentValues(android.content.ContentValues) Intent(android.content.Intent) Uri(android.net.Uri) ContentResolver(android.content.ContentResolver) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Aggregations

MediumTest (android.test.suitebuilder.annotation.MediumTest)996 View (android.view.View)246 ListView (android.widget.ListView)150 Cursor (android.database.Cursor)116 Handler (android.os.Handler)116 Suppress (android.test.suitebuilder.annotation.Suppress)69 TextView (android.widget.TextView)67 ContentValues (android.content.ContentValues)63 ServiceStatus (com.vodafone360.people.service.ServiceStatus)60 SQLiteCursor (android.database.sqlite.SQLiteCursor)54 SQLiteStatement (android.database.sqlite.SQLiteStatement)49 IOException (java.io.IOException)49 UiThreadTest (android.test.UiThreadTest)48 LogRec (com.android.internal.util.StateMachine.LogRec)42 ContentResolver (android.content.ContentResolver)37 Intent (android.content.Intent)36 Message (android.os.Message)36 GridView (android.widget.GridView)36 InputStream (java.io.InputStream)36 ByteArrayInputStream (java.io.ByteArrayInputStream)35