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

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

Issue 2271113002: Accept any string for currency code in PaymentRequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Allow null as per spec Created 4 years, 4 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 e84048e8c4e922e6b1659566794358a6698e9ca2..b13d45d048425a495f9b4d20f81227d7647e7c44 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
@@ -74,13 +74,14 @@ public class CurrencyStringFormatterTest {
"$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},
+
// Invalid amount currency codes.
- {"55.00", "", "en-US", null, ExpectedValidity.INVALID_AMOUNT_CURRENCY_CODE},
- {"55.00", "usd", "en-US", null, ExpectedValidity.INVALID_AMOUNT_CURRENCY_CODE},
- {"55.00", "US8", "en-US", null, ExpectedValidity.INVALID_AMOUNT_CURRENCY_CODE},
- {"55.00", "US", "en-US", null, ExpectedValidity.INVALID_AMOUNT_CURRENCY_CODE},
- {"55.00", "USDR", "en-US", null, ExpectedValidity.INVALID_AMOUNT_CURRENCY_CODE},
- {"55.00", "USDr", "en-US", null, ExpectedValidity.INVALID_AMOUNT_CURRENCY_CODE},
+ {"55.00", longStringOfLength(2049), "en-US", null,
+ ExpectedValidity.INVALID_AMOUNT_CURRENCY_CODE},
// Invalid amount values.
{"", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
@@ -102,6 +103,14 @@ public class CurrencyStringFormatterTest {
private final String mExpectedFormatting;
private final ExpectedValidity mExpectedValidity;
+ private static String longStringOfLength(int len) {
+ StringBuilder currency = new StringBuilder();
+ for (int i = 0; i < len; i++) {
+ currency.append("A");
+ }
+ return currency.toString();
+ }
+
public CurrencyStringFormatterTest(String amount, String currency, String languageTag,
String expectedFormatting, ExpectedValidity expectedValidity) {
mAmount = amount;

Powered by Google App Engine
This is Rietveld 408576698