This source file includes following definitions.
- TEST_F
- TEST_F
- TEST_F
#include "base/prefs/pref_value_map.h"
#include "base/values.h"
#include "components/autofill/core/common/autofill_pref_names.h"
#include "components/policy/core/browser/autofill_policy_handler.h"
#include "components/policy/core/common/policy_map.h"
#include "policy/policy_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace policy {
class AutofillPolicyHandlerTest : public testing::Test {};
TEST_F(AutofillPolicyHandlerTest, Default) {
PolicyMap policy;
PrefValueMap prefs;
AutofillPolicyHandler handler;
handler.ApplyPolicySettings(policy, &prefs);
EXPECT_FALSE(prefs.GetValue(autofill::prefs::kAutofillEnabled, NULL));
}
TEST_F(AutofillPolicyHandlerTest, Enabled) {
PolicyMap policy;
policy.Set(key::kAutoFillEnabled,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
base::Value::CreateBooleanValue(true),
NULL);
PrefValueMap prefs;
AutofillPolicyHandler handler;
handler.ApplyPolicySettings(policy, &prefs);
EXPECT_FALSE(prefs.GetValue(autofill::prefs::kAutofillEnabled, NULL));
}
TEST_F(AutofillPolicyHandlerTest, Disabled) {
PolicyMap policy;
policy.Set(key::kAutoFillEnabled,
POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER,
base::Value::CreateBooleanValue(false),
NULL);
PrefValueMap prefs;
AutofillPolicyHandler handler;
handler.ApplyPolicySettings(policy, &prefs);
const base::Value* value = NULL;
EXPECT_TRUE(prefs.GetValue(autofill::prefs::kAutofillEnabled, &value));
ASSERT_TRUE(value);
bool autofill_enabled = true;
bool result = value->GetAsBoolean(&autofill_enabled);
ASSERT_TRUE(result);
EXPECT_FALSE(autofill_enabled);
}
}