Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappInfoTest.java

Issue 1224273003: webapps: propogate name and shortName from manifest to Java (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix cl issues Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappInfoTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappInfoTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappInfoTest.java
index 63f08f02d1447cc2186fcaa1ae441f9f7d032fb9..9d0bb37ebcfd0b5d81614344ee5b8e9191d78515 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappInfoTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappInfoTest.java
@@ -21,11 +21,12 @@ public class WebappInfoTest extends InstrumentationTestCase {
@Feature({"Webapps"})
public void testAbout() {
String id = "webapp id";
- String title = "webapp title";
+ String name = "longName";
+ String shortName = "name";
String url = "about:blank";
- WebappInfo info = WebappInfo.create(id, url,
- null, title, ScreenOrientationValues.DEFAULT, ShortcutSource.UNKNOWN);
+ WebappInfo info = WebappInfo.create(id, url, null, name, shortName,
+ ScreenOrientationValues.DEFAULT, ShortcutSource.UNKNOWN);
assertNotNull(info);
}
@@ -33,11 +34,12 @@ public class WebappInfoTest extends InstrumentationTestCase {
@Feature({"Webapps"})
public void testRandomUrl() {
String id = "webapp id";
- String title = "webapp title";
+ String name = "longName";
+ String shortName = "name";
String url = "http://google.com";
- WebappInfo info = WebappInfo.create(id, url,
- null, title, ScreenOrientationValues.DEFAULT, ShortcutSource.UNKNOWN);
+ WebappInfo info = WebappInfo.create(id, url, null, name, shortName,
+ ScreenOrientationValues.DEFAULT, ShortcutSource.UNKNOWN);
assertNotNull(info);
}
@@ -45,12 +47,14 @@ public class WebappInfoTest extends InstrumentationTestCase {
@Feature({"Webapps"})
public void testSpacesInUrl() {
String id = "webapp id";
- String title = "webapp title";
+ String name = "longName";
+ String shortName = "name";
String bustedUrl = "http://money.cnn.com/?category=Latest News";
Intent intent = new Intent();
intent.putExtra(ShortcutHelper.EXTRA_ID, id);
- intent.putExtra(ShortcutHelper.EXTRA_TITLE, title);
+ intent.putExtra(ShortcutHelper.EXTRA_NAME, name);
+ intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName);
intent.putExtra(ShortcutHelper.EXTRA_URL, bustedUrl);
WebappInfo info = WebappInfo.create(intent);
@@ -59,13 +63,90 @@ public class WebappInfoTest extends InstrumentationTestCase {
@SmallTest
@Feature({"Webapps"})
- public void testOrientationAndSource() {
+ public void testIntentTitleFallBack() {
+ String id = "webapp id";
+ String title = "webapp title";
+ String url = "about:blank";
+
+ Intent intent = new Intent();
+ intent.putExtra(ShortcutHelper.EXTRA_ID, id);
+ intent.putExtra(ShortcutHelper.EXTRA_TITLE, title);
+ intent.putExtra(ShortcutHelper.EXTRA_URL, url);
+
+ WebappInfo info = WebappInfo.create(intent);
+ assertNotNull(info);
gone 2015/07/20 22:20:16 nit: the expected values are always first in test
Lalit Maganti 2015/07/21 09:07:27 Swapped.
+ assertEquals(info.name(), title);
+ assertEquals(info.shortName(), title);
+ }
+
+ @SmallTest
+ @Feature({"Webapps"})
+ public void testIntentNameBlankNoTitle() {
+ String id = "webapp id";
+ String shortName = "name";
+ String url = "about:blank";
+
+ Intent intent = new Intent();
+ intent.putExtra(ShortcutHelper.EXTRA_ID, id);
+ intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName);
+ intent.putExtra(ShortcutHelper.EXTRA_URL, url);
+
+ WebappInfo info = WebappInfo.create(intent);
+ assertNotNull(info);
+ assertEquals(info.name(), "");
+ assertEquals(info.shortName(), shortName);
+ }
+
+ @SmallTest
+ @Feature({"Webapps"})
+ public void testIntentShortNameFallBack() {
String id = "webapp id";
String title = "webapp title";
+ String shortName = "name";
+ String url = "about:blank";
+
+ Intent intent = new Intent();
+ intent.putExtra(ShortcutHelper.EXTRA_ID, id);
+ intent.putExtra(ShortcutHelper.EXTRA_TITLE, shortName);
+ intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName);
+ intent.putExtra(ShortcutHelper.EXTRA_URL, url);
+
+ WebappInfo info = WebappInfo.create(intent);
+ assertNotNull(info);
+ assertEquals(info.name(), title);
+ assertEquals(info.shortName(), shortName);
+ }
+
+ @SmallTest
+ @Feature({"Webapps"})
+ public void testIntentNameShortname() {
+ String id = "webapp id";
+ String name = "longName";
+ String shortName = "name";
+ String url = "about:blank";
+
+ Intent intent = new Intent();
+ intent.putExtra(ShortcutHelper.EXTRA_ID, id);
+ intent.putExtra(ShortcutHelper.EXTRA_NAME, name);
+ intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName);
+ intent.putExtra(ShortcutHelper.EXTRA_URL, url);
+
+ WebappInfo info = WebappInfo.create(intent);
+ assertNotNull(info);
+ assertEquals(info.name(), name);
+ assertEquals(info.shortName(), shortName);
+ }
+
+ @SmallTest
+ @Feature({"Webapps"})
+ public void testOrientationAndSource() {
+ String id = "webapp id";
+ String name = "longName";
+ String shortName = "name";
String url = "http://money.cnn.com";
- WebappInfo info = WebappInfo.create(id, url,
- null, title, ScreenOrientationValues.DEFAULT, ShortcutSource.UNKNOWN);
+ WebappInfo info = WebappInfo.create(id, url, null, name, shortName,
+ ScreenOrientationValues.DEFAULT, ShortcutSource.UNKNOWN);
assertNotNull(info);
assertEquals(info.orientation(), ScreenOrientationValues.DEFAULT);
assertEquals(info.source(), ShortcutSource.UNKNOWN);

Powered by Google App Engine
This is Rietveld 408576698