Commit c8058925 authored by rbpotter's avatar rbpotter Committed by Commit Bot

Print Preview: Fix decimal text box inputs for custom margins

Custom margins text boxes were incorrectly not accepting decimal
inputs, due to a regression in delimiter value computation. Fix
regression and add test.

Bug: 819806
Change-Id: I73093bbd0193e388cfc29b92f5397e0b73a9f23d
Reviewed-on: https://chromium-review.googlesource.com/954711
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542151}
parent 40d64a60
......@@ -891,7 +891,7 @@ void PrintPreviewHandler::GetNumberFormatAndMeasurementSystem(
// Getting the number formatting based on the locale and writing to
// dictionary.
base::string16 number_format = base::FormatDouble(123456.78, 2);
settings->SetString(kDecimalDelimeter, number_format.substr(6, 1));
settings->SetString(kDecimalDelimeter, number_format.substr(7, 1));
settings->SetString(kThousandsDelimeter, number_format.substr(3, 1));
settings->SetInteger(kUnitType, system);
}
......
......@@ -6,6 +6,7 @@
#include "base/base64.h"
#include "base/containers/flat_set.h"
#include "base/i18n/rtl.h"
#include "base/json/json_writer.h"
#include "base/memory/ref_counted_memory.h"
#include "base/strings/string16.h"
......@@ -339,6 +340,10 @@ class PrintPreviewHandlerTest : public testing::Test {
}
void Initialize() {
// Set locale since the delimeters we check in VerifyInitialSettings()
// depend on it.
base::i18n::SetICUDefaultLocale("en");
// Sending this message will enable javascript, so it must always be called
// before any other messages are sent.
base::Value args(base::Value::Type::LIST);
......@@ -376,7 +381,8 @@ class PrintPreviewHandlerTest : public testing::Test {
// print_preview.NativeInitialSettings type in
// chrome/browser/resources/print_preview/native_layer.js. Checks that
// |default_printer_name| is the printer name returned and that
// |initiator_title| is the initiator title returned. Assumes
// |initiator_title| is the initiator title returned and validates that
// delimeters are correct for "en" locale (set in Initialize()). Assumes
// "test-callback-id-0" was used as the callback id.
void ValidateInitialSettings(const content::TestWebUI::CallData& data,
const std::string& default_printer_name,
......@@ -387,10 +393,16 @@ class PrintPreviewHandlerTest : public testing::Test {
base::Value::Type::BOOLEAN));
ASSERT_TRUE(settings->FindKeyOfType("isInAppKioskMode",
base::Value::Type::BOOLEAN));
ASSERT_TRUE(settings->FindKeyOfType("thousandsDelimeter",
base::Value::Type::STRING));
ASSERT_TRUE(
settings->FindKeyOfType("decimalDelimeter", base::Value::Type::STRING));
const base::Value* thousandsDelimeter = settings->FindKeyOfType(
"thousandsDelimeter", base::Value::Type::STRING);
ASSERT_TRUE(thousandsDelimeter);
EXPECT_EQ(",", thousandsDelimeter->GetString());
const base::Value* decimalDelimeter =
settings->FindKeyOfType("decimalDelimeter", base::Value::Type::STRING);
ASSERT_TRUE(decimalDelimeter);
EXPECT_EQ(".", decimalDelimeter->GetString());
ASSERT_TRUE(
settings->FindKeyOfType("unitType", base::Value::Type::INTEGER));
ASSERT_TRUE(settings->FindKeyOfType("previewModifiable",
......
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