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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java

Issue 2281913002: Currency code exceeding 6 chars will be ellipsized. (Closed)
Patch Set: formatCurrency() 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 android.test.InstrumentationTestCase; 7 import android.test.InstrumentationTestCase;
8 import android.test.suitebuilder.annotation.SmallTest; 8 import android.test.suitebuilder.annotation.SmallTest;
9 9
10 import java.util.Locale; 10 import java.util.Locale;
11 11
12 /** 12 /**
13 * A lightweight integration test for CurrencyStringFormatter to run on an Andro id device. 13 * A lightweight integration test for CurrencyStringFormatter to run on an Andro id device.
14 */ 14 */
15 public class CurrencyStringFormatterTest extends InstrumentationTestCase { 15 public class CurrencyStringFormatterTest extends InstrumentationTestCase {
16 /**
17 * Unicode for ellipsis.
18 */
19 private static final String ELLIPSIS = "\u2026";
20
16 @SmallTest 21 @SmallTest
17 public void testCad() throws Exception { 22 public void testCad() throws Exception {
18 CurrencyStringFormatter formatter = new CurrencyStringFormatter("CAD", n ew Locale("en-US")); 23 CurrencyStringFormatter formatter = new CurrencyStringFormatter("CAD", n ew Locale("en-US"));
19 assertEquals("$5.00", formatter.format("5")); 24 assertEquals("$5.00", formatter.format("5"));
20 } 25 }
21 26
22 @SmallTest 27 @SmallTest
23 public void testAzn() throws Exception { 28 public void testAzn() throws Exception {
24 CurrencyStringFormatter formatter = new CurrencyStringFormatter("AZN", n ew Locale("en-US")); 29 CurrencyStringFormatter formatter = new CurrencyStringFormatter("AZN", n ew Locale("en-US"));
25 assertEquals("5.00", formatter.format("5")); 30 assertEquals("5.00", formatter.format("5"));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 public void testEur() throws Exception { 82 public void testEur() throws Exception {
78 CurrencyStringFormatter formatter = new CurrencyStringFormatter("EUR", n ew Locale("en-US")); 83 CurrencyStringFormatter formatter = new CurrencyStringFormatter("EUR", n ew Locale("en-US"));
79 assertEquals("€5.00", formatter.format("5")); 84 assertEquals("€5.00", formatter.format("5"));
80 } 85 }
81 86
82 @SmallTest 87 @SmallTest
83 public void testPkr() throws Exception { 88 public void testPkr() throws Exception {
84 CurrencyStringFormatter formatter = new CurrencyStringFormatter("PKR", n ew Locale("en-US")); 89 CurrencyStringFormatter formatter = new CurrencyStringFormatter("PKR", n ew Locale("en-US"));
85 assertEquals("5", formatter.format("5")); 90 assertEquals("5", formatter.format("5"));
86 } 91 }
92
93 @SmallTest
94 public void testCurrency6Chars() throws Exception {
95 CurrencyStringFormatter formatter =
96 new CurrencyStringFormatter("ABCDEF", new Locale("en-US"));
97 assertEquals("ABCDEF", formatter.formatCurrency("ABCDEF"));
98 }
99
100 @SmallTest
101 public void testCurrencyEllipsized() throws Exception {
102 CurrencyStringFormatter formatter =
103 new CurrencyStringFormatter("ABCDEFG", new Locale("en-US"));
104 assertEquals("ABCDE" + ELLIPSIS, formatter.formatCurrency("ABCDEFG"));
please use gerrit instead 2016/09/02 17:30:55 Use use the ELLIPSIS only once here., so it's fewe
pals 2016/09/06 06:09:00 Done.
105 }
106
107 @SmallTest
108 public void testCurrencyEmpty() throws Exception {
109 CurrencyStringFormatter formatter = new CurrencyStringFormatter("", new Locale("en-US"));
110 assertEquals("", formatter.formatCurrency(""));
111 }
87 } 112 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698