[pdf] Use a different string for square page sizes in properties dialog
Currently, square page sizes appear as "portrait", which can be confusing. Fixed: 1184345 Change-Id: I1e70438c285cb218759185a613f7e657fe726ba1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3036622 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Daniel Hosseinian <dhoss@chromium.org> Cr-Commit-Position: refs/heads/master@{#903224}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
3194a1d985
commit
178b51deb4
chrome/test/data/pdf
components
pdf/ui
@ -59,7 +59,7 @@ const tests = [
|
||||
['pdf-producer', 'fixup_pdf_template.py'],
|
||||
['pdf-version', '1.7'],
|
||||
['page-count', '1'],
|
||||
['page-size', '2.78 × 2.78 in (portrait)'],
|
||||
['page-size', '2.78 × 2.78 in (square)'],
|
||||
['fast-web-view', 'No'],
|
||||
].forEach(([field, expectedValue]) => assertField(field, expectedValue));
|
||||
|
||||
|
@ -97,6 +97,9 @@
|
||||
<message name="IDS_PDF_PROPERTIES_PAGE_SIZE_LANDSCAPE" desc="Label for a landscape page orientation.">
|
||||
landscape
|
||||
</message>
|
||||
<message name="IDS_PDF_PROPERTIES_PAGE_SIZE_SQUARE" desc="Label for a square page that has neither portrait nor landscape orientation.">
|
||||
square
|
||||
</message>
|
||||
<message name="IDS_PDF_PROPERTIES_PAGE_SIZE_VARIABLE" desc="Value for the page size of a PDF that lacks a uniform page size.">
|
||||
Varies
|
||||
</message>
|
||||
|
@ -0,0 +1 @@
|
||||
161d76850b84697ce3498aec6b98e927b4fefc86
|
@ -53,11 +53,15 @@ std::u16string FormatLengthInMillimeters(int length_points) {
|
||||
|
||||
// Returns the localized string for the orientation.
|
||||
std::u16string GetOrientation(const gfx::Size& size) {
|
||||
// TODO(crbug.com/1184345): Add a string for square sizes such that they are
|
||||
// not displayed as "portrait".
|
||||
return l10n_util::GetStringUTF16(
|
||||
size.height() >= size.width() ? IDS_PDF_PROPERTIES_PAGE_SIZE_PORTRAIT
|
||||
: IDS_PDF_PROPERTIES_PAGE_SIZE_LANDSCAPE);
|
||||
int message_id;
|
||||
if (size.height() > size.width())
|
||||
message_id = IDS_PDF_PROPERTIES_PAGE_SIZE_PORTRAIT;
|
||||
else if (size.height() < size.width())
|
||||
message_id = IDS_PDF_PROPERTIES_PAGE_SIZE_LANDSCAPE;
|
||||
else
|
||||
message_id = IDS_PDF_PROPERTIES_PAGE_SIZE_SQUARE;
|
||||
|
||||
return l10n_util::GetStringUTF16(message_id);
|
||||
}
|
||||
|
||||
bool ShowInches() {
|
||||
|
@ -53,7 +53,7 @@ class FormatPageSizeMillimetersTest : public FormatPageSizeTest {
|
||||
};
|
||||
|
||||
TEST_F(FormatPageSizeMillimetersTest, EmptySize) {
|
||||
EXPECT_EQ(FormatPageSize(gfx::Size()), u"0 × 0 mm (portrait)");
|
||||
EXPECT_EQ(FormatPageSize(gfx::Size()), u"0 × 0 mm (square)");
|
||||
}
|
||||
|
||||
TEST_F(FormatPageSizeMillimetersTest, Portrait) {
|
||||
@ -65,12 +65,12 @@ TEST_F(FormatPageSizeMillimetersTest, Landscape) {
|
||||
}
|
||||
|
||||
TEST_F(FormatPageSizeMillimetersTest, Square) {
|
||||
EXPECT_EQ(FormatPageSize(gfx::Size(100, 100)), u"35 × 35 mm (portrait)");
|
||||
EXPECT_EQ(FormatPageSize(gfx::Size(100, 100)), u"35 × 35 mm (square)");
|
||||
}
|
||||
|
||||
TEST_F(FormatPageSizeMillimetersTest, Large) {
|
||||
EXPECT_EQ(FormatPageSize(gfx::Size(72000, 72000)),
|
||||
u"25,400 × 25,400 mm (portrait)");
|
||||
u"25,400 × 25,400 mm (square)");
|
||||
}
|
||||
|
||||
class FormatPageSizeMillimetersPeriodSeparatorTest : public FormatPageSizeTest {
|
||||
@ -80,7 +80,7 @@ class FormatPageSizeMillimetersPeriodSeparatorTest : public FormatPageSizeTest {
|
||||
|
||||
TEST_F(FormatPageSizeMillimetersPeriodSeparatorTest, Large) {
|
||||
EXPECT_EQ(FormatPageSize(gfx::Size(72000, 72000)),
|
||||
u"25.400 × 25.400 mm (portrait)");
|
||||
u"25.400 × 25.400 mm (square)");
|
||||
}
|
||||
|
||||
class FormatPageSizeInchesTest : public FormatPageSizeTest {
|
||||
@ -89,7 +89,7 @@ class FormatPageSizeInchesTest : public FormatPageSizeTest {
|
||||
};
|
||||
|
||||
TEST_F(FormatPageSizeInchesTest, EmptySize) {
|
||||
EXPECT_EQ(FormatPageSize(gfx::Size()), u"0.00 × 0.00 in (portrait)");
|
||||
EXPECT_EQ(FormatPageSize(gfx::Size()), u"0.00 × 0.00 in (square)");
|
||||
}
|
||||
|
||||
TEST_F(FormatPageSizeInchesTest, Portrait) {
|
||||
@ -101,12 +101,12 @@ TEST_F(FormatPageSizeInchesTest, Landscape) {
|
||||
}
|
||||
|
||||
TEST_F(FormatPageSizeInchesTest, Square) {
|
||||
EXPECT_EQ(FormatPageSize(gfx::Size(100, 100)), u"1.39 × 1.39 in (portrait)");
|
||||
EXPECT_EQ(FormatPageSize(gfx::Size(100, 100)), u"1.39 × 1.39 in (square)");
|
||||
}
|
||||
|
||||
TEST_F(FormatPageSizeInchesTest, Large) {
|
||||
EXPECT_EQ(FormatPageSize(gfx::Size(72000, 72000)),
|
||||
u"1,000.00 × 1,000.00 in (portrait)");
|
||||
u"1,000.00 × 1,000.00 in (square)");
|
||||
}
|
||||
|
||||
TEST(FormatPdfVersion, Valid) {
|
||||
|
Reference in New Issue
Block a user