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

Side by Side 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: Fixed 640847 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.payments; 5 package org.chromium.chrome.browser.payments;
6 6
7 import org.junit.Assert; 7 import org.junit.Assert;
8 import org.junit.Test; 8 import org.junit.Test;
9 import org.junit.runner.RunWith; 9 import org.junit.runner.RunWith;
10 import org.junit.runners.Parameterized; 10 import org.junit.runners.Parameterized;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 {"123456789012345678901234567890.123456789012345678901234567890", "U SD", "fr-FR", 63 {"123456789012345678901234567890.123456789012345678901234567890", "U SD", "fr-FR",
64 "$123" + SPACE + "456" + SPACE + "789" + SPACE + "012" + SPA CE + "345" 64 "$123" + SPACE + "456" + SPACE + "789" + SPACE + "012" + SPA CE + "345"
65 + SPACE + "678" + SPACE + "901" + SPACE + "234" + SP ACE + "567" 65 + SPACE + "678" + SPACE + "901" + SPACE + "234" + SP ACE + "567"
66 + SPACE + "890,123456789012345678901234567890", 66 + SPACE + "890,123456789012345678901234567890",
67 ExpectedValidity.VALID_AMOUNT}, 67 ExpectedValidity.VALID_AMOUNT},
68 {"123456789012345678901234567890.123456789012345678901234567890", "U SD", "en-US", 68 {"123456789012345678901234567890.123456789012345678901234567890", "U SD", "en-US",
69 "$123,456,789,012,345,678,901,234,567,890.123456789012345678 901234567890", 69 "$123,456,789,012,345,678,901,234,567,890.123456789012345678 901234567890",
70 ExpectedValidity.VALID_AMOUNT}, 70 ExpectedValidity.VALID_AMOUNT},
71 71
72 // Invalid amount currency codes.
73 {"55.00", "", "en-US", null, ExpectedValidity.INVALID_AMOUNT_CURRENC Y_CODE},
74 {"55.00", "usd", "en-US", null, ExpectedValidity.INVALID_AMOUNT_CURR ENCY_CODE},
75 {"55.00", "US8", "en-US", null, ExpectedValidity.INVALID_AMOUNT_CURR ENCY_CODE},
76 {"55.00", "US", "en-US", null, ExpectedValidity.INVALID_AMOUNT_CURRE NCY_CODE},
77 {"55.00", "USDR", "en-US", null, ExpectedValidity.INVALID_AMOUNT_CUR RENCY_CODE},
78 {"55.00", "USDr", "en-US", null, ExpectedValidity.INVALID_AMOUNT_CUR RENCY_CODE},
please use gerrit instead 2016/08/25 16:47:38 Once you move currency truncation into CurrenycStr
pals 2016/08/26 07:20:26 If it is ok, I'll do the application related chang
please use gerrit instead 2016/08/26 17:01:37 OK
79
80 // Invalid amount values. 72 // Invalid amount values.
81 {"", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE}, 73 {"", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
82 {"-", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE}, 74 {"-", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE},
83 {"notdigits", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_ VALUE}, 75 {"notdigits", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_ VALUE},
84 {"ALSONOTDIGITS", "USD", "en-US", null, ExpectedValidity.INVALID_AMO UNT_VALUE}, 76 {"ALSONOTDIGITS", "USD", "en-US", null, ExpectedValidity.INVALID_AMO UNT_VALUE},
85 {"10.", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE} , 77 {"10.", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE} ,
86 {".99", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE} , 78 {".99", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE} ,
87 {"10-", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE} , 79 {"10-", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE} ,
88 {"1-0", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE} , 80 {"1-0", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALUE} ,
89 {"1.0.0", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALU E}, 81 {"1.0.0", "USD", "en-US", null, ExpectedValidity.INVALID_AMOUNT_VALU E},
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 formatter.isValidAmountValue(mAmount)); 119 formatter.isValidAmountValue(mAmount));
128 } 120 }
129 121
130 if (mExpectedValidity == ExpectedValidity.VALID_AMOUNT) { 122 if (mExpectedValidity == ExpectedValidity.VALID_AMOUNT) {
131 Assert.assertEquals("\"" + mCurrency + "\" \"" + mAmount + "\" (\"" + mLanguageTag 123 Assert.assertEquals("\"" + mCurrency + "\" \"" + mAmount + "\" (\"" + mLanguageTag
132 + "\" locale) should be formatted into \"" + mExpect edFormatting + "\"", 124 + "\" locale) should be formatted into \"" + mExpect edFormatting + "\"",
133 mExpectedFormatting, formatter.format(mAmount)); 125 mExpectedFormatting, formatter.format(mAmount));
134 } 126 }
135 } 127 }
136 } 128 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698