diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-16 17:05:11 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-16 17:05:11 +0000 |
commit | 9c9c761a2e070a8a6eb00f22a4365fc6cc2e1eff (patch) | |
tree | 11e6d28d263457e00395401c938ff5fb45d6eba6 /chrome/browser/views | |
parent | 6920f5ac0d0ea336b79f02b5d36751d1043ace29 (diff) | |
download | chromium_src-9c9c761a2e070a8a6eb00f22a4365fc6cc2e1eff.zip chromium_src-9c9c761a2e070a8a6eb00f22a4365fc6cc2e1eff.tar.gz chromium_src-9c9c761a2e070a8a6eb00f22a4365fc6cc2e1eff.tar.bz2 |
Removes entirely dead code paths related to ConstrainedWindows.
- Removes parts of the interface that probably made sense at some time, but now only have a DLOG(INFO) as their implementation. Also remove their callers.
- Remove all usage of the ConstrainedWindowProxy interface in the automation system. It was *never* used.
- Rename constrianed_window_impl_interactive_uitests.cc to blocked_popup_container_interactive_uitest.cc. The test case hasn't tested code in constrained_window_impl.cc since the rewrite of the blocked popup system back last autumn.
Review URL: http://codereview.chromium.org/125160
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18498 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/constrained_window_impl.cc | 52 | ||||
-rw-r--r-- | chrome/browser/views/constrained_window_impl.h | 8 | ||||
-rw-r--r-- | chrome/browser/views/constrained_window_impl_interactive_uitest.cc | 233 |
3 files changed, 26 insertions, 267 deletions
diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc index af40fc5..4ff891e 100644 --- a/chrome/browser/views/constrained_window_impl.cc +++ b/chrome/browser/views/constrained_window_impl.cc @@ -592,28 +592,6 @@ views::NonClientFrameView* ConstrainedWindowImpl::CreateFrameViewForWindow() { return new ConstrainedWindowFrameView(this); } -void ConstrainedWindowImpl::ActivateConstrainedWindow() { - // Other pop-ups are simply moved to the front of the z-order. - SetWindowPos(HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); - - // Store the focus of our parent focus manager so we can restore it when we - // close. - views::FocusManager* focus_manager = - views::FocusManager::GetFocusManager(GetNativeView()); - DCHECK(focus_manager); - focus_manager = focus_manager->GetParentFocusManager(); - if (focus_manager) { - // We could not have a parent focus manager if the ConstrainedWindow is - // displayed in a tab that is not currently selected. - // TODO(jcampan): we should store the ConstrainedWindow active events in - // that case and replay them when the TabContents becomes selected. - focus_manager->StoreFocusedView(); - - // Give our window the focus so we get keyboard messages. - ::SetFocus(GetNativeView()); - } -} - void ConstrainedWindowImpl::CloseConstrainedWindow() { // Broadcast to all observers of NOTIFY_CWINDOW_CLOSED. // One example of such an observer is AutomationCWindowTracker in the @@ -625,14 +603,6 @@ void ConstrainedWindowImpl::CloseConstrainedWindow() { Close(); } -void ConstrainedWindowImpl::WasHidden() { - DLOG(INFO) << "WasHidden"; -} - -void ConstrainedWindowImpl::DidBecomeSelected() { - DLOG(INFO) << "DidBecomeSelected"; -} - std::wstring ConstrainedWindowImpl::GetWindowTitle() const { std::wstring display_title; if (GetDelegate()) @@ -671,6 +641,28 @@ void ConstrainedWindowImpl::InitAsDialog(const gfx::Rect& initial_bounds) { ActivateConstrainedWindow(); } +void ConstrainedWindowImpl::ActivateConstrainedWindow() { + // Other pop-ups are simply moved to the front of the z-order. + SetWindowPos(HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); + + // Store the focus of our parent focus manager so we can restore it when we + // close. + views::FocusManager* focus_manager = + views::FocusManager::GetFocusManager(GetNativeView()); + DCHECK(focus_manager); + focus_manager = focus_manager->GetParentFocusManager(); + if (focus_manager) { + // We could not have a parent focus manager if the ConstrainedWindow is + // displayed in a tab that is not currently selected. + // TODO(jcampan): we should store the ConstrainedWindow active events in + // that case and replay them when the TabContents becomes selected. + focus_manager->StoreFocusedView(); + + // Give our window the focus so we get keyboard messages. + ::SetFocus(GetNativeView()); + } +} + //////////////////////////////////////////////////////////////////////////////// // ConstrainedWindowImpl, views::WidgetWin overrides: diff --git a/chrome/browser/views/constrained_window_impl.h b/chrome/browser/views/constrained_window_impl.h index 0760a4d..2f3c32e 100644 --- a/chrome/browser/views/constrained_window_impl.h +++ b/chrome/browser/views/constrained_window_impl.h @@ -36,10 +36,6 @@ class ConstrainedWindowImpl : public ConstrainedWindow, // Overridden from ConstrainedWindow: virtual void CloseConstrainedWindow(); - virtual void ActivateConstrainedWindow(); - virtual void RepositionConstrainedWindowTo(const gfx::Point& anchor_point) {} - virtual void WasHidden(); - virtual void DidBecomeSelected(); virtual std::wstring GetWindowTitle() const; virtual const gfx::Rect& GetCurrentBounds() const; @@ -63,6 +59,10 @@ class ConstrainedWindowImpl : public ConstrainedWindow, // views::View client area. void InitAsDialog(const gfx::Rect& initial_bounds); + // Moves this window to the front of the Z-order and registers us with the + // focus manager. + void ActivateConstrainedWindow(); + // The TabContents that owns and constrains this ConstrainedWindow. TabContents* owner_; diff --git a/chrome/browser/views/constrained_window_impl_interactive_uitest.cc b/chrome/browser/views/constrained_window_impl_interactive_uitest.cc deleted file mode 100644 index fcd7639..0000000 --- a/chrome/browser/views/constrained_window_impl_interactive_uitest.cc +++ /dev/null @@ -1,233 +0,0 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <string> - -#include "app/l10n_util.h" -#include "base/file_path.h" -#include "chrome/browser/view_ids.h" -#include "chrome/common/chrome_constants.h" -#include "chrome/test/automation/automation_constants.h" -#include "chrome/test/automation/browser_proxy.h" -#include "chrome/test/automation/constrained_window_proxy.h" -#include "chrome/test/automation/tab_proxy.h" -#include "chrome/test/automation/window_proxy.h" -#include "chrome/test/ui/ui_test.h" -#include "grit/generated_resources.h" -#include "net/base/net_util.h" -#include "views/event.h" - -class InteractiveConstrainedWindowTest : public UITest { - protected: - InteractiveConstrainedWindowTest() { - show_window_ = true; - } - - virtual void SetUp() { - UITest::SetUp(); - - browser_ = automation()->GetBrowserWindow(0); - ASSERT_TRUE(browser_.get()); - - window_ = browser_->GetWindow(); - ASSERT_TRUE(window_.get()); - - tab_ = browser_->GetTab(0); - ASSERT_TRUE(tab_.get()); - } - - void NavigateMainTabTo(const std::wstring& file_name) { - FilePath filename(test_data_directory_); - filename = filename.AppendASCII("constrained_files"); - filename = filename.Append(FilePath::FromWStringHack(file_name)); - ASSERT_TRUE(tab_->NavigateToURL(net::FilePathToFileURL(filename))); - } - - void SimulateClickInCenterOf(const scoped_refptr<WindowProxy>& window) { - gfx::Rect tab_view_bounds; - ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_CONTAINER, - &tab_view_bounds, true)); - - // Simulate a click of the actual link to force user_gesture to be - // true; if we don't, the resulting popup will be constrained, which - // isn't what we want to test. - POINT link_point(tab_view_bounds.CenterPoint().ToPOINT()); - ASSERT_TRUE(window->SimulateOSClick(link_point, - views::Event::EF_LEFT_BUTTON_DOWN)); - } - - scoped_refptr<BrowserProxy> browser_; - scoped_refptr<WindowProxy> window_; - scoped_refptr<TabProxy> tab_; -}; - -TEST_F(InteractiveConstrainedWindowTest, TestOpenAndResizeTo) { - NavigateMainTabTo(L"constrained_window_onload_resizeto.html"); - SimulateClickInCenterOf(window_); - - ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 1000)); - - scoped_refptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1)); - ASSERT_TRUE(popup_browser != NULL); - scoped_refptr<WindowProxy> popup_window(popup_browser->GetWindow()); - ASSERT_TRUE(popup_window != NULL); - - // Make sure we were created with the correct width and height. - gfx::Rect rect; - bool is_timeout = false; - ASSERT_TRUE(popup_window->GetViewBoundsWithTimeout( - VIEW_ID_TAB_CONTAINER, &rect, false, 1000, &is_timeout)); - ASSERT_FALSE(is_timeout); - ASSERT_EQ(300, rect.width()); - ASSERT_EQ(320, rect.height()); - - SimulateClickInCenterOf(popup_window); - - // No idea how to wait here other then sleeping. This timeout used to be - // lower, then we started hitting it before it was done. :( - PlatformThread::Sleep(5000); - - // The actual content will be LESS than (200, 200) because resizeTo - // deals with a window's outer{Width,Height} instead of its - // inner{Width,Height}. - is_timeout = false; - ASSERT_TRUE(popup_window->GetViewBoundsWithTimeout( - VIEW_ID_TAB_CONTAINER, &rect, false, 1000, &is_timeout)); - ASSERT_FALSE(is_timeout); - ASSERT_LT(rect.width(), 200); - ASSERT_LT(rect.height(), 200); -} - -// Helper function used to get the number of blocked popups out of the window -// title. -bool ParseCountOutOfTitle(const std::wstring& title, int* output) { - // Since we will be reading the number of popup windows open by grabbing the - // number out of the window title, and that format string is localized, we - // need to find out the offset into that string. - const wchar_t* placeholder = L"XXXX"; - size_t offset = - l10n_util::GetStringF(IDS_POPUPS_BLOCKED_COUNT, placeholder). - find(placeholder); - - std::wstring number; - while (offset < title.size() && iswdigit(title[offset])) { - number += title[offset]; - offset++; - } - - return StringToInt(number, output); -} - -// Tests that in the window.open() equivalent of a fork bomb, we stop building -// windows. -TEST_F(InteractiveConstrainedWindowTest, DontSpawnEndlessPopups) { - NavigateMainTabTo(L"infinite_popups.html"); - SimulateClickInCenterOf(window_); - - ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 1000)); - - scoped_refptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1)); - ASSERT_TRUE(popup_browser.get()); - scoped_refptr<TabProxy> popup_tab(popup_browser->GetTab(0)); - ASSERT_TRUE(popup_tab.get()); - - // And now we spin, waiting to make sure that we don't spawn popup - // windows endlessly. The current limit is 25, so allowing for possible race - // conditions and one off errors, don't break out until we go over 30 popup - // windows (in which case we are bork bork bork). - const int kMaxPopupWindows = 30; - - int popup_window_count = 0; - int new_popup_window_count = 0; - int times_slept = 0; - bool continuing = true; - while (continuing && popup_window_count < kMaxPopupWindows) { - ASSERT_TRUE(popup_tab->GetBlockedPopupCount(&new_popup_window_count)); - if (new_popup_window_count == popup_window_count) { - if (times_slept == 10) { - continuing = false; - } else { - // Nothing intereseting is going on wait it out. - PlatformThread::Sleep(automation::kSleepTime); - times_slept++; - } - } else { - times_slept = 0; - } - - EXPECT_GE(new_popup_window_count, popup_window_count); - EXPECT_LE(new_popup_window_count, kMaxPopupWindows); - popup_window_count = new_popup_window_count; - } -} - -// Make sure that we refuse to close windows when a constrained popup is -// displayed. -TEST_F(InteractiveConstrainedWindowTest, WindowOpenWindowClosePopup) { - NavigateMainTabTo(L"openclose_main.html"); - SimulateClickInCenterOf(window_); - - ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 5000)); - - // Make sure we have a blocked popup notification - scoped_refptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1)); - ASSERT_TRUE(popup_browser.get()); - scoped_refptr<WindowProxy> popup_window(popup_browser->GetWindow()); - ASSERT_TRUE(popup_window.get()); - scoped_refptr<TabProxy> popup_tab(popup_browser->GetTab(0)); - ASSERT_TRUE(popup_tab.get()); - ASSERT_TRUE(popup_tab->WaitForBlockedPopupCountToChangeTo(1, 1000)); - - // Ensure we didn't close the first popup window. - ASSERT_FALSE(automation()->WaitForWindowCountToBecome(1, 3000)); -} - -TEST_F(InteractiveConstrainedWindowTest, BlockAlertFromBlockedPopup) { - NavigateMainTabTo(L"block_alert.html"); - - // Wait for there to be an app modal dialog (and fail if it's shown). - ASSERT_FALSE(automation()->WaitForAppModalDialog(4000)); - - // Ensure one browser window. - int browser_window_count; - ASSERT_TRUE(automation()->GetBrowserWindowCount(&browser_window_count)); - ASSERT_EQ(1, browser_window_count); - - // Ensure one blocked popup window: the popup didn't escape. - int popup_count = 0; - ASSERT_TRUE(tab_->GetBlockedPopupCount(&popup_count)); - ASSERT_EQ(1, popup_count); -} - -TEST_F(InteractiveConstrainedWindowTest, ShowAlertFromNormalPopup) { - NavigateMainTabTo(L"show_alert.html"); - SimulateClickInCenterOf(window_); - - ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 5000)); - - scoped_refptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1)); - ASSERT_TRUE(popup_browser.get()); - scoped_refptr<WindowProxy> popup_window(popup_browser->GetWindow()); - ASSERT_TRUE(popup_window.get()); - scoped_refptr<TabProxy> popup_tab(popup_browser->GetTab(0)); - ASSERT_TRUE(popup_tab.get()); - - SimulateClickInCenterOf(popup_window); - - // Wait for there to be an app modal dialog. - ASSERT_TRUE(automation()->WaitForAppModalDialog(5000)); -} - -// Make sure that window focus works while creating a popup window so that we -// don't -TEST_F(InteractiveConstrainedWindowTest, DontBreakOnBlur) { - NavigateMainTabTo(L"window_blur_test.html"); - SimulateClickInCenterOf(window_); - - // Wait for the popup window to open. - ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 1000)); - - // We popup shouldn't be closed by the onblur handler. - ASSERT_FALSE(automation()->WaitForWindowCountToBecome(1, 1500)); -} |