Commit 61430215 authored by Charlene Yan's avatar Charlene Yan Committed by Commit Bot

Revert "Reland "Add ability to drag tabs between pinned and unpinned tabs to modify the""

This reverts commit 2af55fab.

Reason for revert: Still flaky

Original change's description:
> Reland "Add ability to drag tabs between pinned and unpinned tabs to modify the"
> 
> This reverts commit 1158f5ef.
> 
> Reason for revert: This is an experimental reland since this broke older
> mac waterfall bots. This was fixed with https://chromium-review.googlesource.com/c/chromium/src/+/1649313
> 
> Original change's description:
> > Revert "Add ability to drag tabs between pinned and unpinned tabs to modify the"
> >
> > This reverts commit 91948560.
> >
> > Reason for revert: https://ci.chromium.org/p/chromium/builders/ci/Mac10.11%20Tests/38757, consistent failures on mac of the following tests:
> > TabDragging/DetachToBrowserTabDragControllerTest.DragToPinEnabled_DragToUnpinInNewWindow/0
> > TabDragging/DetachToBrowserTabDragControllerTest.DragToPinInNewWindow/0
> >
> > Original change's description:
> > > Add ability to drag tabs between pinned and unpinned tabs to modify the
> > > pinned state.
> > >
> > > Bug: 965681
> > > Change-Id: I4cebf850839a1fdbee702ab2cd3c2fccbdba811e
> > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1637045
> > > Reviewed-by: Bret Sepulveda <bsep@chromium.org>
> > > Commit-Queue: Charlene Yan <cyan@chromium.org>
> > > Cr-Commit-Position: refs/heads/master@{#666796}
> >
> > TBR=bsep@chromium.org,cyan@chromium.org
> >
> > Change-Id: I0a68811b31c718fcdccba6058ab6bdf664a1547a
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: 965681
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1649316
> > Reviewed-by: Armando Miraglia <armax@chromium.org>
> > Commit-Queue: Armando Miraglia <armax@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#667042}
> 
> TBR=bsep@chromium.org,armax@chromium.org,cyan@chromium.org
> 
> Change-Id: Ia1521f2c2443c40a3b2ac55be079c6e1be91dea2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 965681
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1648899
> Commit-Queue: Charlene Yan <cyan@chromium.org>
> Reviewed-by: Charlene Yan <cyan@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#669906}

TBR=bsep@chromium.org,armax@chromium.org,cyan@chromium.org

Change-Id: I8ab3f943b2aed204f318c329fca88a0459f2255b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 965681
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663582Reviewed-by: default avatarCharlene Yan <cyan@chromium.org>
Commit-Queue: Charlene Yan <cyan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#669934}
parent 33b7b105
......@@ -12,9 +12,7 @@
#include "base/auto_reset.h"
#include "base/bind.h"
#include "base/callback.h"
#include "base/feature_list.h"
#include "base/i18n/rtl.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/numerics/ranges.h"
#include "base/stl_util.h"
......@@ -28,7 +26,6 @@
#include "chrome/browser/ui/sad_tab_helper.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/tabs/tab.h"
#include "chrome/browser/ui/views/tabs/tab_strip.h"
......@@ -476,9 +473,9 @@ void TabDragController::Init(TabDragContext* source_context,
source_context_->AsView()->GetWidget()->GetNativeWindow());
if (source_tab->width() > 0) {
offset_to_width_ratio_ =
float{source_tab->GetMirroredXInView(source_tab_offset)} /
float{source_tab->width()};
offset_to_width_ratio_ = static_cast<float>(
source_tab->GetMirroredXInView(source_tab_offset)) /
static_cast<float>(source_tab->width());
}
InitWindowCreatePoint();
initial_selection_model_ = std::move(initial_selection_model);
......@@ -546,7 +543,7 @@ void TabDragController::Drag(const gfx::Point& point_in_screen) {
}
current_state_ = DragState::kDraggingTabs;
Attach(source_context_, gfx::Point());
if (int{drag_data_.size()} ==
if (static_cast<int>(drag_data_.size()) ==
source_context_->GetTabStripModel()->count()) {
views::Widget* widget = GetAttachedBrowserWidget();
gfx::Rect new_bounds;
......@@ -754,8 +751,8 @@ bool TabDragController::CanStartDrag(const gfx::Point& point_in_screen) const {
static const int kMinimumDragDistance = 10;
int x_offset = abs(point_in_screen.x() - start_point_in_screen_.x());
int y_offset = abs(point_in_screen.y() - start_point_in_screen_.y());
return sqrt(pow(float{x_offset}, 2) + pow(float{y_offset}, 2)) >
kMinimumDragDistance;
return sqrt(pow(static_cast<float>(x_offset), 2) +
pow(static_cast<float>(y_offset), 2)) > kMinimumDragDistance;
}
TabDragController::Liveness TabDragController::ContinueDragging(
......@@ -909,7 +906,8 @@ TabDragController::DragBrowserToNewTabStrip(TabDragContext* target_context,
void TabDragController::DragActiveTabStacked(
const gfx::Point& point_in_screen) {
if (attached_context_->GetTabCount() != int{initial_tab_positions_.size()})
if (attached_context_->GetTabCount() !=
static_cast<int>(initial_tab_positions_.size()))
return; // TODO: should cancel drag if this happens.
int delta = point_in_screen.x() - start_point_in_screen_.x();
......@@ -959,7 +957,7 @@ void TabDragController::MoveAttached(const gfx::Point& point_in_screen) {
TabStripModel* attached_model = attached_context_->GetTabStripModel();
int to_index = attached_context_->GetInsertionIndexForDraggedBounds(
GetDraggedViewTabStripBounds(dragged_view_point), false,
int{drag_data_.size()}, mouse_has_ever_moved_left_,
static_cast<int>(drag_data_.size()), mouse_has_ever_moved_left_,
mouse_has_ever_moved_right_);
bool do_move = true;
// While dragging within a tabstrip the expectation is the insertion index
......@@ -1001,9 +999,6 @@ void TabDragController::MoveAttached(const gfx::Point& point_in_screen) {
initial_move_);
did_layout = true;
}
if (base::FeatureList::IsEnabled(features::kDragToPinTabs)) {
UpdatePinnednessOfDraggedTab(to_index);
}
attached_model->MoveSelectedTabsTo(to_index);
// Move may do nothing in certain situations (such as when dragging pinned
......@@ -1160,7 +1155,6 @@ void TabDragController::Attach(TabDragContext* attached_context,
std::vector<Tab*> tabs = GetTabsMatchingDraggedContents(attached_context_);
TabStripModel* attached_model = attached_context_->GetTabStripModel();
if (tabs.empty()) {
// Transitioning from detached to attached to a new context. Add tabs to
// the new model.
......@@ -1184,7 +1178,7 @@ void TabDragController::Attach(TabDragContext* attached_context,
tab_strip_point.Offset(0, -mouse_offset_.y());
int index = attached_context_->GetInsertionIndexForDraggedBounds(
GetDraggedViewTabStripBounds(tab_strip_point), true,
int{drag_data_.size()}, mouse_has_ever_moved_left_,
static_cast<int>(drag_data_.size()), mouse_has_ever_moved_left_,
mouse_has_ever_moved_right_);
attach_index_ = index;
attach_x_ = tab_strip_point.x();
......@@ -1197,26 +1191,10 @@ void TabDragController::Attach(TabDragContext* attached_context,
DCHECK_EQ(1u, drag_data_.size());
add_types |= TabStripModel::ADD_ACTIVE;
}
const int target_index = index + i;
if (base::FeatureList::IsEnabled(features::kDragToPinTabs)) {
if (drag_data_[i].pinned) {
// Attaching a tab is effectively an insertion at the target index. A
// pinned tab will only need to unpin if the previous tab is unpinned.
drag_data_[i].pinned = !CheckValidPinnedness(
target_index - 1, TabAnimationState::TabPinnedness::kUnpinned);
} else {
// An unpinned tab will only need to be pinned if the tab to the right
// of it is is pinned.
drag_data_[i].pinned = CheckValidPinnedness(
target_index, TabAnimationState::TabPinnedness::kPinned);
}
}
if (drag_data_[i].pinned)
add_types |= TabStripModel::ADD_PINNED;
attached_model->InsertWebContentsAt(
target_index, std::move(drag_data_[i].owned_contents), add_types);
attached_context_->GetTabStripModel()->InsertWebContentsAt(
index + i, std::move(drag_data_[i].owned_contents), add_types);
// If a sad tab is showing, the SadTabView needs to be updated.
SadTabHelper* sad_tab_helper =
......@@ -1224,13 +1202,14 @@ void TabDragController::Attach(TabDragContext* attached_context,
if (sad_tab_helper)
sad_tab_helper->ReinstallInWebView();
}
tabs = GetTabsMatchingDraggedContents(attached_context_);
}
DCHECK_EQ(tabs.size(), drag_data_.size());
for (size_t i = 0; i < drag_data_.size(); ++i)
drag_data_[i].attached_tab = tabs[i];
ResetSelection(attached_model);
ResetSelection(attached_context_->GetTabStripModel());
// This should be called after ResetSelection() in order to generate
// bounds correctly. http://crbug.com/836004
......@@ -1255,7 +1234,8 @@ void TabDragController::Attach(TabDragContext* attached_context,
attached_context_->OwnDragController(this);
SetTabDraggingInfo();
attached_context_tabs_closed_tracker_ =
std::make_unique<DraggedTabsClosedTracker>(attached_model, this);
std::make_unique<DraggedTabsClosedTracker>(
attached_context_->GetTabStripModel(), this);
}
void TabDragController::Detach(ReleaseCapture release_capture) {
......@@ -1317,7 +1297,7 @@ void TabDragController::Detach(ReleaseCapture release_capture) {
void TabDragController::DetachIntoNewBrowserAndRunMoveLoop(
const gfx::Point& point_in_screen) {
if (attached_context_->GetTabStripModel()->count() ==
int{drag_data_.size()}) {
static_cast<int>(drag_data_.size())) {
// All the tabs in a browser are being dragged but all the tabs weren't
// initially being dragged. For this to happen the user would have to
// start dragging a set of tabs, the other tabs close, then detach.
......@@ -1940,12 +1920,12 @@ void TabDragController::AdjustBrowserAndTabBoundsForDrag(
// If the new tabstrip is smaller than the old resize the tabs.
if (dragged_context_width < tab_area_width) {
const float leading_ratio =
drag_bounds->front().x() / float{tab_area_width};
drag_bounds->front().x() / static_cast<float>(tab_area_width);
*drag_bounds = CalculateBoundsForDraggedTabs();
if (drag_bounds->back().right() < dragged_context_width) {
const int delta_x = std::min(
int{leading_ratio * dragged_context_width},
static_cast<int>(leading_ratio * dragged_context_width),
dragged_context_width -
(drag_bounds->back().right() - drag_bounds->front().x()));
OffsetX(delta_x, drag_bounds);
......@@ -2111,49 +2091,6 @@ bool TabDragController::ShouldDisallowDrag(gfx::NativeWindow window) {
#endif
}
void TabDragController::UpdatePinnednessOfDraggedTab(int to_index) {
TabStripModel* attached_model = attached_context_->GetTabStripModel();
const int selected_count =
int{attached_model->selection_model().selected_indices().size()};
for (int i = 0; i < selected_count; i++) {
const int current_index =
attached_model->selection_model().selected_indices()[i];
const int target_index = to_index + i;
if (current_index != target_index) {
// When dragging a tab to the target index, the tab is effectively
// swapping places with the tab at its target index.This means that
// if the current tab is pinned but the tab it is swapping with is
// not, the current tab will need to be unpinned. The opposite is
// true when moving an unpinned tab.
if (attached_model->IsTabPinned(current_index) &&
CheckValidPinnedness(target_index,
TabAnimationState::TabPinnedness::kUnpinned)) {
attached_model->SetTabPinned(current_index, false);
} else if (!attached_model->IsTabPinned(current_index) &&
CheckValidPinnedness(
target_index, TabAnimationState::TabPinnedness::kPinned)) {
attached_model->SetTabPinned(current_index, true);
}
}
}
}
bool TabDragController::CheckValidPinnedness(
int index,
TabAnimationState::TabPinnedness expected_pinnedness) {
TabStripModel* attached_model = attached_context_->GetTabStripModel();
if (!attached_model->ContainsIndex(index))
return false;
TabAnimationState::TabPinnedness pinnedness =
attached_model->IsTabPinned(index)
? TabAnimationState::TabPinnedness::kPinned
: TabAnimationState::TabPinnedness::kUnpinned;
return expected_pinnedness == pinnedness;
}
void TabDragController::SetDeferredTargetTabstrip(
TabDragContext* deferred_target_context) {
#if defined(OS_CHROMEOS)
......
......@@ -14,7 +14,6 @@
#include "base/memory/weak_ptr.h"
#include "base/timer/timer.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
#include "chrome/browser/ui/views/tabs/tab_animation_state.h"
#include "chrome/browser/ui/views/tabs/tab_drag_context.h"
#include "chrome/browser/ui/views/tabs/tab_strip_types.h"
#include "ui/base/models/list_selection_model.h"
......@@ -495,19 +494,6 @@ class TabDragController : public views::WidgetObserver {
// is showing a modal).
bool ShouldDisallowDrag(gfx::NativeWindow window);
// Helper method for TabDragController::MoveAttached to update the pinnedness
// of the tab being moved by checking the pinnedness of the tabs being
// dragged with the pinnedness of the tab at the target dragged location.
// TODO (crbug.com/971676): This will swap and update the pinnedness of
// multi-selected tabs one at a time, which is unintended.
void UpdatePinnednessOfDraggedTab(int to_index);
// Helper method that checks if the index is valid in the TabDragContext and
// the pin at the index has the expected pinned value.
bool CheckValidPinnedness(
int index,
TabAnimationState::TabPinnedness expected_pinnedness);
EventSource event_source_;
// The TabDragContext the drag originated from. This is set to null
......
......@@ -23,7 +23,6 @@
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/bind_test_util.h"
#include "base/test/scoped_feature_list.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "chrome/browser/chrome_notification_types.h"
......@@ -32,7 +31,6 @@
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/native_browser_frame_factory.h"
#include "chrome/browser/ui/views/tabs/tab.h"
......@@ -423,50 +421,6 @@ class DetachToBrowserTabDragControllerTest
#endif // OS_MACOSX
}
// Set up the test environment with 4 tabs. Two pinned and two unpinned.
void SetUpDragToChangePinnednessTest() {
AddTabAndResetBrowser(browser());
AddTabAndResetBrowser(browser());
AddTabAndResetBrowser(browser());
TabStrip* tab_strip = GetTabStripForBrowser(browser());
TabStripModel* model = browser()->tab_strip_model();
model->SetTabPinned(0, true);
model->SetTabPinned(1, true);
StopAnimating(tab_strip);
ASSERT_TRUE(model->IsTabPinned(0));
ASSERT_TRUE(model->IsTabPinned(1));
ASSERT_FALSE(model->IsTabPinned(2));
ASSERT_FALSE(model->IsTabPinned(3));
EXPECT_EQ("0 1 2 3", IDString(model));
}
// Set up the test environment another browser with two unpinned tabs.
Browser* SetUpSecondBrowserWithTwoUnpinnedTabs() {
Browser* browser2 = CreateAnotherBrowserAndResize();
AddTabAndResetBrowser(browser2);
ResetIDs(browser2->tab_strip_model(), 100);
return browser2;
}
void SelectIndicies(TabStrip* tabstrip,
TabStripModel* model,
std::vector<int> indicies) {
DCHECK(!indicies.empty());
// The last tab opened will automatically be selected. Simulating a click to
// select the first index will ensure others are no longer selected.
ASSERT_TRUE(PressInput(
GetCenterInScreenCoordinates(tabstrip->tab_at(indicies.at(0)))));
ASSERT_TRUE(ReleaseInput());
if (indicies.size() > 1) {
for (auto it = std::next(indicies.begin()); it != indicies.end(); ++it) {
model->ToggleSelectionAt(*it);
}
}
}
InputSource input_source() const {
return strstr(GetParam(), "mouse") ?
INPUT_SOURCE_MOUSE : INPUT_SOURCE_TOUCH;
......@@ -642,23 +596,6 @@ class DetachToBrowserTabDragControllerTest
Browser* browser() const { return InProcessBrowserTest::browser(); }
void DragToSeparateWindowBeforeFirstTab(TabStrip* tabstrip_to) {
gfx::Point tab_left_center =
tabstrip_to->tab_at(0)->GetLocalBounds().left_center();
views::View::ConvertPointToScreen(tabstrip_to->tab_at(0), &tab_left_center);
ASSERT_TRUE(DragInputToAsync(tab_left_center));
}
void DragToSeparateWindowAfterFirstTab(TabStrip* tabstrip_to) {
gfx::Point tab_right_center =
tabstrip_to->tab_at(0)->GetLocalBounds().right_center();
views::View::ConvertPointToScreen(tabstrip_to->tab_at(0),
&tab_right_center);
ASSERT_TRUE(DragInputToAsync(tab_right_center));
}
base::test::ScopedFeatureList scoped_feature_list_;
private:
#if defined(OS_CHROMEOS)
// The root window for the event generator.
......@@ -670,6 +607,12 @@ class DetachToBrowserTabDragControllerTest
// Creates a browser with two tabs, drags the second to the first.
IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, DragInSameWindow) {
// TODO(sky): this won't work with touch as it requires a long press.
if (input_source() == INPUT_SOURCE_TOUCH) {
VLOG(1) << "Test is DISABLED for touch input.";
return;
}
AddTabAndResetBrowser(browser());
TabStrip* tab_strip = GetTabStripForBrowser(browser());
......@@ -691,160 +634,6 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, DragInSameWindow) {
EXPECT_FALSE(tab_strip->GetWidget()->HasCapture());
}
// Creates a browser with four tabs two pinned two unpinned. With the
// kDragToPinTabs flag off, dragging tabs between pinned and unpinned will have
// no effect
IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
DragInSameWindow_CannotDragBetweenPinnedness) {
scoped_feature_list_.InitAndDisableFeature(features::kDragToPinTabs);
SetUpDragToChangePinnednessTest();
TabStrip* tab_strip = GetTabStripForBrowser(browser());
TabStripModel* model = browser()->tab_strip_model();
// Dragging an unpinned tab before a pinned tab will have no effect.
ASSERT_TRUE(PressInput(GetCenterInScreenCoordinates(tab_strip->tab_at(2))));
ASSERT_TRUE(DragInputTo(GetCenterInScreenCoordinates(tab_strip->tab_at(1))));
ASSERT_TRUE(ReleaseInput());
EXPECT_EQ("0 1 2 3", IDString(model));
EXPECT_TRUE(model->IsTabPinned(0));
EXPECT_TRUE(model->IsTabPinned(1));
EXPECT_FALSE(model->IsTabPinned(2));
EXPECT_FALSE(model->IsTabPinned(3));
// Dragging a pinned tab after an unpinned tab will have no effect.
ASSERT_TRUE(PressInput(GetCenterInScreenCoordinates(tab_strip->tab_at(1))));
ASSERT_TRUE(DragInputTo(GetCenterInScreenCoordinates(tab_strip->tab_at(2))));
ASSERT_TRUE(ReleaseInput());
EXPECT_EQ("0 1 2 3", IDString(model));
EXPECT_TRUE(model->IsTabPinned(0));
EXPECT_TRUE(model->IsTabPinned(1));
EXPECT_FALSE(model->IsTabPinned(2));
EXPECT_FALSE(model->IsTabPinned(3));
}
// Creates a browser with four tabs two pinned two unpinned. With the
// kDragToPinTabs flag on, dragging unpinned tabs before a pinned tab will
// pin the unpinned tab.
IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
DragInSameWindow_DragUnpinnedBeforePinned) {
scoped_feature_list_.InitAndEnableFeature(features::kDragToPinTabs);
SetUpDragToChangePinnednessTest();
TabStrip* tab_strip = GetTabStripForBrowser(browser());
TabStripModel* model = browser()->tab_strip_model();
SelectIndicies(tab_strip, model, std::vector<int>{2, 3});
ASSERT_TRUE(PressInput(GetCenterInScreenCoordinates(tab_strip->tab_at(2))));
ASSERT_TRUE(DragInputTo(GetCenterInScreenCoordinates(tab_strip->tab_at(0))));
ASSERT_TRUE(ReleaseInput());
StopAnimating(tab_strip);
EXPECT_EQ("2 3 0 1", IDString(model));
EXPECT_TRUE(model->IsTabPinned(0));
EXPECT_TRUE(model->IsTabPinned(1));
EXPECT_TRUE(model->IsTabPinned(2));
EXPECT_TRUE(model->IsTabPinned(3));
}
// Creates a browser with four tabs two pinned two unpinned. With the
// kDragToPinTabs flag on, dragging pinned tabs after the unpinned tab will
// unpin the pinned tab.
IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
DragInSameWindow_DragPinnedAfterUnpinned) {
scoped_feature_list_.InitAndEnableFeature(features::kDragToPinTabs);
SetUpDragToChangePinnednessTest();
TabStrip* tab_strip = GetTabStripForBrowser(browser());
TabStripModel* model = browser()->tab_strip_model();
SelectIndicies(tab_strip, model, std::vector<int>{0, 1});
// TODO (crbug.com/965681): Investigate and fix the dragging case for dragging
// pinned tabs to after unpinned tabs.
gfx::Point tab_2 = GetCenterInScreenCoordinates(tab_strip->tab_at(2));
gfx::Point tab_2_left_center =
tab_strip->tab_at(2)->GetLocalBounds().left_center();
views::View::ConvertPointToScreen(tab_strip->tab_at(2), &tab_2_left_center);
ASSERT_TRUE(PressInput(GetCenterInScreenCoordinates(tab_strip->tab_at(0))));
ASSERT_TRUE(DragInputTo(tab_2_left_center));
ASSERT_TRUE(DragInputTo(tab_2));
ASSERT_TRUE(ReleaseInput());
StopAnimating(tab_strip);
EXPECT_FALSE(model->IsTabPinned(0));
EXPECT_FALSE(model->IsTabPinned(1));
EXPECT_FALSE(model->IsTabPinned(2));
EXPECT_FALSE(model->IsTabPinned(3));
}
// Creates one browser with a single pinned tab as well as another browser
// (browser2) with one pinned tab and one unpinned tab. With the kDragToPinTabs
// flag on, dragging a both tabs from browser2 to the other browser to the left
// of the first pinned tab will pin both tabs dragged.
IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
DragToPinInNewWindow) {
scoped_feature_list_.InitAndEnableFeature(features::kDragToPinTabs);
TabStrip* tab_strip = GetTabStripForBrowser(browser());
TabStripModel* model = browser()->tab_strip_model();
model->SetTabPinned(0, true);
StopAnimating(tab_strip);
// Create another browser.
Browser* browser2 = SetUpSecondBrowserWithTwoUnpinnedTabs();
TabStrip* tab_strip2 = GetTabStripForBrowser(browser2);
browser2->tab_strip_model()->SetTabPinned(0, true);
StopAnimating(tab_strip2);
SelectIndicies(tab_strip2, browser2->tab_strip_model(),
std::vector<int>{0, 1});
// This should be moving the entire window.
DragTabAndNotify(tab_strip2,
base::BindOnce(&DetachToBrowserTabDragControllerTest::
DragToSeparateWindowBeforeFirstTab,
base::Unretained(this), tab_strip));
ASSERT_TRUE(ReleaseInput());
EXPECT_EQ(3, model->count());
EXPECT_TRUE(model->IsTabPinned(0));
EXPECT_TRUE(model->IsTabPinned(1));
EXPECT_TRUE(model->IsTabPinned(2));
}
// Creates one browser with a single unpinned tab as well as another browser
// (browser2) with one pinned tab and one unpinned tab. With the kDragToPinTabs
// flag on, dragging a both tabs from browser2 to the other browser to the right
// of the unpinned tab will unpin both tabs dragged.
IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
DragToPinEnabled_DragToUnpinInNewWindow) {
scoped_feature_list_.InitAndEnableFeature(features::kDragToPinTabs);
TabStrip* tab_strip = GetTabStripForBrowser(browser());
TabStripModel* model = browser()->tab_strip_model();
// Create another browser.
Browser* browser2 = SetUpSecondBrowserWithTwoUnpinnedTabs();
TabStrip* tab_strip2 = GetTabStripForBrowser(browser2);
browser2->tab_strip_model()->SetTabPinned(0, true);
StopAnimating(tab_strip2);
SelectIndicies(tab_strip2, browser2->tab_strip_model(),
std::vector<int>{0, 1});
// This should be moving the entire window.
DragTabAndNotify(tab_strip2,
base::BindOnce(&DetachToBrowserTabDragControllerTest::
DragToSeparateWindowAfterFirstTab,
base::Unretained(this), tab_strip));
ASSERT_TRUE(ReleaseInput());
EXPECT_EQ(3, model->count());
EXPECT_FALSE(model->IsTabPinned(0));
EXPECT_FALSE(model->IsTabPinned(1));
EXPECT_FALSE(model->IsTabPinned(2));
}
#if defined(USE_AURA)
bool SubtreeShouldBeExplored(aura::Window* window,
const gfx::Point& local_point) {
......
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