Index: chrome/browser/ui/panels/old_base_panel_browser_test.cc |
=================================================================== |
--- chrome/browser/ui/panels/old_base_panel_browser_test.cc (revision 141691) |
+++ chrome/browser/ui/panels/old_base_panel_browser_test.cc (working copy) |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/ui/panels/old_base_panel_browser_test.h" |
+#include "chrome/browser/ui/panels/base_panel_browser_test.h" |
#include "chrome/browser/ui/browser_list.h" |
@@ -55,7 +55,7 @@ |
}; |
class MockDisplaySettingsProviderImpl : |
- public OldBasePanelBrowserTest::MockDisplaySettingsProvider { |
+ public BasePanelBrowserTest::MockDisplaySettingsProvider { |
public: |
explicit MockDisplaySettingsProviderImpl(PanelManager* panel_manager); |
virtual ~MockDisplaySettingsProviderImpl() { } |
@@ -187,10 +187,10 @@ |
} // namespace |
-const FilePath::CharType* OldBasePanelBrowserTest::kTestDir = |
+const FilePath::CharType* BasePanelBrowserTest::kTestDir = |
FILE_PATH_LITERAL("panels"); |
-OldBasePanelBrowserTest::OldBasePanelBrowserTest() |
+BasePanelBrowserTest::BasePanelBrowserTest() |
: InProcessBrowserTest(), |
mock_display_settings_enabled_(true) { |
#if defined(OS_MACOSX) |
@@ -198,10 +198,10 @@ |
#endif |
} |
-OldBasePanelBrowserTest::~OldBasePanelBrowserTest() { |
+BasePanelBrowserTest::~BasePanelBrowserTest() { |
} |
-bool OldBasePanelBrowserTest::SkipTestIfIceWM() { |
+bool BasePanelBrowserTest::SkipTestIfIceWM() { |
#if defined(OS_LINUX) |
return ui::GuessWindowManager() == ui::WM_ICE_WM; |
#else |
@@ -209,7 +209,7 @@ |
#endif |
} |
-bool OldBasePanelBrowserTest::SkipTestIfCompizWM() { |
+bool BasePanelBrowserTest::SkipTestIfCompizWM() { |
#if defined(OS_LINUX) |
return ui::GuessWindowManager() == ui::WM_COMPIZ; |
#else |
@@ -217,12 +217,12 @@ |
#endif |
} |
-void OldBasePanelBrowserTest::SetUpCommandLine(CommandLine* command_line) { |
+void BasePanelBrowserTest::SetUpCommandLine(CommandLine* command_line) { |
EnableDOMAutomation(); |
command_line->AppendSwitch(switches::kEnablePanels); |
} |
-void OldBasePanelBrowserTest::SetUpOnMainThread() { |
+void BasePanelBrowserTest::SetUpOnMainThread() { |
InProcessBrowserTest::SetUpOnMainThread(); |
// Setup the work area and desktop bar so that we have consistent testing |
@@ -243,7 +243,7 @@ |
ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
} |
-void OldBasePanelBrowserTest::WaitForPanelActiveState( |
+void BasePanelBrowserTest::WaitForPanelActiveState( |
Panel* panel, ActiveState expected_state) { |
DCHECK(expected_state == SHOW_AS_ACTIVE || |
expected_state == SHOW_AS_INACTIVE); |
@@ -257,7 +257,7 @@ |
EXPECT_TRUE(panel->IsActive() == (expected_state == SHOW_AS_ACTIVE)); |
} |
-void OldBasePanelBrowserTest::WaitForWindowSizeAvailable(Panel* panel) { |
+void BasePanelBrowserTest::WaitForWindowSizeAvailable(Panel* panel) { |
scoped_ptr<NativePanelTesting> panel_testing( |
NativePanelTesting::Create(panel->native_panel())); |
ui_test_utils::WindowedNotificationObserver signal( |
@@ -269,7 +269,7 @@ |
EXPECT_TRUE(panel_testing->IsWindowSizeKnown()); |
} |
-void OldBasePanelBrowserTest::WaitForBoundsAnimationFinished(Panel* panel) { |
+void BasePanelBrowserTest::WaitForBoundsAnimationFinished(Panel* panel) { |
scoped_ptr<NativePanelTesting> panel_testing( |
NativePanelTesting::Create(panel->native_panel())); |
ui_test_utils::WindowedNotificationObserver signal( |
@@ -281,7 +281,7 @@ |
EXPECT_TRUE(!panel_testing->IsAnimatingBounds()); |
} |
-void OldBasePanelBrowserTest::WaitForExpansionStateChanged( |
+void BasePanelBrowserTest::WaitForExpansionStateChanged( |
Panel* panel, Panel::ExpansionState expansion_state) { |
ui_test_utils::WindowedNotificationObserver signal( |
chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE, |
@@ -292,7 +292,7 @@ |
EXPECT_EQ(expansion_state, panel->expansion_state()); |
} |
-Panel* OldBasePanelBrowserTest::CreatePanelWithParams( |
+Panel* BasePanelBrowserTest::CreatePanelWithParams( |
const CreatePanelParams& params) { |
#if defined(OS_MACOSX) |
// Opening panels on a Mac causes NSWindowController of the Panel window |
@@ -330,6 +330,20 @@ |
EXPECT_TRUE(panel->auto_resizable()); |
} |
+#if defined(OS_LINUX) |
+ // On bots, we might have a simple window manager which always activates new |
+ // windows, and can't always deactivate them. Keep track of the previously |
+ // active window so we can activate that window back to ensure the new window |
+ // is inactive. |
+ Browser* last_active_browser_to_restore = NULL; |
+ if (params.expected_active_state == SHOW_AS_INACTIVE && |
+ ui::GuessWindowManager() == ui::WM_ICE_WM) { |
+ last_active_browser_to_restore = BrowserList::GetLastActive(); |
+ EXPECT_TRUE(last_active_browser_to_restore); |
+ EXPECT_NE(last_active_browser_to_restore, panel_browser); |
+ } |
+#endif |
+ |
if (params.show_flag == SHOW_AS_ACTIVE) { |
panel->Show(); |
} else { |
@@ -340,13 +354,9 @@ |
MessageLoopForUI::current()->RunAllPending(); |
#if defined(OS_LINUX) |
- // On bots, we might have a simple window manager which always activates new |
- // windows, and can't always deactivate them. Re-activate the main tabbed |
- // browser to "deactivate" the newly created panel. |
- if (params.expected_active_state == SHOW_AS_INACTIVE && |
- ui::GuessWindowManager() == ui::WM_ICE_WM) { |
- browser()->window()->Activate(); |
- } |
+ // Restore focus where it was. It will deactivate the new panel. |
+ if (last_active_browser_to_restore) |
+ last_active_browser_to_restore->window()->Activate(); |
#endif |
// More waiting, because gaining or losing focus may require inter-process |
// asynchronous communication, and it is not enough to just run the local |
@@ -364,25 +374,25 @@ |
return panel; |
} |
-Panel* OldBasePanelBrowserTest::CreatePanelWithBounds( |
+Panel* BasePanelBrowserTest::CreatePanelWithBounds( |
const std::string& panel_name, const gfx::Rect& bounds) { |
CreatePanelParams params(panel_name, bounds, SHOW_AS_ACTIVE); |
return CreatePanelWithParams(params); |
} |
-Panel* OldBasePanelBrowserTest::CreatePanel(const std::string& panel_name) { |
+Panel* BasePanelBrowserTest::CreatePanel(const std::string& panel_name) { |
CreatePanelParams params(panel_name, gfx::Rect(), SHOW_AS_ACTIVE); |
return CreatePanelWithParams(params); |
} |
-Panel* OldBasePanelBrowserTest::CreateDockedPanel(const std::string& name, |
+Panel* BasePanelBrowserTest::CreateDockedPanel(const std::string& name, |
const gfx::Rect& bounds) { |
Panel* panel = CreatePanelWithBounds(name, bounds); |
EXPECT_EQ(PanelStrip::DOCKED, panel->panel_strip()->type()); |
return panel; |
} |
-Panel* OldBasePanelBrowserTest::CreateDetachedPanel(const std::string& name, |
+Panel* BasePanelBrowserTest::CreateDetachedPanel(const std::string& name, |
const gfx::Rect& bounds) { |
Panel* panel = CreatePanelWithBounds(name, bounds); |
panel->manager()->MovePanelToStrip(panel, |
@@ -397,14 +407,14 @@ |
return panel; |
} |
-void OldBasePanelBrowserTest::CreateTestTabContents(Browser* browser) { |
+void BasePanelBrowserTest::CreateTestTabContents(Browser* browser) { |
TabContentsWrapper* tab_contents = |
new TabContentsWrapper( |
WebContentsTester::CreateTestWebContents(browser->profile(), NULL)); |
browser->AddTab(tab_contents, content::PAGE_TRANSITION_LINK); |
} |
-scoped_refptr<Extension> OldBasePanelBrowserTest::CreateExtension( |
+scoped_refptr<Extension> BasePanelBrowserTest::CreateExtension( |
const FilePath::StringType& path, |
Extension::Location location, |
const DictionaryValue& extra_value) { |
@@ -429,16 +439,15 @@ |
return extension; |
} |
-void OldBasePanelBrowserTest::SetTestingAreas( |
- const gfx::Rect& primary_screen_area, |
- const gfx::Rect& work_area) { |
+void BasePanelBrowserTest::SetTestingAreas(const gfx::Rect& primary_screen_area, |
+ const gfx::Rect& work_area) { |
DCHECK(primary_screen_area.Contains(work_area)); |
mock_display_settings_provider_->SetPrimaryScreenArea(primary_screen_area); |
mock_display_settings_provider_->SetWorkArea( |
work_area.IsEmpty() ? primary_screen_area : work_area); |
} |
-void OldBasePanelBrowserTest::CloseWindowAndWait(Panel* panel) { |
+void BasePanelBrowserTest::CloseWindowAndWait(Panel* panel) { |
// Closing a panel may involve several async tasks. Need to use |
// message pump and wait for the notification. |
PanelManager* manager = PanelManager::GetInstance(); |
@@ -463,7 +472,7 @@ |
#endif // OS_MACOSX |
} |
-void OldBasePanelBrowserTest::MoveMouseAndWaitForExpansionStateChange( |
+void BasePanelBrowserTest::MoveMouseAndWaitForExpansionStateChange( |
Panel* panel, |
const gfx::Point& position) { |
ui_test_utils::WindowedNotificationObserver signal( |
@@ -473,11 +482,11 @@ |
signal.Wait(); |
} |
-void OldBasePanelBrowserTest::MoveMouse(const gfx::Point& position) { |
+void BasePanelBrowserTest::MoveMouse(const gfx::Point& position) { |
PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); |
} |
-std::string OldBasePanelBrowserTest::MakePanelName(int index) { |
+std::string BasePanelBrowserTest::MakePanelName(int index) { |
std::string panel_name("Panel"); |
return panel_name + base::IntToString(index); |
} |