1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ash/child_accounts/child_user_interactive_base_test.h"
#include <memory>
#include <string>
#include "base/json/json_writer.h"
#include "chrome/browser/ash/app_restore/full_restore_app_launch_handler.h"
#include "chrome/browser/ash/child_accounts/parent_access_code/parent_access_test_utils.h"
#include "chrome/browser/ash/child_accounts/time_limits/app_time_limits_allowlist_policy_test_utils.h"
#include "chrome/browser/ash/child_accounts/time_limits/app_time_limits_policy_builder.h"
#include "chrome/browser/policy/developer_tools_policy_handler.h"
#include "chrome/test/base/ash/interactive/interactive_ash_test.h"
namespace {
constexpr char kEduCoexistenceToSVersion[] = "333024512";
constexpr char kFlagsUrl[] = "chrome://flags";
} // namespace
namespace ash {
void SetUpSupervisedUserPolicies(
enterprise_management::CloudPolicySettings* policy_payload) {
policy_payload->mutable_developertoolsavailability()->set_value(
static_cast<int64_t>(
policy::DeveloperToolsPolicyHandler::Availability::kDisallowed));
policy_payload->mutable_educoexistencetosversion()->set_value(
kEduCoexistenceToSVersion);
std::string parent_access_config;
base::JSONWriter::Write(parent_access::PolicyFromConfigs(
parent_access::GetDefaultTestConfig(),
parent_access::GetDefaultTestConfig(), {}),
&parent_access_config);
policy_payload->mutable_parentaccesscodeconfig()->set_value(
parent_access_config);
app_time::AppTimeLimitsPolicyBuilder time_limits_policy;
time_limits_policy.SetResetTime(6, 0);
std::string time_limits_policy_value;
base::JSONWriter::Write(time_limits_policy.value(),
&time_limits_policy_value);
policy_payload->mutable_perapptimelimits()->set_value(
time_limits_policy_value);
app_time::AppTimeLimitsAllowlistPolicyBuilder allowlist_policy;
allowlist_policy.SetUp();
std::string allowlist_policy_value;
base::JSONWriter::Write(allowlist_policy.dict(), &allowlist_policy_value);
policy_payload->mutable_perapptimelimitsallowlist()->set_value(
allowlist_policy_value);
policy_payload->mutable_reportarcstatusenabled()->set_value(true);
policy_payload->mutable_urlblocklist()->mutable_value()->add_entries(
kFlagsUrl);
}
ChildUserInteractiveBaseTest::ChildUserInteractiveBaseTest() {
// The InteractiveAshTest constructor does not launch a browser in its
// constructor, but it is needed here to use the LoggedInUserMixin.
set_launch_browser_for_testing(
std::make_unique<full_restore::ScopedLaunchBrowserForTesting>());
}
void ChildUserInteractiveBaseTest::SetUpOnMainThread() {
InteractiveAshTest::SetUpOnMainThread();
SetupContextWidget();
SetUpSupervisedUserPolicies(logged_in_user_mixin_.GetUserPolicyMixin()
->RequestPolicyUpdate()
->policy_payload());
logged_in_user_mixin_.LogInUser();
}
} // namespace ash
|