#include "chrome/browser/policy/printing_restrictions_policy_handler.h"
#include "base/json/json_reader.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/common/pref_names.h"
#include "components/policy/core/browser/policy_error_map.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/core/common/policy_types.h"
#include "components/policy/policy_constants.h"
#include "components/prefs/pref_value_map.h"
#include "printing/buildflags/buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace policy {
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
class PrintingRestrictionsPolicyHandlerTest : public testing::Test { … };
TEST_F(PrintingRestrictionsPolicyHandlerTest, NoPolicy) { … }
TEST_F(PrintingRestrictionsPolicyHandlerTest, StandardPaperSize) { … }
TEST_F(PrintingRestrictionsPolicyHandlerTest, CustomPaperSize) { … }
TEST_F(PrintingRestrictionsPolicyHandlerTest, BothStandardAndCustomPaperSize) { … }
TEST_F(PrintingRestrictionsPolicyHandlerTest, NoCustomPaperSize) { … }
TEST_F(PrintingRestrictionsPolicyHandlerTest, NoWidthInCustomSize) { … }
TEST_F(PrintingRestrictionsPolicyHandlerTest, NoHeightInCustomSize) { … }
class PrintPdfAsImageRestrictionsPolicyHandlerTest : public testing::Test { … };
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
TEST_F(PrintPdfAsImageRestrictionsPolicyHandlerTest,
DefaultWithAvailabilityEnabled) {
base::Value availability_value(true);
base::Value default_value(true);
CheckValidPolicy(key::kPrintPdfAsImageAvailability,
availability_value.Clone());
CheckValidPolicy(key::kPrintPdfAsImageDefault, default_value.Clone());
ApplyPolicies();
base::Value* value;
EXPECT_TRUE(prefs_.GetValue(prefs::kPrintPdfAsImageDefault, &value));
ASSERT_TRUE(value);
EXPECT_EQ(*value, default_value);
}
TEST_F(PrintPdfAsImageRestrictionsPolicyHandlerTest,
DefaultWithAvailabilityDisabled) {
base::Value availability_value(false);
base::Value default_value(true);
CheckValidPolicy(key::kPrintPdfAsImageAvailability,
availability_value.Clone());
CheckInvalidPolicy(key::kPrintPdfAsImageDefault, default_value.Clone());
}
TEST_F(PrintPdfAsImageRestrictionsPolicyHandlerTest,
DefaultWithoutAvailability) {
base::Value default_value(true);
CheckInvalidPolicy(key::kPrintPdfAsImageDefault, default_value.Clone());
}
#endif
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
TEST_F(PrintPdfAsImageRestrictionsPolicyHandlerTest,
DefaultWithoutAvailability) { … }
#endif
#endif
}