Commit 083e677b authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

tablet: Speculative reenable of Tablet*ScreenshotVisibility*.

It's failing on asan/lsan builders. It wasn't reproducible locally
after 1000 tries, so uploading a speculative fix. According to the
stack in the builders, it seems there's no animation running after
waiting for tablet mode to enter. It seems plausible the animation
has been scheduled but not started yet, so add a waiter if the
animation is not running.

Test: ash_unittests TabletModeControllerScreenshotTest.ScreenshotVisibility
Bug: 1091085
Change-Id: I8bf796016122b0368edf860fe93299d8718f6f86
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2231270Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#776298}
parent add166ae
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/test/test_window_delegate.h" #include "ui/aura/test/test_window_delegate.h"
#include "ui/base/hit_test.h" #include "ui/base/hit_test.h"
#include "ui/compositor/layer_animator.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h" #include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/display/manager/display_manager.h" #include "ui/display/manager/display_manager.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
...@@ -1774,10 +1775,39 @@ TEST_P(TabletModeControllerScreenshotTest, EnterTabletModeWhileAnimating) { ...@@ -1774,10 +1775,39 @@ TEST_P(TabletModeControllerScreenshotTest, EnterTabletModeWhileAnimating) {
EXPECT_TRUE(IsShelfOpaque()); EXPECT_TRUE(IsShelfOpaque());
} }
namespace {
class LayerStartAnimationWaiter : public ui::LayerAnimationObserver {
public:
explicit LayerStartAnimationWaiter(ui::LayerAnimator* animator)
: animator_(animator) {
animator_->AddObserver(this);
run_loop_.Run();
}
LayerStartAnimationWaiter(const LayerStartAnimationWaiter&) = delete;
LayerStartAnimationWaiter& operator=(const LayerStartAnimationWaiter&) =
delete;
~LayerStartAnimationWaiter() override { animator_->RemoveObserver(this); }
// ui::LayerAnimationObserver:
void OnLayerAnimationStarted(ui::LayerAnimationSequence* sequence) override {
run_loop_.Quit();
}
void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) override {}
void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) override {}
void OnLayerAnimationScheduled(
ui::LayerAnimationSequence* sequence) override {}
private:
ui::LayerAnimator* animator_;
base::RunLoop run_loop_;
};
} // namespace
// Tests that the screenshot is visible when a window animation happens when // Tests that the screenshot is visible when a window animation happens when
// entering tablet mode. // entering tablet mode.
// Crashes on Linux Chrome OS. http://crbug.com/1091085 TEST_P(TabletModeControllerScreenshotTest, ScreenshotVisibility) {
TEST_P(TabletModeControllerScreenshotTest, DISABLED_ScreenshotVisibility) {
auto window = CreateTestWindow(gfx::Rect(200, 200)); auto window = CreateTestWindow(gfx::Rect(200, 200));
auto window2 = CreateTestWindow(gfx::Rect(300, 200)); auto window2 = CreateTestWindow(gfx::Rect(300, 200));
...@@ -1786,27 +1816,23 @@ TEST_P(TabletModeControllerScreenshotTest, DISABLED_ScreenshotVisibility) { ...@@ -1786,27 +1816,23 @@ TEST_P(TabletModeControllerScreenshotTest, DISABLED_ScreenshotVisibility) {
ASSERT_FALSE(IsScreenshotShown()); ASSERT_FALSE(IsScreenshotShown());
EXPECT_TRUE(IsShelfOpaque()); EXPECT_TRUE(IsShelfOpaque());
TabletMode::Waiter waiter(/*enable=*/true);
SetTabletMode(true); SetTabletMode(true);
EXPECT_FALSE(IsScreenshotShown()); EXPECT_FALSE(IsScreenshotShown());
EXPECT_FALSE(IsShelfOpaque()); EXPECT_FALSE(IsShelfOpaque());
EXPECT_FALSE(window2->layer()->GetAnimator()->is_animating()); // The layer we observe is actually the windows layer before starting the
// The layer we observer is actually the windows layer before starting the
// animation. The animation performed is a cross-fade animation which // animation. The animation performed is a cross-fade animation which
// copies the window layer to another layer host. So cache them here for // copies the window layer to another layer host. So cache them here for
// later use. // later use. Wait until the animation has started, at this point the
ui::Layer* old_layer = window2->layer(); // screenshot should be visible.
ui::LayerAnimator* old_animator = window2->layer()->GetAnimator();
// Tests that after waiting for the async tablet mode entry, the screenshot is ASSERT_FALSE(old_animator->is_animating());
// shown. { LayerStartAnimationWaiter waiter(old_animator); }
waiter.Wait();
EXPECT_TRUE(IsScreenshotShown()); EXPECT_TRUE(IsScreenshotShown());
EXPECT_TRUE(window2->layer()->GetAnimator()->is_animating());
EXPECT_TRUE(IsShelfOpaque()); EXPECT_TRUE(IsShelfOpaque());
// Tests that the screenshot is destroyed after the window is done animating. // Tests that the screenshot is destroyed after the window is done animating.
old_layer->GetAnimator()->StopAnimating(); old_animator->StopAnimating();
window2->layer()->GetAnimator()->StopAnimating(); window2->layer()->GetAnimator()->StopAnimating();
EXPECT_FALSE(IsScreenshotShown()); EXPECT_FALSE(IsScreenshotShown());
EXPECT_TRUE(IsShelfOpaque()); EXPECT_TRUE(IsShelfOpaque());
......
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