use of com.android.frameworks.servicestests.R in project platform_frameworks_base by android.
the class ShortcutManagerTest1 method testManifestShortcuts_checkAllFields.
public void testManifestShortcuts_checkAllFields() {
mService.handleUnlockUser(USER_0);
// Package 1 updated, which has one valid manifest shortcut and one invalid.
addManifestShortcutResource(new ComponentName(CALLING_PACKAGE_1, ShortcutActivity.class.getName()), R.xml.shortcut_5);
updatePackageVersion(CALLING_PACKAGE_1, 1);
mService.mPackageMonitor.onReceive(getTestContext(), genPackageAddIntent(CALLING_PACKAGE_1, USER_0));
// Only the valid one is published.
runWithCaller(CALLING_PACKAGE_1, USER_0, () -> {
assertWith(getCallerShortcuts()).haveIds("ms1", "ms2", "ms3", "ms4", "ms5").areAllManifest().areAllImmutable().areAllEnabled().areAllNotPinned().areAllNotDynamic().forShortcutWithId("ms1", si -> {
assertEquals(R.drawable.icon1, si.getIconResourceId());
assertEquals(new ComponentName(CALLING_PACKAGE_1, ShortcutActivity.class.getName()), si.getActivity());
assertEquals(R.string.shortcut_title1, si.getTitleResId());
assertEquals("r" + R.string.shortcut_title1, si.getTitleResName());
assertEquals(R.string.shortcut_text1, si.getTextResId());
assertEquals("r" + R.string.shortcut_text1, si.getTextResName());
assertEquals(R.string.shortcut_disabled_message1, si.getDisabledMessageResourceId());
assertEquals("r" + R.string.shortcut_disabled_message1, si.getDisabledMessageResName());
assertEquals(set("android.shortcut.conversation", "android.shortcut.media"), si.getCategories());
assertEquals("action1", si.getIntent().getAction());
assertEquals(Uri.parse("http://a.b.c/1"), si.getIntent().getData());
}).forShortcutWithId("ms2", si -> {
assertEquals("ms2", si.getId());
assertEquals(R.drawable.icon2, si.getIconResourceId());
assertEquals(R.string.shortcut_title2, si.getTitleResId());
assertEquals("r" + R.string.shortcut_title2, si.getTitleResName());
assertEquals(R.string.shortcut_text2, si.getTextResId());
assertEquals("r" + R.string.shortcut_text2, si.getTextResName());
assertEquals(R.string.shortcut_disabled_message2, si.getDisabledMessageResourceId());
assertEquals("r" + R.string.shortcut_disabled_message2, si.getDisabledMessageResName());
assertEquals(set("android.shortcut.conversation"), si.getCategories());
assertEquals("action2", si.getIntent().getAction());
assertEquals(null, si.getIntent().getData());
}).forShortcutWithId("ms3", si -> {
assertEquals(0, si.getIconResourceId());
assertEquals(R.string.shortcut_title1, si.getTitleResId());
assertEquals("r" + R.string.shortcut_title1, si.getTitleResName());
assertEquals(0, si.getTextResId());
assertEquals(null, si.getTextResName());
assertEquals(0, si.getDisabledMessageResourceId());
assertEquals(null, si.getDisabledMessageResName());
assertEmpty(si.getCategories());
assertEquals("android.intent.action.VIEW", si.getIntent().getAction());
assertEquals(null, si.getIntent().getData());
}).forShortcutWithId("ms4", si -> {
assertEquals(0, si.getIconResourceId());
assertEquals(R.string.shortcut_title2, si.getTitleResId());
assertEquals("r" + R.string.shortcut_title2, si.getTitleResName());
assertEquals(0, si.getTextResId());
assertEquals(null, si.getTextResName());
assertEquals(0, si.getDisabledMessageResourceId());
assertEquals(null, si.getDisabledMessageResName());
assertEquals(set("cat"), si.getCategories());
assertEquals("android.intent.action.VIEW2", si.getIntent().getAction());
assertEquals(null, si.getIntent().getData());
}).forShortcutWithId("ms5", si -> {
si = getCallerShortcut("ms5");
assertEquals("action", si.getIntent().getAction());
assertEquals("http://www/", si.getIntent().getData().toString());
assertEquals("foo/bar", si.getIntent().getType());
assertEquals(new ComponentName("abc", ".xyz"), si.getIntent().getComponent());
assertEquals(set("cat1", "cat2"), si.getIntent().getCategories());
assertEquals("value1", si.getIntent().getStringExtra("key1"));
assertEquals("value2", si.getIntent().getStringExtra("key2"));
});
});
}
use of com.android.frameworks.servicestests.R in project android_frameworks_base by DirtyUnicorns.
the class ShortcutManagerTest1 method testManifestShortcuts_checkAllFields.
public void testManifestShortcuts_checkAllFields() {
mService.handleUnlockUser(USER_0);
// Package 1 updated, which has one valid manifest shortcut and one invalid.
addManifestShortcutResource(new ComponentName(CALLING_PACKAGE_1, ShortcutActivity.class.getName()), R.xml.shortcut_5);
updatePackageVersion(CALLING_PACKAGE_1, 1);
mService.mPackageMonitor.onReceive(getTestContext(), genPackageAddIntent(CALLING_PACKAGE_1, USER_0));
// Only the valid one is published.
runWithCaller(CALLING_PACKAGE_1, USER_0, () -> {
assertWith(getCallerShortcuts()).haveIds("ms1", "ms2", "ms3", "ms4", "ms5").areAllManifest().areAllImmutable().areAllEnabled().areAllNotPinned().areAllNotDynamic().forShortcutWithId("ms1", si -> {
assertEquals(R.drawable.icon1, si.getIconResourceId());
assertEquals(new ComponentName(CALLING_PACKAGE_1, ShortcutActivity.class.getName()), si.getActivity());
assertEquals(R.string.shortcut_title1, si.getTitleResId());
assertEquals("r" + R.string.shortcut_title1, si.getTitleResName());
assertEquals(R.string.shortcut_text1, si.getTextResId());
assertEquals("r" + R.string.shortcut_text1, si.getTextResName());
assertEquals(R.string.shortcut_disabled_message1, si.getDisabledMessageResourceId());
assertEquals("r" + R.string.shortcut_disabled_message1, si.getDisabledMessageResName());
assertEquals(set("android.shortcut.conversation", "android.shortcut.media"), si.getCategories());
assertEquals("action1", si.getIntent().getAction());
assertEquals(Uri.parse("http://a.b.c/1"), si.getIntent().getData());
}).forShortcutWithId("ms2", si -> {
assertEquals("ms2", si.getId());
assertEquals(R.drawable.icon2, si.getIconResourceId());
assertEquals(R.string.shortcut_title2, si.getTitleResId());
assertEquals("r" + R.string.shortcut_title2, si.getTitleResName());
assertEquals(R.string.shortcut_text2, si.getTextResId());
assertEquals("r" + R.string.shortcut_text2, si.getTextResName());
assertEquals(R.string.shortcut_disabled_message2, si.getDisabledMessageResourceId());
assertEquals("r" + R.string.shortcut_disabled_message2, si.getDisabledMessageResName());
assertEquals(set("android.shortcut.conversation"), si.getCategories());
assertEquals("action2", si.getIntent().getAction());
assertEquals(null, si.getIntent().getData());
}).forShortcutWithId("ms3", si -> {
assertEquals(0, si.getIconResourceId());
assertEquals(R.string.shortcut_title1, si.getTitleResId());
assertEquals("r" + R.string.shortcut_title1, si.getTitleResName());
assertEquals(0, si.getTextResId());
assertEquals(null, si.getTextResName());
assertEquals(0, si.getDisabledMessageResourceId());
assertEquals(null, si.getDisabledMessageResName());
assertEmpty(si.getCategories());
assertEquals("android.intent.action.VIEW", si.getIntent().getAction());
assertEquals(null, si.getIntent().getData());
}).forShortcutWithId("ms4", si -> {
assertEquals(0, si.getIconResourceId());
assertEquals(R.string.shortcut_title2, si.getTitleResId());
assertEquals("r" + R.string.shortcut_title2, si.getTitleResName());
assertEquals(0, si.getTextResId());
assertEquals(null, si.getTextResName());
assertEquals(0, si.getDisabledMessageResourceId());
assertEquals(null, si.getDisabledMessageResName());
assertEquals(set("cat"), si.getCategories());
assertEquals("android.intent.action.VIEW2", si.getIntent().getAction());
assertEquals(null, si.getIntent().getData());
}).forShortcutWithId("ms5", si -> {
si = getCallerShortcut("ms5");
assertEquals("action", si.getIntent().getAction());
assertEquals("http://www/", si.getIntent().getData().toString());
assertEquals("foo/bar", si.getIntent().getType());
assertEquals(new ComponentName("abc", ".xyz"), si.getIntent().getComponent());
assertEquals(set("cat1", "cat2"), si.getIntent().getCategories());
assertEquals("value1", si.getIntent().getStringExtra("key1"));
assertEquals("value2", si.getIntent().getStringExtra("key2"));
});
});
}
use of com.android.frameworks.servicestests.R in project android_frameworks_base by ResurrectionRemix.
the class ShortcutManagerTest1 method testManifestShortcuts_checkAllFields.
public void testManifestShortcuts_checkAllFields() {
mService.handleUnlockUser(USER_0);
// Package 1 updated, which has one valid manifest shortcut and one invalid.
addManifestShortcutResource(new ComponentName(CALLING_PACKAGE_1, ShortcutActivity.class.getName()), R.xml.shortcut_5);
updatePackageVersion(CALLING_PACKAGE_1, 1);
mService.mPackageMonitor.onReceive(getTestContext(), genPackageAddIntent(CALLING_PACKAGE_1, USER_0));
// Only the valid one is published.
runWithCaller(CALLING_PACKAGE_1, USER_0, () -> {
assertWith(getCallerShortcuts()).haveIds("ms1", "ms2", "ms3", "ms4", "ms5").areAllManifest().areAllImmutable().areAllEnabled().areAllNotPinned().areAllNotDynamic().forShortcutWithId("ms1", si -> {
assertEquals(R.drawable.icon1, si.getIconResourceId());
assertEquals(new ComponentName(CALLING_PACKAGE_1, ShortcutActivity.class.getName()), si.getActivity());
assertEquals(R.string.shortcut_title1, si.getTitleResId());
assertEquals("r" + R.string.shortcut_title1, si.getTitleResName());
assertEquals(R.string.shortcut_text1, si.getTextResId());
assertEquals("r" + R.string.shortcut_text1, si.getTextResName());
assertEquals(R.string.shortcut_disabled_message1, si.getDisabledMessageResourceId());
assertEquals("r" + R.string.shortcut_disabled_message1, si.getDisabledMessageResName());
assertEquals(set("android.shortcut.conversation", "android.shortcut.media"), si.getCategories());
assertEquals("action1", si.getIntent().getAction());
assertEquals(Uri.parse("http://a.b.c/1"), si.getIntent().getData());
}).forShortcutWithId("ms2", si -> {
assertEquals("ms2", si.getId());
assertEquals(R.drawable.icon2, si.getIconResourceId());
assertEquals(R.string.shortcut_title2, si.getTitleResId());
assertEquals("r" + R.string.shortcut_title2, si.getTitleResName());
assertEquals(R.string.shortcut_text2, si.getTextResId());
assertEquals("r" + R.string.shortcut_text2, si.getTextResName());
assertEquals(R.string.shortcut_disabled_message2, si.getDisabledMessageResourceId());
assertEquals("r" + R.string.shortcut_disabled_message2, si.getDisabledMessageResName());
assertEquals(set("android.shortcut.conversation"), si.getCategories());
assertEquals("action2", si.getIntent().getAction());
assertEquals(null, si.getIntent().getData());
}).forShortcutWithId("ms3", si -> {
assertEquals(0, si.getIconResourceId());
assertEquals(R.string.shortcut_title1, si.getTitleResId());
assertEquals("r" + R.string.shortcut_title1, si.getTitleResName());
assertEquals(0, si.getTextResId());
assertEquals(null, si.getTextResName());
assertEquals(0, si.getDisabledMessageResourceId());
assertEquals(null, si.getDisabledMessageResName());
assertEmpty(si.getCategories());
assertEquals("android.intent.action.VIEW", si.getIntent().getAction());
assertEquals(null, si.getIntent().getData());
}).forShortcutWithId("ms4", si -> {
assertEquals(0, si.getIconResourceId());
assertEquals(R.string.shortcut_title2, si.getTitleResId());
assertEquals("r" + R.string.shortcut_title2, si.getTitleResName());
assertEquals(0, si.getTextResId());
assertEquals(null, si.getTextResName());
assertEquals(0, si.getDisabledMessageResourceId());
assertEquals(null, si.getDisabledMessageResName());
assertEquals(set("cat"), si.getCategories());
assertEquals("android.intent.action.VIEW2", si.getIntent().getAction());
assertEquals(null, si.getIntent().getData());
}).forShortcutWithId("ms5", si -> {
si = getCallerShortcut("ms5");
assertEquals("action", si.getIntent().getAction());
assertEquals("http://www/", si.getIntent().getData().toString());
assertEquals("foo/bar", si.getIntent().getType());
assertEquals(new ComponentName("abc", ".xyz"), si.getIntent().getComponent());
assertEquals(set("cat1", "cat2"), si.getIntent().getCategories());
assertEquals("value1", si.getIntent().getStringExtra("key1"));
assertEquals("value2", si.getIntent().getStringExtra("key2"));
});
});
}
use of com.android.frameworks.servicestests.R in project android_frameworks_base by crdroidandroid.
the class ShortcutManagerTest1 method testManifestShortcuts_checkAllFields.
public void testManifestShortcuts_checkAllFields() {
mService.handleUnlockUser(USER_0);
// Package 1 updated, which has one valid manifest shortcut and one invalid.
addManifestShortcutResource(new ComponentName(CALLING_PACKAGE_1, ShortcutActivity.class.getName()), R.xml.shortcut_5);
updatePackageVersion(CALLING_PACKAGE_1, 1);
mService.mPackageMonitor.onReceive(getTestContext(), genPackageAddIntent(CALLING_PACKAGE_1, USER_0));
// Only the valid one is published.
runWithCaller(CALLING_PACKAGE_1, USER_0, () -> {
assertWith(getCallerShortcuts()).haveIds("ms1", "ms2", "ms3", "ms4", "ms5").areAllManifest().areAllImmutable().areAllEnabled().areAllNotPinned().areAllNotDynamic().forShortcutWithId("ms1", si -> {
assertEquals(R.drawable.icon1, si.getIconResourceId());
assertEquals(new ComponentName(CALLING_PACKAGE_1, ShortcutActivity.class.getName()), si.getActivity());
assertEquals(R.string.shortcut_title1, si.getTitleResId());
assertEquals("r" + R.string.shortcut_title1, si.getTitleResName());
assertEquals(R.string.shortcut_text1, si.getTextResId());
assertEquals("r" + R.string.shortcut_text1, si.getTextResName());
assertEquals(R.string.shortcut_disabled_message1, si.getDisabledMessageResourceId());
assertEquals("r" + R.string.shortcut_disabled_message1, si.getDisabledMessageResName());
assertEquals(set("android.shortcut.conversation", "android.shortcut.media"), si.getCategories());
assertEquals("action1", si.getIntent().getAction());
assertEquals(Uri.parse("http://a.b.c/1"), si.getIntent().getData());
}).forShortcutWithId("ms2", si -> {
assertEquals("ms2", si.getId());
assertEquals(R.drawable.icon2, si.getIconResourceId());
assertEquals(R.string.shortcut_title2, si.getTitleResId());
assertEquals("r" + R.string.shortcut_title2, si.getTitleResName());
assertEquals(R.string.shortcut_text2, si.getTextResId());
assertEquals("r" + R.string.shortcut_text2, si.getTextResName());
assertEquals(R.string.shortcut_disabled_message2, si.getDisabledMessageResourceId());
assertEquals("r" + R.string.shortcut_disabled_message2, si.getDisabledMessageResName());
assertEquals(set("android.shortcut.conversation"), si.getCategories());
assertEquals("action2", si.getIntent().getAction());
assertEquals(null, si.getIntent().getData());
}).forShortcutWithId("ms3", si -> {
assertEquals(0, si.getIconResourceId());
assertEquals(R.string.shortcut_title1, si.getTitleResId());
assertEquals("r" + R.string.shortcut_title1, si.getTitleResName());
assertEquals(0, si.getTextResId());
assertEquals(null, si.getTextResName());
assertEquals(0, si.getDisabledMessageResourceId());
assertEquals(null, si.getDisabledMessageResName());
assertEmpty(si.getCategories());
assertEquals("android.intent.action.VIEW", si.getIntent().getAction());
assertEquals(null, si.getIntent().getData());
}).forShortcutWithId("ms4", si -> {
assertEquals(0, si.getIconResourceId());
assertEquals(R.string.shortcut_title2, si.getTitleResId());
assertEquals("r" + R.string.shortcut_title2, si.getTitleResName());
assertEquals(0, si.getTextResId());
assertEquals(null, si.getTextResName());
assertEquals(0, si.getDisabledMessageResourceId());
assertEquals(null, si.getDisabledMessageResName());
assertEquals(set("cat"), si.getCategories());
assertEquals("android.intent.action.VIEW2", si.getIntent().getAction());
assertEquals(null, si.getIntent().getData());
}).forShortcutWithId("ms5", si -> {
si = getCallerShortcut("ms5");
assertEquals("action", si.getIntent().getAction());
assertEquals("http://www/", si.getIntent().getData().toString());
assertEquals("foo/bar", si.getIntent().getType());
assertEquals(new ComponentName("abc", ".xyz"), si.getIntent().getComponent());
assertEquals(set("cat1", "cat2"), si.getIntent().getCategories());
assertEquals("value1", si.getIntent().getStringExtra("key1"));
assertEquals("value2", si.getIntent().getStringExtra("key2"));
});
});
}
Aggregations