summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/test/functional/bookmark_bar.py20
-rw-r--r--chrome/test/pyautolib/pyautolib.cc16
-rw-r--r--chrome/test/pyautolib/pyautolib.h5
-rw-r--r--chrome/test/pyautolib/pyautolib.i5
4 files changed, 46 insertions, 0 deletions
diff --git a/chrome/test/functional/bookmark_bar.py b/chrome/test/functional/bookmark_bar.py
index a91113f..083f857 100644
--- a/chrome/test/functional/bookmark_bar.py
+++ b/chrome/test/functional/bookmark_bar.py
@@ -3,6 +3,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import time
import unittest
import pyauto
@@ -18,6 +19,25 @@ class BookmarkBarTest(pyauto.PyUITest):
self.ApplyAccelerator(pyauto.IDC_SHOW_BOOKMARK_BAR)
self.assertFalse(self.GetBookmarkBarVisibility())
+ def _timeAndWaitForBookmarkBarVisibilityChange(self, wait_for_open):
+ """Wait for a bookmark bar visibility change and print the wait time.
+
+ We cannot use timeit since we need to reference self.
+ """
+ start = time.time()
+ self.assertTrue(self.WaitForBookmarkBarVisibilityChange(wait_for_open))
+ end = time.time()
+ print 'Wait for bookmark bar animation complete: %2.2fsec' % (end - start)
+
+ def testBookmarkBarVisibleWait(self):
+ """Test waiting for the animation to finish."""
+ self.assertFalse(self.GetBookmarkBarVisibility())
+ self.ApplyAccelerator(pyauto.IDC_SHOW_BOOKMARK_BAR)
+ self._timeAndWaitForBookmarkBarVisibilityChange(True);
+ self.assertTrue(self.GetBookmarkBarVisibility())
+ self.ApplyAccelerator(pyauto.IDC_SHOW_BOOKMARK_BAR)
+ self._timeAndWaitForBookmarkBarVisibilityChange(False);
+ self.assertFalse(self.GetBookmarkBarVisibility())
if __name__ == '__main__':
unittest.main()
diff --git a/chrome/test/pyautolib/pyautolib.cc b/chrome/test/pyautolib/pyautolib.cc
index 7a9efc9..9f0dd41 100644
--- a/chrome/test/pyautolib/pyautolib.cc
+++ b/chrome/test/pyautolib/pyautolib.cc
@@ -129,3 +129,19 @@ bool PyUITestSuite::GetBookmarkBarVisibility() {
return visible;
}
+bool PyUITestSuite::WaitForBookmarkBarVisibilityChange(bool wait_for_open) {
+ scoped_refptr<BrowserProxy> browser_proxy =
+ automation()->GetBrowserWindow(0); // Window doesn't matter.
+ EXPECT_TRUE(browser_proxy.get());
+ if (!browser_proxy.get())
+ return false;
+
+ // This has a 20sec timeout. If that's not enough we have serious problems.
+ bool completed = UITestBase::WaitForBookmarkBarVisibilityChange(
+ browser_proxy.get(),
+ wait_for_open);
+ EXPECT_TRUE(completed);
+ return completed;
+}
+
+
diff --git a/chrome/test/pyautolib/pyautolib.h b/chrome/test/pyautolib/pyautolib.h
index 0833e2a..b6bb8c3 100644
--- a/chrome/test/pyautolib/pyautolib.h
+++ b/chrome/test/pyautolib/pyautolib.h
@@ -90,6 +90,11 @@ class PyUITestSuite : public UITestSuite, public UITestBase {
// change this return value unexpectedly.
bool IsBookmarkBarAnimating();
+ // Wait for the bookmark bar animation to complete.
+ // If |wait_for_open| is true, wait for it to open.
+ // If |wait_for_open| is false, wait for it to close.
+ bool WaitForBookmarkBarVisibilityChange(bool wait_for_open);
+
private:
base::ScopedNSAutoreleasePool pool_;
};
diff --git a/chrome/test/pyautolib/pyautolib.i b/chrome/test/pyautolib/pyautolib.i
index c406005..f745fbb 100644
--- a/chrome/test/pyautolib/pyautolib.i
+++ b/chrome/test/pyautolib/pyautolib.i
@@ -128,6 +128,11 @@ class PyUITestSuite {
"(to the chrome).") GetBookmarkBarVisibility;
bool GetBookmarkBarVisibility();
+ %feature("docstring", "Wait for the bookmark bar animation to complete. "
+ "|wait_for_open| specifies which kind of change we wait for.")
+ WaitForBookmarkBarVisibilityChange;
+ bool WaitForBookmarkBarVisibilityChange(bool wait_for_open);
+
%feature("docstring", "Open the Find box in the given or first browser "
"window.") OpenFindInPage;
void OpenFindInPage(int window_index=0);