summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-21 20:37:49 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-21 20:37:49 +0000
commit2a1a1815a228089514ca0eb52ea9533d9e070672 (patch)
tree5ae6e2d6376cf68b61a404b8771fb01c034a7052 /chrome/browser
parent0f08bf3692c1db8ff2032a7e944335cb5bb6a453 (diff)
downloadchromium_src-2a1a1815a228089514ca0eb52ea9533d9e070672.zip
chromium_src-2a1a1815a228089514ca0eb52ea9533d9e070672.tar.gz
chromium_src-2a1a1815a228089514ca0eb52ea9533d9e070672.tar.bz2
Convert all but one Find test from ui_test to In-Process
Browser test. I also added initialization for a struct that static code analysis complained about. Not technically needed, but harmless to add. BUG=None TEST=None (covered by tests already). Review URL: http://codereview.chromium.org/115652 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16651 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/views/find_bar_win.cc16
-rw-r--r--chrome/browser/views/find_bar_win.h5
-rw-r--r--chrome/browser/views/find_bar_win_browsertest.cc84
-rw-r--r--chrome/browser/views/find_bar_win_uitest.cc70
4 files changed, 101 insertions, 74 deletions
diff --git a/chrome/browser/views/find_bar_win.cc b/chrome/browser/views/find_bar_win.cc
index 007dcc0..5c2af1a 100644
--- a/chrome/browser/views/find_bar_win.cc
+++ b/chrome/browser/views/find_bar_win.cc
@@ -23,6 +23,9 @@
// The minimum space between the FindInPage window and the search result.
static const int kMinFindWndDistanceFromSelection = 5;
+// static
+bool FindBarWin::disable_animations_during_testing_ = false;
+
////////////////////////////////////////////////////////////////////////////////
// FindBarWin, public:
@@ -153,7 +156,7 @@ void FindBarWin::UpdateWindowEdges(const gfx::Rect& new_pos) {
views::NativeScrollBar::GetVerticalScrollBarWidth() +
1;
if (difference > 0) {
- POINT exclude[4];
+ POINT exclude[4] = {0};
exclude[0].x = max_x - difference; // Top left corner.
exclude[0].y = 0;
@@ -177,8 +180,13 @@ void FindBarWin::UpdateWindowEdges(const gfx::Rect& new_pos) {
}
void FindBarWin::Show() {
- animation_->Reset();
- animation_->Show();
+ if (disable_animations_during_testing_) {
+ animation_->Reset(1);
+ MoveWindowIfNecessary(gfx::Rect(), true);
+ } else {
+ animation_->Reset();
+ animation_->Show();
+ }
}
void FindBarWin::SetFocusAndSelection() {
@@ -190,7 +198,7 @@ bool FindBarWin::IsAnimating() {
}
void FindBarWin::Hide(bool animate) {
- if (animate) {
+ if (animate && !disable_animations_during_testing_) {
animation_->Reset(1.0);
animation_->Hide();
} else {
diff --git a/chrome/browser/views/find_bar_win.h b/chrome/browser/views/find_bar_win.h
index c97d6cf..1a983bd 100644
--- a/chrome/browser/views/find_bar_win.h
+++ b/chrome/browser/views/find_bar_win.h
@@ -110,6 +110,11 @@ class FindBarWin : public views::FocusChangeListener,
// Get the offset with which to paint the theme image.
void GetThemePosition(gfx::Rect* bounds);
+ // During testing we can disable animations by setting this flag to true,
+ // so that opening and closing the Find box happens instantly, instead of
+ // having to poll it while it animates to open/closed status.
+ static bool disable_animations_during_testing_;
+
private:
// Retrieves the boundaries that the find bar has to work with within the
// Chrome frame window. The resulting rectangle will be a rectangle that
diff --git a/chrome/browser/views/find_bar_win_browsertest.cc b/chrome/browser/views/find_bar_win_browsertest.cc
index 84248ba..b24f229 100644
--- a/chrome/browser/views/find_bar_win_browsertest.cc
+++ b/chrome/browser/views/find_bar_win_browsertest.cc
@@ -14,6 +14,7 @@
#include "chrome/test/in_process_browser_test.h"
#include "chrome/test/ui_test_utils.h"
+const std::wstring kSimplePage = L"404_is_enough_for_us.html";
const std::wstring kFramePage = L"files/find_in_page/frames.html";
const std::wstring kFrameData = L"files/find_in_page/framedata_general.html";
const std::wstring kUserSelectPage = L"files/find_in_page/user-select.html";
@@ -104,6 +105,12 @@ class FindInPageControllerTest : public InProcessBrowserTest {
*ordinal = observer.active_match_ordinal();
return observer.number_of_matches();
}
+
+ void GetFindBarWindowInfo(gfx::Point* position, bool* fully_visible) {
+ FindBarTesting* find_bar =
+ browser()->find_bar()->find_bar()->GetFindBarTesting();
+ find_bar->GetFindBarWindowInfo(position, fully_visible);
+ }
};
// This test loads a page with frames and starts FindInPage requests.
@@ -403,3 +410,80 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
EXPECT_EQ(2, FindInPage(L"html ", FWD, IGNORE_CASE, false, &ordinal));
EXPECT_EQ(1, ordinal);
}
+
+// Make sure Find box disappears on Navigate but not on Refresh.
+IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) {
+ HTTPTestServer* server = StartHTTPServer();
+
+ // First we navigate to our special focus tracking page.
+ GURL url = server->TestServerPageW(kSimplePage);
+ GURL url2 = server->TestServerPageW(kFramePage);
+ ui_test_utils::NavigateToURL(browser(), url);
+
+ // Open the Find window with animations disabled.
+ FindBarWin::disable_animations_during_testing_ = true;
+ browser()->ShowFindBar();
+
+ gfx::Point position;
+ bool fully_visible = false;
+
+ // Make sure it is open.
+ GetFindBarWindowInfo(&position, &fully_visible);
+ EXPECT_TRUE(fully_visible);
+
+ // Reload the tab and make sure Find window doesn't go away.
+ browser()->Reload();
+
+ GetFindBarWindowInfo(&position, &fully_visible);
+ EXPECT_TRUE(fully_visible);
+
+ // Navigate and make sure the Find window goes away.
+ ui_test_utils::NavigateToURL(browser(), url2);
+
+ GetFindBarWindowInfo(&position, &fully_visible);
+ EXPECT_FALSE(fully_visible);
+}
+
+// Make sure Find box disappears when History/Downloads page is opened, and
+// when a New Tab is opened.
+IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
+ FindDisappearOnNewTabAndHistory) {
+ HTTPTestServer* server = StartHTTPServer();
+
+ // First we navigate to our special focus tracking page.
+ GURL url = server->TestServerPageW(kSimplePage);
+ ui_test_utils::NavigateToURL(browser(), url);
+
+ // Open the Find window with animations disabled.
+ FindBarWin::disable_animations_during_testing_ = true;
+ browser()->ShowFindBar();
+
+ gfx::Point position;
+ bool fully_visible = false;
+
+ // Make sure it is open.
+ GetFindBarWindowInfo(&position, &fully_visible);
+ EXPECT_TRUE(fully_visible);
+
+ // Open another tab (tab B).
+ browser()->NewTab();
+ ui_test_utils::NavigateToURL(browser(), url);
+
+ // Make sure Find box is closed.
+ GetFindBarWindowInfo(&position, &fully_visible);
+ EXPECT_FALSE(fully_visible);
+
+ // Close tab B.
+ browser()->CloseTab();
+
+ // Make sure Find window appears again.
+ GetFindBarWindowInfo(&position, &fully_visible);
+ EXPECT_TRUE(fully_visible);
+
+ browser()->ShowHistoryTab();
+
+ // Make sure Find box is closed.
+ GetFindBarWindowInfo(&position, &fully_visible);
+ EXPECT_FALSE(fully_visible);
+}
+
diff --git a/chrome/browser/views/find_bar_win_uitest.cc b/chrome/browser/views/find_bar_win_uitest.cc
index 2b9a5ac..6ec3200 100644
--- a/chrome/browser/views/find_bar_win_uitest.cc
+++ b/chrome/browser/views/find_bar_win_uitest.cc
@@ -3,10 +3,8 @@
// found in the LICENSE file.
#include "chrome/app/chrome_dll_resource.h"
-#include "chrome/browser/views/find_bar_win.h"
#include "chrome/test/automation/browser_proxy.h"
#include "chrome/test/automation/tab_proxy.h"
-#include "chrome/test/automation/window_proxy.h"
#include "chrome/test/ui/ui_test.h"
#include "net/url_request/url_request_unittest.h"
@@ -18,7 +16,6 @@ class FindInPageControllerTest : public UITest {
};
const std::wstring kSimplePage = L"404_is_enough_for_us.html";
-const std::wstring kFramePage = L"files/find_in_page/frames.html";
// The find window should not change its location just because we open and close
// a new tab.
@@ -81,70 +78,3 @@ TEST_F(FindInPageControllerTest, FindMovesOnTabClose_Issue1343052) {
EXPECT_EQ(x, new_x);
EXPECT_EQ(y, new_y);
}
-
-// Make sure Find box disappears on Navigate but not on Refresh.
-TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) {
- scoped_refptr<HTTPTestServer> server =
- HTTPTestServer::CreateServer(L"chrome/test/data", NULL);
- ASSERT_TRUE(NULL != server.get());
-
- GURL url = server->TestServerPageW(kSimplePage);
- GURL url2 = server->TestServerPageW(kFramePage);
- scoped_ptr<TabProxy> tab(GetActiveTab());
- ASSERT_TRUE(tab->NavigateToURL(url));
- WaitUntilTabCount(1);
-
- scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
- ASSERT_TRUE(browser.get() != NULL);
-
- // Open the Find window and wait for it to animate.
- EXPECT_TRUE(browser->OpenFindInPage());
- EXPECT_TRUE(WaitForFindWindowVisibilityChange(browser.get(), true));
-
- // Reload the tab and make sure Find box doesn't go away.
- EXPECT_TRUE(tab->Reload());
- EXPECT_TRUE(WaitForFindWindowVisibilityChange(browser.get(), true));
-
- // Navigate and make sure the Find box goes away.
- EXPECT_TRUE(tab->NavigateToURL(url2));
- EXPECT_TRUE(WaitForFindWindowVisibilityChange(browser.get(), false));
-}
-
-// Make sure Find box disappears when History/Downloads page is opened, and
-// when a New Tab is opened.
-TEST_F(FindInPageControllerTest, FindDisappearOnNewTabAndHistory) {
- scoped_refptr<HTTPTestServer> server =
- HTTPTestServer::CreateServer(L"chrome/test/data", NULL);
- ASSERT_TRUE(NULL != server.get());
-
- GURL url = server->TestServerPageW(kSimplePage);
- scoped_ptr<TabProxy> tab(GetActiveTab());
- ASSERT_TRUE(tab->NavigateToURL(url));
- WaitUntilTabCount(1);
-
- scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
- ASSERT_TRUE(browser.get() != NULL);
-
- // Open the Find window and wait for it to animate.
- EXPECT_TRUE(browser->OpenFindInPage());
- EXPECT_TRUE(WaitForFindWindowVisibilityChange(browser.get(), true));
-
- // Open another tab (tab B).
- EXPECT_TRUE(browser->AppendTab(url));
- scoped_ptr<TabProxy> tabB(GetActiveTab());
-
- // Wait for the Find box to disappear.
- EXPECT_TRUE(WaitForFindWindowVisibilityChange(browser.get(), false));
-
- // Close tab B.
- EXPECT_TRUE(tabB->Close(true));
-
- // Wait for the Find box to appear again.
- EXPECT_TRUE(WaitForFindWindowVisibilityChange(browser.get(), true));
-
- // Open History page.
- EXPECT_TRUE(browser->RunCommandAsync(IDC_SHOW_HISTORY));
-
- // Wait for the Find box to disappear.
- EXPECT_TRUE(WaitForFindWindowVisibilityChange(browser.get(), false));
-}