summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorfinnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-05 21:36:57 +0000
committerfinnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-05 21:36:57 +0000
commitc2cbeb9dd8aec543d5c6f0fe2aa99c1f8c655351 (patch)
tree6f71cefde95cc33d0f656917a48df2466f8c655a /chrome/test
parent970556302b1ea50d4fc680d3656269cd50f6cf08 (diff)
downloadchromium_src-c2cbeb9dd8aec543d5c6f0fe2aa99c1f8c655351.zip
chromium_src-c2cbeb9dd8aec543d5c6f0fe2aa99c1f8c655351.tar.gz
chromium_src-c2cbeb9dd8aec543d5c6f0fe2aa99c1f8c655351.tar.bz2
Readding UI test I pulled yesterday; hopefully the bots will like it more now. I need to wait for the bookmark bar to become visible so I plumbed in similar code as for the Find box instead of using Sleep's.
Review URL: http://codereview.chromium.org/473 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1809 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/automation/automation_messages_internal.h8
-rw-r--r--chrome/test/automation/browser_proxy.cc25
-rw-r--r--chrome/test/automation/browser_proxy.h8
-rw-r--r--chrome/test/ui/ui_test.cc17
-rw-r--r--chrome/test/ui/ui_test.h6
5 files changed, 62 insertions, 2 deletions
diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h
index 57a4f3e..aed439e 100644
--- a/chrome/test/automation/automation_messages_internal.h
+++ b/chrome/test/automation/automation_messages_internal.h
@@ -752,5 +752,13 @@ IPC_BEGIN_MESSAGES(Automation, 0)
IPC_MESSAGE_ROUTED2(AutomationMsg_FindWindowLocationResponse,
int, /* x */
int /* y */)
+
+ // Is the Bookmark bar visible? The response will indicate whether it is
+ // visible or not and whether it is being animated into (or out of its place).
+ IPC_MESSAGE_ROUTED1(AutomationMsg_BookmarkBarVisibilityRequest,
+ int /* browser_handle */)
+ IPC_MESSAGE_ROUTED2(AutomationMsg_BookmarkBarVisibilityResponse,
+ bool, /* is_visible */
+ bool /* still_animating */)
IPC_END_MESSAGES(Automation)
diff --git a/chrome/test/automation/browser_proxy.cc b/chrome/test/automation/browser_proxy.cc
index 88c447d..425c6b5 100644
--- a/chrome/test/automation/browser_proxy.cc
+++ b/chrome/test/automation/browser_proxy.cc
@@ -347,3 +347,28 @@ bool BrowserProxy::RunCommand(int browser_command) const {
return false;
}
+bool BrowserProxy::GetBookmarkBarVisibility(bool* is_visible,
+ bool* is_animating) {
+ if (!is_valid())
+ return false;
+
+ if (!is_visible || !is_animating) {
+ NOTREACHED();
+ return false;
+ }
+
+ IPC::Message* response = NULL;
+ bool succeeded = sender_->SendAndWaitForResponse(
+ new AutomationMsg_BookmarkBarVisibilityRequest(0, handle_),
+ &response,
+ AutomationMsg_BookmarkBarVisibilityResponse::ID);
+
+ if (!succeeded)
+ return false;
+
+ void* iter = NULL;
+ response->ReadBool(&iter, is_visible);
+ response->ReadBool(&iter, is_animating);
+ delete response;
+ return true;
+}
diff --git a/chrome/test/automation/browser_proxy.h b/chrome/test/automation/browser_proxy.h
index fdb7dc9..133a93d2 100644
--- a/chrome/test/automation/browser_proxy.h
+++ b/chrome/test/automation/browser_proxy.h
@@ -5,8 +5,8 @@
#ifndef CHROME_TEST_AUTOMATION_BROWSER_PROXY_H_
#define CHROME_TEST_AUTOMATION_BROWSER_PROXY_H_
-#include <string>
#include <windows.h>
+#include <string>
#include "chrome/test/automation/automation_handle_tracker.h"
class GURL;
@@ -139,8 +139,12 @@ class BrowserProxy : public AutomationResourceProxy {
// executed, false otherwise.
bool RunCommand(int browser_command) const;
+ // Returns whether the Bookmark bar is visible and whether we are animating
+ // it into position. Returns false on failure.
+ bool GetBookmarkBarVisibility(bool* is_visible, bool* is_animating);
+
private:
- DISALLOW_EVIL_CONSTRUCTORS(BrowserProxy);
+ DISALLOW_COPY_AND_ASSIGN(BrowserProxy);
};
#endif // CHROME_TEST_AUTOMATION_BROWSER_PROXY_H_
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index d2d619f..d6949e5d 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -376,6 +376,23 @@ bool UITest::WaitForFindWindowFullyVisible(TabProxy* tab) {
return false;
}
+bool UITest::WaitForBookmarkBarVisibilityChange(BrowserProxy* browser,
+ bool wait_for_open) {
+ const int kCycles = 20;
+ for (int i = 0; i < kCycles; i++) {
+ bool visible = false;
+ bool animating = true;
+ if (!browser->GetBookmarkBarVisibility(&visible, &animating))
+ return false; // Some error.
+ if (visible == wait_for_open && !animating)
+ return true; // Bookmark bar visibility change complete.
+
+ // 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())
diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h
index 20c8b1b..fe080a0 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -127,6 +127,12 @@ class UITest : public testing::Test {
// if the window doesn't appear within a specific time.
bool WaitForFindWindowFullyVisible(TabProxy* tab);
+ // Waits until the Bookmark bar has stopped animating and become fully visible
+ // (if |wait_for_open| is true) or fully hidden (if |wait_for_open| is false).
+ // This function can time out (in which case it returns false).
+ bool WaitForBookmarkBarVisibilityChange(BrowserProxy* browser,
+ bool wait_for_open);
+
// 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