Index: chrome/test/webdriver/webdriver_automation.cc |
diff --git a/chrome/test/webdriver/webdriver_automation.cc b/chrome/test/webdriver/webdriver_automation.cc |
index 72cb45f916828b1c6abc305eb514ee6df83242b8..f418722b21cc6bc7834d3854c31cbe79c29a9521 100644 |
--- a/chrome/test/webdriver/webdriver_automation.cc |
+++ b/chrome/test/webdriver/webdriver_automation.cc |
@@ -306,19 +306,19 @@ void Automation::Terminate() { |
} |
} |
-void Automation::ExecuteScript(int tab_id, |
+void Automation::ExecuteScript(const WebViewId& view_id, |
const FramePath& frame_path, |
const std::string& script, |
std::string* result, |
Error** error) { |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
Value* unscoped_value; |
std::string error_msg; |
- if (!SendExecuteJavascriptJSONRequest(automation(), windex, tab_index, |
+ if (!SendExecuteJavascriptJSONRequest(automation(), view_locator, |
frame_path.value(), script, |
&unscoped_value, &error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
@@ -329,144 +329,144 @@ void Automation::ExecuteScript(int tab_id, |
*error = new Error(kUnknownError, "Execute script did not return string"); |
} |
-void Automation::MouseMove(int tab_id, |
+void Automation::MouseMove(const WebViewId& view_id, |
const Point& p, |
Error** error) { |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
std::string error_msg; |
if (!SendMouseMoveJSONRequest( |
- automation(), windex, tab_index, p.rounded_x(), p.rounded_y(), |
+ automation(), view_locator, p.rounded_x(), p.rounded_y(), |
&error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
} |
} |
-void Automation::MouseClick(int tab_id, |
+void Automation::MouseClick(const WebViewId& view_id, |
const Point& p, |
automation::MouseButton button, |
Error** error) { |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
std::string error_msg; |
if (!SendMouseClickJSONRequest( |
- automation(), windex, tab_index, button, p.rounded_x(), |
+ automation(), view_locator, button, p.rounded_x(), |
p.rounded_y(), &error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
} |
} |
-void Automation::MouseDrag(int tab_id, |
+void Automation::MouseDrag(const WebViewId& view_id, |
const Point& start, |
const Point& end, |
Error** error) { |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
std::string error_msg; |
if (!SendMouseDragJSONRequest( |
- automation(), windex, tab_index, start.rounded_x(), start.rounded_y(), |
+ automation(), view_locator, start.rounded_x(), start.rounded_y(), |
end.rounded_x(), end.rounded_y(), &error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
} |
} |
-void Automation::MouseButtonUp(int tab_id, |
+void Automation::MouseButtonUp(const WebViewId& view_id, |
const Point& p, |
Error** error) { |
*error = CheckAdvancedInteractionsSupported(); |
if (*error) |
return; |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
std::string error_msg; |
if (!SendMouseButtonUpJSONRequest( |
- automation(), windex, tab_index, p.rounded_x(), p.rounded_y(), |
+ automation(), view_locator, p.rounded_x(), p.rounded_y(), |
&error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
} |
} |
-void Automation::MouseButtonDown(int tab_id, |
+void Automation::MouseButtonDown(const WebViewId& view_id, |
const Point& p, |
Error** error) { |
*error = CheckAdvancedInteractionsSupported(); |
if (*error) |
return; |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
std::string error_msg; |
if (!SendMouseButtonDownJSONRequest( |
- automation(), windex, tab_index, p.rounded_x(), p.rounded_y(), |
+ automation(), view_locator, p.rounded_x(), p.rounded_y(), |
&error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
} |
} |
-void Automation::MouseDoubleClick(int tab_id, |
+void Automation::MouseDoubleClick(const WebViewId& view_id, |
const Point& p, |
Error** error) { |
*error = CheckAdvancedInteractionsSupported(); |
if (*error) |
return; |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
std::string error_msg; |
if (!SendMouseDoubleClickJSONRequest( |
- automation(), windex, tab_index, p.rounded_x(), p.rounded_y(), |
+ automation(), view_locator, p.rounded_x(), p.rounded_y(), |
&error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
} |
} |
void Automation::DragAndDropFilePaths( |
- int tab_id, const Point& location, |
+ const WebViewId& view_id, const Point& location, |
const std::vector<FilePath::StringType>& paths, Error** error) { |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) { |
return; |
} |
std::string error_msg; |
if (!SendDragAndDropFilePathsJSONRequest( |
- automation(), windex, tab_index, location.rounded_x(), |
+ automation(), view_locator, location.rounded_x(), |
location.rounded_y(), paths, &error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
} |
} |
-void Automation::SendWebKeyEvent(int tab_id, |
+void Automation::SendWebKeyEvent(const WebViewId& view_id, |
const WebKeyEvent& key_event, |
Error** error) { |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
std::string error_msg; |
if (!SendWebKeyEventJSONRequest( |
- automation(), windex, tab_index, key_event, &error_msg)) { |
+ automation(), view_locator, key_event, &error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
} |
} |
@@ -608,18 +608,34 @@ void Automation::SetCookie(const std::string& url, |
*error = new Error(kUnknownError, error_msg); |
} |
-void Automation::GetTabIds(std::vector<int>* tab_ids, |
- Error** error) { |
+void Automation::GetViews(std::vector<WebViewInfo>* views, |
+ Error** error) { |
+ bool has_views = false; |
+ *error = CompareVersion(500, 0, &has_views); |
+ if (*error) |
+ return; |
+ |
std::string error_msg; |
- if (!SendGetTabIdsJSONRequest(automation(), tab_ids, &error_msg)) |
- *error = new Error(kUnknownError, error_msg); |
+ if (has_views) { |
+ if (!SendGetWebViewsJSONRequest(automation(), views, &error_msg)) |
+ *error = new Error(kUnknownError, error_msg); |
+ } else { |
+ if (!SendGetTabIdsJSONRequest(automation(), views, &error_msg)) |
+ *error = new Error(kUnknownError, error_msg); |
+ } |
} |
-void Automation::DoesTabExist(int tab_id, bool* does_exist, Error** error) { |
+void Automation::DoesViewExist( |
+ const WebViewId& view_id, bool* does_exist, Error** error) { |
std::string error_msg; |
- if (!SendIsTabIdValidJSONRequest( |
- automation(), tab_id, does_exist, &error_msg)) { |
- *error = new Error(kUnknownError, error_msg); |
+ if (view_id.type == WebViewId::kTypeTabId) { |
+ if (!SendIsTabIdValidJSONRequest( |
+ automation(), view_id, does_exist, &error_msg)) |
+ *error = new Error(kUnknownError, error_msg); |
+ } else { |
+ if (!SendDoesViewExistJSONRequest( |
+ automation(), view_id, does_exist, &error_msg)) |
+ *error = new Error(kUnknownError, error_msg); |
} |
} |
@@ -749,10 +765,29 @@ AutomationProxy* Automation::automation() const { |
Error* Automation::GetIndicesForTab( |
int tab_id, int* browser_index, int* tab_index) { |
- std::string error_msg; |
- if (!SendGetIndicesFromTabIdJSONRequest( |
- automation(), tab_id, browser_index, tab_index, &error_msg)) { |
- return new Error(kUnknownError, error_msg); |
+ std::string error_msg; |
+ if (!SendGetIndicesFromTabIdJSONRequest( |
+ automation(), tab_id, browser_index, tab_index, &error_msg)) { |
+ return new Error(kUnknownError, error_msg); |
+ } |
+ return NULL; |
+} |
+ |
+Error* Automation::ConvertViewIdToLocator( |
+ const WebViewId& view_id, WebViewLocator* view_locator) { |
+ if (view_id.type == WebViewId::kTypeTabId) { |
+ int browser_index, tab_index; |
+ std::string error_msg; |
+ if (!SendGetIndicesFromTabIdJSONRequest( |
+ automation(), view_id.id.tab_id, &browser_index, &tab_index, &error_msg)) { |
+ return new Error(kUnknownError, error_msg); |
+ } |
+ view_locator->type = WebViewLocator::kTypeIndexPair; |
+ view_locator->locator.index_pair.browser_index = browser_index; |
+ view_locator->locator.index_pair.tab_index = tab_index; |
+ } else if (view_id.type == WebViewId::kTypeViewId) { |
+ view_locator->type = WebViewLocator::kTypeViewId; |
+ view_locator->locator.view_id = view_id.id.view_id; |
} |
return NULL; |
} |