Commit 1ce46851 authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

Reland "Reland "cros: Add tablet <-> clamshell performance test.""

This is a reland of 09566165. Fixed
and ran locally.

TBR=oshima@chromium.org

Original change's description:
> Reland "cros: Add tablet <-> clamshell performance test."
>
> This is a reland of 963bfd6e
>
> Could not reproduce locally with the new changes. Suspected causes for
> flakiness before.
> 1) Rounding down because of int means we never waited for browser to
> startup.
> 2) Disabling animations too early means the creation of the browser window
> has an animation which may have interfered with the tablet window animation.
>
> Original change's description:
> > cros: Add tablet <-> clamshell performance test.
> >
> > Test: interactive_ui_tests TabletModeTransitionTest.EnterExit
> > Bug: 953896
> > Change-Id: Ie2332df2bea2f7d2a63b39d8b390fcf4b28999f8
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1580583
> > Commit-Queue: Sammie Quon <sammiequon@chromium.org>
> > Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#656911}
>
> Bug: 953896
> Change-Id: I214d12fc24f16423f323c87fa7a182eebb0ee745
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1598784
> Commit-Queue: Sammie Quon <sammiequon@chromium.org>
> Reviewed-by: Mitsuru Oshima (slow - gardening) <oshima@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#658294}

Bug: 953896
Change-Id: Ifce43db563c6901a7095d4b8137e041f74cca8e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1606761Reviewed-by: default avatarSammie Quon <sammiequon@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#658817}
parent 5039e0cc
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/command_line.h"
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
#include "chrome/browser/ui/ash/ash_test_util.h"
#include "chrome/browser/ui/ash/tablet_mode_client_test_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/test/base/perf/performance_test.h"
#include "ui/aura/window.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_observer.h"
#include "ui/compositor/layer_animator.h"
#include "ui/wm/core/window_util.h"
#include "ui/wm/core/wm_core_switches.h"
namespace {
class TestLayerAnimationObserver : public ui::LayerAnimationObserver {
public:
TestLayerAnimationObserver(ui::LayerAnimator* animator,
base::OnceClosure callback)
: animator_(animator), callback_(std::move(callback)) {
animator_->AddObserver(this);
}
~TestLayerAnimationObserver() override = default;
void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) override {
if (!animator_->is_animating()) {
std::move(callback_).Run();
animator_->RemoveObserver(this);
}
}
void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) override {}
void OnLayerAnimationScheduled(
ui::LayerAnimationSequence* sequence) override {}
private:
ui::LayerAnimator* animator_;
base::OnceClosure callback_;
DISALLOW_COPY_AND_ASSIGN(TestLayerAnimationObserver);
};
} // namespace
class TabletModeTransitionTest : public UIPerformanceTest {
public:
TabletModeTransitionTest() = default;
~TabletModeTransitionTest() override = default;
// UIPerformanceTest:
void SetUpOnMainThread() override {
UIPerformanceTest::SetUpOnMainThread();
constexpr int additional_browsers = 5;
constexpr int cost_per_browser = 100;
for (int i = 0; i < additional_browsers; ++i)
CreateBrowser(browser()->profile());
int wait_ms = (base::SysInfo::IsRunningOnChromeOS() ? 5000 : 0) +
(additional_browsers + 1) * cost_per_browser;
base::RunLoop run_loop;
base::PostDelayedTask(FROM_HERE, run_loop.QuitClosure(),
base::TimeDelta::FromMilliseconds(wait_ms));
run_loop.Run();
// The uma stats we are interested in measure the animations directly so we
// need to ensure they are turned on.
auto* cmd = base::CommandLine::ForCurrentProcess();
if (cmd->HasSwitch(wm::switches::kWindowAnimationsDisabled))
cmd->RemoveSwitch(wm::switches::kWindowAnimationsDisabled);
}
std::vector<std::string> GetUMAHistogramNames() const override {
return {
"Ash.TabletMode.AnimationSmoothness.Enter",
"Ash.TabletMode.AnimationSmoothness.Exit",
};
}
private:
DISALLOW_COPY_AND_ASSIGN(TabletModeTransitionTest);
};
IN_PROC_BROWSER_TEST_F(TabletModeTransitionTest, EnterExit) {
// Activate the first window. The top window is the only window which animates
// and is the one we should check to see if the tablet animation has finished.
Browser* browser = BrowserList::GetInstance()->GetLastActive();
aura::Window* browser_window = browser->window()->GetNativeWindow();
{
base::RunLoop run_loop;
ui::LayerAnimator* animator = browser_window->layer()->GetAnimator();
TestLayerAnimationObserver waiter(animator, run_loop.QuitClosure());
test::SetAndWaitForTabletMode(true);
run_loop.Run();
}
{
base::RunLoop run_loop;
ui::LayerAnimator* animator = browser_window->layer()->GetAnimator();
TestLayerAnimationObserver waiter(animator, run_loop.QuitClosure());
test::SetAndWaitForTabletMode(false);
run_loop.Run();
}
}
......@@ -5311,6 +5311,7 @@ if (!is_android) {
"../browser/ui/ash/overview_window_drag_interactive_uitest.cc",
"../browser/ui/ash/screen_rotation_interactive_uitest.cc",
"../browser/ui/ash/split_view_interactive_uitest.cc",
"../browser/ui/ash/tablet_mode_transition_interactive_uitest.cc",
"base/perf/drag_event_generator.cc",
"base/perf/drag_event_generator.h",
]
......
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