Skip to content

Commit

Permalink
Rename cups_ipp_util* files to cups_ipp_helper*
Browse files Browse the repository at this point in the history
Currently, cups_ipp_util.h is used by files outside of the "printing"
target, and contains exported methods. However, we might want to add
utility functions that we don't want to expose to other targets, and we
might want to place these in a header that is named similarly to
cups_ipp_util.h.

The name cups_ipp_helper.h was chosen because it contains methods
for parsing IPP printer attributes, and cups_helper.h, which contains
methods for parsing PPD printer attributes, already exists. The new
name is consistent with the existing one.

Bug: 226176
Change-Id: I333d4380e6e333c319989879d41d93404a38de4a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2062579
Reviewed-by: Sean Kau <skau@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Auto-Submit: Daniel Hosseinian <dhoss@chromium.org>
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743330}
  • Loading branch information
Daniel Hosseinian authored and Commit Bot committed Feb 20, 2020
1 parent a9e92e5 commit 9c72599
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 35 deletions.
2 changes: 1 addition & 1 deletion chrome/services/cups_proxy/ipp_validator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "chrome/services/cups_proxy/ipp_attribute_validator.h"
#include "chrome/services/cups_proxy/public/cpp/cups_util.h"
#include "net/http/http_util.h"
#include "printing/backend/cups_ipp_util.h"
#include "printing/backend/cups_ipp_helper.h"

namespace cups_proxy {
namespace {
Expand Down
2 changes: 1 addition & 1 deletion chrome/services/cups_proxy/ipp_validator_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "chrome/services/cups_proxy/fake_cups_proxy_service_delegate.h"
#include "chrome/services/cups_proxy/public/cpp/cups_util.h"
#include "chrome/services/cups_proxy/public/cpp/ipp_messages.h"
#include "printing/backend/cups_ipp_util.h"
#include "printing/backend/cups_ipp_helper.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace cups_proxy {
Expand Down
2 changes: 1 addition & 1 deletion chrome/services/cups_proxy/printer_installer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "base/test/task_environment.h"
#include "chrome/services/cups_proxy/fake_cups_proxy_service_delegate.h"
#include "chrome/services/cups_proxy/printer_installer.h"
#include "printing/backend/cups_ipp_util.h"
#include "printing/backend/cups_ipp_helper.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace cups_proxy {
Expand Down
2 changes: 1 addition & 1 deletion chrome/services/cups_proxy/proxy_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "mojo/public/cpp/bindings/remote.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
#include "printing/backend/cups_ipp_util.h"
#include "printing/backend/cups_ipp_helper.h"
#include "services/service_manager/public/cpp/connector.h"

namespace cups_proxy {
Expand Down
2 changes: 1 addition & 1 deletion chrome/services/cups_proxy/public/cpp/ipp_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include "base/optional.h"
#include "chrome/services/ipp_parser/public/cpp/ipp_converter.h"
#include "printing/backend/cups_ipp_util.h"
#include "printing/backend/cups_ipp_helper.h"

// POD representations of HTTP/IPP objects.
namespace cups_proxy {
Expand Down
2 changes: 1 addition & 1 deletion chrome/services/ipp_parser/public/cpp/ipp_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "base/containers/span.h"
#include "base/strings/string_piece.h"
#include "chrome/services/ipp_parser/public/mojom/ipp_parser.mojom.h"
#include "printing/backend/cups_ipp_util.h"
#include "printing/backend/cups_ipp_helper.h"

// This namespace is filled with helpful (conversion) functions for working with
// arbitrary byte buffers representing IPP requests.
Expand Down
10 changes: 5 additions & 5 deletions printing/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ component("printing") {
"backend/cups_deleters.h",
"backend/cups_ipp_constants.cc",
"backend/cups_ipp_constants.h",
"backend/cups_ipp_util.cc",
"backend/cups_ipp_util.h",
"backend/cups_ipp_helper.cc",
"backend/cups_ipp_helper.h",
"backend/cups_jobs.cc",
"backend/cups_jobs.h",
"backend/cups_printer.cc",
Expand All @@ -219,8 +219,8 @@ component("printing") {
sources += [
"backend/cups_ipp_constants.cc",
"backend/cups_ipp_constants.h",
"backend/cups_ipp_util.cc",
"backend/cups_ipp_util.h",
"backend/cups_ipp_helper.cc",
"backend/cups_ipp_helper.h",
]
}
}
Expand Down Expand Up @@ -325,7 +325,7 @@ test("printing_unittests") {
configs += [ ":cups" ]

if (is_chromeos) {
sources += [ "backend/cups_ipp_util_unittest.cc" ]
sources += [ "backend/cups_ipp_helper_unittest.cc" ]
} else {
sources += [ "backend/cups_helper_unittest.cc" ]
if (is_linux) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "printing/backend/cups_ipp_util.h"
#include "printing/backend/cups_ipp_helper.h"

#include <cups/cups.h>

Expand All @@ -17,6 +17,7 @@
#include "base/strings/string_piece.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "printing/backend/cups_connection.h"
#include "printing/backend/cups_ipp_constants.h"
#include "printing/backend/cups_printer.h"
#include "printing/backend/print_backend_consts.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

// Methods for parsing IPP Printer attributes.

#ifndef PRINTING_BACKEND_CUPS_IPP_UTIL_H_
#define PRINTING_BACKEND_CUPS_IPP_UTIL_H_
#ifndef PRINTING_BACKEND_CUPS_IPP_HELPER_H_
#define PRINTING_BACKEND_CUPS_IPP_HELPER_H_

#include <memory>

Expand Down Expand Up @@ -33,4 +33,4 @@ PRINTING_EXPORT ScopedIppPtr WrapIpp(ipp_t* ipp);

} // namespace printing

#endif // PRINTING_BACKEND_CUPS_IPP_UTIL_H_
#endif // PRINTING_BACKEND_CUPS_IPP_HELPER_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "printing/backend/cups_ipp_helper.h"

#include <cups/cups.h>

#include <map>
Expand All @@ -10,7 +12,6 @@
#include "base/logging.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "printing/backend/cups_ipp_util.h"
#include "printing/backend/cups_printer.h"
#include "printing/printing_features.h"
#include "testing/gmock/include/gmock/gmock.h"
Expand Down Expand Up @@ -68,7 +69,7 @@ class MockCupsOptionProvider : public CupsOptionProvider {
std::map<base::StringPiece, ipp_attribute_t*> default_attributes_;
};

class PrintBackendCupsIppUtilTest : public ::testing::Test {
class PrintBackendCupsIppHelperTest : public ::testing::Test {
protected:
void SetUp() override {
ipp_ = ippNew();
Expand Down Expand Up @@ -110,7 +111,7 @@ ipp_attribute_t* MakeStringCollection(ipp_t* ipp,
strings.size(), nullptr, strings.data());
}

TEST_F(PrintBackendCupsIppUtilTest, CopiesCapable) {
TEST_F(PrintBackendCupsIppHelperTest, CopiesCapable) {
printer_->SetSupportedOptions("copies", MakeRange(ipp_, 1, 2));

PrinterSemanticCapsAndDefaults caps;
Expand All @@ -119,15 +120,15 @@ TEST_F(PrintBackendCupsIppUtilTest, CopiesCapable) {
EXPECT_TRUE(caps.copies_capable);
}

TEST_F(PrintBackendCupsIppUtilTest, CopiesNotCapable) {
TEST_F(PrintBackendCupsIppHelperTest, CopiesNotCapable) {
// copies missing, no setup
PrinterSemanticCapsAndDefaults caps;
CapsAndDefaultsFromPrinter(*printer_, &caps);

EXPECT_FALSE(caps.copies_capable);
}

TEST_F(PrintBackendCupsIppUtilTest, ColorPrinter) {
TEST_F(PrintBackendCupsIppHelperTest, ColorPrinter) {
printer_->SetSupportedOptions(
"print-color-mode", MakeStringCollection(ipp_, {"color", "monochrome"}));
printer_->SetOptionDefault("print-color-mode", MakeString(ipp_, "color"));
Expand All @@ -139,7 +140,7 @@ TEST_F(PrintBackendCupsIppUtilTest, ColorPrinter) {
EXPECT_TRUE(caps.color_default);
}

TEST_F(PrintBackendCupsIppUtilTest, BWPrinter) {
TEST_F(PrintBackendCupsIppHelperTest, BWPrinter) {
printer_->SetSupportedOptions("print-color-mode",
MakeStringCollection(ipp_, {"monochrome"}));
printer_->SetOptionDefault("print-color-mode",
Expand All @@ -152,7 +153,7 @@ TEST_F(PrintBackendCupsIppUtilTest, BWPrinter) {
EXPECT_FALSE(caps.color_default);
}

TEST_F(PrintBackendCupsIppUtilTest, DuplexSupported) {
TEST_F(PrintBackendCupsIppHelperTest, DuplexSupported) {
printer_->SetSupportedOptions(
"sides",
MakeStringCollection(ipp_, {"two-sided-long-edge", "one-sided"}));
Expand All @@ -166,7 +167,7 @@ TEST_F(PrintBackendCupsIppUtilTest, DuplexSupported) {
EXPECT_EQ(SIMPLEX, caps.duplex_default);
}

TEST_F(PrintBackendCupsIppUtilTest, DuplexNotSupported) {
TEST_F(PrintBackendCupsIppHelperTest, DuplexNotSupported) {
printer_->SetSupportedOptions("sides",
MakeStringCollection(ipp_, {"one-sided"}));
printer_->SetOptionDefault("sides", MakeString(ipp_, "one-sided"));
Expand All @@ -178,7 +179,7 @@ TEST_F(PrintBackendCupsIppUtilTest, DuplexNotSupported) {
EXPECT_EQ(SIMPLEX, caps.duplex_default);
}

TEST_F(PrintBackendCupsIppUtilTest, A4PaperSupported) {
TEST_F(PrintBackendCupsIppHelperTest, A4PaperSupported) {
printer_->SetSupportedOptions(
"media", MakeStringCollection(ipp_, {"iso_a4_210x297mm"}));

Expand All @@ -194,7 +195,7 @@ TEST_F(PrintBackendCupsIppUtilTest, A4PaperSupported) {
EXPECT_EQ(297000, paper.size_um.height());
}

TEST_F(PrintBackendCupsIppUtilTest, LegalPaperDefault) {
TEST_F(PrintBackendCupsIppHelperTest, LegalPaperDefault) {
printer_->SetOptionDefault("media", MakeString(ipp_, "na_legal_8.5x14in"));

PrinterSemanticCapsAndDefaults caps;
Expand All @@ -211,7 +212,7 @@ TEST_F(PrintBackendCupsIppUtilTest, LegalPaperDefault) {
// with badly formatted vendor IDs - such papers will not transform into
// meaningful ParsedPaper instances and are sometimes inimical to
// ARC++.
TEST_F(PrintBackendCupsIppUtilTest, OmitPapersWithoutVendorIds) {
TEST_F(PrintBackendCupsIppHelperTest, OmitPapersWithoutVendorIds) {
printer_->SetSupportedOptions(
"media", MakeStringCollection(ipp_, {"jis_b5_182x257mm", "invalidsize",
"", "iso_b5_176x250mm"}));
Expand Down Expand Up @@ -239,7 +240,7 @@ TEST_F(PrintBackendCupsIppUtilTest, OmitPapersWithoutVendorIds) {
// Tests that CapsAndDefaultsFromPrinter() does not propagate the
// special IPP values that CUPS happens to expose to the Chromium print
// backend.
TEST_F(PrintBackendCupsIppUtilTest, OmitPapersWithSpecialVendorIds) {
TEST_F(PrintBackendCupsIppHelperTest, OmitPapersWithSpecialVendorIds) {
// Maintainer's note: there's no reason why a printer would deliver
// two discrete sizes for custom_min* and custom_max*; in practice,
// we always see the fully qualified custom_m(in|ax)_<DIMENSIONS>
Expand Down Expand Up @@ -274,7 +275,7 @@ TEST_F(PrintBackendCupsIppUtilTest, OmitPapersWithSpecialVendorIds) {
"iso b0")));
}

TEST_F(PrintBackendCupsIppUtilTest, PinSupported) {
TEST_F(PrintBackendCupsIppHelperTest, PinSupported) {
printer_->SetSupportedOptions("job-password", MakeInteger(ipp_, 4));
printer_->SetSupportedOptions("job-password-encryption",
MakeStringCollection(ipp_, {"none"}));
Expand All @@ -285,15 +286,15 @@ TEST_F(PrintBackendCupsIppUtilTest, PinSupported) {
EXPECT_TRUE(caps.pin_supported);
}

TEST_F(PrintBackendCupsIppUtilTest, PinNotSupported) {
TEST_F(PrintBackendCupsIppHelperTest, PinNotSupported) {
// Pin support missing, no setup.
PrinterSemanticCapsAndDefaults caps;
CapsAndDefaultsFromPrinter(*printer_, &caps);

EXPECT_FALSE(caps.pin_supported);
}

TEST_F(PrintBackendCupsIppUtilTest, PinEncryptionNotSupported) {
TEST_F(PrintBackendCupsIppHelperTest, PinEncryptionNotSupported) {
printer_->SetSupportedOptions("job-password", MakeInteger(ipp_, 4));

PrinterSemanticCapsAndDefaults caps;
Expand All @@ -302,7 +303,7 @@ TEST_F(PrintBackendCupsIppUtilTest, PinEncryptionNotSupported) {
EXPECT_FALSE(caps.pin_supported);
}

TEST_F(PrintBackendCupsIppUtilTest, PinTooShort) {
TEST_F(PrintBackendCupsIppHelperTest, PinTooShort) {
printer_->SetSupportedOptions("job-password", MakeInteger(ipp_, 3));
printer_->SetSupportedOptions("job-password-encryption",
MakeStringCollection(ipp_, {"none"}));
Expand All @@ -313,7 +314,7 @@ TEST_F(PrintBackendCupsIppUtilTest, PinTooShort) {
EXPECT_FALSE(caps.pin_supported);
}

TEST_F(PrintBackendCupsIppUtilTest, AdvancedCaps) {
TEST_F(PrintBackendCupsIppHelperTest, AdvancedCaps) {
base::HistogramTester histograms;
base::test::ScopedFeatureList features;
features.InitAndEnableFeature(printing::features::kAdvancedPpdAttributes);
Expand Down
2 changes: 1 addition & 1 deletion printing/backend/cups_jobs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "base/threading/scoped_blocking_call.h"
#include "base/version.h"
#include "printing/backend/cups_deleters.h"
#include "printing/backend/cups_ipp_util.h"
#include "printing/backend/cups_ipp_helper.h"

namespace printing {
namespace {
Expand Down
2 changes: 1 addition & 1 deletion printing/backend/print_backend_cups_ipp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "printing/backend/cups_connection.h"
#include "printing/backend/cups_ipp_util.h"
#include "printing/backend/cups_ipp_helper.h"
#include "printing/backend/print_backend_consts.h"
#include "printing/units.h"

Expand Down
2 changes: 1 addition & 1 deletion printing/printing_context_chromeos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "base/strings/utf_string_conversions.h"
#include "printing/backend/cups_connection.h"
#include "printing/backend/cups_ipp_constants.h"
#include "printing/backend/cups_ipp_util.h"
#include "printing/backend/cups_ipp_helper.h"
#include "printing/backend/cups_printer.h"
#include "printing/metafile.h"
#include "printing/print_job_constants.h"
Expand Down

0 comments on commit 9c72599

Please sign in to comment.