diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-06 02:19:31 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-06 02:19:31 +0000 |
commit | 23dd7db09af6da5643e10d839b23d484a5b41eab (patch) | |
tree | 8721e1757375d7997c5c5ec4fa35f1227e6e1c22 | |
parent | 5a88e5beb6365142e3d0505f3e7cfcf94ba28494 (diff) | |
download | chromium_src-23dd7db09af6da5643e10d839b23d484a5b41eab.zip chromium_src-23dd7db09af6da5643e10d839b23d484a5b41eab.tar.gz chromium_src-23dd7db09af6da5643e10d839b23d484a5b41eab.tar.bz2 |
Was already a 'wait for animation to complete'.
Added py interface to it.
Review URL: http://codereview.chromium.org/668204
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40812 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/test/functional/bookmark_bar.py | 20 | ||||
-rw-r--r-- | chrome/test/pyautolib/pyautolib.cc | 16 | ||||
-rw-r--r-- | chrome/test/pyautolib/pyautolib.h | 5 | ||||
-rw-r--r-- | chrome/test/pyautolib/pyautolib.i | 5 |
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); |