Allow duplicate papers
Some Windows printer drivers respond to the query of supported capabilities with some paper sizes duplicated. This was in particular found to occur with the Konica Minolta 4750 Series PS. Note that the Print Preview UI is capable of dealing with such duplicates, as only one instance of each paper size shows up in the Paper size dropdown. Drop the mojom validation check for duplicate papers in light of this discovery. Bug: 1214139 Change-Id: Iea70af07b9e3dd6b70b9e620f811ada91db31345 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2965700 Reviewed-by: Alex Gough <ajgo@chromium.org> Commit-Queue: Alan Screen <awscreen@chromium.org> Cr-Commit-Position: refs/heads/master@{#893020}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
a38313afbe
commit
83cc9ccc15
printing/backend/mojom
@ -63,7 +63,7 @@ struct PrinterSemanticCapsAndDefaults {
|
||||
bool color_default = false;
|
||||
ColorModel color_model = kUnknownColorModel;
|
||||
ColorModel bw_model = kUnknownColorModel;
|
||||
array<Paper> papers;
|
||||
array<Paper> papers; // Duplicates allowed.
|
||||
array<Paper> user_defined_papers;
|
||||
Paper default_paper;
|
||||
array<gfx.mojom.Size> dpis; // Duplicates allowed.
|
||||
|
@ -221,20 +221,13 @@ bool StructTraits<printing::mojom::PrinterSemanticCapsAndDefaultsDataView,
|
||||
return false;
|
||||
}
|
||||
|
||||
// There should not be duplicates in any of the arrays.
|
||||
// There should not be duplicates in certain arrays.
|
||||
DuplicateChecker<printing::mojom::DuplexMode> duplex_modes_dup_checker;
|
||||
if (duplex_modes_dup_checker.HasDuplicates(out->duplex_modes)) {
|
||||
DLOG(ERROR) << "Duplicate duplex_modes detected.";
|
||||
return false;
|
||||
}
|
||||
|
||||
DuplicateChecker<printing::PrinterSemanticCapsAndDefaults::Paper>
|
||||
papers_dup_checker;
|
||||
if (papers_dup_checker.HasDuplicates(out->papers)) {
|
||||
DLOG(ERROR) << "Duplicate papers detected.";
|
||||
return false;
|
||||
}
|
||||
|
||||
DuplicateChecker<printing::PrinterSemanticCapsAndDefaults::Paper>
|
||||
user_defined_papers_dup_checker;
|
||||
if (user_defined_papers_dup_checker.HasDuplicates(out->user_defined_papers)) {
|
||||
|
@ -294,15 +294,6 @@ TEST(
|
||||
mojom::DuplexMode::kSimplex,
|
||||
mojom::DuplexMode::kSimplex};
|
||||
|
||||
EXPECT_FALSE(mojo::test::SerializeAndDeserialize<
|
||||
mojom::PrinterSemanticCapsAndDefaults>(input, output));
|
||||
|
||||
// Use a paper with same name but different size.
|
||||
PrinterSemanticCapsAndDefaults::Paper paper_a4_prime = kPaperA4;
|
||||
paper_a4_prime.size_um = kPaperLetter.size_um;
|
||||
input = GenerateSamplePrinterSemanticCapsAndDefaults();
|
||||
input.papers = {kPaperA4, kPaperLetter, kPaperLedger, paper_a4_prime};
|
||||
|
||||
EXPECT_FALSE(mojo::test::SerializeAndDeserialize<
|
||||
mojom::PrinterSemanticCapsAndDefaults>(input, output));
|
||||
|
||||
@ -342,6 +333,21 @@ TEST(
|
||||
mojom::PrinterSemanticCapsAndDefaults>(input, output));
|
||||
|
||||
EXPECT_EQ(kDuplicateDpis, output.dpis);
|
||||
|
||||
// Duplicate papers are known to be possible, seen with the Konica Minolta
|
||||
// 4750 Series PS driver.
|
||||
// Use a paper with same name but different size.
|
||||
PrinterSemanticCapsAndDefaults::Paper paper_a4_prime = kPaperA4;
|
||||
paper_a4_prime.size_um = kPaperLetter.size_um;
|
||||
input = GenerateSamplePrinterSemanticCapsAndDefaults();
|
||||
const PrinterSemanticCapsAndDefaults::Papers kDuplicatePapers{
|
||||
kPaperA4, kPaperLetter, kPaperLedger, paper_a4_prime};
|
||||
input.papers = kDuplicatePapers;
|
||||
|
||||
EXPECT_TRUE(mojo::test::SerializeAndDeserialize<
|
||||
mojom::PrinterSemanticCapsAndDefaults>(input, output));
|
||||
|
||||
EXPECT_EQ(kDuplicatePapers, output.papers);
|
||||
}
|
||||
|
||||
} // namespace printing
|
||||
|
Reference in New Issue
Block a user