diff --git a/tests/res/drawable-hdpi/ic_whatshot_white_24dp.png b/tests/res/drawable-hdpi/ic_whatshot_white_24dp.png new file mode 100644 index 0000000..46ed1f8 Binary files /dev/null and b/tests/res/drawable-hdpi/ic_whatshot_white_24dp.png differ diff --git a/tests/res/drawable-mdpi/ic_whatshot_white_24dp.png b/tests/res/drawable-mdpi/ic_whatshot_white_24dp.png new file mode 100644 index 0000000..4cf6f85 Binary files /dev/null and b/tests/res/drawable-mdpi/ic_whatshot_white_24dp.png differ diff --git a/tests/res/drawable-xhdpi/ic_whatshot_white_24dp.png b/tests/res/drawable-xhdpi/ic_whatshot_white_24dp.png new file mode 100644 index 0000000..3651d06 Binary files /dev/null and b/tests/res/drawable-xhdpi/ic_whatshot_white_24dp.png differ diff --git a/tests/res/drawable-xxhdpi/ic_whatshot_white_24dp.png b/tests/res/drawable-xxhdpi/ic_whatshot_white_24dp.png new file mode 100644 index 0000000..8eaf375 Binary files /dev/null and b/tests/res/drawable-xxhdpi/ic_whatshot_white_24dp.png differ diff --git a/tests/res/drawable-xxxhdpi/ic_whatshot_white_24dp.png b/tests/res/drawable-xxxhdpi/ic_whatshot_white_24dp.png new file mode 100644 index 0000000..5c5d868 Binary files /dev/null and b/tests/res/drawable-xxxhdpi/ic_whatshot_white_24dp.png differ diff --git a/tests/src/org/cyanogenmod/tests/customtiles/CMStatusBarTest.java b/tests/src/org/cyanogenmod/tests/customtiles/CMStatusBarTest.java index 3319f62..904bc3d 100644 --- a/tests/src/org/cyanogenmod/tests/customtiles/CMStatusBarTest.java +++ b/tests/src/org/cyanogenmod/tests/customtiles/CMStatusBarTest.java @@ -18,6 +18,8 @@ package org.cyanogenmod.tests.customtiles; import android.app.PendingIntent; import android.content.Intent; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.net.Uri; import android.os.Handler; @@ -66,6 +68,25 @@ public class CMStatusBarTest extends TestActivity { } }, + new Test("test publish tile with bitmap") { + public void run() { + int resourceInt = R.drawable.ic_whatshot_white_24dp; + Bitmap bitmap = BitmapFactory.decodeResource(getResources(), + resourceInt); + PendingIntent intent = PendingIntent.getActivity(CMStatusBarTest.this, 0, + new Intent(CMStatusBarTest.this, CMStatusBarTest.class) + .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK), 0); + mCustomTile = new CustomTile.Builder(CMStatusBarTest.this) + .setLabel("Test From SDK - remote icon") + .setIcon(bitmap) + .setOnClickIntent(intent) + .shouldCollapsePanel(true) + .setContentDescription("Content description") + .build(); + mCMStatusBarManager.publishTile(CUSTOM_TILE_ID, mCustomTile); + } + }, + new Test("test publish tile in 3 seconds") { public void run() { mHandler.postDelayed(new Runnable() { @@ -171,6 +192,43 @@ public class CMStatusBarTest extends TestActivity { } }, + new Test("test publish tile with expanded list with bitmaps") { + public void run() { + PendingIntent intent = PendingIntent.getActivity(CMStatusBarTest.this, 0, + new Intent(CMStatusBarTest.this, CMStatusBarTest.class) + .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK), 0); + ArrayList expandedListItems = + new ArrayList(); + int resourceInt = R.drawable.ic_whatshot_white_24dp; + Bitmap bitmap = BitmapFactory.decodeResource(getResources(), + resourceInt); + for (int i = 0; i < 20; i++) { + CustomTile.ExpandedListItem expandedListItem = + new CustomTile.ExpandedListItem(); + expandedListItem.setExpandedListItemBitmap(bitmap); + expandedListItem.setExpandedListItemTitle("Test: " + i); + expandedListItem.setExpandedListItemSummary("Test item summary " + i); + expandedListItem.setExpandedListItemOnClickIntent(intent); + expandedListItems.add(expandedListItem); + } + + CustomTile.ListExpandedStyle listExpandedStyle = + new CustomTile.ListExpandedStyle(); + listExpandedStyle.setListItems(expandedListItems); + CustomTile customTile = new CustomTile.Builder(CMStatusBarTest.this) + .setLabel("Test Expanded List Style From SDK") + .setIcon(R.drawable.ic_launcher) + .setExpandedStyle(listExpandedStyle) + .setOnSettingsClickIntent(new Intent(CMStatusBarTest.this, + DummySettings.class) + .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) + .setContentDescription("Content description") + .build(); + CMStatusBarManager.getInstance(CMStatusBarTest.this) + .publishTile(CUSTOM_TILE_SETTINGS_ID, customTile); + } + }, + new Test("test publish tile with expanded grid") { public void run() { PendingIntent intent = PendingIntent.getActivity(CMStatusBarTest.this, 0, @@ -187,6 +245,42 @@ public class CMStatusBarTest extends TestActivity { expandedGridItems.add(expandedGridItem); } + CustomTile.GridExpandedStyle gridExpandedStyle = + new CustomTile.GridExpandedStyle(); + gridExpandedStyle.setGridItems(expandedGridItems); + CustomTile customTile = new CustomTile.Builder(CMStatusBarTest.this) + .setLabel("Test Expanded Grid Style From SDK") + .setIcon(R.drawable.ic_launcher) + .setExpandedStyle(gridExpandedStyle) + .setOnSettingsClickIntent(new Intent(CMStatusBarTest.this, + DummySettings.class) + .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) + .setContentDescription("Content description") + .build(); + CMStatusBarManager.getInstance(CMStatusBarTest.this) + .publishTile(CUSTOM_TILE_SETTINGS_ID, customTile); + } + }, + + new Test("test publish tile with expanded grid with bitmaps") { + public void run() { + PendingIntent intent = PendingIntent.getActivity(CMStatusBarTest.this, 0, + new Intent(CMStatusBarTest.this, CMStatusBarTest.class) + .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK), 0); + ArrayList expandedGridItems = + new ArrayList(); + int resourceInt = R.drawable.ic_whatshot_white_24dp; + Bitmap bitmap = BitmapFactory.decodeResource(getResources(), + resourceInt); + for (int i = 0; i < 8; i++) { + CustomTile.ExpandedGridItem expandedGridItem = + new CustomTile.ExpandedGridItem(); + expandedGridItem.setExpandedGridItemBitmap(bitmap); + expandedGridItem.setExpandedGridItemTitle("Test: " + i); + expandedGridItem.setExpandedGridItemOnClickIntent(intent); + expandedGridItems.add(expandedGridItem); + } + CustomTile.GridExpandedStyle gridExpandedStyle = new CustomTile.GridExpandedStyle(); gridExpandedStyle.setGridItems(expandedGridItems); diff --git a/tests/src/org/cyanogenmod/tests/customtiles/unit/CustomTileBuilderTest.java b/tests/src/org/cyanogenmod/tests/customtiles/unit/CustomTileBuilderTest.java index f2a5e31..93bd132 100644 --- a/tests/src/org/cyanogenmod/tests/customtiles/unit/CustomTileBuilderTest.java +++ b/tests/src/org/cyanogenmod/tests/customtiles/unit/CustomTileBuilderTest.java @@ -18,6 +18,8 @@ package org.cyanogenmod.tests.customtiles.unit; import android.app.PendingIntent; import android.content.Intent; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.net.Uri; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.MediumTest; @@ -106,6 +108,18 @@ public class CustomTileBuilderTest extends AndroidTestCase { assertEquals(resourceInt, customTile.icon); } + @SmallTest + public void testCustomTileBuilderRemoteIconSet() { + int resourceInt = R.drawable.ic_whatshot_white_24dp; + Bitmap bitmap = BitmapFactory.decodeResource(getContext().getResources(), + resourceInt); + CustomTile customTile = new CustomTile.Builder(mContext) + .setIcon(bitmap) + .build(); + assertNotNull(customTile.remoteIcon); + assertEquals(bitmap, customTile.remoteIcon); + } + @SmallTest public void testCustomTileBuilderCollapsePanelSet() { boolean collapsePanel = true;