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

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

Issue 10388251: Support maximize window command. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Unit test in chromedriver_tests.py; nicer error reporting - a method to check whether the current v… Created 8 years, 7 months 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/window_commands.h" 5 #include "chrome/test/webdriver/commands/window_commands.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/test/webdriver/commands/response.h" 8 #include "chrome/test/webdriver/commands/response.h"
9 #include "chrome/test/webdriver/webdriver_error.h" 9 #include "chrome/test/webdriver/webdriver_error.h"
10 #include "chrome/test/webdriver/webdriver_session.h" 10 #include "chrome/test/webdriver/webdriver_session.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 response->SetError(error); 125 response->SetError(error);
126 return; 126 return;
127 } 127 }
128 base::DictionaryValue* size = new base::DictionaryValue(); 128 base::DictionaryValue* size = new base::DictionaryValue();
129 size->SetInteger("x", bounds.x()); 129 size->SetInteger("x", bounds.x());
130 size->SetInteger("y", bounds.y()); 130 size->SetInteger("y", bounds.y());
131 response->SetValue(size); 131 response->SetValue(size);
132 } 132 }
133 133
134 void WindowPositionCommand::ExecutePost(Response* const response) { 134 void WindowPositionCommand::ExecutePost(Response* const response) {
135 // Path segment: "/session/$sessionId/window/$windowHandle/size" 135 // Path segment: "/session/$sessionId/window/$windowHandle/position"
136 WebViewId window_id; 136 WebViewId window_id;
137 WebViewId current_id = session_->current_target().view_id; 137 WebViewId current_id = session_->current_target().view_id;
138 if (!GetWindowId(GetPathVariable(4), current_id, &window_id, response)) 138 if (!GetWindowId(GetPathVariable(4), current_id, &window_id, response))
139 return; 139 return;
140 140
141 int x, y; 141 int x, y;
142 if (!GetIntegerParameter("x", &x) || 142 if (!GetIntegerParameter("x", &x) ||
143 !GetIntegerParameter("y", &y)) { 143 !GetIntegerParameter("y", &y)) {
144 response->SetError(new Error( 144 response->SetError(new Error(
145 kBadRequest, 145 kBadRequest,
146 "Missing or invalid 'x' or 'y' parameters")); 146 "Missing or invalid 'x' or 'y' parameters"));
147 return; 147 return;
148 } 148 }
149 Rect bounds; 149 Rect bounds;
150 Error* error = session_->GetWindowBounds(window_id, &bounds); 150 Error* error = session_->GetWindowBounds(window_id, &bounds);
151 if (!error) { 151 if (!error) {
152 bounds = Rect(Point(x, y), bounds.size()); 152 bounds = Rect(Point(x, y), bounds.size());
153 error = session_->SetWindowBounds(window_id, bounds); 153 error = session_->SetWindowBounds(window_id, bounds);
154 } 154 }
155 if (error) { 155 if (error) {
156 response->SetError(error); 156 response->SetError(error);
157 return; 157 return;
158 } 158 }
159 } 159 }
160 160
161 WindowMaximizeCommand::WindowMaximizeCommand(
162 const std::vector<std::string>& path_segments,
163 const base::DictionaryValue* parameters)
164 : WebDriverCommand(path_segments, parameters) {
165 }
166
167 WindowMaximizeCommand::~WindowMaximizeCommand() {
168 }
169
170 bool WindowMaximizeCommand::DoesPost() {
171 return true;
172 }
173
174 void WindowMaximizeCommand::ExecutePost(Response* const response) {
175 // Path segment: "/session/$sessionId/window/$windowHandle/maximize"
176 WebViewId window_id;
177 WebViewId current_id = session_->current_target().view_id;
178 if (!GetWindowId(GetPathVariable(4), current_id, &window_id, response))
179 return;
180
181 Error* error = session_->MaximizeWindow(window_id);
182 if (error) {
183 response->SetError(error);
184 return;
185 }
186 }
187
161 } // namespace webdriver 188 } // namespace webdriver
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698