Commit 15dad302 authored by Jun Mukai's avatar Jun Mukai Committed by Commit Bot

Add the case of reused widgets for LauncherAnimationsTest

The LauncherAnimationsTest measures the performance for one-shot
action. Recently the app-list widget will remain and be reused
once created for the performance reason, but the existing one-shot
scenario doesn't capture it properly.

This CL adds new test scenarios which opens and closes the app-list
in prior to the actual test scenario, so that we can measure the
performance on both one-shot and reused.

Here's the performance on 5 runs in nocturne:nocturne:
one-shot
Fullscreen: 13, 13, 13, 13, 13
Close: 79, 79, 39, 79, 73

Peeking: 58, 33, 49, 49, 33
Close: 100, 100, 100, 100, 91

Half: 33, 49, 33, 41, 41
Close: 58, 100, 91, 83, 100

FullscreenSearch: 46, 66, 59, 86, 66
Close: 79, 100, 93, 93, 93

reused
Fullscreen: 66, 59, 59, 59, 66
Close: 93, 100, 100, 100, 93

Peeking: 83, 83, 91, 100, 74
Close: 100, 100, 100, 100, 100

Half: 74, 91, 91, 83, 91
Close: 100, 100, 100, 100, 100

FullscreenSearch: 86, 93, 93, 86, 86
Close: 93, 86, 93, 100, 86

So this CL reveals that the reusing improves the appearing animation
smoothness. Fullscreen-app-apps isn't still ideal, but the numbers
aren't bad.

Bug: 961467
Test: cros_run_test on nocturne
Change-Id: I69907f9c70b3dec3655b873ddcbe5611ab3432a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1639558Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Commit-Queue: Jun Mukai <mukai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665942}
parent 1a9e4b32
......@@ -6,6 +6,9 @@
#include "ash/public/cpp/test/shell_test_api.h"
#include "base/bind.h"
#include "base/macros.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/histogram_samples.h"
#include "base/metrics/statistics_recorder.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
#include "chrome/browser/ui/app_list/test/chrome_app_list_test_support.h"
......@@ -17,7 +20,8 @@
#include "ui/base/test/ui_controls.h"
// TODO(oshima): Add tablet mode overview transition.
class LauncherAnimationsTest : public UIPerformanceTest {
class LauncherAnimationsTest : public UIPerformanceTest,
public ::testing::WithParamInterface<bool> {
public:
LauncherAnimationsTest() = default;
~LauncherAnimationsTest() override = default;
......@@ -25,6 +29,7 @@ class LauncherAnimationsTest : public UIPerformanceTest {
// UIPerformanceTest:
void SetUpOnMainThread() override {
UIPerformanceTest::SetUpOnMainThread();
reuse_widget_ = GetParam();
test::PopulateDummyAppListItems(100);
if (base::SysInfo::IsRunningOnChromeOS()) {
......@@ -47,14 +52,73 @@ class LauncherAnimationsTest : public UIPerformanceTest {
protected:
void set_suffix(const std::string& suffix) { suffix_ = suffix; }
// Create the cached widget of the app-list prior to the actual test scenario.
void MaybeCreateCachedWidget() {
if (!reuse_widget_)
return;
// Here goes through several states of the app-list so that the cached
// widget can contain relevant data.
BrowserView* browser_view =
BrowserView::GetBrowserViewForBrowser(browser());
aura::Window* browser_window = browser_view->GetWidget()->GetNativeWindow();
ash::ShellTestApi shell_test_api;
// Open the app-list with peeking state.
ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
/*control=*/false,
/*shift=*/false,
/*alt=*/false,
/* command = */ false);
shell_test_api.WaitForLauncherAnimationState(
ash::AppListViewState::kPeeking);
// Expand to the fullscreen with list of applications.
ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
/*control=*/false,
/*shift=*/true,
/*alt=*/false,
/* command = */ false);
shell_test_api.WaitForLauncherAnimationState(
ash::AppListViewState::kFullscreenAllApps);
// Type a random query to switch to search result view.
ui_controls::SendKeyPress(browser_window, ui::VKEY_X,
/*control=*/false,
/*shift=*/false,
/*alt=*/false,
/* command = */ false);
shell_test_api.WaitForLauncherAnimationState(
ash::AppListViewState::kFullscreenSearch);
// Close.
ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
/*control=*/false,
/*shift=*/false,
/*alt=*/false,
/* command = */ false);
shell_test_api.WaitForLauncherAnimationState(
ash::AppListViewState::kClosed);
// Takes the snapshot delta; so that the samples created so far will be
// eliminated from the samples.
for (const auto& name : GetUMAHistogramNames()) {
auto* histogram = base::StatisticsRecorder::FindHistogram(name);
if (!histogram)
continue;
histogram->SnapshotDelta();
}
}
private:
bool reuse_widget_ = false;
std::string suffix_;
DISALLOW_COPY_AND_ASSIGN(LauncherAnimationsTest);
};
IN_PROC_BROWSER_TEST_F(LauncherAnimationsTest, Fullscreen) {
IN_PROC_BROWSER_TEST_P(LauncherAnimationsTest, Fullscreen) {
set_suffix("FullscreenAllApps.ClamshellMode");
MaybeCreateCachedWidget();
// Browser window is used to identify display, so we can use
// use the 1st browser window regardless of number of windows created.
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
......@@ -76,8 +140,9 @@ IN_PROC_BROWSER_TEST_F(LauncherAnimationsTest, Fullscreen) {
shell_test_api.WaitForLauncherAnimationState(ash::AppListViewState::kClosed);
}
IN_PROC_BROWSER_TEST_F(LauncherAnimationsTest, Peeking) {
IN_PROC_BROWSER_TEST_P(LauncherAnimationsTest, Peeking) {
set_suffix("Peeking.ClamshellMode");
MaybeCreateCachedWidget();
// Browser window is used to identify display, so we can use
// use the 1st browser window regardless of number of windows created.
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
......@@ -98,8 +163,9 @@ IN_PROC_BROWSER_TEST_F(LauncherAnimationsTest, Peeking) {
shell_test_api.WaitForLauncherAnimationState(ash::AppListViewState::kClosed);
}
IN_PROC_BROWSER_TEST_F(LauncherAnimationsTest, Half) {
IN_PROC_BROWSER_TEST_P(LauncherAnimationsTest, Half) {
set_suffix("Half.ClamshellMode");
MaybeCreateCachedWidget();
// Browser window is used to identify display, so we can use
// use the 1st browser window regardless of number of windows created.
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
......@@ -111,6 +177,7 @@ IN_PROC_BROWSER_TEST_F(LauncherAnimationsTest, Half) {
/*shift=*/false,
/*alt=*/false,
/* command = */ false);
shell_test_api.WaitForLauncherAnimationState(ash::AppListViewState::kPeeking);
// Type some query in the launcher; it should show search results in kHalf
......@@ -131,8 +198,9 @@ IN_PROC_BROWSER_TEST_F(LauncherAnimationsTest, Half) {
shell_test_api.WaitForLauncherAnimationState(ash::AppListViewState::kClosed);
}
IN_PROC_BROWSER_TEST_F(LauncherAnimationsTest, FullscreenSearch) {
IN_PROC_BROWSER_TEST_P(LauncherAnimationsTest, FullscreenSearch) {
set_suffix("FullscreenSearch.ClamshellMode");
MaybeCreateCachedWidget();
// Browser window is used to identify display, so we can use
// use the 1st browser window regardless of number of windows created.
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
......@@ -172,3 +240,7 @@ IN_PROC_BROWSER_TEST_F(LauncherAnimationsTest, FullscreenSearch) {
/* command = */ false);
shell_test_api.WaitForLauncherAnimationState(ash::AppListViewState::kClosed);
}
INSTANTIATE_TEST_SUITE_P(,
LauncherAnimationsTest,
/*reuse_widget=*/::testing::Bool());
......@@ -152,7 +152,9 @@ float PerformanceTest::GetHistogramMean(const std::string& name) {
auto* histogram = base::StatisticsRecorder::FindHistogram(name);
if (!histogram)
return 0;
auto samples = histogram->SnapshotSamples();
// Use SnapshotFinalDelta() so that it won't contain the samples before the
// subclass invokes SnapshotDelta() during the test.
auto samples = histogram->SnapshotFinalDelta();
DCHECK_NE(0, samples->TotalCount());
return static_cast<float>(samples->sum()) / samples->TotalCount();
}
......
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