summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-08 20:43:53 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-08 20:43:53 +0000
commit3a4f703d736db716a5279b821574dcedd170509c (patch)
tree8699fb7a08eac8afde6fcf6ab87b7a308b7a8c1a /chrome/test
parent8f327a0086540250d2af9454c2138bbe514a3aea (diff)
downloadchromium_src-3a4f703d736db716a5279b821574dcedd170509c.zip
chromium_src-3a4f703d736db716a5279b821574dcedd170509c.tar.gz
chromium_src-3a4f703d736db716a5279b821574dcedd170509c.tar.bz2
Convert crash recovery tests to browser test framework, which should reduce flakiness.
TEST=none http://crbug.com/16054 Review URL: http://codereview.chromium.org/149235 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20182 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/ui_test_utils.cc23
-rw-r--r--chrome/test/ui_test_utils.h8
2 files changed, 30 insertions, 1 deletions
diff --git a/chrome/test/ui_test_utils.cc b/chrome/test/ui_test_utils.cc
index ac55380..4f65c35 100644
--- a/chrome/test/ui_test_utils.cc
+++ b/chrome/test/ui_test_utils.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/dom_operation_notification_details.h"
#include "chrome/browser/download/download_manager.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
+#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/notification_registrar.h"
@@ -120,7 +121,7 @@ class DownloadsCompleteObserver : public DownloadManager::Observer,
// CheckAllDownloadsComplete will be called when the DownloadManager
// fires it's ModelChanged() call, and also when incomplete downloads
- // fire their OnDownloadUpdated().
+ // fire their OnDownloadUpdated().
bool CheckAllDownloadsComplete() {
if (downloads_.size() < wait_count_)
return false;
@@ -208,6 +209,17 @@ void RunMessageLoop() {
loop->SetNestableTasksAllowed(did_allow_task_nesting);
}
+bool GetCurrentTabTitle(const Browser* browser, string16* title) {
+ TabContents* tab_contents = browser->GetSelectedTabContents();
+ if (!tab_contents)
+ return false;
+ NavigationEntry* last_entry = tab_contents->controller().GetActiveEntry();
+ if (!last_entry)
+ return false;
+ title->assign(last_entry->title());
+ return true;
+}
+
void WaitForNavigation(NavigationController* controller) {
WaitForNavigations(controller, 1);
}
@@ -230,6 +242,15 @@ void NavigateToURLBlockUntilNavigationsComplete(Browser* browser,
WaitForNavigations(controller, number_of_navigations);
}
+bool ReloadCurrentTab(Browser* browser) {
+ browser->Reload();
+ TabContents* tab_contents = browser->GetSelectedTabContents();
+ if (!tab_contents)
+ return false;
+ WaitForNavigation(&tab_contents->controller());
+ return true;
+}
+
Value* ExecuteJavaScript(RenderViewHost* render_view_host,
const std::wstring& frame_xpath,
const std::wstring& original_script) {
diff --git a/chrome/test/ui_test_utils.h b/chrome/test/ui_test_utils.h
index bdae24c..34c8545 100644
--- a/chrome/test/ui_test_utils.h
+++ b/chrome/test/ui_test_utils.h
@@ -8,6 +8,7 @@
#include <string>
#include "base/basictypes.h"
+#include "base/string16.h"
#include "chrome/common/notification_observer.h"
class Browser;
@@ -25,6 +26,9 @@ namespace ui_test_utils {
// process browser tests that need to block until a condition is met.
void RunMessageLoop();
+// Puts the current tab title in |title|. Returns true on success.
+bool GetCurrentTabTitle(const Browser* browser, string16* title);
+
// Waits for |controller| to complete a navigation. This blocks until
// the navigation finishes.
void WaitForNavigation(NavigationController* controller);
@@ -38,6 +42,10 @@ void WaitForNavigations(NavigationController* controller,
// navigation finishes.
void NavigateToURL(Browser* browser, const GURL& url);
+// Reloads current tab contents and waits for navigation to finish.
+// Returns true on success.
+bool ReloadCurrentTab(Browser* browser);
+
// Navigates the selected tab of |browser| to |url|, blocking until the
// number of navigations specified complete.
void NavigateToURLBlockUntilNavigationsComplete(Browser* browser,