Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(680)

Side by Side Diff: chrome/test/webdriver/commands/target_locator_commands.cc

Issue 8649004: Allow chromedriver to install an extension and get all installed extension IDs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/test/webdriver/commands/target_locator_commands.h" 5 #include "chrome/test/webdriver/commands/target_locator_commands.h"
6 6
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/test/webdriver/commands/response.h" 9 #include "chrome/test/webdriver/commands/response.h"
10 #include "chrome/test/webdriver/webdriver_element_id.h" 10 #include "chrome/test/webdriver/webdriver_element_id.h"
11 #include "chrome/test/webdriver/webdriver_error.h" 11 #include "chrome/test/webdriver/webdriver_error.h"
12 #include "chrome/test/webdriver/webdriver_session.h" 12 #include "chrome/test/webdriver/webdriver_session.h"
13 13
14 namespace webdriver { 14 namespace webdriver {
15 15
16 WindowHandleCommand::WindowHandleCommand( 16 WindowHandleCommand::WindowHandleCommand(
17 const std::vector<std::string>& path_segments, 17 const std::vector<std::string>& path_segments,
18 DictionaryValue* parameters) 18 DictionaryValue* parameters)
19 : WebDriverCommand(path_segments, parameters) {} 19 : WebDriverCommand(path_segments, parameters) {}
20 20
21 WindowHandleCommand::~WindowHandleCommand() {} 21 WindowHandleCommand::~WindowHandleCommand() {}
22 22
23 bool WindowHandleCommand::DoesGet() { 23 bool WindowHandleCommand::DoesGet() {
24 return true; 24 return true;
25 } 25 }
26 26
27 void WindowHandleCommand::ExecuteGet(Response* const response) { 27 void WindowHandleCommand::ExecuteGet(Response* const response) {
28 response->SetValue(new StringValue( 28 response->SetValue(new StringValue(
29 base::IntToString(session_->current_target().window_id))); 29 base::IntToString(session_->current_target().view_id.id.tab_id))); // FIX ME
30 } 30 }
31 31
32 WindowHandlesCommand::WindowHandlesCommand( 32 WindowHandlesCommand::WindowHandlesCommand(
33 const std::vector<std::string>& path_segments, 33 const std::vector<std::string>& path_segments,
34 DictionaryValue* parameters) 34 DictionaryValue* parameters)
35 : WebDriverCommand(path_segments, parameters) {} 35 : WebDriverCommand(path_segments, parameters) {}
36 36
37 WindowHandlesCommand::~WindowHandlesCommand() {} 37 WindowHandlesCommand::~WindowHandlesCommand() {}
38 38
39 bool WindowHandlesCommand::DoesGet() { 39 bool WindowHandlesCommand::DoesGet() {
40 return true; 40 return true;
41 } 41 }
42 42
43 void WindowHandlesCommand::ExecuteGet(Response* const response) { 43 void WindowHandlesCommand::ExecuteGet(Response* const response) {
44 std::vector<int> window_ids; 44 std::vector<WebViewInfo> views;
45 Error* error = session_->GetWindowIds(&window_ids); 45 Error* error = session_->GetViews(&views);
46 if (error) { 46 if (error) {
47 response->SetError(error); 47 response->SetError(error);
48 return; 48 return;
49 } 49 }
50 ListValue* id_list = new ListValue(); 50 base::ListValue* views_list = new base::ListValue();
51 for (size_t i = 0; i < window_ids.size(); ++i) 51 for (size_t i = 0; i < views.size(); ++i) {
52 id_list->Append(new StringValue(base::IntToString(window_ids[i]))); 52 if (views[i].view_id.type != WebViewId::kTypeTabId)
53 response->SetValue(id_list); 53 continue;
54 views_list->Append(base::Value::CreateStringValue(
55 base::IntToString(views[i].view_id.id.tab_id)));
56 }
57 response->SetValue(views_list);
54 } 58 }
55 59
56 WindowCommand::WindowCommand( 60 WindowCommand::WindowCommand(
57 const std::vector<std::string>& path_segments, 61 const std::vector<std::string>& path_segments,
58 DictionaryValue* parameters) 62 DictionaryValue* parameters)
59 : WebDriverCommand(path_segments, parameters) {} 63 : WebDriverCommand(path_segments, parameters) {}
60 64
61 WindowCommand::~WindowCommand() {} 65 WindowCommand::~WindowCommand() {}
62 66
63 bool WindowCommand::DoesPost() { 67 bool WindowCommand::DoesPost() {
64 return true; 68 return true;
65 } 69 }
66 70
67 bool WindowCommand::DoesDelete() { 71 bool WindowCommand::DoesDelete() {
68 return true; 72 return true;
69 } 73 }
70 74
71 void WindowCommand::ExecutePost(Response* const response) { 75 void WindowCommand::ExecutePost(Response* const response) {
72 std::string name; 76 std::string name;
73 if (!GetStringParameter("name", &name)) { 77 if (!GetStringParameter("name", &name)) {
74 response->SetError(new Error( 78 response->SetError(new Error(
75 kBadRequest, "Missing or invalid 'name' parameter")); 79 kBadRequest, "Missing or invalid 'name' parameter"));
76 return; 80 return;
77 } 81 }
78 82
79 Error* error = session_->SwitchToWindow(name); 83 Error* error = session_->SwitchToView(name);
80 if (error) 84 if (error)
81 response->SetError(error); 85 response->SetError(error);
82 } 86 }
83 87
84 void WindowCommand::ExecuteDelete(Response* const response) { 88 void WindowCommand::ExecuteDelete(Response* const response) {
85 Error* error = session_->CloseWindow(); 89 Error* error = session_->CloseWindow();
86 if (error) 90 if (error)
87 response->SetError(error); 91 response->SetError(error);
88 } 92 }
89 93
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 Error* error = session_->ExecuteScript( 155 Error* error = session_->ExecuteScript(
152 "return document.activeElement || document.body", &args, &result); 156 "return document.activeElement || document.body", &args, &result);
153 if (error) { 157 if (error) {
154 response->SetError(error); 158 response->SetError(error);
155 return; 159 return;
156 } 160 }
157 response->SetValue(result); 161 response->SetValue(result);
158 } 162 }
159 163
160 } // namespace webdriver 164 } // namespace webdriver
OLDNEW
« no previous file with comments | « chrome/test/webdriver/commands/chrome_commands.cc ('k') | chrome/test/webdriver/test/chromedriver.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698