Skip to content

Commit

Permalink
Convert the RedirectTest ui_tests to browser_tests, and renabled two …
Browse files Browse the repository at this point in the history
…of the disabled ones. Removed all the loop/waiting on timeout.

BUG=121574,62772,69390
Review URL: https://chromiumcodereview.appspot.com/10010045

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131218 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
jam@chromium.org committed Apr 7, 2012
1 parent 7bfc592 commit 9d7a49d
Show file tree
Hide file tree
Showing 8 changed files with 317 additions and 434 deletions.
66 changes: 4 additions & 62 deletions chrome/browser/automation/testing_automation_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,14 @@ class AutomationInterstitialPage : public content::InterstitialPageDelegate {
} // namespace

TestingAutomationProvider::TestingAutomationProvider(Profile* profile)
: AutomationProvider(profile),
: AutomationProvider(profile)
#if defined(TOOLKIT_VIEWS)
popup_menu_waiter_(NULL),
, popup_menu_waiter_(NULL)
#endif
#if defined(OS_CHROMEOS)
power_manager_observer_(NULL),
, power_manager_observer_(NULL)
#endif
redirect_query_(0) {
{
BrowserList::AddObserver(this);
registrar_.Add(this, chrome::NOTIFICATION_SESSION_END,
content::NotificationService::AllSources());
Expand Down Expand Up @@ -354,8 +354,6 @@ bool TestingAutomationProvider::OnMessageReceived(
IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_SetAuth, SetAuth)
IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CancelAuth, CancelAuth)
IPC_MESSAGE_HANDLER(AutomationMsg_NeedsAuth, NeedsAuth)
IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_RedirectsFrom,
GetRedirectsFrom)
IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindowCount, GetBrowserWindowCount)
IPC_MESSAGE_HANDLER(AutomationMsg_NormalBrowserWindowCount,
GetNormalBrowserWindowCount)
Expand Down Expand Up @@ -823,39 +821,6 @@ void TestingAutomationProvider::NeedsAuth(int tab_handle, bool* needs_auth) {
}
}

void TestingAutomationProvider::GetRedirectsFrom(int tab_handle,
const GURL& source_url,
IPC::Message* reply_message) {
if (redirect_query_) {
LOG(ERROR) << "Can only handle one redirect query at once.";
} else if (tab_tracker_->ContainsHandle(tab_handle)) {
NavigationController* tab = tab_tracker_->GetResource(tab_handle);
Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext());
HistoryService* history_service =
profile->GetHistoryService(Profile::EXPLICIT_ACCESS);

DCHECK(history_service) << "Tab " << tab_handle << "'s profile " <<
"has no history service";
if (history_service) {
DCHECK(!reply_message_);
reply_message_ = reply_message;
// Schedule a history query for redirects. The response will be sent
// asynchronously from the callback the history system uses to notify us
// that it's done: OnRedirectQueryComplete.
redirect_query_ = history_service->QueryRedirectsFrom(
source_url, &consumer_,
base::Bind(&TestingAutomationProvider::OnRedirectQueryComplete,
base::Unretained(this)));
return; // Response will be sent when query completes.
}
}

// Send failure response.
std::vector<GURL> empty;
AutomationMsg_RedirectsFrom::WriteReplyParams(reply_message, false, empty);
Send(reply_message);
}

void TestingAutomationProvider::GetBrowserWindowCount(int* window_count) {
*window_count = static_cast<int>(BrowserList::size());
}
Expand Down Expand Up @@ -7121,29 +7086,6 @@ void TestingAutomationProvider::GetParentBrowserOfTab(int tab_handle,
}
}

// TODO(brettw) change this to accept GURLs when history supports it
void TestingAutomationProvider::OnRedirectQueryComplete(
HistoryService::Handle request_handle,
GURL from_url,
bool success,
history::RedirectList* redirects) {
DCHECK_EQ(redirect_query_, request_handle);
DCHECK(reply_message_ != NULL);

std::vector<GURL> redirects_gurl;
reply_message_->WriteBool(success);
if (success) {
for (size_t i = 0; i < redirects->size(); i++)
redirects_gurl.push_back(redirects->at(i));
}

IPC::ParamTraits<std::vector<GURL> >::Write(reply_message_, redirects_gurl);

Send(reply_message_);
redirect_query_ = 0;
reply_message_ = NULL;
}

void TestingAutomationProvider::OnRemoveProvider() {
if (g_browser_process)
g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
Expand Down
13 changes: 0 additions & 13 deletions chrome/browser/automation/testing_automation_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -1569,13 +1569,6 @@ class TestingAutomationProvider : public AutomationProvider,
void GetParentBrowserOfTab(
int tab_handle, int* browser_handle, bool* success);

// Callback for history redirect queries.
virtual void OnRedirectQueryComplete(
HistoryService::Handle request_handle,
GURL from_url,
bool success,
history::RedirectList* redirects);

void OnRemoveProvider(); // Called via PostTask

#if defined(TOOLKIT_VIEWS)
Expand All @@ -1596,12 +1589,6 @@ class TestingAutomationProvider : public AutomationProvider,
// Used to wait on various browser sync events.
scoped_ptr<ProfileSyncServiceHarness> sync_waiter_;

// Handle for an in-process redirect query. We expect only one redirect query
// at a time (we should have only one caller, and it will block while waiting
// for the results) so there is only one handle. When non-0, indicates a
// query in progress.
HistoryService::Handle redirect_query_;

content::NotificationRegistrar registrar_;

// Used to enumerate browser profiles.
Expand Down
Loading

0 comments on commit 9d7a49d

Please sign in to comment.