Commit c07aecbf authored by rouslan's avatar rouslan Committed by Commit bot

Show Canadian dollars as"CAD $5.00" instead of "CAD CA$5.00".

BUG=638481

Review-Url: https://codereview.chromium.org/2250313002
Cr-Commit-Position: refs/heads/master@{#413377}
parent d17622aa
...@@ -78,14 +78,21 @@ public class CurrencyStringFormatter { ...@@ -78,14 +78,21 @@ public class CurrencyStringFormatter {
// The spec does not limit the currencies to official ISO 4217 currency code list, which // The spec does not limit the currencies to official ISO 4217 currency code list, which
// is used by java.util.Currency. For example, "BTX" (bitcoin) is not an official ISO // is used by java.util.Currency. For example, "BTX" (bitcoin) is not an official ISO
// 4217 currency code, but is allowed by the spec. // 4217 currency code, but is allowed by the spec.
currencySymbol = currencyCode; currencySymbol = "";
defaultFractionDigits = 0; defaultFractionDigits = 0;
} }
// If the currency symobl is the same as the currency code, do not display it as part of the // If the prefix of the currency symbol matches the prefix of the currency code, remove the
// amount. The UI already shows the currency code, so there's no need to show duplicate // matching prefix from the symbol. The UI already shows the currency code, so there's no
// information. // need to show duplicate information.
mCurrencySymbol = currencySymbol.equals(currencyCode) ? "" : currencySymbol; String symbol = "";
for (int i = 0; i < currencySymbol.length(); i++) {
if (i >= currencyCode.length() || currencySymbol.charAt(i) != currencyCode.charAt(i)) {
symbol = currencySymbol.substring(i);
break;
}
}
mCurrencySymbol = symbol;
mDefaultFractionDigits = defaultFractionDigits; mDefaultFractionDigits = defaultFractionDigits;
......
...@@ -1237,6 +1237,7 @@ chrome_test_java_sources = [ ...@@ -1237,6 +1237,7 @@ chrome_test_java_sources = [
"javatests/src/org/chromium/chrome/browser/physicalweb/UrlInfoTest.java", "javatests/src/org/chromium/chrome/browser/physicalweb/UrlInfoTest.java",
"javatests/src/org/chromium/chrome/browser/physicalweb/UrlManagerTest.java", "javatests/src/org/chromium/chrome/browser/physicalweb/UrlManagerTest.java",
"javatests/src/org/chromium/chrome/browser/policy/CombinedPolicyProviderTest.java", "javatests/src/org/chromium/chrome/browser/policy/CombinedPolicyProviderTest.java",
"javatests/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java",
"javatests/src/org/chromium/chrome/browser/payments/PaymentRequestAbortTest.java", "javatests/src/org/chromium/chrome/browser/payments/PaymentRequestAbortTest.java",
"javatests/src/org/chromium/chrome/browser/payments/PaymentRequestContactDetailsTest.java", "javatests/src/org/chromium/chrome/browser/payments/PaymentRequestContactDetailsTest.java",
"javatests/src/org/chromium/chrome/browser/payments/PaymentRequestContactDetailsAndFreeShippingTest.java", "javatests/src/org/chromium/chrome/browser/payments/PaymentRequestContactDetailsAndFreeShippingTest.java",
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.payments;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import java.util.Locale;
/**
* A lightweight integration test for CurrencyStringFormatter to run on an Android device.
*/
public class CurrencyStringFormatterTest extends InstrumentationTestCase {
@SmallTest
public void testCad() throws Exception {
CurrencyStringFormatter formatter = new CurrencyStringFormatter("CAD", new Locale("en-US"));
assertEquals("$5.00", formatter.format("5"));
}
@SmallTest
public void testAzn() throws Exception {
CurrencyStringFormatter formatter = new CurrencyStringFormatter("AZN", new Locale("en-US"));
assertEquals("5.00", formatter.format("5"));
}
@SmallTest
public void testBmd() throws Exception {
CurrencyStringFormatter formatter = new CurrencyStringFormatter("BMD", new Locale("en-US"));
assertEquals("5.00", formatter.format("5"));
}
@SmallTest
public void testAud() throws Exception {
CurrencyStringFormatter formatter = new CurrencyStringFormatter("AUD", new Locale("en-US"));
assertEquals("$5.00", formatter.format("5"));
}
@SmallTest
public void testBzd() throws Exception {
CurrencyStringFormatter formatter = new CurrencyStringFormatter("BZD", new Locale("en-US"));
assertEquals("5.00", formatter.format("5"));
}
@SmallTest
public void testClp() throws Exception {
CurrencyStringFormatter formatter = new CurrencyStringFormatter("CLP", new Locale("en-US"));
assertEquals("5", formatter.format("5"));
}
@SmallTest
public void testLrd() throws Exception {
CurrencyStringFormatter formatter = new CurrencyStringFormatter("LRD", new Locale("en-US"));
assertEquals("5.00", formatter.format("5"));
}
@SmallTest
public void testNio() throws Exception {
CurrencyStringFormatter formatter = new CurrencyStringFormatter("NIO", new Locale("en-US"));
assertEquals("5.00", formatter.format("5"));
}
@SmallTest
public void testHrk() throws Exception {
CurrencyStringFormatter formatter = new CurrencyStringFormatter("HRK", new Locale("en-US"));
assertEquals("5.00", formatter.format("5"));
}
@SmallTest
public void testRub() throws Exception {
CurrencyStringFormatter formatter = new CurrencyStringFormatter("RUB", new Locale("en-US"));
assertEquals("5.00", formatter.format("5"));
}
@SmallTest
public void testEur() throws Exception {
CurrencyStringFormatter formatter = new CurrencyStringFormatter("EUR", new Locale("en-US"));
assertEquals("€5.00", formatter.format("5"));
}
@SmallTest
public void testPkr() throws Exception {
CurrencyStringFormatter formatter = new CurrencyStringFormatter("PKR", new Locale("en-US"));
assertEquals("5", formatter.format("5"));
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment