| OLD | NEW |
| 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 16 matching lines...) Expand all Loading... |
| 27 new Error(kBadRequest, "Invalid window ID")); | 27 new Error(kBadRequest, "Invalid window ID")); |
| 28 return false; | 28 return false; |
| 29 } | 29 } |
| 30 return true; | 30 return true; |
| 31 } | 31 } |
| 32 | 32 |
| 33 } | 33 } |
| 34 | 34 |
| 35 WindowSizeCommand::WindowSizeCommand( | 35 WindowSizeCommand::WindowSizeCommand( |
| 36 const std::vector<std::string>& path_segments, | 36 const std::vector<std::string>& path_segments, |
| 37 const base::DictionaryValue* parameters) | 37 base::DictionaryValue* parameters) |
| 38 : WebDriverCommand(path_segments, parameters) { | 38 : WebDriverCommand(path_segments, parameters) { |
| 39 } | 39 } |
| 40 | 40 |
| 41 WindowSizeCommand::~WindowSizeCommand() { | 41 WindowSizeCommand::~WindowSizeCommand() { |
| 42 } | 42 } |
| 43 | 43 |
| 44 bool WindowSizeCommand::DoesGet() { | 44 bool WindowSizeCommand::DoesGet() { |
| 45 return true; | 45 return true; |
| 46 } | 46 } |
| 47 | 47 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 error = session_->SetWindowBounds(window_id, bounds); | 90 error = session_->SetWindowBounds(window_id, bounds); |
| 91 } | 91 } |
| 92 if (error) { | 92 if (error) { |
| 93 response->SetError(error); | 93 response->SetError(error); |
| 94 return; | 94 return; |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 | 97 |
| 98 WindowPositionCommand::WindowPositionCommand( | 98 WindowPositionCommand::WindowPositionCommand( |
| 99 const std::vector<std::string>& path_segments, | 99 const std::vector<std::string>& path_segments, |
| 100 const base::DictionaryValue* parameters) | 100 base::DictionaryValue* parameters) |
| 101 : WebDriverCommand(path_segments, parameters) { | 101 : WebDriverCommand(path_segments, parameters) { |
| 102 } | 102 } |
| 103 | 103 |
| 104 WindowPositionCommand::~WindowPositionCommand() { | 104 WindowPositionCommand::~WindowPositionCommand() { |
| 105 } | 105 } |
| 106 | 106 |
| 107 bool WindowPositionCommand::DoesGet() { | 107 bool WindowPositionCommand::DoesGet() { |
| 108 return true; | 108 return true; |
| 109 } | 109 } |
| 110 | 110 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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( | 161 WindowMaximizeCommand::WindowMaximizeCommand( |
| 162 const std::vector<std::string>& path_segments, | 162 const std::vector<std::string>& path_segments, |
| 163 const base::DictionaryValue* parameters) | 163 base::DictionaryValue* parameters) |
| 164 : WebDriverCommand(path_segments, parameters) { | 164 : WebDriverCommand(path_segments, parameters) { |
| 165 } | 165 } |
| 166 | 166 |
| 167 WindowMaximizeCommand::~WindowMaximizeCommand() { | 167 WindowMaximizeCommand::~WindowMaximizeCommand() { |
| 168 } | 168 } |
| 169 | 169 |
| 170 bool WindowMaximizeCommand::DoesPost() { | 170 bool WindowMaximizeCommand::DoesPost() { |
| 171 return true; | 171 return true; |
| 172 } | 172 } |
| 173 | 173 |
| 174 void WindowMaximizeCommand::ExecutePost(Response* const response) { | 174 void WindowMaximizeCommand::ExecutePost(Response* const response) { |
| 175 // Path segment: "/session/$sessionId/window/$windowHandle/maximize" | 175 // Path segment: "/session/$sessionId/window/$windowHandle/maximize" |
| 176 WebViewId window_id; | 176 WebViewId window_id; |
| 177 WebViewId current_id = session_->current_target().view_id; | 177 WebViewId current_id = session_->current_target().view_id; |
| 178 if (!GetWindowId(GetPathVariable(4), current_id, &window_id, response)) | 178 if (!GetWindowId(GetPathVariable(4), current_id, &window_id, response)) |
| 179 return; | 179 return; |
| 180 | 180 |
| 181 Error* error = session_->MaximizeWindow(window_id); | 181 Error* error = session_->MaximizeWindow(window_id); |
| 182 if (error) { | 182 if (error) { |
| 183 response->SetError(error); | 183 response->SetError(error); |
| 184 return; | 184 return; |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 | 187 |
| 188 } // namespace webdriver | 188 } // namespace webdriver |
| OLD | NEW |