Commit 9a068829 authored by tapted's avatar tapted Committed by Commit bot

Mac: Deflake AppListServiceInteractiveTest.SwitchAppListProfilesDuringSearch

This is flaky because the app list ends up trying to read an ImageSkia
on one of Cocoa's background threads.

While NSView has a `canDrawConcurrently` function, AppKit is not calling
it in the case that is making this test flaky. The documentation says,
"The default is NO for most types of views.." [sic], and I've verified
it is `NO` and tried overriding it, but it was just never called.

However, having -[NSView canDraw] return `NO` seems to work fine.
Returning NO when there is no message loop ensures a draw only occurs on
a thread that Chrome created (not one of Cocoa's background threads),
and doesn't raise any DEPS issues.

BUG=417148, 415264

Review URL: https://codereview.chromium.org/599803002

Cr-Commit-Position: refs/heads/master@{#296591}
parent 4789b6a0
...@@ -49,25 +49,18 @@ class AppListServiceInteractiveTest : public InProcessBrowserTest { ...@@ -49,25 +49,18 @@ class AppListServiceInteractiveTest : public InProcessBrowserTest {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#define MAYBE_ShowAndDismiss DISABLED_ShowAndDismiss #define MAYBE_ShowAndDismiss DISABLED_ShowAndDismiss
#define MAYBE_SwitchAppListProfiles DISABLED_SwitchAppListProfiles #define MAYBE_SwitchAppListProfiles DISABLED_SwitchAppListProfiles
#define MAYBE_SwitchAppListProfilesDuringSearch \
DISABLED_SwitchAppListProfilesDuringSearch
#define MAYBE_ShowAppListNonDefaultProfile \ #define MAYBE_ShowAppListNonDefaultProfile \
DISABLED_ShowAppListNonDefaultProfile DISABLED_ShowAppListNonDefaultProfile
#define MAYBE_DeleteShowingAppList DISABLED_DeleteShowingAppList #define MAYBE_DeleteShowingAppList DISABLED_DeleteShowingAppList
#else #else
#define MAYBE_ShowAndDismiss ShowAndDismiss #define MAYBE_ShowAndDismiss ShowAndDismiss
#define MAYBE_SwitchAppListProfiles SwitchAppListProfiles #define MAYBE_SwitchAppListProfiles SwitchAppListProfiles
#define MAYBE_ShowAppListNonDefaultProfile ShowAppListNonDefaultProfile
#define MAYBE_DeleteShowingAppList DeleteShowingAppList
#endif
// SwitchAppListProfilesDuringSearch disabled on ChromeOS for reasons above.
// Disabled on Mac due to an AppKit bug which makes it flaky in rare cases.
// http://crbug.com/417148.
#if defined(OS_CHROMEOS) || defined(OS_MACOSX)
#define MAYBE_SwitchAppListProfilesDuringSearch \
DISABLED_SwitchAppListProfilesDuringSearch
#else
#define MAYBE_SwitchAppListProfilesDuringSearch \ #define MAYBE_SwitchAppListProfilesDuringSearch \
SwitchAppListProfilesDuringSearch SwitchAppListProfilesDuringSearch
#define MAYBE_ShowAppListNonDefaultProfile ShowAppListNonDefaultProfile
#define MAYBE_DeleteShowingAppList DeleteShowingAppList
#endif #endif
// Show the app list, then dismiss it. // Show the app list, then dismiss it.
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "base/mac/mac_util.h" #include "base/mac/mac_util.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "skia/ext/skia_utils_mac.h" #include "skia/ext/skia_utils_mac.h"
#include "ui/app_list/app_list_constants.h" #include "ui/app_list/app_list_constants.h"
...@@ -401,6 +402,15 @@ const NSBackgroundStyle kBackgroundHovered = NSBackgroundStyleRaised; ...@@ -401,6 +402,15 @@ const NSBackgroundStyle kBackgroundHovered = NSBackgroundStyleRaised;
[self delegate]); [self delegate]);
} }
- (BOOL)canDraw {
// AppKit doesn't call -[NSView canDrawConcurrently] which would have told it
// that this is unsafe. Returning true from canDraw only if there is a message
// loop ensures that no drawing occurs on a background thread. Without this,
// ImageSkia can assert when trying to get bitmaps. http://crbug.com/417148.
// This means unit tests will always return 'NO', but that's OK.
return !!base::MessageLoop::current() && [super canDraw];
}
- (void)mouseDown:(NSEvent*)theEvent { - (void)mouseDown:(NSEvent*)theEvent {
[[self controller] mouseDown:theEvent]; [[self controller] mouseDown:theEvent];
[super mouseDown:theEvent]; [super mouseDown:theEvent];
......
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