Commit 4ef381a6 authored by minch's avatar minch Committed by Chromium LUCI CQ

bento: Flip Bento feature to enabled by default

Bug: 1166374
Change-Id: I9e513de723c7d27cd12ac0bb7604c4ebbe5200b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2628254Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: Min Chen <minch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845756}
parent 0446aec2
......@@ -11,6 +11,7 @@
#include "ash/display/window_tree_host_manager.h"
#include "ash/host/ash_window_tree_host.h"
#include "ash/magnifier/magnifier_test_utils.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/shelf_config.h"
......@@ -22,6 +23,7 @@
#include "ash/test/test_window_builder.h"
#include "ash/wm/desks/desks_bar_view.h"
#include "ash/wm/desks/new_desk_button.h"
#include "ash/wm/desks/zero_state_button.h"
#include "ash/wm/overview/overview_controller.h"
#include "ash/wm/overview/overview_grid.h"
#include "ash/wm/overview/overview_item.h"
......@@ -508,13 +510,32 @@ TEST_F(DockedMagnifierTest, OverviewTabbing) {
const auto* desk_bar_view = GetOverviewSession()
->GetGridWithRootWindow(root_window)
->desks_bar_view();
if (features::IsBentoEnabled()) {
ASSERT_TRUE(desk_bar_view->IsZeroState());
// Tab once. The viewport should be centered on the center of the default
// desk button in the zero state desks bar.
SendKey(ui::VKEY_TAB);
TestMagnifierLayerTransform(desk_bar_view->zero_state_default_desk_button()
->GetBoundsInScreen()
.CenterPoint(),
root_window);
// Tab one more time. The viewport should be centered on the center of the
// new desk button in the zero state desks bar.
SendKey(ui::VKEY_TAB);
TestMagnifierLayerTransform(desk_bar_view->zero_state_new_desk_button()
->GetBoundsInScreen()
.CenterPoint(),
root_window);
} else {
// Tab once. The viewport should be centered on the center of the new desk
// button.
SendKey(ui::VKEY_TAB);
TestMagnifierLayerTransform(
desk_bar_view->new_desk_button()->GetBoundsInScreen().CenterPoint(),
root_window);
}
// Tab one more time. The viewport should be centered on the beginning of the
// overview item's title.
......
......@@ -18,7 +18,7 @@ const base::Feature kAllowAmbientEQ{"AllowAmbientEQ",
const base::Feature kAutoNightLight{"AutoNightLight",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kBento{"Bento", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kBento{"Bento", base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kCaptureMode{"CaptureMode",
base::FEATURE_DISABLED_BY_DEFAULT};
......
......@@ -7,6 +7,7 @@
#include "ash/public/cpp/ash_features.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/desks/desks_controller.h"
#include "ash/wm/desks/desks_util.h"
#include "base/callback_helpers.h"
#include "base/run_loop.h"
#include "base/test/scoped_feature_list.h"
......@@ -68,7 +69,7 @@ TEST_F(AutotestDesksApiTest, ActivateDeskAtIndex) {
auto* controller = DesksController::Get();
while (controller->CanCreateDesks())
EXPECT_TRUE(test_api.CreateNewDesk());
EXPECT_EQ(4u, controller->desks().size());
EXPECT_EQ(desks_util::GetMaxNumberOfDesks(), controller->desks().size());
constexpr int kIndices[] = {1, 2, 3, 0};
for (const int index : kIndices) {
base::RunLoop run_loop;
......@@ -82,19 +83,18 @@ TEST_F(AutotestDesksApiTest, RemoveActiveDesk) {
AutotestDesksApi test_api;
EXPECT_FALSE(test_api.RemoveActiveDesk(base::DoNothing()));
const size_t max_number_of_desks = desks_util::GetMaxNumberOfDesks();
auto* controller = DesksController::Get();
while (controller->CanCreateDesks())
EXPECT_TRUE(test_api.CreateNewDesk());
EXPECT_EQ(4u, controller->desks().size());
EXPECT_EQ(max_number_of_desks, controller->desks().size());
EXPECT_EQ(controller->active_desk(), controller->desks()[0].get());
// List of desks that will be activated after each time we invoke
// RemoveActiveDesk().
const Desk* desks_after_removal[] = {
controller->desks()[1].get(),
controller->desks()[2].get(),
controller->desks()[3].get(),
};
std::vector<Desk*> desks_after_removal;
for (size_t i = 1; i < max_number_of_desks; i++)
desks_after_removal.push_back(controller->desks()[i].get());
for (const Desk* desk : desks_after_removal) {
base::RunLoop run_loop;
......@@ -131,19 +131,20 @@ TEST_F(EnhancedDeskAnimationsAutotestDesksApiTest,
ActivateAdjacentDesksToTargetIndex) {
// Create all desks possible.
AutotestDesksApi test_api;
const int max_number_of_desks = desks_util::GetMaxNumberOfDesks();
auto* controller = DesksController::Get();
while (controller->CanCreateDesks())
EXPECT_TRUE(test_api.CreateNewDesk());
EXPECT_FALSE(
test_api.ActivateAdjacentDesksToTargetIndex(-1, base::DoNothing()));
EXPECT_FALSE(
test_api.ActivateAdjacentDesksToTargetIndex(4, base::DoNothing()));
EXPECT_FALSE(test_api.ActivateAdjacentDesksToTargetIndex(max_number_of_desks,
base::DoNothing()));
// Activating already active desk does nothing.
EXPECT_FALSE(
test_api.ActivateAdjacentDesksToTargetIndex(0, base::DoNothing()));
EXPECT_EQ(4u, controller->desks().size());
EXPECT_EQ(desks_util::GetMaxNumberOfDesks(), controller->desks().size());
// Replacing needs to be done while a current animation is underway, otherwise
// it will have no effect.
......@@ -151,16 +152,17 @@ TEST_F(EnhancedDeskAnimationsAutotestDesksApiTest,
ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
// Activate the rightmost desk. Test that we end on that desk and that we
// observed 3 activation changes.
// observed (max_number_of_desks - 1) activation changes.
TestDesksActivationObserver desk_activation_observer;
{
base::RunLoop run_loop;
EXPECT_TRUE(
test_api.ActivateAdjacentDesksToTargetIndex(3, run_loop.QuitClosure()));
EXPECT_TRUE(test_api.ActivateAdjacentDesksToTargetIndex(
max_number_of_desks - 1, run_loop.QuitClosure()));
run_loop.Run();
}
EXPECT_EQ(controller->active_desk(), controller->desks().back().get());
EXPECT_EQ(3, desk_activation_observer.activation_changes());
EXPECT_EQ(max_number_of_desks - 1,
desk_activation_observer.activation_changes());
// Activate the leftmost desk. Test that we end on that desk and that we
// observed 3 activation changes.
......@@ -172,7 +174,8 @@ TEST_F(EnhancedDeskAnimationsAutotestDesksApiTest,
run_loop.Run();
}
EXPECT_EQ(controller->active_desk(), controller->desks().front().get());
EXPECT_EQ(3, desk_activation_observer.activation_changes());
EXPECT_EQ(max_number_of_desks - 1,
desk_activation_observer.activation_changes());
}
} // namespace ash
This diff is collapsed.
......@@ -48,6 +48,9 @@ DeskButtonBase::DeskButtonBase(const base::string16& text,
SetFocusPainter(nullptr);
SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY);
// TODO(minch): A11y of zero state.
SetAccessibleName(base::UTF8ToUTF16(GetClassName()));
auto border = std::make_unique<WmHighlightItemBorder>(border_corder_radius);
border_ptr_ = border.get();
SetBorder(std::move(border));
......
......@@ -44,6 +44,8 @@ class ASH_EXPORT DeskButtonBase
virtual void UpdateButtonState() {}
SkColor GetBackgroundColorForTesting() const { return background_color_; }
protected:
virtual void OnButtonPressed() = 0;
......
......@@ -343,9 +343,9 @@ class DesksOverviewHighlightControllerTest
DesksOverviewHighlightControllerTest() = default;
~DesksOverviewHighlightControllerTest() override = default;
// AshTestBase:
// OverviewHighlightControllerTest:
void SetUp() override {
AshTestBase::SetUp();
OverviewHighlightControllerTest::SetUp();
// All tests in this suite require the desks bar to be visible in overview,
// which requires at least two desks.
......@@ -362,8 +362,18 @@ class DesksOverviewHighlightControllerTest
const DesksBarView* GetDesksBarViewForRoot(aura::Window* root_window) {
OverviewGrid* grid =
GetOverviewSession()->GetGridWithRootWindow(root_window);
DCHECK(grid->IsDesksBarViewActive());
return grid->desks_bar_view();
const DesksBarView* bar_view = grid->desks_bar_view();
DCHECK(bar_view->IsZeroState() ^ grid->IsDesksBarViewActive());
return bar_view;
}
OverviewHighlightController::OverviewHighlightableView* GetNewDeskButton(
const DesksBarView* bar_view) {
DCHECK(bar_view);
if (features::IsBentoEnabled())
return bar_view->expanded_state_new_desk_button()->new_desk_button();
return bar_view->new_desk_button();
}
protected:
......@@ -407,7 +417,7 @@ TEST_F(DesksOverviewHighlightControllerTest, TabbingBasic) {
SendKey(ui::VKEY_TAB);
SendKey(ui::VKEY_TAB);
SendKey(ui::VKEY_TAB);
EXPECT_EQ(desk_bar_view->new_desk_button(), GetHighlightedView());
EXPECT_EQ(GetNewDeskButton(desk_bar_view), GetHighlightedView());
CheckDeskBarViewSize(desk_bar_view, "new desk button");
// Tests that the overview item gets highlighted after the new desk button.
......@@ -445,7 +455,7 @@ TEST_F(DesksOverviewHighlightControllerTest, TabbingReverse) {
// the new desk button.
SendKey(ui::VKEY_TAB, ui::EF_SHIFT_DOWN);
SendKey(ui::VKEY_TAB, ui::EF_SHIFT_DOWN);
EXPECT_EQ(desk_bar_view->new_desk_button(), GetHighlightedView());
EXPECT_EQ(GetNewDeskButton(desk_bar_view), GetHighlightedView());
// Tests that after the new desk button comes the mini views and their desk
// name views in reverse order.
......@@ -502,7 +512,7 @@ TEST_F(DesksOverviewHighlightControllerTest, TabbingMultiDisplay) {
EXPECT_EQ(desk_bar_view1->mini_views()[1]->desk_name_view(),
GetHighlightedView());
SendKey(ui::VKEY_TAB);
EXPECT_EQ(desk_bar_view1->new_desk_button(), GetHighlightedView());
EXPECT_EQ(GetNewDeskButton(desk_bar_view1), GetHighlightedView());
// Tests that two more tabs, will highlight the two overview items on the
// first display.
......@@ -524,7 +534,7 @@ TEST_F(DesksOverviewHighlightControllerTest, TabbingMultiDisplay) {
SendKey(ui::VKEY_TAB);
SendKey(ui::VKEY_TAB);
SendKey(ui::VKEY_TAB);
EXPECT_EQ(desk_bar_view2->new_desk_button(), GetHighlightedView());
EXPECT_EQ(GetNewDeskButton(desk_bar_view2), GetHighlightedView());
SendKey(ui::VKEY_TAB);
auto* item3 = GetOverviewItemForWindow(window3.get());
EXPECT_EQ(item3->overview_item_view(), GetHighlightedView());
......@@ -540,7 +550,7 @@ TEST_F(DesksOverviewHighlightControllerTest, TabbingMultiDisplay) {
SendKey(ui::VKEY_TAB);
SendKey(ui::VKEY_TAB);
SendKey(ui::VKEY_TAB);
EXPECT_EQ(desk_bar_view3->new_desk_button(), GetHighlightedView());
EXPECT_EQ(GetNewDeskButton(desk_bar_view3), GetHighlightedView());
SendKey(ui::VKEY_TAB);
auto* item4 = GetOverviewItemForWindow(window4.get());
EXPECT_EQ(item4->overview_item_view(), GetHighlightedView());
......@@ -553,6 +563,10 @@ TEST_F(DesksOverviewHighlightControllerTest, TabbingMultiDisplay) {
TEST_F(DesksOverviewHighlightControllerTest,
ActivateCloseHighlightOnNewDeskButton) {
// Tests the new desk button in classic desks.
if (features::IsBentoEnabled())
return;
ToggleOverview();
const auto* desk_bar_view =
GetDesksBarViewForRoot(Shell::GetPrimaryRootWindow());
......@@ -638,45 +652,50 @@ TEST_F(DesksOverviewHighlightControllerTest, CloseHighlightOnMiniView) {
EXPECT_EQ(1u, desks_controller->desks().size());
EXPECT_NE(desk2, desks_controller->desks()[0].get());
// Tests that hitting ctrl-w on the highlighted miniview if it is the last one
// does nothing.
if (features::IsBentoEnabled()) {
// Go back to zero state since there is only a single desk and mini views
// are empty in zero state.
EXPECT_TRUE(desk_bar_view->IsZeroState());
EXPECT_TRUE(desk_bar_view->mini_views().empty());
} else {
// Tests that hitting ctrl-w on the highlighted miniview if it is the last
// one does nothing.
while (mini_view1 != GetHighlightedView())
SendKey(ui::VKEY_TAB);
SendKey(ui::VKEY_W, ui::EF_CONTROL_DOWN);
EXPECT_EQ(1u, desks_controller->desks().size());
}
}
TEST_F(DesksOverviewHighlightControllerTest, ActivateDeskNameView) {
ToggleOverview();
const auto* desk_bar_view =
GetDesksBarViewForRoot(Shell::GetPrimaryRootWindow());
auto* desk_name_view_2 = desk_bar_view->mini_views()[1]->desk_name_view();
auto* desk_name_view_1 = desk_bar_view->mini_views()[0]->desk_name_view();
// Tab until the desk name view of the second desk is highlighted.
// Tab until the desk name view of the first desk is highlighted.
SendKey(ui::VKEY_TAB);
SendKey(ui::VKEY_TAB);
SendKey(ui::VKEY_TAB);
SendKey(ui::VKEY_TAB);
EXPECT_EQ(desk_name_view_2, GetHighlightedView());
EXPECT_EQ(desk_name_view_1, GetHighlightedView());
// Press enter and expect that the desk name is being edited.
SendKey(ui::VKEY_RETURN);
EXPECT_TRUE(desk_name_view_2->HasFocus());
EXPECT_TRUE(desk_name_view_1->HasFocus());
EXPECT_TRUE(desk_bar_view->IsDeskNameBeingModified());
// All should be selected.
EXPECT_TRUE(desk_name_view_2->HasSelection());
EXPECT_TRUE(desk_name_view_1->HasSelection());
const auto* desks_controller = DesksController::Get();
auto* desk_2 = desks_controller->desks()[1].get();
EXPECT_EQ(desk_2->name(), desk_name_view_2->GetSelectedText());
auto* desk_1 = desks_controller->desks()[0].get();
EXPECT_EQ(desk_1->name(), desk_name_view_1->GetSelectedText());
// Arrow keys should not change neither the focus nor the highlight.
SendKey(ui::VKEY_RIGHT);
SendKey(ui::VKEY_RIGHT);
SendKey(ui::VKEY_RIGHT);
SendKey(ui::VKEY_LEFT);
EXPECT_EQ(desk_name_view_2, GetHighlightedView());
EXPECT_TRUE(desk_name_view_2->HasFocus());
EXPECT_EQ(desk_name_view_1, GetHighlightedView());
EXPECT_TRUE(desk_name_view_1->HasFocus());
// Select all and delete.
SendKey(ui::VKEY_A, ui::EF_CONTROL_DOWN);
......@@ -689,10 +708,10 @@ TEST_F(DesksOverviewHighlightControllerTest, ActivateDeskNameView) {
SendKey(ui::VKEY_E);
SendKey(ui::VKEY_TAB);
EXPECT_FALSE(desk_name_view_2->HasFocus());
EXPECT_EQ(desk_bar_view->new_desk_button(), GetHighlightedView());
EXPECT_EQ(base::UTF8ToUTF16("code"), desk_2->name());
EXPECT_TRUE(desk_2->is_name_set_by_user());
EXPECT_FALSE(desk_name_view_1->HasFocus());
EXPECT_EQ(desk_bar_view->mini_views()[1], GetHighlightedView());
EXPECT_EQ(base::UTF8ToUTF16("code"), desk_1->name());
EXPECT_TRUE(desk_1->is_name_set_by_user());
}
TEST_F(DesksOverviewHighlightControllerTest, RemoveDeskWhileNameIsHighlighted) {
......@@ -713,7 +732,13 @@ TEST_F(DesksOverviewHighlightControllerTest, RemoveDeskWhileNameIsHighlighted) {
// Tabbing again should cause no crashes.
EXPECT_EQ(nullptr, GetHighlightedView());
SendKey(ui::VKEY_TAB);
if (features::IsBentoEnabled()) {
EXPECT_TRUE(desk_bar_view->IsZeroState());
EXPECT_EQ(desk_bar_view->zero_state_default_desk_button(),
GetHighlightedView());
} else {
EXPECT_EQ(desk_bar_view->mini_views()[0], GetHighlightedView());
}
}
// A test class for testing Bento features.
......
......@@ -4,6 +4,7 @@
#include "ash/wm/overview/overview_test_util.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/overview_test_api.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/shell.h"
......@@ -42,8 +43,11 @@ void SendKey(ui::KeyboardCode key, int flags) {
}
bool HighlightOverviewWindow(const aura::Window* window) {
if (GetOverviewHighlightedWindow() == nullptr)
if (GetOverviewHighlightedWindow() == nullptr) {
SendKey(ui::VKEY_TAB);
if (features::IsBentoEnabled())
SendKey(ui::VKEY_TAB);
}
const aura::Window* start_window = GetOverviewHighlightedWindow();
if (start_window == window)
return true;
......
......@@ -234,7 +234,7 @@ class OverviewWindowDragControllerDesksPortraitTabletTest : public AshTestBase {
AshTestBase::SetUp();
// Setup a portrait internal display in tablet mode.
UpdateDisplay("800x600");
UpdateDisplay("800x700");
const int64_t display_id =
display::Screen::GetScreen()->GetPrimaryDisplay().id();
display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
......
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