// Copyright 2019 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "third_party/blink/public/common/permissions_policy/document_policy.h" #include "base/functional/callback.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/blink/public/common/permissions_policy/document_policy_features.h" #include "third_party/blink/public/mojom/permissions_policy/document_policy_feature.mojom.h" namespace blink { namespace { DocumentPolicyTest; // Helper function to convert literal to FeatureState. template <class T> DocumentPolicyFeatureState FeatureState( std::vector<std::pair<int32_t, T>> literal, const base::RepeatingCallback<PolicyValue(T)>& create_pv_cb) { … } TEST_F(DocumentPolicyTest, MergeFeatureState) { … } // IsPolicyCompatible should use default value for incoming policy when required // policy specifies a value for a feature and incoming policy is missing value // for that feature. // TODO: This is not testable as only boolean features exist currently. // TEST_F(DocumentPolicyTest, IsPolicyCompatible) { // mojom::DocumentPolicyFeature feature = // mojom::DocumentPolicyFeature::kLosslessImagesMaxBpp; // double default_policy_value = // GetDocumentPolicyFeatureInfoMap().at(feature).default_value.DoubleValue(); // // Cap the default_policy_value, as it can be INF. // double strict_policy_value = // default_policy_value > 1.0 ? 1.0 : default_policy_value / 2; // // EXPECT_FALSE(DocumentPolicy::IsPolicyCompatible( // DocumentPolicyFeatureState{ // {feature, PolicyValue::CreateDecDouble( // strict_policy_value)}}, /* required policy */ // DocumentPolicyFeatureState{} /* incoming policy */ // )); // } } // namespace } // namespace blink