cmsdk: Add functional manual and unit tests for new setIcon

Change-Id: Ia0f83c76429f80a7b7a4216e0cdf7d71844b9b64
This commit is contained in:
Adnan Begovic 2015-07-27 16:27:12 -07:00
parent d61839701e
commit 25daf555d2
7 changed files with 108 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 595 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 866 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -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<CustomTile.ExpandedListItem> expandedListItems =
new ArrayList<CustomTile.ExpandedListItem>();
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<CustomTile.ExpandedGridItem> expandedGridItems =
new ArrayList<CustomTile.ExpandedGridItem>();
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);

View File

@ -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;