#include "base/memory/raw_ptr.h"
#include "base/metrics/field_trial_params.h"
#include "base/test/scoped_feature_list.h"
#include "content/browser/host_zoom_map_impl.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_features.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/shell/browser/shell.h"
#include "net/dns/mock_host_resolver.h"
#include "url/gurl.h"
namespace content {
class HostZoomMapImplBrowserTest : public ContentBrowserTest { … };
#if BUILDFLAG(IS_ANDROID)
class HostZoomMapImplBrowserTestWithPageZoom
: public HostZoomMapImplBrowserTest {
public:
HostZoomMapImplBrowserTestWithPageZoom() {
feature_list_.InitAndEnableFeatureWithParameters(
features::kAccessibilityPageZoom, {{"AdjustForOSLevel", "true"}});
}
};
class HostZoomMapImplBrowserTestWithPageZoomNoOSAdjustment
: public HostZoomMapImplBrowserTest {
public:
HostZoomMapImplBrowserTestWithPageZoomNoOSAdjustment() {
feature_list_.InitAndEnableFeatureWithParameters(
features::kAccessibilityPageZoom, {{"AdjustForOSLevel", "false"}});
}
};
#endif
IN_PROC_BROWSER_TEST_F(HostZoomMapImplBrowserTest, GetZoomForView_Host) { … }
IN_PROC_BROWSER_TEST_F(HostZoomMapImplBrowserTest,
GetZoomForView_HostAndScheme) { … }
#if BUILDFLAG(IS_ANDROID)
IN_PROC_BROWSER_TEST_F(HostZoomMapImplBrowserTestWithPageZoom,
GetZoomLevelForHostAndSchemeAndroid) {
EXPECT_DOUBLE_EQ(host_zoom_map_impl_->GetDefaultZoomLevel(),
host_zoom_map_impl_->GetZoomLevelForHostAndSchemeAndroid(
url_.scheme(), url_.host()));
host_zoom_map_impl_->SetSystemFontScaleForTesting(1.30);
EXPECT_DOUBLE_EQ(1.44,
host_zoom_map_impl_->GetZoomLevelForHostAndSchemeAndroid(
url_.scheme(), url_.host()));
host_zoom_map_impl_->SetSystemFontScaleForTesting(0.85);
EXPECT_DOUBLE_EQ(-0.89,
host_zoom_map_impl_->GetZoomLevelForHostAndSchemeAndroid(
url_.scheme(), url_.host()));
host_zoom_map_impl_->SetSystemFontScaleForTesting(1.15);
EXPECT_DOUBLE_EQ(0.77,
host_zoom_map_impl_->GetZoomLevelForHostAndSchemeAndroid(
url_.scheme(), url_.host()));
}
IN_PROC_BROWSER_TEST_F(HostZoomMapImplBrowserTestWithPageZoomNoOSAdjustment,
GetZoomLevelForHostAndSchemeAndroid) {
EXPECT_DOUBLE_EQ(host_zoom_map_impl_->GetDefaultZoomLevel(),
host_zoom_map_impl_->GetZoomLevelForHostAndSchemeAndroid(
url_.scheme(), url_.host()));
host_zoom_map_impl_->SetSystemFontScaleForTesting(1.30);
EXPECT_DOUBLE_EQ(0, host_zoom_map_impl_->GetZoomLevelForHostAndSchemeAndroid(
url_.scheme(), url_.host()));
host_zoom_map_impl_->SetSystemFontScaleForTesting(0.85);
EXPECT_DOUBLE_EQ(0, host_zoom_map_impl_->GetZoomLevelForHostAndSchemeAndroid(
url_.scheme(), url_.host()));
host_zoom_map_impl_->SetSystemFontScaleForTesting(1.15);
EXPECT_DOUBLE_EQ(0, host_zoom_map_impl_->GetZoomLevelForHostAndSchemeAndroid(
url_.scheme(), url_.host()));
}
#endif
}