Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Unified Diff: chrome/browser/ui/panels/panel_browsertest.cc

Issue 8539025: Fix Panel to always detect when a tab is added. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Test cleanup and fix Mac test hang Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_window_gtk.cc ('k') | chrome/browser/ui/panels/panel_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/panels/panel_browsertest.cc
diff --git a/chrome/browser/ui/panels/panel_browsertest.cc b/chrome/browser/ui/panels/panel_browsertest.cc
index 8b146beab6fe09858c1248c059d139b15f2a3554..1d569a532a9011ecf128e2198bebdbbed001e847 100644
--- a/chrome/browser/ui/panels/panel_browsertest.cc
+++ b/chrome/browser/ui/panels/panel_browsertest.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/find_bar/find_bar.h"
@@ -850,32 +851,28 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, AutoResize) {
EXPECT_LE(100, initial_bounds.height());
// Expand the test page.
+ ui_test_utils::WindowedNotificationObserver enlarge(
+ chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
+ content::Source<Panel>(panel));
EXPECT_TRUE(ui_test_utils::ExecuteJavaScript(
panel->browser()->GetSelectedTabContents()->render_view_host(),
std::wstring(),
L"changeSize(50);"));
-
- // Wait until the bounds get changed.
- gfx::Rect bounds_on_grow;
- while ((bounds_on_grow = panel->GetBounds()) == initial_bounds) {
- MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
- MessageLoop::current()->RunAllPending();
- }
+ enlarge.Wait();
+ gfx::Rect bounds_on_grow = panel->GetBounds();
EXPECT_GT(bounds_on_grow.width(), initial_bounds.width());
EXPECT_EQ(bounds_on_grow.height(), initial_bounds.height());
// Shrink the test page.
+ ui_test_utils::WindowedNotificationObserver shrink(
+ chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
+ content::Source<Panel>(panel));
EXPECT_TRUE(ui_test_utils::ExecuteJavaScript(
panel->browser()->GetSelectedTabContents()->render_view_host(),
std::wstring(),
L"changeSize(-30);"));
-
- // Wait until the bounds get changed.
- gfx::Rect bounds_on_shrink;
- while ((bounds_on_shrink = panel->GetBounds()) == bounds_on_grow) {
- MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
- MessageLoop::current()->RunAllPending();
- }
+ shrink.Wait();
+ gfx::Rect bounds_on_shrink = panel->GetBounds();
EXPECT_LT(bounds_on_shrink.width(), bounds_on_grow.width());
EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width());
EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height());
@@ -1400,6 +1397,62 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest,
panel_other->Close();
}
+IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreateWithExistingContents) {
+ PanelManager::GetInstance()->enable_auto_sizing(true);
+
+ // Load contents into regular tabbed browser.
+ GURL url(ui_test_utils::GetTestUrl(
+ FilePath(FilePath::kCurrentDirectory),
+ FilePath(FILE_PATH_LITERAL("update-preferred-size.html"))));
+ ui_test_utils::NavigateToURL(browser(), url);
+ EXPECT_EQ(1, browser()->tab_count());
+
+ Profile* profile = browser()->profile();
+ CreatePanelParams params("PanelTest1", gfx::Rect(0, 0, 100, 100),
+ SHOW_AS_ACTIVE);
+ Panel* panel = CreatePanelWithParams(params);
+ Browser* panel_browser = panel->browser();
+ EXPECT_EQ(2U, BrowserList::size());
+
+ // Swap tab contents over to the panel from the tabbed browser.
+ TabContentsWrapper* contents =
+ browser()->tabstrip_model()->DetachTabContentsAt(0);
+ panel_browser->tabstrip_model()->InsertTabContentsAt(
+ 0, contents, TabStripModel::ADD_NONE);
+ panel_browser->SelectNumberedTab(0);
+ EXPECT_EQ(contents, panel_browser->GetSelectedTabContentsWrapper());
+ EXPECT_EQ(1, PanelManager::GetInstance()->num_panels());
+
+ // Ensure that the tab contents were noticed by the panel by
+ // verifying that the panel auto resizes correctly. (Panel
+ // enables auto resizing when tab contents are detected.)
+ int initial_width = panel->GetBounds().width();
+ EXPECT_LE(100, initial_width);
+
+ // Expand the test page.
+ ui_test_utils::WindowedNotificationObserver enlarge(
+ chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
+ content::Source<Panel>(panel));
+ EXPECT_TRUE(ui_test_utils::ExecuteJavaScript(
+ panel_browser->GetSelectedTabContents()->render_view_host(),
+ std::wstring(),
+ L"changeSize(50);"));
+ enlarge.Wait();
+ EXPECT_GT(panel->GetBounds().width(), initial_width);
+
+ // Swapping tab contents back to the browser should close the panel.
+ ui_test_utils::WindowedNotificationObserver signal(
+ chrome::NOTIFICATION_BROWSER_CLOSED,
+ content::Source<Browser>(panel_browser));
+ panel_browser->ConvertPopupToTabbedBrowser();
+ signal.Wait();
+ EXPECT_EQ(0, PanelManager::GetInstance()->num_panels());
+
+ Browser* tabbed_browser = BrowserList::FindTabbedBrowser(profile, false);
+ EXPECT_EQ(contents, tabbed_browser->GetSelectedTabContentsWrapper());
+ tabbed_browser->window()->Close();
+}
+
class PanelDownloadTest : public PanelBrowserTest {
public:
PanelDownloadTest() : PanelBrowserTest() { }
@@ -1724,14 +1777,12 @@ IN_PROC_BROWSER_TEST_F(PanelAndNotificationTest, NoOverlapping) {
// Closing short panel should move the notification balloon down to the same
// position when tall panel brings up its titlebar.
- panel1->Close();
- WaitForBoundsAnimationFinished(panel1);
+ CloseWindowAndWait(panel1->browser());
EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up,
GetBalloonBottomPosition(balloon));
// Closing the remaining tall panel should move the notification balloon back
// to its original position.
- panel2->Close();
- WaitForBoundsAnimationFinished(panel2);
+ CloseWindowAndWait(panel2->browser());
EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon));
}
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_window_gtk.cc ('k') | chrome/browser/ui/panels/panel_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698