Commit 1bfb96c9 authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

ui: add --disable-modal-animations for Mac

This switch is similar to the existing --wm-window-animations-disabled switch,
which is Aura/Ash-specific, but more tightly scoped and available only on Mac.
This allows tests to disable closure animations for modal dialogs, which take
a few hundred ms each and introduce test flake.

Bug: 817408
Change-Id: Id6d2703d58b25f0efa34085d34f467ad1bf5a912
Reviewed-on: https://chromium-review.googlesource.com/973463
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544884}
parent a6a52dd5
......@@ -8,6 +8,7 @@
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/password_manager/chrome_password_manager_client.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
......@@ -26,6 +27,7 @@
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "ui/base/ui_base_switches.h"
#include "ui/views/test/widget_test.h"
#include "ui/views/widget/widget.h"
......@@ -134,6 +136,13 @@ class PasswordDialogViewTest : public DialogBrowserTest {
};
void PasswordDialogViewTest::SetUpOnMainThread() {
#if defined(OS_MACOSX)
// On non-Mac platforms, animations are globally disabled during tests; on
// Mac they are generally not, but these tests are dramatically slower and
// flakier with animations.
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kDisableModalAnimations);
#endif
SetupTabWithTestController(browser());
}
......
......@@ -14,6 +14,9 @@ const char kDisableAVFoundationOverlays[] = "disable-avfoundation-overlays";
// based overlay display path.
const char kDisableMacOverlays[] = "disable-mac-overlays";
// Disable animations for showing and hiding modal dialogs.
const char kDisableModalAnimations[] = "disable-modal-animations";
// Disable use of cross-process CALayers to display content directly from the
// GPU process on Mac.
const char kDisableRemoteCoreAnimation[] = "disable-remote-core-animation";
......
......@@ -15,6 +15,7 @@ namespace switches {
#if defined(OS_MACOSX) && !defined(OS_IOS)
UI_BASE_EXPORT extern const char kDisableAVFoundationOverlays[];
UI_BASE_EXPORT extern const char kDisableMacOverlays[];
UI_BASE_EXPORT extern const char kDisableModalAnimations[];
UI_BASE_EXPORT extern const char kDisableRemoteCoreAnimation[];
UI_BASE_EXPORT extern const char kShowMacOverlayBorders[];
#endif
......
......@@ -8,6 +8,7 @@
#include <utility>
#include "base/command_line.h"
#import "base/mac/bind_objc_block.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_nsobject.h"
......@@ -16,6 +17,7 @@
#include "components/crash/core/common/crash_key.h"
#import "ui/base/cocoa/constrained_window/constrained_window_animation.h"
#import "ui/base/cocoa/window_size_constants.h"
#include "ui/base/ui_base_switches.h"
#include "ui/gfx/font_list.h"
#import "ui/gfx/mac/coordinate_conversion.h"
#import "ui/gfx/mac/nswindow_frame_controls.h"
......@@ -46,6 +48,11 @@
namespace views {
namespace {
bool AreModalAnimationsEnabled() {
return !base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableModalAnimations);
}
NSInteger StyleMaskForParams(const Widget::InitParams& params) {
// If the Widget is modal, it will be displayed as a sheet. This works best if
// it has NSTitledWindowMask. For example, with NSBorderlessWindowMask, the
......@@ -365,7 +372,8 @@ void NativeWidgetMac::Close() {
}
// For other modal types, animate the close.
if (bridge_->animate() && delegate_->IsModal()) {
if (bridge_->animate() && AreModalAnimationsEnabled() &&
delegate_->IsModal()) {
[ViewsNSWindowCloseAnimator closeWindowWithAnimation:window];
return;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment