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();
......
...@@ -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