Commit 07b14715 authored by gab@chromium.org's avatar gab@chromium.org

Explicitly hardcode tab_drag_controller_interactive_uitest.cc to use the native desktop list.

Getting rid of some of the last BrowserList:: iterator methods :)!

Also making BrowserListImpl const-safe (otherwise GetLastActive(), required in this CL, couldn't be used on a const BrowserListImpl*).

BUG=129187

Review URL: https://codereview.chromium.org/12213091

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181984 0039d316-1c4b-4281-b951-d872f2087c98
parent 93df0a1f
...@@ -111,13 +111,13 @@ void BrowserListImpl::SetLastActive(Browser* browser) { ...@@ -111,13 +111,13 @@ void BrowserListImpl::SetLastActive(Browser* browser) {
OnBrowserSetLastActive(browser)); OnBrowserSetLastActive(browser));
} }
Browser* BrowserListImpl::GetLastActive() { Browser* BrowserListImpl::GetLastActive() const {
if (!last_active_browsers_.empty()) if (!last_active_browsers_.empty())
return *(last_active_browsers_.rbegin()); return *(last_active_browsers_.rbegin());
return NULL; return NULL;
} }
bool BrowserListImpl::IsIncognitoWindowOpen() { bool BrowserListImpl::IsIncognitoWindowOpen() const {
for (BrowserListImpl::const_iterator i = BrowserListImpl::begin(); for (BrowserListImpl::const_iterator i = BrowserListImpl::begin();
i != BrowserListImpl::end(); ++i) { i != BrowserListImpl::end(); ++i) {
if ((*i)->profile()->IsOffTheRecord()) if ((*i)->profile()->IsOffTheRecord())
...@@ -126,7 +126,7 @@ bool BrowserListImpl::IsIncognitoWindowOpen() { ...@@ -126,7 +126,7 @@ bool BrowserListImpl::IsIncognitoWindowOpen() {
return false; return false;
} }
bool BrowserListImpl::IsIncognitoWindowOpenForProfile(Profile* profile) { bool BrowserListImpl::IsIncognitoWindowOpenForProfile(Profile* profile) const {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
// In ChromeOS, we assume that the default profile is always valid, so if // In ChromeOS, we assume that the default profile is always valid, so if
// we are in guest mode, keep the OTR profile active so it won't be deleted. // we are in guest mode, keep the OTR profile active so it won't be deleted.
......
...@@ -40,7 +40,7 @@ class BrowserListImpl { ...@@ -40,7 +40,7 @@ class BrowserListImpl {
// allows us to determine what the last active Browser was. // allows us to determine what the last active Browser was.
void SetLastActive(Browser* browser); void SetLastActive(Browser* browser);
Browser* GetLastActive(); Browser* GetLastActive() const;
// Browsers are added to the list before they have constructed windows, // Browsers are added to the list before they have constructed windows,
// so the |window()| member function may return NULL. // so the |window()| member function may return NULL.
...@@ -56,18 +56,18 @@ class BrowserListImpl { ...@@ -56,18 +56,18 @@ class BrowserListImpl {
// they were last active. The underlying data structure is a vector // they were last active. The underlying data structure is a vector
// and we push_back on recent access so a reverse iterator gives the // and we push_back on recent access so a reverse iterator gives the
// latest accessed browser first. // latest accessed browser first.
const_reverse_iterator begin_last_active() { const_reverse_iterator begin_last_active() const {
return last_active_browsers_.rbegin(); return last_active_browsers_.rbegin();
} }
const_reverse_iterator end_last_active() { const_reverse_iterator end_last_active() const {
return last_active_browsers_.rend(); return last_active_browsers_.rend();
} }
// Returns true if at least one incognito window is open. // Returns true if at least one incognito window is open.
bool IsIncognitoWindowOpen(); bool IsIncognitoWindowOpen() const;
// Returns true if at least one incognito window is open for |profile|. // Returns true if at least one incognito window is open for |profile|.
bool IsIncognitoWindowOpenForProfile(Profile* profile); bool IsIncognitoWindowOpenForProfile(Profile* profile) const;
private: private:
BrowserListImpl(); BrowserListImpl();
......
...@@ -11,7 +11,9 @@ ...@@ -11,7 +11,9 @@
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_list_impl.h"
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/views/frame/browser_view.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.h"
...@@ -140,7 +142,9 @@ using test::ResetIDs; ...@@ -140,7 +142,9 @@ using test::ResetIDs;
using test::IDString; using test::IDString;
using test::GetTabStripForBrowser; using test::GetTabStripForBrowser;
TabDragControllerTest::TabDragControllerTest() { TabDragControllerTest::TabDragControllerTest()
: native_browser_list(chrome::BrowserListImpl::GetInstance(
chrome::HOST_DESKTOP_TYPE_NATIVE)) {
} }
TabDragControllerTest::~TabDragControllerTest() { TabDragControllerTest::~TabDragControllerTest() {
...@@ -445,8 +449,8 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, ...@@ -445,8 +449,8 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
ASSERT_FALSE(TabDragController::IsActive()); ASSERT_FALSE(TabDragController::IsActive());
// There should now be another browser. // There should now be another browser.
ASSERT_EQ(2u, BrowserList::size()); ASSERT_EQ(2u, native_browser_list->size());
Browser* new_browser = *(++BrowserList::begin()); Browser* new_browser = native_browser_list->get(1);
ASSERT_TRUE(new_browser->window()->IsActive()); ASSERT_TRUE(new_browser->window()->IsActive());
TabStrip* tab_strip2 = GetTabStripForBrowser(new_browser); TabStrip* tab_strip2 = GetTabStripForBrowser(new_browser);
ASSERT_FALSE(tab_strip2->IsDragSessionActive()); ASSERT_FALSE(tab_strip2->IsDragSessionActive());
...@@ -559,9 +563,10 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, ...@@ -559,9 +563,10 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
namespace { namespace {
void DeleteSourceDetachedStep2(WebContents* tab) { void DeleteSourceDetachedStep2(WebContents* tab,
ASSERT_EQ(2u, BrowserList::size()); const chrome::BrowserListImpl* browser_list) {
Browser* new_browser = *(++BrowserList::begin()); ASSERT_EQ(2u, browser_list->size());
Browser* new_browser = browser_list->get(1);
// This ends up closing the source window. // This ends up closing the source window.
delete tab; delete tab;
// Cancel the drag. // Cancel the drag.
...@@ -585,12 +590,12 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, ...@@ -585,12 +590,12 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
ASSERT_TRUE(PressInput(tab_0_center)); ASSERT_TRUE(PressInput(tab_0_center));
ASSERT_TRUE(DragInputToNotifyWhenDone( ASSERT_TRUE(DragInputToNotifyWhenDone(
tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip),
base::Bind(&DeleteSourceDetachedStep2, to_delete))); base::Bind(&DeleteSourceDetachedStep2, to_delete, native_browser_list)));
QuitWhenNotDragging(); QuitWhenNotDragging();
// Should not be dragging. // Should not be dragging.
ASSERT_EQ(1u, BrowserList::size()); ASSERT_EQ(1u, native_browser_list->size());
Browser* new_browser = *BrowserList::begin(); Browser* new_browser = native_browser_list->get(0);
ASSERT_FALSE(GetTabStripForBrowser(new_browser)->IsDragSessionActive()); ASSERT_FALSE(GetTabStripForBrowser(new_browser)->IsDragSessionActive());
ASSERT_FALSE(TabDragController::IsActive()); ASSERT_FALSE(TabDragController::IsActive());
...@@ -601,9 +606,10 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, ...@@ -601,9 +606,10 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
namespace { namespace {
void PressEscapeWhileDetachedStep2() { void PressEscapeWhileDetachedStep2(
ASSERT_EQ(2u, BrowserList::size()); const chrome::BrowserListImpl* browser_list) {
Browser* new_browser = *(++BrowserList::begin()); ASSERT_EQ(2u, browser_list->size());
Browser* new_browser = browser_list->get(1);
ui_controls::SendKeyPress( ui_controls::SendKeyPress(
new_browser->window()->GetNativeWindow(), ui::VKEY_ESCAPE, false, false, new_browser->window()->GetNativeWindow(), ui::VKEY_ESCAPE, false, false,
false, false); false, false);
...@@ -624,7 +630,7 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, ...@@ -624,7 +630,7 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
ASSERT_TRUE(PressInput(tab_0_center)); ASSERT_TRUE(PressInput(tab_0_center));
ASSERT_TRUE(DragInputToNotifyWhenDone( ASSERT_TRUE(DragInputToNotifyWhenDone(
tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip),
base::Bind(&PressEscapeWhileDetachedStep2))); base::Bind(&PressEscapeWhileDetachedStep2, native_browser_list)));
QuitWhenNotDragging(); QuitWhenNotDragging();
// Should not be dragging. // Should not be dragging.
...@@ -632,16 +638,17 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, ...@@ -632,16 +638,17 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
ASSERT_FALSE(TabDragController::IsActive()); ASSERT_FALSE(TabDragController::IsActive());
// And there should only be one window. // And there should only be one window.
EXPECT_EQ(1u, BrowserList::size()); EXPECT_EQ(1u, native_browser_list->size());
EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); EXPECT_EQ("0 1", IDString(browser()->tab_strip_model()));
} }
namespace { namespace {
void DragAllStep2(DetachToBrowserTabDragControllerTest* test) { void DragAllStep2(DetachToBrowserTabDragControllerTest* test,
const chrome::BrowserListImpl* browser_list) {
// Should only be one window. // Should only be one window.
ASSERT_EQ(1u, BrowserList::size()); ASSERT_EQ(1u, browser_list->size());
if (test->input_source() == INPUT_SOURCE_TOUCH) { if (test->input_source() == INPUT_SOURCE_TOUCH) {
ASSERT_TRUE(test->ReleaseInput()); ASSERT_TRUE(test->ReleaseInput());
} else { } else {
...@@ -665,7 +672,7 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, DragAll) { ...@@ -665,7 +672,7 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, DragAll) {
ASSERT_TRUE(PressInput(tab_0_center)); ASSERT_TRUE(PressInput(tab_0_center));
ASSERT_TRUE(DragInputToNotifyWhenDone( ASSERT_TRUE(DragInputToNotifyWhenDone(
tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip),
base::Bind(&DragAllStep2, this))); base::Bind(&DragAllStep2, this, native_browser_list)));
QuitWhenNotDragging(); QuitWhenNotDragging();
// Should not be dragging. // Should not be dragging.
...@@ -673,7 +680,7 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, DragAll) { ...@@ -673,7 +680,7 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, DragAll) {
ASSERT_FALSE(TabDragController::IsActive()); ASSERT_FALSE(TabDragController::IsActive());
// And there should only be one window. // And there should only be one window.
EXPECT_EQ(1u, BrowserList::size()); EXPECT_EQ(1u, native_browser_list->size());
EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); EXPECT_EQ("0 1", IDString(browser()->tab_strip_model()));
...@@ -685,11 +692,12 @@ namespace { ...@@ -685,11 +692,12 @@ namespace {
// Invoked from the nested message loop. // Invoked from the nested message loop.
void DragAllToSeparateWindowStep2(DetachToBrowserTabDragControllerTest* test, void DragAllToSeparateWindowStep2(DetachToBrowserTabDragControllerTest* test,
TabStrip* attached_tab_strip, TabStrip* attached_tab_strip,
TabStrip* target_tab_strip) { TabStrip* target_tab_strip,
const chrome::BrowserListImpl* browser_list) {
ASSERT_TRUE(attached_tab_strip->IsDragSessionActive()); ASSERT_TRUE(attached_tab_strip->IsDragSessionActive());
ASSERT_FALSE(target_tab_strip->IsDragSessionActive()); ASSERT_FALSE(target_tab_strip->IsDragSessionActive());
ASSERT_TRUE(TabDragController::IsActive()); ASSERT_TRUE(TabDragController::IsActive());
ASSERT_EQ(2u, BrowserList::size()); ASSERT_EQ(2u, browser_list->size());
// Drag to target_tab_strip. This should stop the nested loop from dragging // Drag to target_tab_strip. This should stop the nested loop from dragging
// the window. // the window.
...@@ -723,13 +731,14 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, ...@@ -723,13 +731,14 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
ASSERT_TRUE(PressInput(tab_0_center)); ASSERT_TRUE(PressInput(tab_0_center));
ASSERT_TRUE(DragInputToNotifyWhenDone( ASSERT_TRUE(DragInputToNotifyWhenDone(
tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip),
base::Bind(&DragAllToSeparateWindowStep2, this, tab_strip, tab_strip2))); base::Bind(&DragAllToSeparateWindowStep2, this, tab_strip, tab_strip2,
native_browser_list)));
QuitWhenNotDragging(); QuitWhenNotDragging();
// Should now be attached to tab_strip2. // Should now be attached to tab_strip2.
ASSERT_TRUE(tab_strip2->IsDragSessionActive()); ASSERT_TRUE(tab_strip2->IsDragSessionActive());
ASSERT_TRUE(TabDragController::IsActive()); ASSERT_TRUE(TabDragController::IsActive());
ASSERT_EQ(1u, BrowserList::size()); ASSERT_EQ(1u, native_browser_list->size());
// Release the mouse, stopping the drag session. // Release the mouse, stopping the drag session.
ASSERT_TRUE(ReleaseInput()); ASSERT_TRUE(ReleaseInput());
...@@ -746,11 +755,12 @@ namespace { ...@@ -746,11 +755,12 @@ namespace {
void DragAllToSeparateWindowAndCancelStep2( void DragAllToSeparateWindowAndCancelStep2(
DetachToBrowserTabDragControllerTest* test, DetachToBrowserTabDragControllerTest* test,
TabStrip* attached_tab_strip, TabStrip* attached_tab_strip,
TabStrip* target_tab_strip) { TabStrip* target_tab_strip,
const chrome::BrowserListImpl* browser_list) {
ASSERT_TRUE(attached_tab_strip->IsDragSessionActive()); ASSERT_TRUE(attached_tab_strip->IsDragSessionActive());
ASSERT_FALSE(target_tab_strip->IsDragSessionActive()); ASSERT_FALSE(target_tab_strip->IsDragSessionActive());
ASSERT_TRUE(TabDragController::IsActive()); ASSERT_TRUE(TabDragController::IsActive());
ASSERT_EQ(2u, BrowserList::size()); ASSERT_EQ(2u, browser_list->size());
// Drag to target_tab_strip. This should stop the nested loop from dragging // Drag to target_tab_strip. This should stop the nested loop from dragging
// the window. // the window.
...@@ -786,13 +796,13 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, ...@@ -786,13 +796,13 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
ASSERT_TRUE(DragInputToNotifyWhenDone( ASSERT_TRUE(DragInputToNotifyWhenDone(
tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip),
base::Bind(&DragAllToSeparateWindowAndCancelStep2, this, base::Bind(&DragAllToSeparateWindowAndCancelStep2, this,
tab_strip, tab_strip2))); tab_strip, tab_strip2, native_browser_list)));
QuitWhenNotDragging(); QuitWhenNotDragging();
// Should now be attached to tab_strip2. // Should now be attached to tab_strip2.
ASSERT_TRUE(tab_strip2->IsDragSessionActive()); ASSERT_TRUE(tab_strip2->IsDragSessionActive());
ASSERT_TRUE(TabDragController::IsActive()); ASSERT_TRUE(TabDragController::IsActive());
ASSERT_EQ(1u, BrowserList::size()); ASSERT_EQ(1u, native_browser_list->size());
// Cancel the drag. // Cancel the drag.
ASSERT_TRUE(ui_test_utils::SendKeyPressSync( ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
...@@ -803,7 +813,7 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, ...@@ -803,7 +813,7 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
EXPECT_EQ("100 0 1", IDString(browser2->tab_strip_model())); EXPECT_EQ("100 0 1", IDString(browser2->tab_strip_model()));
// browser() will have been destroyed, but browser2 should remain. // browser() will have been destroyed, but browser2 should remain.
ASSERT_EQ(1u, BrowserList::size()); ASSERT_EQ(1u, native_browser_list->size());
EXPECT_TRUE(GetTrackedByWorkspace(browser2)); EXPECT_TRUE(GetTrackedByWorkspace(browser2));
} }
...@@ -872,13 +882,14 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, ...@@ -872,13 +882,14 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
ASSERT_TRUE(PressInput(tab_0_center)); ASSERT_TRUE(PressInput(tab_0_center));
ASSERT_TRUE(DragInputToNotifyWhenDone( ASSERT_TRUE(DragInputToNotifyWhenDone(
tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip),
base::Bind(&DragAllToSeparateWindowStep2, this, tab_strip, tab_strip2))); base::Bind(&DragAllToSeparateWindowStep2, this, tab_strip, tab_strip2,
native_browser_list)));
QuitWhenNotDragging(); QuitWhenNotDragging();
// Should now be attached to tab_strip2. // Should now be attached to tab_strip2.
ASSERT_TRUE(tab_strip2->IsDragSessionActive()); ASSERT_TRUE(tab_strip2->IsDragSessionActive());
ASSERT_TRUE(TabDragController::IsActive()); ASSERT_TRUE(TabDragController::IsActive());
ASSERT_EQ(1u, BrowserList::size()); ASSERT_EQ(1u, native_browser_list->size());
// Release the mouse, stopping the drag session. // Release the mouse, stopping the drag session.
ASSERT_TRUE(ReleaseInput()); ASSERT_TRUE(ReleaseInput());
...@@ -900,12 +911,13 @@ namespace { ...@@ -900,12 +911,13 @@ namespace {
// Invoked from the nested message loop. // Invoked from the nested message loop.
void CancelOnNewTabWhenDraggingStep2( void CancelOnNewTabWhenDraggingStep2(
DetachToBrowserTabDragControllerTest* test) { DetachToBrowserTabDragControllerTest* test,
const chrome::BrowserListImpl* browser_list) {
ASSERT_TRUE(TabDragController::IsActive()); ASSERT_TRUE(TabDragController::IsActive());
ASSERT_EQ(2u, BrowserList::size()); ASSERT_EQ(2u, browser_list->size());
// Add another tab. This shoudl trigger exiting the nested loop. // Add another tab. This should trigger exiting the nested loop.
test->AddBlankTabAndShow(*BrowserList::begin_last_active()); test->AddBlankTabAndShow(browser_list->GetLastActive());
} }
} // namespace } // namespace
...@@ -925,16 +937,14 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, ...@@ -925,16 +937,14 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
ASSERT_TRUE(PressInput(tab_0_center)); ASSERT_TRUE(PressInput(tab_0_center));
ASSERT_TRUE(DragInputToNotifyWhenDone( ASSERT_TRUE(DragInputToNotifyWhenDone(
tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip),
base::Bind(&CancelOnNewTabWhenDraggingStep2, this))); base::Bind(&CancelOnNewTabWhenDraggingStep2, this, native_browser_list)));
QuitWhenNotDragging(); QuitWhenNotDragging();
// Should be two windows and not dragging. // Should be two windows and not dragging.
ASSERT_FALSE(TabDragController::IsActive()); ASSERT_FALSE(TabDragController::IsActive());
ASSERT_EQ(2u, BrowserList::size()); ASSERT_EQ(2u, native_browser_list->size());
for (BrowserList::const_iterator i = BrowserList::begin(); for (chrome::BrowserIterator it; !it.done(); it.Next())
i != BrowserList::end(); ++i) { EXPECT_TRUE(GetTrackedByWorkspace(*it));
EXPECT_TRUE(GetTrackedByWorkspace(*i));
}
} }
#if defined(USE_ASH) && !defined(OS_WIN) // TODO(win_ash) #if defined(USE_ASH) && !defined(OS_WIN) // TODO(win_ash)
...@@ -943,10 +953,11 @@ namespace { ...@@ -943,10 +953,11 @@ namespace {
void DragInMaximizedWindowStep2(DetachToBrowserTabDragControllerTest* test, void DragInMaximizedWindowStep2(DetachToBrowserTabDragControllerTest* test,
Browser* browser, Browser* browser,
TabStrip* tab_strip) { TabStrip* tab_strip,
const chrome::BrowserListImpl* browser_list) {
// There should be another browser. // There should be another browser.
ASSERT_EQ(2u, BrowserList::size()); ASSERT_EQ(2u, browser_list->size());
Browser* new_browser = *(++BrowserList::begin()); Browser* new_browser = browser_list->get(1);
EXPECT_NE(browser, new_browser); EXPECT_NE(browser, new_browser);
ASSERT_TRUE(new_browser->window()->IsActive()); ASSERT_TRUE(new_browser->window()->IsActive());
TabStrip* tab_strip2 = GetTabStripForBrowser(new_browser); TabStrip* tab_strip2 = GetTabStripForBrowser(new_browser);
...@@ -978,14 +989,15 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, ...@@ -978,14 +989,15 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
ASSERT_TRUE(PressInput(tab_0_center)); ASSERT_TRUE(PressInput(tab_0_center));
ASSERT_TRUE(DragInputToNotifyWhenDone( ASSERT_TRUE(DragInputToNotifyWhenDone(
tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip),
base::Bind(&DragInMaximizedWindowStep2, this, browser(), tab_strip))); base::Bind(&DragInMaximizedWindowStep2, this, browser(), tab_strip,
native_browser_list)));
QuitWhenNotDragging(); QuitWhenNotDragging();
ASSERT_FALSE(TabDragController::IsActive()); ASSERT_FALSE(TabDragController::IsActive());
// Should be two browsers. // Should be two browsers.
ASSERT_EQ(2u, BrowserList::size()); ASSERT_EQ(2u, native_browser_list->size());
Browser* new_browser = *(++BrowserList::begin()); Browser* new_browser = native_browser_list->get(1);
ASSERT_TRUE(new_browser->window()->IsActive()); ASSERT_TRUE(new_browser->window()->IsActive());
// Only the new browser should be visible. // Only the new browser should be visible.
...@@ -1052,8 +1064,8 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserInSeparateDisplayTabDragControllerTest, ...@@ -1052,8 +1064,8 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserInSeparateDisplayTabDragControllerTest,
ASSERT_FALSE(TabDragController::IsActive()); ASSERT_FALSE(TabDragController::IsActive());
// There should now be another browser. // There should now be another browser.
ASSERT_EQ(2u, BrowserList::size()); ASSERT_EQ(2u, native_browser_list->size());
Browser* new_browser = *(++BrowserList::begin()); Browser* new_browser = native_browser_list->get(1);
ASSERT_TRUE(new_browser->window()->IsActive()); ASSERT_TRUE(new_browser->window()->IsActive());
TabStrip* tab_strip2 = GetTabStripForBrowser(new_browser); TabStrip* tab_strip2 = GetTabStripForBrowser(new_browser);
ASSERT_FALSE(tab_strip2->IsDragSessionActive()); ASSERT_FALSE(tab_strip2->IsDragSessionActive());
...@@ -1266,10 +1278,11 @@ class DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest ...@@ -1266,10 +1278,11 @@ class DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest
// Invoked from the nested message loop. // Invoked from the nested message loop.
void CancelDragTabToWindowInSeparateDisplayStep3( void CancelDragTabToWindowInSeparateDisplayStep3(
TabStrip* tab_strip) { TabStrip* tab_strip,
const chrome::BrowserListImpl* browser_list) {
ASSERT_FALSE(tab_strip->IsDragSessionActive()); ASSERT_FALSE(tab_strip->IsDragSessionActive());
ASSERT_TRUE(TabDragController::IsActive()); ASSERT_TRUE(TabDragController::IsActive());
ASSERT_EQ(2u, BrowserList::size()); ASSERT_EQ(2u, browser_list->size());
// Switching display mode should cancel the drag operation. // Switching display mode should cancel the drag operation.
ash::internal::DisplayManager::CycleDisplay(); ash::internal::DisplayManager::CycleDisplay();
...@@ -1280,19 +1293,20 @@ void CancelDragTabToWindowInSeparateDisplayStep2( ...@@ -1280,19 +1293,20 @@ void CancelDragTabToWindowInSeparateDisplayStep2(
DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest* test, DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest* test,
TabStrip* tab_strip, TabStrip* tab_strip,
aura::RootWindow* current_root, aura::RootWindow* current_root,
gfx::Point final_destination) { gfx::Point final_destination,
const chrome::BrowserListImpl* browser_list) {
ASSERT_FALSE(tab_strip->IsDragSessionActive()); ASSERT_FALSE(tab_strip->IsDragSessionActive());
ASSERT_TRUE(TabDragController::IsActive()); ASSERT_TRUE(TabDragController::IsActive());
ASSERT_EQ(2u, BrowserList::size()); ASSERT_EQ(2u, browser_list->size());
Browser* new_browser = *(++BrowserList::begin()); Browser* new_browser = browser_list->get(1);
EXPECT_EQ(current_root, EXPECT_EQ(current_root,
new_browser->window()->GetNativeWindow()->GetRootWindow()); new_browser->window()->GetNativeWindow()->GetRootWindow());
ASSERT_TRUE(test->DragTabAndExecuteTaskWhenDone( ASSERT_TRUE(test->DragTabAndExecuteTaskWhenDone(
final_destination, final_destination,
base::Bind(&CancelDragTabToWindowInSeparateDisplayStep3, base::Bind(&CancelDragTabToWindowInSeparateDisplayStep3,
tab_strip))); tab_strip, browser_list)));
} }
} // namespace } // namespace
...@@ -1321,10 +1335,11 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1321,10 +1335,11 @@ IN_PROC_BROWSER_TEST_F(
tab_0_dst.Offset(0, GetDetachY(tab_strip)); tab_0_dst.Offset(0, GetDetachY(tab_strip));
ASSERT_TRUE(DragTabAndExecuteTaskWhenDone( ASSERT_TRUE(DragTabAndExecuteTaskWhenDone(
tab_0_dst, base::Bind(&CancelDragTabToWindowInSeparateDisplayStep2, tab_0_dst, base::Bind(&CancelDragTabToWindowInSeparateDisplayStep2,
this, tab_strip, roots[0], final_destination))); this, tab_strip, roots[0], final_destination,
native_browser_list)));
QuitWhenNotDragging(); QuitWhenNotDragging();
ASSERT_EQ(1u, BrowserList::size()); ASSERT_EQ(1u, native_browser_list->size());
ASSERT_FALSE(tab_strip->IsDragSessionActive()); ASSERT_FALSE(tab_strip->IsDragSessionActive());
ASSERT_FALSE(TabDragController::IsActive()); ASSERT_FALSE(TabDragController::IsActive());
EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); EXPECT_EQ("0 1", IDString(browser()->tab_strip_model()));
...@@ -1365,10 +1380,11 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1365,10 +1380,11 @@ IN_PROC_BROWSER_TEST_F(
tab_0_dst.Offset(0, GetDetachY(tab_strip)); tab_0_dst.Offset(0, GetDetachY(tab_strip));
ASSERT_TRUE(DragTabAndExecuteTaskWhenDone( ASSERT_TRUE(DragTabAndExecuteTaskWhenDone(
tab_0_dst, base::Bind(&CancelDragTabToWindowInSeparateDisplayStep2, tab_0_dst, base::Bind(&CancelDragTabToWindowInSeparateDisplayStep2,
this, tab_strip, roots[1], final_destination))); this, tab_strip, roots[1], final_destination,
native_browser_list)));
QuitWhenNotDragging(); QuitWhenNotDragging();
ASSERT_EQ(1u, BrowserList::size()); ASSERT_EQ(1u, native_browser_list->size());
ASSERT_FALSE(tab_strip->IsDragSessionActive()); ASSERT_FALSE(tab_strip->IsDragSessionActive());
ASSERT_FALSE(TabDragController::IsActive()); ASSERT_FALSE(TabDragController::IsActive());
EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); EXPECT_EQ("0 1", IDString(browser()->tab_strip_model()));
......
...@@ -13,6 +13,10 @@ class Browser; ...@@ -13,6 +13,10 @@ class Browser;
class TabStrip; class TabStrip;
class TabStripModel; class TabStripModel;
namespace chrome {
class BrowserListImpl;
}
namespace content { namespace content {
class WebContents; class WebContents;
} }
...@@ -43,6 +47,10 @@ class TabDragControllerTest : public InProcessBrowserTest { ...@@ -43,6 +47,10 @@ class TabDragControllerTest : public InProcessBrowserTest {
// side by side. // side by side.
Browser* CreateAnotherWindowBrowserAndRelayout(); Browser* CreateAnotherWindowBrowserAndRelayout();
// The tab drag controller interactive ui tests only use the native desktop
// for now.
const chrome::BrowserListImpl* native_browser_list;
private: private:
DISALLOW_COPY_AND_ASSIGN(TabDragControllerTest); DISALLOW_COPY_AND_ASSIGN(TabDragControllerTest);
}; };
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list_impl.h"
#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/browser_view.h"
...@@ -129,8 +129,8 @@ IN_PROC_BROWSER_TEST_F(TabDragControllerTest, DetachToOwnWindow) { ...@@ -129,8 +129,8 @@ IN_PROC_BROWSER_TEST_F(TabDragControllerTest, DetachToOwnWindow) {
ASSERT_FALSE(TabDragController::IsActive()); ASSERT_FALSE(TabDragController::IsActive());
// There should now be another browser. // There should now be another browser.
ASSERT_EQ(2u, BrowserList::size()); ASSERT_EQ(2u, native_browser_list->size());
Browser* new_browser = *(++BrowserList::begin()); Browser* new_browser = native_browser_list->get(1);
ASSERT_TRUE(new_browser->window()->IsActive()); ASSERT_TRUE(new_browser->window()->IsActive());
TabStrip* tab_strip2 = GetTabStripForBrowser(new_browser); TabStrip* tab_strip2 = GetTabStripForBrowser(new_browser);
ASSERT_FALSE(tab_strip2->IsDragSessionActive()); ASSERT_FALSE(tab_strip2->IsDragSessionActive());
...@@ -247,8 +247,8 @@ IN_PROC_BROWSER_TEST_F(TabDragControllerTest, DeleteSourceDetached) { ...@@ -247,8 +247,8 @@ IN_PROC_BROWSER_TEST_F(TabDragControllerTest, DeleteSourceDetached) {
// Releasing the mouse should destroy the existing browser and create a new // Releasing the mouse should destroy the existing browser and create a new
// one. // one.
ASSERT_EQ(1u, BrowserList::size()); ASSERT_EQ(1u, native_browser_list->size());
Browser* new_browser = *BrowserList::begin(); Browser* new_browser = native_browser_list->get(0);
EXPECT_NE(new_browser, browser()); EXPECT_NE(new_browser, browser());
ASSERT_FALSE(GetTabStripForBrowser(new_browser)->IsDragSessionActive()); ASSERT_FALSE(GetTabStripForBrowser(new_browser)->IsDragSessionActive());
...@@ -285,7 +285,7 @@ IN_PROC_BROWSER_TEST_F(TabDragControllerTest, DragAllToSeparateWindow) { ...@@ -285,7 +285,7 @@ IN_PROC_BROWSER_TEST_F(TabDragControllerTest, DragAllToSeparateWindow) {
ASSERT_TRUE(tab_strip->IsDragSessionActive()); ASSERT_TRUE(tab_strip->IsDragSessionActive());
ASSERT_FALSE(tab_strip2->IsDragSessionActive()); ASSERT_FALSE(tab_strip2->IsDragSessionActive());
ASSERT_TRUE(TabDragController::IsActive()); ASSERT_TRUE(TabDragController::IsActive());
ASSERT_EQ(2u, BrowserList::size()); ASSERT_EQ(2u, native_browser_list->size());
// Drag to tab_strip2. // Drag to tab_strip2.
gfx::Point target_point(tab_strip2->width() - 1, gfx::Point target_point(tab_strip2->width() - 1,
...@@ -333,7 +333,7 @@ IN_PROC_BROWSER_TEST_F(TabDragControllerTest, ...@@ -333,7 +333,7 @@ IN_PROC_BROWSER_TEST_F(TabDragControllerTest,
ASSERT_TRUE(tab_strip->IsDragSessionActive()); ASSERT_TRUE(tab_strip->IsDragSessionActive());
ASSERT_FALSE(tab_strip2->IsDragSessionActive()); ASSERT_FALSE(tab_strip2->IsDragSessionActive());
ASSERT_TRUE(TabDragController::IsActive()); ASSERT_TRUE(TabDragController::IsActive());
ASSERT_EQ(2u, BrowserList::size()); ASSERT_EQ(2u, native_browser_list->size());
// Drag to tab_strip2. // Drag to tab_strip2.
gfx::Point target_point(tab_strip2->width() - 1, gfx::Point target_point(tab_strip2->width() - 1,
...@@ -343,7 +343,7 @@ IN_PROC_BROWSER_TEST_F(TabDragControllerTest, ...@@ -343,7 +343,7 @@ IN_PROC_BROWSER_TEST_F(TabDragControllerTest,
ASSERT_TRUE(tab_strip->IsDragSessionActive()); ASSERT_TRUE(tab_strip->IsDragSessionActive());
ASSERT_TRUE(TabDragController::IsActive()); ASSERT_TRUE(TabDragController::IsActive());
ASSERT_EQ(2u, BrowserList::size()); ASSERT_EQ(2u, native_browser_list->size());
// Cancel the drag. // Cancel the drag.
ASSERT_TRUE(ui_test_utils::SendKeyPressSync( ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
...@@ -352,7 +352,7 @@ IN_PROC_BROWSER_TEST_F(TabDragControllerTest, ...@@ -352,7 +352,7 @@ IN_PROC_BROWSER_TEST_F(TabDragControllerTest,
ASSERT_FALSE(tab_strip->IsDragSessionActive()); ASSERT_FALSE(tab_strip->IsDragSessionActive());
ASSERT_FALSE(tab_strip2->IsDragSessionActive()); ASSERT_FALSE(tab_strip2->IsDragSessionActive());
ASSERT_FALSE(TabDragController::IsActive()); ASSERT_FALSE(TabDragController::IsActive());
ASSERT_EQ(2u, BrowserList::size()); ASSERT_EQ(2u, native_browser_list->size());
EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); EXPECT_EQ("0 1", IDString(browser()->tab_strip_model()));
EXPECT_EQ("100", IDString(browser2->tab_strip_model())); EXPECT_EQ("100", IDString(browser2->tab_strip_model()));
} }
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