Skip to content

Commit

Permalink
Tighten fuzzy parameters in form_controls_browsertest.cc
Browse files Browse the repository at this point in the history
This is a followup of crrev.com/c/4184656 and crrev.com/c/4185898.

Now form_controls_browsertest.cc tolerates fewer large error pixels
and more small error pixels. The tolerances are updated based on
try results, with baselines regenerated.

form_controls_browsertest.cc is moved from content/browser to
content/renderer because it tests renderer functionality. Also move
function MacOSVersionSupportsDarkMode() into browser_test_utils.h and
use it from both form_controls_browsertest.cc and
focus_ring_browsertest.cc.

Cq-Include-Trybots: luci.chromium.try:mac10.13-blink-rel,mac10.14-blink-rel,mac10.15-blink-rel
Change-Id: I3ad18958917ea0280a18d842b8784a26faa497d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4183008
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1098071}
  • Loading branch information
wangxianzhu authored and Chromium LUCI CQ committed Jan 27, 2023
1 parent f0b248c commit 3fc2887
Show file tree
Hide file tree
Showing 43 changed files with 60 additions and 81 deletions.
10 changes: 7 additions & 3 deletions chrome/browser/focus_ring_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "cc/test/pixel_comparator.h"
#include "chrome/browser/focus_ring_browsertest_mac.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/base/in_process_browser_test.h"
Expand Down Expand Up @@ -107,6 +106,10 @@ class FocusRingBrowserTest : public InProcessBrowserTest {
}
};

#if BUILDFLAG(IS_MAC)
using content::MacOSVersionSupportsDarkMode;
#endif

// TODO(crbug.com/1222757): Flaky on Mac.
#if BUILDFLAG(IS_MAC)
#define MAYBE_Checkbox DISABLED_Checkbox
Expand Down Expand Up @@ -198,8 +201,9 @@ IN_PROC_BROWSER_TEST_F(FocusRingBrowserTest, MAYBE_Anchor) {
#endif
IN_PROC_BROWSER_TEST_F(FocusRingBrowserTest, MAYBE_DarkModeButton) {
#if BUILDFLAG(IS_MAC)
if (!MacOSVersionSupportsDarkMode())
return;
if (!MacOSVersionSupportsDarkMode()) {
GTEST_SKIP();
}
auto comparator = mac_strict_comparator;
#else
cc::AlphaDiscardingExactPixelComparator comparator;
Expand Down
10 changes: 0 additions & 10 deletions chrome/browser/focus_ring_browsertest_mac.h

This file was deleted.

11 changes: 0 additions & 11 deletions chrome/browser/focus_ring_browsertest_mac.mm

This file was deleted.

2 changes: 0 additions & 2 deletions chrome/test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -9900,8 +9900,6 @@ if (!is_android) {
"../browser/app_controller_mac_interactive_uitest.mm",
"../browser/apps/platform_apps/app_shim_interactive_uitest_mac.mm",
"../browser/apps/platform_apps/app_shim_quit_interactive_uitest_mac.mm",
"../browser/focus_ring_browsertest_mac.h",
"../browser/focus_ring_browsertest_mac.mm",
"../browser/global_keyboard_shortcuts_mac_browsertest.mm",
"../browser/notifications/notification_interactive_uitest_mac.mm",
"../browser/spellchecker/spellcheck_mac_view_interactive_uitest.mm",
Expand Down
10 changes: 0 additions & 10 deletions content/browser/form_controls_browsertest_mac.h

This file was deleted.

11 changes: 0 additions & 11 deletions content/browser/form_controls_browsertest_mac.mm

This file was deleted.

2 changes: 2 additions & 0 deletions content/public/test/browser_test_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2405,6 +2405,8 @@ RegisterWebContentsCreationCallback(
// and/or main. This can be useful to enable when the process hosting the window
// is a standalone executable without an Info.plist.
bool EnableNativeWindowActivation();

bool MacOSVersionSupportsDarkMode();
#endif // BUILDFLAG(IS_MAC)

} // namespace content
Expand Down
7 changes: 7 additions & 0 deletions content/public/test/browser_test_utils_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,11 @@ bool EnableNativeWindowActivation() {
: false;
}

bool MacOSVersionSupportsDarkMode() {
if (@available(macOS 10.14, *)) {
return true;
}
return false;
}

} // namespace content
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "cc/test/pixel_comparator.h"
#include "content/browser/form_controls_browsertest_mac.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/common/content_paths.h"
#include "content/public/common/content_switches.h"
Expand Down Expand Up @@ -104,9 +103,9 @@ class FormControlsBrowserTest : public ContentBrowserTest {
// TODO(wangxianzhu): Tighten these parameters.
auto comparator = cc::FuzzyPixelComparator()
.DiscardAlpha()
.SetErrorPixelsPercentageLimit(26.f)
.SetErrorPixelsPercentageLimit(5.f, 25.f)
.SetAvgAbsErrorLimit(20.f)
.SetAbsErrorLimit(120);
.SetAbsErrorLimit(120, 2);
#elif BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) || (OS_LINUX) || \
BUILDFLAG(IS_FUCHSIA)
// Different versions of android may have slight differences in rendering.
Expand All @@ -116,9 +115,9 @@ class FormControlsBrowserTest : public ContentBrowserTest {
// This also applies to different versions of other OSes.
auto comparator = cc::FuzzyPixelComparator()
.DiscardAlpha()
.SetErrorPixelsPercentageLimit(11.f)
.SetErrorPixelsPercentageLimit(1.f, 2.f)
.SetAvgAbsErrorLimit(5.f)
.SetAbsErrorLimit(140);
.SetAbsErrorLimit(10, 2);
#else
cc::AlphaDiscardingExactPixelComparator comparator;
#endif
Expand Down Expand Up @@ -150,8 +149,9 @@ class FormControlsBrowserTest : public ContentBrowserTest {
#endif

IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, MAYBE_Checkbox) {
if (SkipTestForOldAndroidVersions())
return;
if (SkipTestForOldAndroidVersions()) {
GTEST_SKIP();
}

RunTest("form_controls_browsertest_checkbox",
"<input type=checkbox>"
Expand All @@ -167,8 +167,9 @@ IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, MAYBE_Checkbox) {
}

IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, Radio) {
if (SkipTestForOldAndroidVersions())
return;
if (SkipTestForOldAndroidVersions()) {
GTEST_SKIP();
}

RunTest("form_controls_browsertest_radio",
"<input type=radio>"
Expand All @@ -185,12 +186,14 @@ IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, Radio) {

IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, DarkModeTextSelection) {
#if BUILDFLAG(IS_MAC)
if (!MacOSVersionSupportsDarkMode())
return;
if (!MacOSVersionSupportsDarkMode()) {
GTEST_SKIP();
}
#endif

if (SkipTestForOldAndroidVersions())
return;
if (SkipTestForOldAndroidVersions()) {
GTEST_SKIP();
}

RunTest("form_controls_browsertest_dark_mode_text_selection",
"<meta name=\"color-scheme\" content=\"dark\">"
Expand All @@ -208,8 +211,9 @@ IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, DarkModeTextSelection) {
}

IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, Input) {
if (SkipTestForOldAndroidVersions())
return;
if (SkipTestForOldAndroidVersions()) {
GTEST_SKIP();
}

RunTest("form_controls_browsertest_input",
"<style>body {margin: 8px} input {width: 150px; "
Expand All @@ -231,8 +235,9 @@ IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, Input) {
}

IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, Textarea) {
if (SkipTestForOldAndroidVersions())
return;
if (SkipTestForOldAndroidVersions()) {
GTEST_SKIP();
}

RunTest("form_controls_browsertest_textarea",
R"HTML(
Expand All @@ -251,8 +256,9 @@ IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, Textarea) {
}

IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, Button) {
if (SkipTestForOldAndroidVersions())
return;
if (SkipTestForOldAndroidVersions()) {
GTEST_SKIP();
}

RunTest("form_controls_browsertest_button",
R"HTML(
Expand Down Expand Up @@ -283,8 +289,9 @@ IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, Button) {
#define MAYBE_ColorInput ColorInput
#endif
IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, MAYBE_ColorInput) {
if (SkipTestForOldAndroidVersions())
return;
if (SkipTestForOldAndroidVersions()) {
GTEST_SKIP();
}

RunTest("form_controls_browsertest_color_input",
R"HTML(
Expand All @@ -302,8 +309,9 @@ IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, MAYBE_ColorInput) {
}

IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, Select) {
if (SkipTestForOldAndroidVersions())
return;
if (SkipTestForOldAndroidVersions()) {
GTEST_SKIP();
}

RunTest("form_controls_browsertest_select",
R"HTML(
Expand All @@ -325,8 +333,9 @@ IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, Select) {
}

IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, MultiSelect) {
if (SkipTestForOldAndroidVersions())
return;
if (SkipTestForOldAndroidVersions()) {
GTEST_SKIP();
}

RunTest("form_controls_browsertest_multi_select",
R"HTML(
Expand All @@ -351,8 +360,9 @@ IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, MultiSelect) {
}

IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, Progress) {
if (SkipTestForOldAndroidVersions())
return;
if (SkipTestForOldAndroidVersions()) {
GTEST_SKIP();
}

RunTest("form_controls_browsertest_progress",
R"HTML(
Expand All @@ -371,8 +381,9 @@ IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, Progress) {
}

IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, Meter) {
if (SkipTestForOldAndroidVersions())
return;
if (SkipTestForOldAndroidVersions()) {
GTEST_SKIP();
}

RunTest("form_controls_browsertest_meter",
R"HTML(
Expand All @@ -398,8 +409,9 @@ IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, Meter) {
}

IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, Range) {
if (SkipTestForOldAndroidVersions())
return;
if (SkipTestForOldAndroidVersions()) {
GTEST_SKIP();
}

RunTest("form_controls_browsertest_range",
R"HTML(
Expand Down
4 changes: 1 addition & 3 deletions content/test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,6 @@ test("content_browsertests") {
"../browser/find_request_manager_browsertest.cc",
"../browser/font_access/font_access_manager_browsertest.cc",
"../browser/font_unique_name_lookup/font_unique_name_browsertest.cc",
"../browser/form_controls_browsertest.cc",
"../browser/generic_sensor/generic_sensor_browsertest.cc",
"../browser/gpu/gpu_ipc_browsertests.cc",
"../browser/gpu/in_process_gpu_thread_browsertests.cc",
Expand Down Expand Up @@ -1520,6 +1519,7 @@ test("content_browsertests") {
"../child/webthemeengine_impl_default_browsertest.cc",
"../renderer/accessibility/render_accessibility_impl_browsertest.cc",
"../renderer/blink_platform_audio_hardware_browsertest.cc",
"../renderer/form_controls_browsertest.cc",
"../renderer/gin_browsertest.cc",
"../renderer/media/renderer_webmediaplayer_delegate_browsertest.cc",
"../renderer/media/too_many_web_media_players_intervention_browsertest.cc",
Expand Down Expand Up @@ -1940,8 +1940,6 @@ test("content_browsertests") {
"../browser/accessibility/ax_tree_formatter_mac_browsertest.mm",
"../browser/accessibility/browser_accessibility_cocoa_browsertest.mm",
"../browser/accessibility/hit_testing_mac_browsertest.mm",
"../browser/form_controls_browsertest_mac.h",
"../browser/form_controls_browsertest_mac.mm",
"../browser/keyboard_lock_browsertest_mac.mm",
"../browser/pointer_lock_browsertest_mac.mm",
"../browser/renderer_host/render_frame_host_impl_mac_browsertest.mm",
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified content/test/data/forms/form_controls_browsertest_button_linux.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified content/test/data/forms/form_controls_browsertest_button_win.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified content/test/data/forms/form_controls_browsertest_input_linux.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified content/test/data/forms/form_controls_browsertest_input_mac.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified content/test/data/forms/form_controls_browsertest_input_win.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified content/test/data/forms/form_controls_browsertest_meter_mac.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified content/test/data/forms/form_controls_browsertest_meter_win.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified content/test/data/forms/form_controls_browsertest_progress_mac.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified content/test/data/forms/form_controls_browsertest_progress_win.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified content/test/data/forms/form_controls_browsertest_range_mac.png
Binary file modified content/test/data/forms/form_controls_browsertest_select_linux.png
Binary file modified content/test/data/forms/form_controls_browsertest_select_win.png
Binary file modified content/test/data/forms/form_controls_browsertest_textarea_win.png

0 comments on commit 3fc2887

Please sign in to comment.