aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/org
diff options
context:
space:
mode:
authorAdnan Begovic <adnan@cyngn.com>2016-06-14 17:36:57 -0700
committerAdnan Begovic <adnan@cyngn.com>2016-06-16 11:08:28 -0700
commitafa47a7973cceaf9cffc6ad67cc728cd7d22e97b (patch)
tree8c4ec37de6c0078d79203326c30a1a892025166f /tests/src/org
parent5d5e556c4998ee9f627a7a5556b777d94aef4d04 (diff)
downloadvendor_cmsdk-afa47a7973cceaf9cffc6ad67cc728cd7d22e97b.zip
vendor_cmsdk-afa47a7973cceaf9cffc6ad67cc728cd7d22e97b.tar.gz
vendor_cmsdk-afa47a7973cceaf9cffc6ad67cc728cd7d22e97b.tar.bz2
cmsdk: Provide remainder test coverage for CMStatusbarManager.
Change-Id: I4cfa89ac3d9e27b234c3209c203f2a3f2bf9c46b TICKET: CYNGNOS-3050
Diffstat (limited to 'tests/src/org')
-rw-r--r--tests/src/org/cyanogenmod/tests/customtiles/unit/CMStatusBarManagerTest.java9
-rw-r--r--tests/src/org/cyanogenmod/tests/customtiles/unit/CustomTileBuilderTest.java19
-rw-r--r--tests/src/org/cyanogenmod/tests/customtiles/unit/StatusBarPanelCustomTileTest.java43
3 files changed, 66 insertions, 5 deletions
diff --git a/tests/src/org/cyanogenmod/tests/customtiles/unit/CMStatusBarManagerTest.java b/tests/src/org/cyanogenmod/tests/customtiles/unit/CMStatusBarManagerTest.java
index 09c636d..e894462 100644
--- a/tests/src/org/cyanogenmod/tests/customtiles/unit/CMStatusBarManagerTest.java
+++ b/tests/src/org/cyanogenmod/tests/customtiles/unit/CMStatusBarManagerTest.java
@@ -105,6 +105,7 @@ public class CMStatusBarManagerTest extends AndroidTestCase {
@MediumTest
public void testCustomTileListenerServiceOnCustomTilePosted() {
final CustomTile expectedCustomTile = createSampleCustomTile();
+ final UserHandle expectedUserHandle = new UserHandle(UserHandle.myUserId());
final CountDownLatch signal = new CountDownLatch(COUNTDOWN);
CustomTileListenerService customTileListenerService =
@@ -114,7 +115,8 @@ public class CMStatusBarManagerTest extends AndroidTestCase {
super.onListenerConnected();
Log.d(TAG, "Connected");
// publish
- mCMStatusBarManager.publishTile(1337, expectedCustomTile);
+ mCMStatusBarManager.publishTileAsUser(null, 1337, expectedCustomTile,
+ expectedUserHandle);
}
@Override
@@ -122,7 +124,6 @@ public class CMStatusBarManagerTest extends AndroidTestCase {
super.onCustomTilePosted(sbc);
Log.d(TAG, "Posted " + sbc.getCustomTile());
if (TextUtils.equals(expectedCustomTile.label, sbc.getCustomTile().label)) {
- removeCustomTile(mContext.getPackageName(), null, 1337);
signal.countDown();
}
}
@@ -137,6 +138,8 @@ public class CMStatusBarManagerTest extends AndroidTestCase {
throw new AssertionError(e);
}
+ mCMStatusBarManager.removeTileAsUser(null, 1337, expectedUserHandle);
+
unregisterCustomTileListenerService(customTileListenerService);
}
@@ -151,7 +154,7 @@ public class CMStatusBarManagerTest extends AndroidTestCase {
public void onListenerConnected() {
super.onListenerConnected();
Log.d(TAG, "Connected");
- // publish
+ // publish as user
mCMStatusBarManager.publishTile(1338, expectedCustomTile);
}
diff --git a/tests/src/org/cyanogenmod/tests/customtiles/unit/CustomTileBuilderTest.java b/tests/src/org/cyanogenmod/tests/customtiles/unit/CustomTileBuilderTest.java
index 544089d..1368af5 100644
--- a/tests/src/org/cyanogenmod/tests/customtiles/unit/CustomTileBuilderTest.java
+++ b/tests/src/org/cyanogenmod/tests/customtiles/unit/CustomTileBuilderTest.java
@@ -114,6 +114,15 @@ public class CustomTileBuilderTest extends AndroidTestCase {
}
@SmallTest
+ public void testCustomTileBuilderLabelAsRes() {
+ String message = mContext.getString(R.string.app_name);
+ CustomTile customTile = new CustomTile.Builder(mContext)
+ .setLabel(R.string.app_name).build();
+ assertNotNull(customTile);
+ assertEquals(message, customTile.label);
+ }
+
+ @SmallTest
public void testCustomTileBuilderContentDescription() {
String message = "Test content description";
CustomTile customTile = new CustomTile.Builder(mContext)
@@ -124,6 +133,16 @@ public class CustomTileBuilderTest extends AndroidTestCase {
}
@SmallTest
+ public void testCustomTileBuilderContentDescriptionAsRes() {
+ String message = mContext.getString(R.string.app_name);
+ CustomTile customTile = new CustomTile.Builder(mContext)
+ .setContentDescription(R.string.app_name)
+ .build();
+ assertNotNull(customTile);
+ assertEquals(message, customTile.contentDescription);
+ }
+
+ @SmallTest
public void testCustomTileBuilderIconSet() {
int resourceInt = R.drawable.ic_launcher;
CustomTile customTile = new CustomTile.Builder(mContext)
diff --git a/tests/src/org/cyanogenmod/tests/customtiles/unit/StatusBarPanelCustomTileTest.java b/tests/src/org/cyanogenmod/tests/customtiles/unit/StatusBarPanelCustomTileTest.java
index 6b22f38..dd11e9b 100644
--- a/tests/src/org/cyanogenmod/tests/customtiles/unit/StatusBarPanelCustomTileTest.java
+++ b/tests/src/org/cyanogenmod/tests/customtiles/unit/StatusBarPanelCustomTileTest.java
@@ -56,13 +56,15 @@ public class StatusBarPanelCustomTileTest extends AndroidTestCase {
int expectedPid = Binder.getCallingPid();
CustomTile expectedCustomTile = createSampleCustomTile();
UserHandle expectedUserHandle = new UserHandle(mContext.getUserId());
+ long expectedPostTime = System.currentTimeMillis();
// public StatusBarPanelCustomTile(String pkg, String resPkg, String opPkg,
- // int id, String tag, int uid, int initialPid, CustomTile customTile, UserHandle user)
+ // int id, String tag, int uid, int initialPid, CustomTile customTile, UserHandle user,
+ // long postTime)
StatusBarPanelCustomTile statusBarPanelCustomTile =
new StatusBarPanelCustomTile(expectedPackage, expectedOpresPackage,
expectedOpPackage, expectedId, expectedTag, expectedUid, expectedPid,
- expectedCustomTile, expectedUserHandle);
+ expectedCustomTile, expectedUserHandle, expectedPostTime);
// Write to parcel
Parcel parcel = Parcel.obtain();
@@ -77,16 +79,53 @@ public class StatusBarPanelCustomTileTest extends AndroidTestCase {
assertNotNull(fromParcel);
assertEquals(expectedPackage, fromParcel.getPackage());
+ assertEquals(expectedPostTime, fromParcel.getPostTime());
assertEquals(expectedOpresPackage, fromParcel.getResPkg());
assertEquals(expectedOpPackage, fromParcel.getOpPkg());
assertEquals(expectedId, fromParcel.getId());
+ assertNotNull(fromParcel.getKey());
assertEquals(expectedTag, fromParcel.getTag());
assertEquals(expectedUid, fromParcel.getUid());
assertEquals(expectedPid, fromParcel.getInitialPid());
//CustomTile validation is excessive
assertEquals(expectedUserHandle.getIdentifier(), fromParcel.getUser().getIdentifier());
+ assertEquals(expectedUserHandle.getIdentifier(), fromParcel.getUserId());
}
+ @SmallTest
+ public void testDefaultConstructor() {
+ String expectedPackage = "expectedPackage";
+ String expectedOpresPackage = "resPackage";
+ String expectedOpPackage = "opPackage";
+ int expectedId = 1337;
+ String expectedTag = "TAG";
+ int expectedUid = mContext.getUserId();
+ int expectedPid = Binder.getCallingPid();
+ CustomTile expectedCustomTile = createSampleCustomTile();
+ UserHandle expectedUserHandle = new UserHandle(mContext.getUserId());
+
+ // public StatusBarPanelCustomTile(String pkg, String resPkg, String opPkg,
+ // int id, String tag, int uid, int initialPid, CustomTile customTile, UserHandle user)
+ StatusBarPanelCustomTile statusBarPanelCustomTile =
+ new StatusBarPanelCustomTile(expectedPackage, expectedOpresPackage,
+ expectedOpPackage, expectedId, expectedTag, expectedUid, expectedPid,
+ expectedCustomTile, expectedUserHandle);
+
+ assertNotNull(statusBarPanelCustomTile);
+ assertEquals(expectedPackage, statusBarPanelCustomTile.getPackage());
+ assertEquals(expectedOpresPackage, statusBarPanelCustomTile.getResPkg());
+ assertEquals(expectedOpPackage, statusBarPanelCustomTile.getOpPkg());
+ assertEquals(expectedId, statusBarPanelCustomTile.getId());
+ assertNotNull(statusBarPanelCustomTile.getKey());
+ assertEquals(expectedTag, statusBarPanelCustomTile.getTag());
+ assertEquals(expectedUid, statusBarPanelCustomTile.getUid());
+ assertEquals(expectedPid, statusBarPanelCustomTile.getInitialPid());
+ //CustomTile validation is excessive
+ assertEquals(expectedUserHandle.getIdentifier(),
+ statusBarPanelCustomTile.getUser().getIdentifier());
+ assertEquals(expectedUserHandle.getIdentifier(),
+ statusBarPanelCustomTile.getUserId());
+ }
private CustomTile createSampleCustomTile() {
Intent intent = new Intent(Intent.ACTION_DIAL);