Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: printing/backend/cups_helper_unittest.cc

Issue 313723002: Convert local printer capabilites to CDD format to unify with cloud printers and PDF printer. This … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix clang reported errors. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « printing/backend/cups_helper.cc ('k') | printing/backend/print_backend.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "printing/backend/cups_helper.h" 5 #include "printing/backend/cups_helper.h"
6 #include "printing/backend/print_backend.h" 6 #include "printing/backend/print_backend.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 TEST(PrintBackendCupsHelperTest, TestPpdParsingNoColorDuplexLongEdge) { 9 TEST(PrintBackendCupsHelperTest, TestPpdParsingNoColorDuplexLongEdge) {
10 std::string test_ppd_data; 10 std::string test_ppd_data;
(...skipping 15 matching lines...) Expand all
26 "setpagedevice\"\n" 26 "setpagedevice\"\n"
27 "*Duplex DuplexNoTumble/LongEdge: \"" 27 "*Duplex DuplexNoTumble/LongEdge: \""
28 "<</Duplex true/Tumble false>>setpagedevice\"\n" 28 "<</Duplex true/Tumble false>>setpagedevice\"\n"
29 "*Duplex DuplexTumble/ShortEdge: \"" 29 "*Duplex DuplexTumble/ShortEdge: \""
30 "<</Duplex true/Tumble true>>setpagedevice\"\n" 30 "<</Duplex true/Tumble true>>setpagedevice\"\n"
31 "*CloseUI: *Duplex\n\n" 31 "*CloseUI: *Duplex\n\n"
32 "*CloseGroup: General\n"); 32 "*CloseGroup: General\n");
33 33
34 printing::PrinterSemanticCapsAndDefaults caps; 34 printing::PrinterSemanticCapsAndDefaults caps;
35 EXPECT_TRUE(printing::ParsePpdCapabilities("test", test_ppd_data, &caps)); 35 EXPECT_TRUE(printing::ParsePpdCapabilities("test", test_ppd_data, &caps));
36 EXPECT_TRUE(caps.collate_capable);
37 EXPECT_TRUE(caps.collate_default);
38 EXPECT_TRUE(caps.copies_capable);
39 EXPECT_TRUE(caps.duplex_capable);
40 EXPECT_EQ(caps.duplex_default, printing::LONG_EDGE);
36 EXPECT_FALSE(caps.color_changeable); 41 EXPECT_FALSE(caps.color_changeable);
37 EXPECT_FALSE(caps.color_default); 42 EXPECT_FALSE(caps.color_default);
38 EXPECT_TRUE(caps.duplex_capable);
39 EXPECT_EQ(caps.duplex_default, printing::LONG_EDGE);
40 } 43 }
41 44
42 // Test duplex detection code, which regressed in http://crbug.com/103999. 45 // Test duplex detection code, which regressed in http://crbug.com/103999.
43 TEST(PrintBackendCupsHelperTest, TestPpdParsingNoColorDuplexSimples) { 46 TEST(PrintBackendCupsHelperTest, TestPpdParsingNoColorDuplexSimples) {
44 std::string test_ppd_data; 47 std::string test_ppd_data;
45 test_ppd_data.append( 48 test_ppd_data.append(
46 "*PPD-Adobe: \"4.3\"\n\n" 49 "*PPD-Adobe: \"4.3\"\n\n"
47 "*OpenGroup: General/General\n\n" 50 "*OpenGroup: General/General\n\n"
48 "*OpenUI *Duplex/Double-Sided Printing: PickOne\n" 51 "*OpenUI *Duplex/Double-Sided Printing: PickOne\n"
49 "*DefaultDuplex: None\n" 52 "*DefaultDuplex: None\n"
50 "*Duplex None/Off: " 53 "*Duplex None/Off: "
51 "\"<</Duplex false>>setpagedevice\"\n" 54 "\"<</Duplex false>>setpagedevice\"\n"
52 "*Duplex DuplexNoTumble/Long Edge (Standard): " 55 "*Duplex DuplexNoTumble/Long Edge (Standard): "
53 "\"<</Duplex true/Tumble false>>setpagedevice\"\n" 56 "\"<</Duplex true/Tumble false>>setpagedevice\"\n"
54 "*Duplex DuplexTumble/Short Edge (Flip): " 57 "*Duplex DuplexTumble/Short Edge (Flip): "
55 "\"<</Duplex true/Tumble true>>setpagedevice\"\n" 58 "\"<</Duplex true/Tumble true>>setpagedevice\"\n"
56 "*CloseUI: *Duplex\n\n" 59 "*CloseUI: *Duplex\n\n"
57 "*CloseGroup: General\n"); 60 "*CloseGroup: General\n");
58 61
59 printing::PrinterSemanticCapsAndDefaults caps; 62 printing::PrinterSemanticCapsAndDefaults caps;
60 EXPECT_TRUE(printing::ParsePpdCapabilities("test", test_ppd_data, &caps)); 63 EXPECT_TRUE(printing::ParsePpdCapabilities("test", test_ppd_data, &caps));
64 EXPECT_TRUE(caps.collate_capable);
65 EXPECT_TRUE(caps.collate_default);
66 EXPECT_TRUE(caps.copies_capable);
67 EXPECT_TRUE(caps.duplex_capable);
68 EXPECT_EQ(caps.duplex_default, printing::SIMPLEX);
61 EXPECT_FALSE(caps.color_changeable); 69 EXPECT_FALSE(caps.color_changeable);
62 EXPECT_FALSE(caps.color_default); 70 EXPECT_FALSE(caps.color_default);
63 EXPECT_TRUE(caps.duplex_capable);
64 EXPECT_EQ(caps.duplex_default, printing::SIMPLEX);
65 } 71 }
66 72
67 TEST(PrintBackendCupsHelperTest, TestPpdParsingNoColorNoDuplex) { 73 TEST(PrintBackendCupsHelperTest, TestPpdParsingNoColorNoDuplex) {
68 std::string test_ppd_data; 74 std::string test_ppd_data;
69 test_ppd_data.append( 75 test_ppd_data.append(
70 "*PPD-Adobe: \"4.3\"\n\n" 76 "*PPD-Adobe: \"4.3\"\n\n"
71 "*OpenGroup: General/General\n\n" 77 "*OpenGroup: General/General\n\n"
72 "*OpenUI *ColorModel/Color Model: PickOne\n" 78 "*OpenUI *ColorModel/Color Model: PickOne\n"
73 "*DefaultColorModel: Gray\n" 79 "*DefaultColorModel: Gray\n"
74 "*ColorModel Gray/Grayscale: \"" 80 "*ColorModel Gray/Grayscale: \""
75 "<</cupsColorSpace 0/cupsColorOrder 0>>" 81 "<</cupsColorSpace 0/cupsColorOrder 0>>"
76 "setpagedevice\"\n" 82 "setpagedevice\"\n"
77 "*ColorModel Black/Inverted Grayscale: \"" 83 "*ColorModel Black/Inverted Grayscale: \""
78 "<</cupsColorSpace 3/cupsColorOrder 0>>" 84 "<</cupsColorSpace 3/cupsColorOrder 0>>"
79 "setpagedevice\"\n" 85 "setpagedevice\"\n"
80 "*CloseUI: *ColorModel\n" 86 "*CloseUI: *ColorModel\n"
81 "*CloseGroup: General\n"); 87 "*CloseGroup: General\n");
82 88
83 printing::PrinterSemanticCapsAndDefaults caps; 89 printing::PrinterSemanticCapsAndDefaults caps;
84 EXPECT_TRUE(printing::ParsePpdCapabilities("test", test_ppd_data, &caps)); 90 EXPECT_TRUE(printing::ParsePpdCapabilities("test", test_ppd_data, &caps));
91 EXPECT_TRUE(caps.collate_capable);
92 EXPECT_TRUE(caps.collate_default);
93 EXPECT_TRUE(caps.copies_capable);
94 EXPECT_FALSE(caps.duplex_capable);
95 EXPECT_EQ(caps.duplex_default, printing::UNKNOWN_DUPLEX_MODE);
85 EXPECT_FALSE(caps.color_changeable); 96 EXPECT_FALSE(caps.color_changeable);
86 EXPECT_FALSE(caps.color_default); 97 EXPECT_FALSE(caps.color_default);
87 EXPECT_FALSE(caps.duplex_capable);
88 EXPECT_EQ(caps.duplex_default, printing::UNKNOWN_DUPLEX_MODE);
89 } 98 }
90 99
91 TEST(PrintBackendCupsHelperTest, TestPpdParsingColorTrueDuplexLongEdge) { 100 TEST(PrintBackendCupsHelperTest, TestPpdParsingColorTrueDuplexLongEdge) {
92 std::string test_ppd_data; 101 std::string test_ppd_data;
93 test_ppd_data.append( 102 test_ppd_data.append(
94 "*PPD-Adobe: \"4.3\"\n\n" 103 "*PPD-Adobe: \"4.3\"\n\n"
95 "*ColorDevice: True\n" 104 "*ColorDevice: True\n"
96 "*DefaultColorSpace: CMYK\n\n" 105 "*DefaultColorSpace: CMYK\n\n"
97 "*OpenGroup: General/General\n\n" 106 "*OpenGroup: General/General\n\n"
98 "*OpenUI *ColorModel/Color Model: PickOne\n" 107 "*OpenUI *ColorModel/Color Model: PickOne\n"
99 "*DefaultColorModel: CMYK\n" 108 "*DefaultColorModel: CMYK\n"
100 "*ColorModel CMYK/Color: " 109 "*ColorModel CMYK/Color: "
101 "\"(cmyk) RCsetdevicecolor\"\n" 110 "\"(cmyk) RCsetdevicecolor\"\n"
102 "*ColorModel Gray/Black and White: " 111 "*ColorModel Gray/Black and White: "
103 "\"(gray) RCsetdevicecolor\"\n" 112 "\"(gray) RCsetdevicecolor\"\n"
104 "*CloseUI: *ColorModel\n" 113 "*CloseUI: *ColorModel\n"
105 "*OpenUI *Duplex/2-Sided Printing: PickOne\n" 114 "*OpenUI *Duplex/2-Sided Printing: PickOne\n"
106 "*DefaultDuplex: DuplexTumble\n" 115 "*DefaultDuplex: DuplexTumble\n"
107 "*Duplex None/Off: \"<</Duplex false>>" 116 "*Duplex None/Off: \"<</Duplex false>>"
108 "setpagedevice\"\n" 117 "setpagedevice\"\n"
109 "*Duplex DuplexNoTumble/LongEdge: \"" 118 "*Duplex DuplexNoTumble/LongEdge: \""
110 "<</Duplex true/Tumble false>>setpagedevice\"\n" 119 "<</Duplex true/Tumble false>>setpagedevice\"\n"
111 "*Duplex DuplexTumble/ShortEdge: \"" 120 "*Duplex DuplexTumble/ShortEdge: \""
112 "<</Duplex true/Tumble true>>setpagedevice\"\n" 121 "<</Duplex true/Tumble true>>setpagedevice\"\n"
113 "*CloseUI: *Duplex\n\n" 122 "*CloseUI: *Duplex\n\n"
114 "*CloseGroup: General\n"); 123 "*CloseGroup: General\n");
115 124
116 printing::PrinterSemanticCapsAndDefaults caps; 125 printing::PrinterSemanticCapsAndDefaults caps;
117 EXPECT_TRUE(printing::ParsePpdCapabilities("test", test_ppd_data, &caps)); 126 EXPECT_TRUE(printing::ParsePpdCapabilities("test", test_ppd_data, &caps));
127 EXPECT_TRUE(caps.collate_capable);
128 EXPECT_TRUE(caps.collate_default);
129 EXPECT_TRUE(caps.copies_capable);
130 EXPECT_TRUE(caps.duplex_capable);
131 EXPECT_EQ(caps.duplex_default, printing::LONG_EDGE);
118 EXPECT_TRUE(caps.color_changeable); 132 EXPECT_TRUE(caps.color_changeable);
119 EXPECT_TRUE(caps.color_default); 133 EXPECT_TRUE(caps.color_default);
120 EXPECT_TRUE(caps.duplex_capable);
121 EXPECT_EQ(caps.duplex_default, printing::LONG_EDGE);
122 } 134 }
123 135
124 TEST(PrintBackendCupsHelperTest, TestPpdParsingColorFalseDuplexLongEdge) { 136 TEST(PrintBackendCupsHelperTest, TestPpdParsingColorFalseDuplexLongEdge) {
125 std::string test_ppd_data; 137 std::string test_ppd_data;
126 test_ppd_data.append( 138 test_ppd_data.append(
127 "*PPD-Adobe: \"4.3\"\n\n" 139 "*PPD-Adobe: \"4.3\"\n\n"
128 "*ColorDevice: True\n" 140 "*ColorDevice: True\n"
129 "*DefaultColorSpace: CMYK\n\n" 141 "*DefaultColorSpace: CMYK\n\n"
130 "*OpenGroup: General/General\n\n" 142 "*OpenGroup: General/General\n\n"
131 "*OpenUI *ColorModel/Color Model: PickOne\n" 143 "*OpenUI *ColorModel/Color Model: PickOne\n"
(...skipping 13 matching lines...) Expand all
145 "setpagedevice\"\n" 157 "setpagedevice\"\n"
146 "*Duplex DuplexNoTumble/LongEdge: \"" 158 "*Duplex DuplexNoTumble/LongEdge: \""
147 "<</Duplex true/Tumble false>>setpagedevice\"\n" 159 "<</Duplex true/Tumble false>>setpagedevice\"\n"
148 "*Duplex DuplexTumble/ShortEdge: \"" 160 "*Duplex DuplexTumble/ShortEdge: \""
149 "<</Duplex true/Tumble true>>setpagedevice\"\n" 161 "<</Duplex true/Tumble true>>setpagedevice\"\n"
150 "*CloseUI: *Duplex\n\n" 162 "*CloseUI: *Duplex\n\n"
151 "*CloseGroup: General\n"); 163 "*CloseGroup: General\n");
152 164
153 printing::PrinterSemanticCapsAndDefaults caps; 165 printing::PrinterSemanticCapsAndDefaults caps;
154 EXPECT_TRUE(printing::ParsePpdCapabilities("test", test_ppd_data, &caps)); 166 EXPECT_TRUE(printing::ParsePpdCapabilities("test", test_ppd_data, &caps));
167 EXPECT_TRUE(caps.collate_capable);
168 EXPECT_TRUE(caps.collate_default);
169 EXPECT_TRUE(caps.copies_capable);
170 EXPECT_TRUE(caps.duplex_capable);
171 EXPECT_EQ(caps.duplex_default, printing::LONG_EDGE);
155 EXPECT_TRUE(caps.color_changeable); 172 EXPECT_TRUE(caps.color_changeable);
156 EXPECT_FALSE(caps.color_default); 173 EXPECT_FALSE(caps.color_default);
157 EXPECT_TRUE(caps.duplex_capable);
158 EXPECT_EQ(caps.duplex_default, printing::LONG_EDGE);
159 } 174 }
OLDNEW
« no previous file with comments | « printing/backend/cups_helper.cc ('k') | printing/backend/print_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698