Commit 125ffef6 authored by Charlene Yan's avatar Charlene Yan Committed by Commit Bot

[Tab Groups Collapse] Test cleanup.

Changing dragging collapsed group header tests to checking that the
group expands when drag starts. There are other tests for dragging an
expanded header. It was also bugged since functionality was added to
auto create a bubble on tab group creation, and the tests were not
updated.

Change-Id: I456b4b1c0e6b834fcc553b1dfd7619b8a7e5c893
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2457370Reviewed-by: default avatarTaylor Bergquist <tbergquist@chromium.org>
Commit-Queue: Charlene Yan <cyan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816402}
parent b4ceb3be
......@@ -634,10 +634,10 @@ class DetachToBrowserTabDragControllerTest
observer.Wait();
}
void DragGroupAndNotify(TabStrip* tab_strip,
base::OnceClosure task,
tab_groups::TabGroupId group,
int drag_x_offset = 0) {
void DragToDetachGroupAndNotify(TabStrip* tab_strip,
base::OnceClosure task,
tab_groups::TabGroupId group,
int drag_x_offset = 0) {
test::QuitDraggingObserver observer;
// Move to the tab and drag it enough so that it detaches.
const gfx::Point group_header_center =
......@@ -2116,10 +2116,10 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTestWithTabGroupsEnabled,
StopAnimating(tab_strip2);
// Drag the group by its header into the second browser.
DragGroupAndNotify(tab_strip,
base::BindOnce(&DragAllToSeparateWindowStep2, this,
tab_strip, tab_strip2),
group);
DragToDetachGroupAndNotify(tab_strip,
base::BindOnce(&DragAllToSeparateWindowStep2, this,
tab_strip, tab_strip2),
group);
ASSERT_TRUE(ReleaseInput());
// Expect the group to be in browser2, but with a new tab_groups::TabGroupId.
......@@ -2233,9 +2233,9 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTestWithTabGroupsEnabled,
StopAnimating(tab_strip);
EnsureFocusToTabStrip(tab_strip);
DragGroupAndNotify(tab_strip,
base::BindOnce(&PressEscapeWhileDetachedHeaderStep2, this),
group);
DragToDetachGroupAndNotify(
tab_strip, base::BindOnce(&PressEscapeWhileDetachedHeaderStep2, this),
group);
EXPECT_FALSE(tab_strip->group_header(group)->dragging());
......@@ -2349,9 +2349,9 @@ IN_PROC_BROWSER_TEST_P(
StopAnimating(tab_strip);
EXPECT_TRUE(model->IsGroupCollapsed(group));
DragGroupAndNotify(tab_strip,
base::BindOnce(&PressEscapeWhileDetachedHeaderStep2, this),
group);
DragToDetachGroupAndNotify(
tab_strip, base::BindOnce(&PressEscapeWhileDetachedHeaderStep2, this),
group);
EXPECT_FALSE(tab_strip->group_header(group)->dragging());
ASSERT_FALSE(tab_strip->GetDragContext()->IsDragSessionActive());
......@@ -2366,110 +2366,36 @@ IN_PROC_BROWSER_TEST_P(
EXPECT_TRUE(tab_strip->controller()->IsGroupCollapsed(group));
}
// Creates a browser with four tabs. The first two belong in Tab Group 1, and
// the last two belong in Tab Group 2. Dragging the collapsed group header of
// Tab Group 1 right will result in Tab Group 1 moving but avoiding Tab Group 2.
// Creates a browser with four tabs. The first two tabs belong in Tab Group 1.
// Dragging the collapsed group header of Tab Group 1 will result in Tab Group 1
// expanding.
IN_PROC_BROWSER_TEST_P(
DetachToBrowserTabDragControllerTestWithTabGroupsCollapseEnabled,
DragCollapsedGroupHeaderRightAvoidsOtherGroups) {
DragCollapsedGroupHeaderExpandsGroup) {
TabStrip* tab_strip = GetTabStripForBrowser(browser());
TabStripModel* model = browser()->tab_strip_model();
TabGroupModel* group_model = model->group_model();
AddTabsAndResetBrowser(browser(), 3);
tab_groups::TabGroupId group1 = model->AddToNewGroup({0, 1});
EXPECT_FALSE(model->IsGroupCollapsed(group1));
tab_strip->controller()->ToggleTabGroupCollapsedState(group1);
StopAnimating(tab_strip);
EXPECT_TRUE(model->IsGroupCollapsed(group1));
tab_groups::TabGroupId group2 = model->AddToNewGroup({2, 3});
StopAnimating(tab_strip);
ASSERT_EQ(4, model->count());
ASSERT_EQ(2u, group_model->GetTabGroup(group1)->ListTabs().size());
ASSERT_EQ(2u, group_model->GetTabGroup(group2)->ListTabs().size());
// Drag group1 right, but not far enough to get to the other side of group2.
ASSERT_TRUE(PressInput(
GetCenterInScreenCoordinates(tab_strip->group_header(group1))));
ASSERT_TRUE(DragInputTo(GetCenterInScreenCoordinates(tab_strip->tab_at(0))));
ASSERT_TRUE(ReleaseInput());
StopAnimating(tab_strip);
// Expect group1 to "snap back" to its current position, avoiding group2.
EXPECT_EQ("0 1 2 3", IDString(model));
EXPECT_THAT(group_model->GetTabGroup(group1)->ListTabs(),
testing::ElementsAre(0, 1));
EXPECT_THAT(group_model->GetTabGroup(group2)->ListTabs(),
testing::ElementsAre(2, 3));
// Drag group1 right, far enough to get to the other side of group2.
ASSERT_TRUE(PressInput(
GetCenterInScreenCoordinates(tab_strip->group_header(group1))));
ASSERT_TRUE(DragInputTo(GetCenterInScreenCoordinates(tab_strip->tab_at(1))));
ASSERT_TRUE(ReleaseInput());
StopAnimating(tab_strip);
// Expect group1 to "snap to" the other side of group2 and not land in the
// middle.
EXPECT_EQ("2 3 0 1", IDString(model));
EXPECT_THAT(group_model->GetTabGroup(group1)->ListTabs(),
testing::ElementsAre(2, 3));
EXPECT_THAT(group_model->GetTabGroup(group2)->ListTabs(),
testing::ElementsAre(0, 1));
}
// Creates a browser with four tabs. The first two belong in Tab Group 1, and
// the last two belong in Tab Group 2. Dragging the collapsed group header of
// Tab Group 2 left will result in Tab Group 2 moving but avoiding Tab Group 1.
IN_PROC_BROWSER_TEST_P(
DetachToBrowserTabDragControllerTestWithTabGroupsCollapseEnabled,
DragCollapsedGroupHeaderLeftAvoidsOtherGroups) {
TabStrip* tab_strip = GetTabStripForBrowser(browser());
TabStripModel* model = browser()->tab_strip_model();
TabGroupModel* group_model = model->group_model();
AddTabsAndResetBrowser(browser(), 3);
tab_groups::TabGroupId group1 = model->AddToNewGroup({0, 1});
tab_groups::TabGroupId group2 = model->AddToNewGroup({2, 3});
EXPECT_FALSE(model->IsGroupCollapsed(group2));
tab_strip->controller()->ToggleTabGroupCollapsedState(group2);
tab_groups::TabGroupId group = model->AddToNewGroup({2, 3});
ASSERT_FALSE(model->IsGroupCollapsed(group));
tab_strip->controller()->ToggleTabGroupCollapsedState(group);
StopAnimating(tab_strip);
EXPECT_TRUE(model->IsGroupCollapsed(group2));
ASSERT_TRUE(model->IsGroupCollapsed(group));
EnsureFocusToTabStrip(tab_strip);
ASSERT_EQ(4, model->count());
ASSERT_EQ(2u, group_model->GetTabGroup(group1)->ListTabs().size());
ASSERT_EQ(2u, group_model->GetTabGroup(group2)->ListTabs().size());
ASSERT_EQ(2u, group_model->GetTabGroup(group)->ListTabs().size());
// Drag group2 left, but not far enough to get to the other side of group1.
ASSERT_TRUE(PressInput(
GetCenterInScreenCoordinates(tab_strip->group_header(group2))));
// Drag group1, this should expand the group.
ASSERT_TRUE(
PressInput(GetCenterInScreenCoordinates(tab_strip->group_header(group))));
ASSERT_TRUE(DragInputTo(GetCenterInScreenCoordinates(tab_strip->tab_at(1))));
ASSERT_TRUE(TabDragController::IsActive());
EXPECT_FALSE(model->IsGroupCollapsed(group));
ASSERT_TRUE(ReleaseInput());
StopAnimating(tab_strip);
// Expect group2 to "snap back" to its current position, avoiding group1.
EXPECT_EQ("0 1 2 3", IDString(model));
EXPECT_THAT(group_model->GetTabGroup(group1)->ListTabs(),
testing::ElementsAre(0, 1));
EXPECT_THAT(group_model->GetTabGroup(group2)->ListTabs(),
testing::ElementsAre(2, 3));
// Drag group2 left, far enough to get to the other side of group1.
ASSERT_TRUE(PressInput(
GetCenterInScreenCoordinates(tab_strip->group_header(group2))));
ASSERT_TRUE(DragInputTo(GetCenterInScreenCoordinates(tab_strip->tab_at(0))));
ASSERT_TRUE(ReleaseInput());
StopAnimating(tab_strip);
// Expect group2 to "snap to" the other side of group1 and not land in the
// middle.
EXPECT_EQ("2 3 0 1", IDString(model));
EXPECT_THAT(group_model->GetTabGroup(group1)->ListTabs(),
testing::ElementsAre(2, 3));
EXPECT_THAT(group_model->GetTabGroup(group2)->ListTabs(),
testing::ElementsAre(0, 1));
EXPECT_FALSE(model->IsGroupCollapsed(group));
}
// Creates two browsers, then drags a collapsed group from one to the other.
......@@ -2492,7 +2418,7 @@ IN_PROC_BROWSER_TEST_P(
StopAnimating(tab_strip2);
// Drag the group by its header into the second browser.
DragGroupAndNotify(
DragToDetachGroupAndNotify(
tab_strip,
base::BindOnce(&DragToSeparateWindowStep2, this, tab_strip, tab_strip2),
group);
......
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