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

Side by Side Diff: chrome/browser/printing/print_system_task_proxy_unittest.cc

Issue 8226024: Reland 105087: PrintPreview: Fix printer color settings issues based on printer ppd/schema info. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 2 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <cups/cups.h> 5 #include <cups/cups.h>
6 6
7 #include <cstring> 7 #include <cstring>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/scoped_temp_dir.h" 13 #include "base/scoped_temp_dir.h"
14 #include "chrome/browser/ui/webui/print_preview_handler.h" 14 #include "chrome/browser/printing/print_system_task_proxy.h"
15 #include "printing/backend/print_backend.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 namespace { 18 namespace {
18 19
19 // TestEntry stores the printer name and the expected number of options. 20 // TestEntry stores the printer name and the expected number of options.
20 struct TestEntry { 21 struct TestEntry {
21 TestEntry(std::string name, int count) 22 TestEntry(std::string name, int count)
22 : printer_name(name), 23 : printer_name(name),
23 expected_option_count(count) {} 24 expected_option_count(count) {}
24 25
(...skipping 13 matching lines...) Expand all
38 } 39 }
39 ASSERT_TRUE(option_choice); 40 ASSERT_TRUE(option_choice);
40 EXPECT_EQ(strcmp(option_choice->choice, expected_choice_value.c_str()), 0); 41 EXPECT_EQ(strcmp(option_choice->choice, expected_choice_value.c_str()), 0);
41 } 42 }
42 43
43 } // namespace 44 } // namespace
44 45
45 using printing_internal::parse_lpoptions; 46 using printing_internal::parse_lpoptions;
46 47
47 // Test to verify that lpoption custom settings are marked on the ppd file. 48 // Test to verify that lpoption custom settings are marked on the ppd file.
48 TEST(PrintPreviewHandlerTest, MarkLpoptionsInPPD) { 49 TEST(PrintSystemTaskProxyTest, MarkLpoptionsInPPD) {
49 const std::string kColorModel = "ColorModel"; 50 const std::string kColorModel = "ColorModel";
50 const std::string kBlack = "Black"; 51 const std::string kBlack = "Black";
51 const std::string kGray = "Gray"; 52 const std::string kGray = "Gray";
52 53
53 const std::string kDuplex = "Duplex"; 54 const std::string kDuplex = "Duplex";
54 const std::string kDuplexNone = "None"; 55 const std::string kDuplexNone = "None";
55 const std::string kDuplexNoTumble = "DuplexNoTumble"; 56 const std::string kDuplexNoTumble = "DuplexNoTumble";
56 const std::string kDuplexTumble = "DuplexTumble"; 57 const std::string kDuplexTumble = "DuplexTumble";
57 const std::string kTestPrinterName = "printerE"; 58 const std::string kTestPrinterName = "printerE";
58 59
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 cupsFreeOptions(num_options, options); 146 cupsFreeOptions(num_options, options);
146 147
147 // Verify that the settings are updated as per user lpoptions. Make sure 148 // Verify that the settings are updated as per user lpoptions. Make sure
148 // duplex setting is updated but the color setting remains the same. 149 // duplex setting is updated but the color setting remains the same.
149 verifyOptionValue(ppd, kDuplex, kDuplexNoTumble); 150 verifyOptionValue(ppd, kDuplex, kDuplexNoTumble);
150 verifyOptionValue(ppd, kColorModel, kBlack); 151 verifyOptionValue(ppd, kColorModel, kBlack);
151 ppdClose(ppd); 152 ppdClose(ppd);
152 } 153 }
153 154
154 // Test the lpoption parsing code. 155 // Test the lpoption parsing code.
155 TEST(PrintPreviewHandlerTest, ParseLpoptionData) { 156 TEST(PrintSystemTaskProxyTest, ParseLpoptionData) {
156 // Specifies the user lpoption data. 157 // Specifies the user lpoption data.
157 std::string user_lpoptions; 158 std::string user_lpoptions;
158 159
159 // Printer A default printer settings. 160 // Printer A default printer settings.
160 user_lpoptions.append("Default printerA Duplex=None landscape=true "); 161 user_lpoptions.append("Default printerA Duplex=None landscape=true ");
161 user_lpoptions.append("media=A4 Collate=True sides=two-sided-long-edge "); 162 user_lpoptions.append("media=A4 Collate=True sides=two-sided-long-edge ");
162 user_lpoptions.append("ColorModel=Color nUp=7\n"); 163 user_lpoptions.append("ColorModel=Color nUp=7\n");
163 164
164 // PrinterB custom settings. 165 // PrinterB custom settings.
165 user_lpoptions.append("Dest printerB Duplex=None scaling=98 "); 166 user_lpoptions.append("Dest printerB Duplex=None scaling=98 ");
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 it != test_cases.end(); ++it) { 214 it != test_cases.end(); ++it) {
214 num_options = 0; 215 num_options = 0;
215 options = NULL; 216 options = NULL;
216 printing_internal::parse_lpoptions(userLpOptionsFile, it->printer_name, 217 printing_internal::parse_lpoptions(userLpOptionsFile, it->printer_name,
217 &num_options, &options); 218 &num_options, &options);
218 ASSERT_EQ(num_options, it->expected_option_count); 219 ASSERT_EQ(num_options, it->expected_option_count);
219 EXPECT_EQ(num_options != 0, options != NULL); 220 EXPECT_EQ(num_options != 0, options != NULL);
220 cupsFreeOptions(num_options, options); 221 cupsFreeOptions(num_options, options);
221 } 222 }
222 } 223 }
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_system_task_proxy.cc ('k') | chrome/browser/resources/print_preview/color_settings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698