chromium/components/cloud_devices/common/printer_description_unittest.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/cloud_devices/common/printer_description.h"

#include <memory>
#include <utility>

#include "base/containers/flat_set.h"
#include "base/json/json_writer.h"
#include "base/strings/string_util.h"
#include "base/test/values_test_util.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/rect.h"

namespace cloud_devices {

namespace printer {

// Makes sure that same JSON value represented by same strings to simplify
// comparison.
std::string NormalizeJson(const std::string& json) {}

const char kCdd[] =;

const char kDefaultCdd[] =;

const char kBadVersionCdd[] =;

const char kMultyDefaultCdd[] =;

const char kDocumentTypeColorOnlyCdd[] =;

const char kDocumentTypeGrayOnlyCdd[] =;

const char kDocumentTypeColorAndGrayCdd[] =;

const char kDocumentTypeColorAndUnsupportedCdd[] =;

const char kDocumentTypeNoneCdd[] =;

const char kDocumentTypeNotStringCdd[] =;

const char kDocumentTypeNotListCdd[] =;

const char kIntegerRangeVendorCapabilityJson[] =;

const char kFloatDefaultRangeVendorCapabilityJson[] =;

const char kInvalidTypeRangeVendorCapabilityJson[] =;

const char kMissingMinValueRangeVendorCapabilityJson[] =;

const char kInvalidBoundariesRangeVendorCapabilityJson[] =;

const char kInvalidDefaultValueRangeVendorCapabilityJson[] =;

const char kSelectVendorCapabilityJson[] =;

const char kNotListSelectVendorCapabilityJson[] =;

const char kMissingValueSelectVendorCapabilityJson[] =;

const char kMissingDisplayNameSelectVendorCapabilityJson[] =;

const char kNoDefaultSelectVendorCapabilityJson[] =;

const char kSeveralDefaultsSelectVendorCapabilityJson[] =;

const char kBooleanTypedValueVendorCapabilityJson[] =;

const char kFloatTypedValueVendorCapabilityJson[] =;

const char kIntegerTypedValueVendorCapabilityJson[] =;

const char kStringTypedValueVendorCapabilityJson[] =;

const char kMissingValueTypeTypedValueVendorCapabilityJson[] =;

const char kInvalidBooleanTypedValueVendorCapabilityJson[] =;

const char kInvalidFloatTypedValueVendorCapabilityJson[] =;

const char kInvalidIntegerTypedValueVendorCapabilityJson[] =;

const char kVendorCapabilityOnlyCdd[] =;

const char kMissingIdVendorCapabilityCdd[] =;

const char kInvalidInnerCapabilityVendorCapabilityCdd[] =;

const char kNoInnerCapabilityVendorCapabilityCdd[] =;

const char kSeveralInnerCapabilitiesVendorCapabilityCdd[] =;

#if BUILDFLAG(IS_CHROMEOS)
const char kPinOnlyCdd[] = R"(
    {
      "version": "1.0",
      "printer": {
        "pin": {
          "supported": true
        }
      }
    })";
#endif  // BUILDFLAG(IS_CHROMEOS)

// Invalid because `is_continuous_feed` is true and `min_height_microns` is
// missing.
const char kInvalidCustomMediaNoMinHeightCdd[] =;

// Invalid because `is_continuous_feed` is true and `width_microns` is missing.
const char kInvalidCustomMediaNoWidthCdd[] =;

// Invalid because `max_height_microns` is less than `min_height_microns`.
const char kInvalidCustomMediaBadMaxHeightCdd[] =;

// Invalid because `min_height_microns` is 0.
const char kInvalidCustomMediaBadMinHeightCdd[] =;

const char kCjt[] =;

const char kDefaultCjt[] =;

const char kBadVersionCjt[] =;

const struct TestRangeCapabilities {} kTestRangeCapabilities[] =;

const struct TestTypedValueCapabilities {} kTestTypedValueCapabilities[] =;

TEST(PrinterDescriptionTest, CddInit) {}

TEST(PrinterDescriptionTest, CddInvalid) {}

TEST(PrinterDescriptionTest, CddSetAll) {}

TEST(PrinterDescriptionTest, CddGetDocumentTypeSupported) {}

TEST(PrinterDescriptionTest, CddSetDocumentTypeSupported) {}

TEST(PrinterDescriptionTest, CddGetRangeVendorCapability) {}

TEST(PrinterDescriptionTest, CddSetRangeVendorCapability) {}

TEST(PrinterDescriptionTest, CddGetSelectVendorCapability) {}

TEST(PrinterDescriptionTest, CddSetSelectVendorCapability) {}

TEST(PrinterDescriptionTest, CddGetTypedValueVendorCapability) {}

TEST(PrinterDescriptionTest, CddSetTypedValueVendorCapability) {}

TEST(PrinterDescriptionTest, CddGetVendorCapability) {}

TEST(PrinterDescriptionTest, CddSetVendorCapability) {}

#if BUILDFLAG(IS_CHROMEOS)
TEST(PrinterDescriptionTest, CddGetPin) {
  {
    CloudDeviceDescription description;
    ASSERT_TRUE(description.InitFromString(kPinOnlyCdd));

    PinCapability pin_capability;
    EXPECT_TRUE(pin_capability.LoadFrom(description));
    EXPECT_TRUE(pin_capability.value());
  }
  {
    CloudDeviceDescription description;
    ASSERT_TRUE(description.InitFromString(kDefaultCdd));
    PinCapability pin_capability;
    EXPECT_FALSE(pin_capability.LoadFrom(description));
  }
}

TEST(PrinterDescriptionTest, CddSetPin) {
  CloudDeviceDescription description;

  PinCapability pin_capability;
  pin_capability.set_value(true);
  pin_capability.SaveTo(&description);
  EXPECT_EQ(NormalizeJson(kPinOnlyCdd),
            NormalizeJson(description.ToStringForTesting()));
}
#endif  // BUILDFLAG(IS_CHROMEOS)

TEST(PrinterDescriptionTest, CddInvalidCustomMediaNoMinHeight) {}

TEST(PrinterDescriptionTest, CddInvalidCustomMediaNoWidth) {}

TEST(PrinterDescriptionTest, CddInvalidCustomMediaBadMaxHeight) {}

TEST(PrinterDescriptionTest, CddInvalidCustomMediaBadMinHeight) {}

TEST(PrinterDescriptionTest, CddGetAll) {}

TEST(PrinterDescriptionTest, CjtInit) {}

TEST(PrinterDescriptionTest, CjtInvalid) {}

TEST(PrinterDescriptionTest, CjtSetAll) {}

TEST(PrinterDescriptionTest, CjtGetAll) {}

TEST(PrinterDescriptionTest, ContentTypesCapabilityIterator) {}

TEST(PrinterDescriptionMediaBuilderTest, StandardName) {}

TEST(PrinterDescriptionMediaBuilderTest, CustomName) {}

TEST(PrinterDescriptionMediaBuilderTest, EmptySize) {}

TEST(PrinterDescriptionMediaBuilderTest, EmptyWidth) {}

TEST(PrinterDescriptionMediaBuilderTest, ContinuousFeedHeight) {}

TEST(PrinterDescriptionMediaBuilderTest, WithNameMaybeBasedOnSize) {}

TEST(PrinterDescriptionMediaBuilderTest,
     WithSizeAndPrintableAreaBasedOnStandardName) {}

TEST(PrinterDescriptionMediaBuilderTest, MultipleBuilds) {}

}  // namespace printer

}  // namespace cloud_devices