Index: printing/backend/cups_helper_unittest.cc |
=================================================================== |
--- printing/backend/cups_helper_unittest.cc (revision 0) |
+++ printing/backend/cups_helper_unittest.cc (revision 0) |
@@ -0,0 +1,64 @@ |
+// Copyright (c) 2012 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. |
+ |
+#include "printing/backend/cups_helper.h" |
+#include "printing/backend/print_backend.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+TEST(PrintBackendCupsHelperTest, TestPpdParsing) { |
+ std::string test_ppd_data; |
+ test_ppd_data.append("*PPD-Adobe: \"4.3\"\n\n" |
+ "*OpenGroup: General/General\n\n" |
+ "*OpenUI *ColorModel/Color Model: PickOne\n" |
+ "*DefaultColorModel: Gray\n" |
+ "*ColorModel Gray/Grayscale: \"" |
+ "<</cupsColorSpace 0/cupsColorOrder 0>>" |
+ "setpagedevice\"\n" |
+ "*ColorModel Black/Inverted Grayscale: \"" |
+ "<</cupsColorSpace 3/cupsColorOrder 0>>" |
+ "setpagedevice\"\n" |
+ "*CloseUI: *ColorModel\n" |
+ "*OpenUI *Duplex/2-Sided Printing: PickOne\n" |
+ "*DefaultDuplex: DuplexTumble\n" |
+ "*Duplex None/Off: \"<</Duplex false>>" |
+ "setpagedevice\"\n" |
+ "*Duplex DuplexNoTumble/LongEdge: \"" |
+ "<</Duplex true/Tumble false>>setpagedevice\"\n" |
+ "*Duplex DuplexTumble/ShortEdge: \"" |
+ "<</Duplex true/Tumble true>>setpagedevice\"\n" |
+ "*CloseUI: *Duplex\n\n" |
+ "*CloseGroup: General\n"); |
+ |
+ printing::PrinterSemanticCapsAndDefaults caps; |
+ EXPECT_TRUE(printing::parsePpdCapabilities("test", test_ppd_data, &caps)); |
+ EXPECT_FALSE(caps.color_capable); |
+ EXPECT_FALSE(caps.color_default); |
+ EXPECT_TRUE(caps.duplex_capable); |
+ EXPECT_EQ(caps.duplex_default, printing::LONG_EDGE); |
+} |
+ |
+// Test duplex detection code, which regressed in http://crbug.com/103999. |
Albert Bodenhamer
2012/09/04 23:09:36
Should there be more tests here? Different ways o
gene
2012/09/04 23:19:50
Sure. Let me add more. I've copied existing tests
|
+TEST(PrintBackendCupsHelperTest, TestPpdParsing2) { |
+ std::string test_ppd_data; |
+ test_ppd_data.append( |
+ "*PPD-Adobe: \"4.3\"\n\n" |
+ "*OpenGroup: General/General\n\n" |
+ "*OpenUI *Duplex/Double-Sided Printing: PickOne\n" |
+ "*DefaultDuplex: None\n" |
+ "*Duplex None/Off: " |
+ "\"<</Duplex false>>setpagedevice\"\n" |
+ "*Duplex DuplexNoTumble/Long Edge (Standard): " |
+ "\"<</Duplex true/Tumble false>>setpagedevice\"\n" |
+ "*Duplex DuplexTumble/Short Edge (Flip): " |
+ "\"<</Duplex true/Tumble true>>setpagedevice\"\n" |
+ "*CloseUI: *Duplex\n\n" |
+ "*CloseGroup: General\n"); |
+ |
+ printing::PrinterSemanticCapsAndDefaults caps; |
+ EXPECT_TRUE(printing::parsePpdCapabilities("test", test_ppd_data, &caps)); |
+ EXPECT_FALSE(caps.color_capable); |
+ EXPECT_FALSE(caps.color_default); |
+ EXPECT_TRUE(caps.duplex_capable); |
+ EXPECT_EQ(caps.duplex_default, printing::SIMPLEX); |
+} |