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

Unified Diff: chrome/android/junit/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java

Issue 2281913002: Currency code exceeding 6 chars will be ellipsized. (Closed)
Patch Set: Added comments Created 4 years, 3 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/junit/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java
index b13d45d048425a495f9b4d20f81227d7647e7c44..3ebb069e0ccdd5c464648a4c5dece53a0a26b0a5 100644
--- a/chrome/android/junit/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java
@@ -33,74 +33,78 @@ public class CurrencyStringFormatterTest {
@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] {
- {"55.00", "USD", "en-US", "$55.00", ExpectedValidity.VALID_AMOUNT},
- {"55.00", "USD", "en-CA", "$55.00", ExpectedValidity.VALID_AMOUNT},
- {"55.00", "USD", "fr-CA", "$55,00", ExpectedValidity.VALID_AMOUNT},
- {"55.00", "USD", "fr-FR", "$55,00", ExpectedValidity.VALID_AMOUNT},
-
- {"55.00", "EUR", "en-US", "55.00", ExpectedValidity.VALID_AMOUNT},
- {"55.00", "EUR", "en-CA", "55.00", ExpectedValidity.VALID_AMOUNT},
- {"55.00", "EUR", "fr-CA", "55,00", ExpectedValidity.VALID_AMOUNT},
- {"55.00", "EUR", "fr-FR", "55,00", ExpectedValidity.VALID_AMOUNT},
-
- {"55.00", "CAD", "en-US", "55.00", ExpectedValidity.VALID_AMOUNT},
- {"55.00", "CAD", "en-CA", "55.00", ExpectedValidity.VALID_AMOUNT},
- {"55.00", "CAD", "fr-CA", "55,00", ExpectedValidity.VALID_AMOUNT},
- {"55.00", "CAD", "fr-FR", "55,00", ExpectedValidity.VALID_AMOUNT},
-
- {"55.12", "JPY", "ja-JP", "55.12", ExpectedValidity.VALID_AMOUNT},
- {"55.00", "JPY", "ja-JP", "55.00", ExpectedValidity.VALID_AMOUNT},
- {"55.0", "JPY", "ja-JP", "55.0", ExpectedValidity.VALID_AMOUNT},
- {"55", "JPY", "ja-JP", "55", ExpectedValidity.VALID_AMOUNT},
+ {"55.00", "USD", "en-US", "USD", "$55.00", ExpectedValidity.VALID_AMOUNT},
+ {"55.00", "USD", "en-CA", "USD", "$55.00", ExpectedValidity.VALID_AMOUNT},
+ {"55.00", "USD", "fr-CA", "USD", "$55,00", ExpectedValidity.VALID_AMOUNT},
+ {"55.00", "USD", "fr-FR", "USD", "$55,00", ExpectedValidity.VALID_AMOUNT},
+
+ {"55.00", "EUR", "en-US", "EUR", "55.00", ExpectedValidity.VALID_AMOUNT},
+ {"55.00", "EUR", "en-CA", "EUR", "55.00", ExpectedValidity.VALID_AMOUNT},
+ {"55.00", "EUR", "fr-CA", "EUR", "55,00", ExpectedValidity.VALID_AMOUNT},
+ {"55.00", "EUR", "fr-FR", "EUR", "55,00", ExpectedValidity.VALID_AMOUNT},
+
+ {"55.00", "CAD", "en-US", "CAD", "55.00", ExpectedValidity.VALID_AMOUNT},
+ {"55.00", "CAD", "en-CA", "CAD", "55.00", ExpectedValidity.VALID_AMOUNT},
+ {"55.00", "CAD", "fr-CA", "CAD", "55,00", ExpectedValidity.VALID_AMOUNT},
+ {"55.00", "CAD", "fr-FR", "CAD", "55,00", ExpectedValidity.VALID_AMOUNT},
+
+ {"55.12", "JPY", "ja-JP", "JPY", "55.12", ExpectedValidity.VALID_AMOUNT},
+ {"55.00", "JPY", "ja-JP", "JPY", "55.00", ExpectedValidity.VALID_AMOUNT},
+ {"55.0", "JPY", "ja-JP", "JPY", "55.0", ExpectedValidity.VALID_AMOUNT},
+ {"55", "JPY", "ja-JP", "JPY", "55", ExpectedValidity.VALID_AMOUNT},
// Unofficial ISO 4217 currency code.
- {"55.00", "BTX", "en-US", "55.00", ExpectedValidity.VALID_AMOUNT},
- {"-55.00", "BTX", "en-US", "-55.00", ExpectedValidity.VALID_AMOUNT},
+ {"55.00", "BTX", "en-US", "BTX", "55.00", ExpectedValidity.VALID_AMOUNT},
+ {"-55.00", "BTX", "en-US", "BTX", "-55.00", ExpectedValidity.VALID_AMOUNT},
- {"55.5", "USD", "en-US", "$55.50", ExpectedValidity.VALID_AMOUNT},
- {"55", "USD", "en-US", "$55.00", ExpectedValidity.VALID_AMOUNT},
- {"123", "USD", "en-US", "$123.00", ExpectedValidity.VALID_AMOUNT},
- {"1234", "USD", "en-US", "$1,234.00", ExpectedValidity.VALID_AMOUNT},
+ {"55.5", "USD", "en-US", "USD", "$55.50", ExpectedValidity.VALID_AMOUNT},
+ {"55", "USD", "en-US", "USD", "$55.00", ExpectedValidity.VALID_AMOUNT},
+ {"123", "USD", "en-US", "USD", "$123.00", ExpectedValidity.VALID_AMOUNT},
+ {"1234", "USD", "en-US", "USD", "$1,234.00", ExpectedValidity.VALID_AMOUNT},
- {"-123", "USD", "en-US", "-$123.00", ExpectedValidity.VALID_AMOUNT},
- {"-1234", "USD", "en-US", "-$1,234.00", ExpectedValidity.VALID_AMOUNT},
+ {"-123", "USD", "en-US", "USD", "-$123.00", ExpectedValidity.VALID_AMOUNT},
+ {"-1234", "USD", "en-US", "USD", "-$1,234.00", ExpectedValidity.VALID_AMOUNT},
- {"123456789012345678901234567890.123456789012345678901234567890", "USD", "fr-FR",
+ {"123456789012345678901234567890.123456789012345678901234567890", "USD", "fr-FR", "USD",
"$123" + SPACE + "456" + SPACE + "789" + SPACE + "012" + SPACE + "345"
+ SPACE + "678" + SPACE + "901" + SPACE + "234" + SPACE + "567"
+ SPACE + "890,123456789012345678901234567890",
ExpectedValidity.VALID_AMOUNT},
- {"123456789012345678901234567890.123456789012345678901234567890", "USD", "en-US",
+ {"123456789012345678901234567890.123456789012345678901234567890", "USD", "en-US", "USD",
"$123,456,789,012,345,678,901,234,567,890.123456789012345678901234567890",
ExpectedValidity.VALID_AMOUNT},
// Any string of at most 2048 characters can be valid amount currency codes.
- {"55.00", "", "en-US", "55.00", ExpectedValidity.VALID_AMOUNT},
- {"55.00", "ABCDEF", "en-US", "55.00", ExpectedValidity.VALID_AMOUNT},
- {"55.00", longStringOfLength(2048), "en-US", "55.00", ExpectedValidity.VALID_AMOUNT},
+ {"55.00", "", "en-US", "", "55.00", ExpectedValidity.VALID_AMOUNT},
+ {"55.00", "ABCDEF", "en-US", "ABCDEF", "55.00", ExpectedValidity.VALID_AMOUNT},
+ // Currency code more than 6 character is formatted to first 5 characters and ellipsis.
+ // "\u2026" is unicode for ellipsis.
+ {"55.00", longStringOfLength(2048), "en-US", "AAAAA\u2026", "55.00",
+ ExpectedValidity.VALID_AMOUNT},
// Invalid amount currency codes.
- {"55.00", longStringOfLength(2049), "en-US", null,
+ {"55.00", longStringOfLength(2049), "en-US", null, null,
ExpectedValidity.INVALID_AMOUNT_CURRENCY_CODE},
// Invalid amount values.
- {"", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
- {"-", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
- {"notdigits", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
- {"ALSONOTDIGITS", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
- {"10.", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
- {".99", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
- {"10-", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
- {"1-0", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
- {"1.0.0", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
- {"1/3", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
+ {"", "USD", "en-US", "USD", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
+ {"-", "USD", "en-US", "USD", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
+ {"notdigits", "USD", "en-US", "USD", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
+ {"ALSONOTDIGITS", "USD", "en-US", "USD", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
+ {"10.", "USD", "en-US", "USD", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
+ {".99", "USD", "en-US", "USD", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
+ {"10-", "USD", "en-US", "USD", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
+ {"1-0", "USD", "en-US", "USD", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
+ {"1.0.0", "USD", "en-US", "USD", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
+ {"1/3", "USD", "en-US", "USD", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
});
}
private final String mAmount;
private final String mCurrency;
private final String mLanguageTag;
- private final String mExpectedFormatting;
+ private final String mExpectedCurrencyFormatting;
+ private final String mExpectedAmountFormatting;
private final ExpectedValidity mExpectedValidity;
private static String longStringOfLength(int len) {
@@ -112,11 +116,13 @@ public class CurrencyStringFormatterTest {
}
public CurrencyStringFormatterTest(String amount, String currency, String languageTag,
- String expectedFormatting, ExpectedValidity expectedValidity) {
+ String expectedCurrencyFormatting, String expectedAmountFormatting,
+ ExpectedValidity expectedValidity) {
mAmount = amount;
mCurrency = currency;
mLanguageTag = languageTag;
- mExpectedFormatting = expectedFormatting;
+ mExpectedCurrencyFormatting = expectedCurrencyFormatting;
+ mExpectedAmountFormatting = expectedAmountFormatting;
mExpectedValidity = expectedValidity;
}
@@ -143,8 +149,12 @@ public class CurrencyStringFormatterTest {
if (mExpectedValidity == ExpectedValidity.VALID_AMOUNT) {
Assert.assertEquals("\"" + mCurrency + "\" \"" + mAmount + "\" (\"" + mLanguageTag
- + "\" locale) should be formatted into \"" + mExpectedFormatting + "\"",
- mExpectedFormatting, formatter.format(mAmount));
+ + "\" locale) should be formatted into \""
+ + mExpectedAmountFormatting + "\"",
+ mExpectedAmountFormatting, formatter.format(mAmount));
+ Assert.assertEquals("\"" + mCurrency + "\"" + " should be formatted into \""
+ + mExpectedCurrencyFormatting + "\"",
+ mExpectedCurrencyFormatting, formatter.getFormattedCurrencyCode());
}
}
}

Powered by Google App Engine
This is Rietveld 408576698