Commit c9ba6b51 authored by Jun Mukai's avatar Jun Mukai Committed by Commit Bot

Introduce performance test of app-list's page transition smoothness

This CL adds the tests for the animation smoothness of the page
transition between the apps grid in the list.

I ran this for 5 times on nocturne, here's the result;
next-page / clamshell: 73, 80, 73, 46, 46
next-page / tablet: 86, 66, 86, 6, 86
page-jump / clamshell: 40, 80, 26, 26, 40
page-jump / tablet: 73, 40, 66, 6, 86

Bug: 970879
Test: interactive_ui_tests
Change-Id: Ibc519b0cf47e3540d9a2c57f521ed64ee981c572
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1643783Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Jun Mukai <mukai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#666395}
parent 228cdb6b
...@@ -21,6 +21,7 @@ enum class AppListViewState; ...@@ -21,6 +21,7 @@ enum class AppListViewState;
class DragDropController; class DragDropController;
class MessageCenterController; class MessageCenterController;
class NativeCursorManagerAsh; class NativeCursorManagerAsh;
class PaginationModel;
class PowerPrefs; class PowerPrefs;
class ScreenPositionController; class ScreenPositionController;
class Shell; class Shell;
...@@ -94,6 +95,10 @@ class ASH_EXPORT ShellTestApi { ...@@ -94,6 +95,10 @@ class ASH_EXPORT ShellTestApi {
// state transition animation. // state transition animation.
void WaitForLauncherAnimationState(AppListViewState state); void WaitForLauncherAnimationState(AppListViewState state);
// Returns the pagination model of the currently visible app-list view.
// It returns nullptr when app-list is not shown.
PaginationModel* GetAppListPaginationModel();
// Returns the list of windows used in overview item. Returns empty // Returns the list of windows used in overview item. Returns empty
// if not in the overview mode. // if not in the overview mode.
std::vector<aura::Window*> GetItemWindowListInOverviewGrids(); std::vector<aura::Window*> GetItemWindowListInOverviewGrids();
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ash/accelerators/accelerator_commands.h" #include "ash/accelerators/accelerator_commands.h"
#include "ash/accelerometer/accelerometer_reader.h" #include "ash/accelerometer/accelerometer_reader.h"
#include "ash/app_list/app_list_controller_impl.h" #include "ash/app_list/app_list_controller_impl.h"
#include "ash/app_list/presenter/app_list_presenter_impl.h"
#include "ash/app_list/views/app_list_view.h" #include "ash/app_list/views/app_list_view.h"
#include "ash/keyboard/ash_keyboard_controller.h" #include "ash/keyboard/ash_keyboard_controller.h"
#include "ash/public/cpp/app_list/app_list_types.h" #include "ash/public/cpp/app_list/app_list_types.h"
...@@ -250,6 +251,14 @@ void ShellTestApi::WaitForLauncherAnimationState( ...@@ -250,6 +251,14 @@ void ShellTestApi::WaitForLauncherAnimationState(
run_loop.Run(); run_loop.Run();
} }
PaginationModel* ShellTestApi::GetAppListPaginationModel() {
app_list::AppListView* view =
Shell::Get()->app_list_controller()->presenter()->GetView();
if (!view)
return nullptr;
return view->GetAppsPaginationModel();
}
std::vector<aura::Window*> ShellTestApi::GetItemWindowListInOverviewGrids() { std::vector<aura::Window*> ShellTestApi::GetItemWindowListInOverviewGrids() {
return ash::Shell::Get() return ash::Shell::Get()
->overview_controller() ->overview_controller()
......
// 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 "ash/public/cpp/app_list/app_list_types.h"
#include "ash/public/cpp/pagination/pagination_model.h"
#include "ash/public/cpp/pagination/pagination_model_observer.h"
#include "ash/public/cpp/test/shell_test_api.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"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/test/base/perf/performance_test.h"
#include "ui/base/test/ui_controls.h"
namespace {
class PageSwitchWaiter : public ash::PaginationModelObserver {
public:
explicit PageSwitchWaiter(ash::PaginationModel* model) : model_(model) {
model_->AddObserver(this);
}
~PageSwitchWaiter() override { model_->RemoveObserver(this); }
void Wait() { run_loop_.Run(); }
private:
// ash::PaginationModelObserver:
void TransitionEnded() override { run_loop_.Quit(); }
ash::PaginationModel* model_;
base::RunLoop run_loop_;
DISALLOW_COPY_AND_ASSIGN(PageSwitchWaiter);
};
} // namespace
class LauncherPageSwitchesTest : public UIPerformanceTest,
public ::testing::WithParamInterface<bool> {
public:
LauncherPageSwitchesTest() = default;
~LauncherPageSwitchesTest() override = default;
// UIPerformanceTest:
void SetUpOnMainThread() override {
UIPerformanceTest::SetUpOnMainThread();
is_tablet_mode_ = GetParam();
test::PopulateDummyAppListItems(100);
if (base::SysInfo::IsRunningOnChromeOS()) {
base::RunLoop run_loop;
base::PostDelayedTask(FROM_HERE, run_loop.QuitClosure(),
base::TimeDelta::FromSeconds(5));
run_loop.Run();
}
ash::ShellTestApi shell_test_api;
// switch to tablet-mode if necessary.
if (is_tablet_mode_)
shell_test_api.EnableTabletModeWindowManager(true);
// Open the fullscreen app; required for page switching.
BrowserView* browser_view =
BrowserView::GetBrowserViewForBrowser(browser());
aura::Window* browser_window = browser_view->GetWidget()->GetNativeWindow();
ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH,
/*control=*/false,
/*shift=*/true,
/*alt=*/false,
/* command = */ false);
shell_test_api.WaitForLauncherAnimationState(
ash::AppListViewState::kFullscreenAllApps);
}
// UIPerformanceTest:
std::vector<std::string> GetUMAHistogramNames() const override {
return {
is_tablet_mode_
? "Apps.PaginationTransition.AnimationSmoothness.TabletMode"
: "Apps.PaginationTransition.AnimationSmoothness.ClamshellMode",
};
}
private:
bool is_tablet_mode_ = false;
DISALLOW_COPY_AND_ASSIGN(LauncherPageSwitchesTest);
};
IN_PROC_BROWSER_TEST_P(LauncherPageSwitchesTest, SwitchToNextPage) {
ash::PaginationModel* model = ash::ShellTestApi().GetAppListPaginationModel();
ASSERT_TRUE(model);
EXPECT_LT(1, model->total_pages());
EXPECT_EQ(0, model->selected_page());
PageSwitchWaiter waiter(model);
model->SelectPageRelative(1, /*animate=*/true);
waiter.Wait();
}
IN_PROC_BROWSER_TEST_P(LauncherPageSwitchesTest, SwitchToFarPage) {
ash::PaginationModel* model = ash::ShellTestApi().GetAppListPaginationModel();
ASSERT_TRUE(model);
EXPECT_LT(2, model->total_pages());
EXPECT_EQ(0, model->selected_page());
PageSwitchWaiter waiter(model);
model->SelectPageRelative(2, /*animate=*/true);
waiter.Wait();
}
INSTANTIATE_TEST_SUITE_P(,
LauncherPageSwitchesTest,
/*tablet_mode=*/::testing::Bool());
...@@ -5417,6 +5417,7 @@ if (!is_android) { ...@@ -5417,6 +5417,7 @@ if (!is_android) {
"../browser/ui/ash/drag_to_overview_interactive_uitest.cc", "../browser/ui/ash/drag_to_overview_interactive_uitest.cc",
"../browser/ui/ash/launcher_animations_interactive_uitest.cc", "../browser/ui/ash/launcher_animations_interactive_uitest.cc",
"../browser/ui/ash/launcher_drag_interactive_uitest.cc", "../browser/ui/ash/launcher_drag_interactive_uitest.cc",
"../browser/ui/ash/launcher_page_switches_interactive_uitest.cc",
"../browser/ui/ash/overview_animations_interactive_uitest.cc", "../browser/ui/ash/overview_animations_interactive_uitest.cc",
"../browser/ui/ash/overview_window_drag_interactive_uitest.cc", "../browser/ui/ash/overview_window_drag_interactive_uitest.cc",
"../browser/ui/ash/screen_rotation_interactive_uitest.cc", "../browser/ui/ash/screen_rotation_interactive_uitest.cc",
......
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