Index: chrome/browser/ui/panels/base_panel_browser_test.cc |
diff --git a/chrome/browser/ui/panels/base_panel_browser_test.cc b/chrome/browser/ui/panels/base_panel_browser_test.cc |
index 0b662197c32f424d26f0aa27f6536b456ce779d2..8f3b6fb7691fc109329cff508f173977fdb7d7de 100644 |
--- a/chrome/browser/ui/panels/base_panel_browser_test.cc |
+++ b/chrome/browser/ui/panels/base_panel_browser_test.cc |
@@ -11,11 +11,13 @@ |
#include "base/memory/weak_ptr.h" |
#include "base/message_loop.h" |
#include "base/path_service.h" |
+#include "base/string_number_conversions.h" |
#include "chrome/browser/extensions/extension_service.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/panels/native_panel.h" |
#include "chrome/browser/ui/panels/panel_manager.h" |
+#include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
#include "chrome/common/chrome_paths.h" |
#include "chrome/common/chrome_switches.h" |
@@ -152,7 +154,7 @@ void MockAutoHidingDesktopBarImpl::NotifyThicknessChange() { |
} |
bool ExistsPanel(Panel* panel) { |
- const PanelManager::Panels& panels = PanelManager::GetInstance()->panels(); |
+ std::vector<Panel*> panels = PanelManager::GetInstance()->panels(); |
return find(panels.begin(), panels.end(), panel) != panels.end(); |
} |
@@ -325,18 +327,21 @@ Panel* BasePanelBrowserTest::CreatePanelWithParams( |
panel->ShowInactive(); |
#endif |
} |
- MessageLoopForUI::current()->RunAllPending(); |
- // More waiting, because gaining or losing focus may require inter-process |
- // asynchronous communication, and it is not enough to just run the local |
- // message loop to make sure this activity has completed. |
- WaitForPanelActiveState(panel, params.show_flag); |
- // On Linux, window size is not available right away and we should wait |
- // before moving forward with the test. |
- WaitForWindowSizeAvailable(panel); |
+ if (params.wait_for_fully_created) { |
+ MessageLoopForUI::current()->RunAllPending(); |
+ // More waiting, because gaining or losing focus may require inter-process |
+ // asynchronous communication, and it is not enough to just run the local |
+ // message loop to make sure this activity has completed. |
+ WaitForPanelActiveState(panel, params.show_flag); |
- // Wait for the bounds animations on creation to finish. |
- WaitForBoundsAnimationFinished(panel); |
+ // On Linux, window size is not available right away and we should wait |
+ // before moving forward with the test. |
+ WaitForWindowSizeAvailable(panel); |
+ |
+ // Wait for the bounds animations on creation to finish. |
+ WaitForBoundsAnimationFinished(panel); |
+ } |
return panel; |
} |
@@ -383,3 +388,25 @@ scoped_refptr<Extension> BasePanelBrowserTest::CreateExtension( |
OnExtensionInstalled(extension.get(), false, StringOrdinal()); |
return extension; |
} |
+ |
+void BasePanelBrowserTest::CloseWindowAndWait(Browser* browser) { |
+ // Closing a browser window may involve several async tasks. Need to use |
+ // message pump and wait for the notification. |
+ size_t browser_count = BrowserList::size(); |
+ ui_test_utils::WindowedNotificationObserver signal( |
+ chrome::NOTIFICATION_BROWSER_CLOSED, |
+ content::Source<Browser>(browser)); |
+ browser->CloseWindow(); |
+ signal.Wait(); |
+ // Now we have one less browser instance. |
+ EXPECT_EQ(browser_count - 1, BrowserList::size()); |
+} |
+ |
+void BasePanelBrowserTest::MoveMouse(const gfx::Point& position) { |
+ PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); |
+} |
+ |
+std::string BasePanelBrowserTest::MakePanelName(int index) { |
+ std::string panel_name("Panel"); |
+ return panel_name + base::IntToString(index); |
+} |