summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorfinnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-28 16:31:57 +0000
committerfinnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-28 16:31:57 +0000
commit20e93d1f20dc0e3c626a2500c96f85e89cf184c9 (patch)
tree80307da7589ce802e88ca79c6b60493496770e80 /chrome/test
parent50664fdc92a8d1db14d83c902f67b7a8dce76480 (diff)
downloadchromium_src-20e93d1f20dc0e3c626a2500c96f85e89cf184c9.zip
chromium_src-20e93d1f20dc0e3c626a2500c96f85e89cf184c9.tar.gz
chromium_src-20e93d1f20dc0e3c626a2500c96f85e89cf184c9.tar.bz2
Adding a test to catch regressions where the Find box moves when you open and close a tab. Test is disabled until we fix the bug.
Also made the error message for when tests fails because crash_service isn't running a bit explicit (unrelated to the rest of this change). BUG=1343052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1488 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/automation/automation_messages_internal.h13
-rw-r--r--chrome/test/automation/tab_proxy.cc42
-rw-r--r--chrome/test/automation/tab_proxy.h8
-rw-r--r--chrome/test/ui/ui_test.cc21
-rw-r--r--chrome/test/ui/ui_test.h12
5 files changed, 90 insertions, 6 deletions
diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h
index ca8553a..57a4f3e 100644
--- a/chrome/test/automation/automation_messages_internal.h
+++ b/chrome/test/automation/automation_messages_internal.h
@@ -739,5 +739,18 @@ IPC_BEGIN_MESSAGES(Automation, 0)
int, /* tab_handle */
FindInPageRequest /* request */)
+ // Is the Find window fully visible (and not animating) for the specified
+ // tab?
+ IPC_MESSAGE_ROUTED1(AutomationMsg_FindWindowVisibilityRequest,
+ int /* tab_handle */)
+ IPC_MESSAGE_ROUTED1(AutomationMsg_FindWindowVisibilityResponse,
+ bool /* is_visible */)
+
+ // Where is the Find window located. |x| and |y| will be -1, -1 on failure.
+ IPC_MESSAGE_ROUTED1(AutomationMsg_FindWindowLocationRequest,
+ int /* tab_handle */)
+ IPC_MESSAGE_ROUTED2(AutomationMsg_FindWindowLocationResponse,
+ int, /* x */
+ int /* y */)
IPC_END_MESSAGES(Automation)
diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc
index e3529b5..f284b26 100644
--- a/chrome/test/automation/tab_proxy.cc
+++ b/chrome/test/automation/tab_proxy.cc
@@ -76,6 +76,48 @@ bool TabProxy::OpenFindInPage() {
// This message expects no response.
}
+bool TabProxy::IsFindWindowFullyVisible(bool* is_visible) {
+ if (!is_valid())
+ return false;
+
+ if (!is_visible) {
+ NOTREACHED();
+ return false;
+ }
+
+ IPC::Message* response = NULL;
+ bool succeeded = sender_->SendAndWaitForResponse(
+ new AutomationMsg_FindWindowVisibilityRequest(0, handle_),
+ &response,
+ AutomationMsg_FindWindowVisibilityResponse::ID);
+ if (!succeeded)
+ return false;
+
+ void* iter = NULL;
+ response->ReadBool(&iter, is_visible);
+ delete response;
+ return true;
+}
+
+bool TabProxy::GetFindWindowLocation(int* x, int* y) {
+ if (!is_valid() || !x || !y)
+ return false;
+
+ IPC::Message* response = NULL;
+ bool succeeded = sender_->SendAndWaitForResponse(
+ new AutomationMsg_FindWindowLocationRequest(0, handle_),
+ &response,
+ AutomationMsg_FindWindowLocationResponse::ID);
+ if (!succeeded)
+ return false;
+
+ void* iter = NULL;
+ response->ReadInt(&iter, x);
+ response->ReadInt(&iter, y);
+ delete response;
+ return true;
+}
+
int TabProxy::FindInPage(const std::wstring& search_string,
FindInPageDirection forward,
FindInPageCase match_case,
diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h
index c1c156b..b135288 100644
--- a/chrome/test/automation/tab_proxy.h
+++ b/chrome/test/automation/tab_proxy.h
@@ -167,6 +167,14 @@ class TabProxy : public AutomationResourceProxy {
// you don't need to call this function, just use FindInPage(...) directly.
bool OpenFindInPage();
+ // Returns whether the Find window is fully visible If animating, |is_visible|
+ // will be false. Returns false on failure.
+ bool IsFindWindowFullyVisible(bool* is_visible);
+
+ // Get the x, y coordinates for the Find window. If animating, |x| and |y|
+ // will be -1, -1. Returns false on failure.
+ bool GetFindWindowLocation(int* x, int* y);
+
// Starts a search within the current tab. The parameter |search_string|
// specifies what string to search for, |forward| specifies whether to search
// in forward direction, and |match_case| specifies case sensitivity
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index 22678ff..d2d619f 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -114,7 +114,9 @@ void UITest::TearDown() {
std::wstring error_msg =
L"Encountered an unexpected crash in the program during this test.";
if (expected_crashes_ > 0 && actual_crashes == 0)
- error_msg += L" Have you started crash_service.exe?";
+ error_msg += L" NOTE: This test is expected to fail if crash_service.exe "
+ L"is not running. Start it manually before running this "
+ L"test (see the build output directory).";
EXPECT_EQ(expected_crashes_, actual_crashes) << error_msg;
}
@@ -359,6 +361,21 @@ bool UITest::WaitForDownloadShelfVisible(TabProxy* tab) {
return false;
}
+bool UITest::WaitForFindWindowFullyVisible(TabProxy* tab) {
+ const int kCycles = 20;
+ for (int i = 0; i < kCycles; i++) {
+ bool visible = false;
+ if (!tab->IsFindWindowFullyVisible(&visible))
+ return false; // Some error.
+ if (visible)
+ return true; // Find window is visible.
+
+ // Give it a chance to catch up.
+ Sleep(kWaitForActionMaxMsec / kCycles);
+ }
+ return false;
+}
+
GURL UITest::GetActiveTabURL() {
scoped_ptr<TabProxy> tab_proxy(GetActiveTab());
if (!tab_proxy.get())
@@ -416,7 +433,7 @@ DictionaryValue* UITest::GetLocalState() {
}
DictionaryValue* UITest::GetDefaultProfilePreferences() {
- std::wstring path;
+ std::wstring path;
PathService::Get(chrome::DIR_USER_DATA, &path);
file_util::AppendToPath(&path, chrome::kNotSignedInProfile);
file_util::AppendToPath(&path, chrome::kPreferencesFilename);
diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h
index f7f9257..20c8b1b 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_TEST_UI_UI_TEST_H__
-#define CHROME_TEST_UI_UI_TEST_H__
+#ifndef CHROME_TEST_UI_UI_TEST_H_
+#define CHROME_TEST_UI_UI_TEST_H_
// This file provides a common base for running UI unit tests, which operate
// the entire browser application in a separate process for holistic
@@ -122,6 +122,11 @@ class UITest : public testing::Test {
// as possible.
bool WaitForDownloadShelfVisible(TabProxy* tab);
+ // Waits until the Find window has become fully visible (and stopped
+ // animating) in the specified tab. This function can time out (return false)
+ // if the window doesn't appear within a specific time.
+ bool WaitForFindWindowFullyVisible(TabProxy* tab);
+
// Closes the specified browser. Returns true if the browser was closed.
// This call is blocking. |application_closed| is set to true if this was
// the last browser window (and therefore as a result of it closing the
@@ -345,5 +350,4 @@ std::ostream& operator<<(std::ostream& out, const ::scoped_ptr<T>& ptr) {
}
#endif // UNIT_TEST
-#endif // CHROME_TEST_UI_UI_TEST_H__
-
+#endif // CHROME_TEST_UI_UI_TEST_H_