blob: edb7644a72fbc5b745812e200faf85b2433531d4 [file] [log] [blame]
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/values.h"
#include "chrome/browser/policy/policy_test_utils.h"
#include "chrome/browser/prefetch/prefetch_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/core/common/policy_types.h"
#include "components/policy/policy_constants.h"
#include "content/public/test/browser_test.h"
namespace policy {
IN_PROC_BROWSER_TEST_F(PolicyTest, NetworkPrediction) {
PrefService* prefs = browser()->profile()->GetPrefs();
// Enabled by default.
EXPECT_TRUE(prefetch::IsSomePreloadingEnabled(*prefs));
// Disable by old, deprecated policy.
PolicyMap policies;
policies.Set(key::kDnsPrefetchingEnabled, POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, base::Value(false),
nullptr);
UpdateProviderPolicy(policies);
EXPECT_FALSE(prefetch::IsSomePreloadingEnabled(*prefs));
// Enabled by new policy, this should override old one.
policies.Set(key::kNetworkPredictionOptions, POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
base::Value(static_cast<int>(
prefetch::NetworkPredictionOptions::kStandard)),
nullptr);
UpdateProviderPolicy(policies);
EXPECT_TRUE(prefetch::IsSomePreloadingEnabled(*prefs));
}
} // namespace policy