| 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/html5_storage_commands.h" | 5 #include "chrome/test/webdriver/commands/html5_storage_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" |
| 11 | 11 |
| 12 namespace webdriver { | 12 namespace webdriver { |
| 13 | 13 |
| 14 LocalStorageCommand::LocalStorageCommand( | 14 LocalStorageCommand::LocalStorageCommand( |
| 15 const std::vector<std::string>& path_segments, | 15 const std::vector<std::string>& path_segments, |
| 16 const base::DictionaryValue* const parameters) | 16 base::DictionaryValue* const parameters) |
| 17 : WebDriverCommand(path_segments, parameters) {} | 17 : WebDriverCommand(path_segments, parameters) {} |
| 18 | 18 |
| 19 LocalStorageCommand::~LocalStorageCommand() {} | 19 LocalStorageCommand::~LocalStorageCommand() {} |
| 20 | 20 |
| 21 bool LocalStorageCommand::DoesGet() { | 21 bool LocalStorageCommand::DoesGet() { |
| 22 return true; | 22 return true; |
| 23 } | 23 } |
| 24 | 24 |
| 25 bool LocalStorageCommand::DoesPost() { | 25 bool LocalStorageCommand::DoesPost() { |
| 26 return true; | 26 return true; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 57 } | 57 } |
| 58 | 58 |
| 59 void LocalStorageCommand::ExecuteDelete(Response* const response) { | 59 void LocalStorageCommand::ExecuteDelete(Response* const response) { |
| 60 Error* error = session_->ClearStorage(kLocalStorageType); | 60 Error* error = session_->ClearStorage(kLocalStorageType); |
| 61 if (error) | 61 if (error) |
| 62 response->SetError(error); | 62 response->SetError(error); |
| 63 } | 63 } |
| 64 | 64 |
| 65 LocalStorageKeyCommand::LocalStorageKeyCommand( | 65 LocalStorageKeyCommand::LocalStorageKeyCommand( |
| 66 const std::vector<std::string>& path_segments, | 66 const std::vector<std::string>& path_segments, |
| 67 const base::DictionaryValue* const parameters) | 67 base::DictionaryValue* const parameters) |
| 68 : WebDriverCommand(path_segments, parameters) {} | 68 : WebDriverCommand(path_segments, parameters) {} |
| 69 | 69 |
| 70 LocalStorageKeyCommand::~LocalStorageKeyCommand() {} | 70 LocalStorageKeyCommand::~LocalStorageKeyCommand() {} |
| 71 | 71 |
| 72 bool LocalStorageKeyCommand::DoesGet() { | 72 bool LocalStorageKeyCommand::DoesGet() { |
| 73 return true; | 73 return true; |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool LocalStorageKeyCommand::DoesDelete() { | 76 bool LocalStorageKeyCommand::DoesDelete() { |
| 77 return true; | 77 return true; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 96 Error* error = session_->RemoveStorageItem(kLocalStorageType, key, &value); | 96 Error* error = session_->RemoveStorageItem(kLocalStorageType, key, &value); |
| 97 if (error) { | 97 if (error) { |
| 98 response->SetError(error); | 98 response->SetError(error); |
| 99 return; | 99 return; |
| 100 } | 100 } |
| 101 response->SetValue(new base::StringValue(value)); | 101 response->SetValue(new base::StringValue(value)); |
| 102 } | 102 } |
| 103 | 103 |
| 104 LocalStorageSizeCommand::LocalStorageSizeCommand( | 104 LocalStorageSizeCommand::LocalStorageSizeCommand( |
| 105 const std::vector<std::string>& path_segments, | 105 const std::vector<std::string>& path_segments, |
| 106 const base::DictionaryValue* const parameters) | 106 base::DictionaryValue* const parameters) |
| 107 : WebDriverCommand(path_segments, parameters) {} | 107 : WebDriverCommand(path_segments, parameters) {} |
| 108 | 108 |
| 109 LocalStorageSizeCommand::~LocalStorageSizeCommand() {} | 109 LocalStorageSizeCommand::~LocalStorageSizeCommand() {} |
| 110 | 110 |
| 111 bool LocalStorageSizeCommand::DoesGet() { | 111 bool LocalStorageSizeCommand::DoesGet() { |
| 112 return true; | 112 return true; |
| 113 } | 113 } |
| 114 | 114 |
| 115 void LocalStorageSizeCommand::ExecuteGet(Response* const response) { | 115 void LocalStorageSizeCommand::ExecuteGet(Response* const response) { |
| 116 int size; | 116 int size; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 168 } |
| 169 | 169 |
| 170 void SessionStorageCommand::ExecuteDelete(Response* const response) { | 170 void SessionStorageCommand::ExecuteDelete(Response* const response) { |
| 171 Error* error = session_->ClearStorage(kSessionStorageType); | 171 Error* error = session_->ClearStorage(kSessionStorageType); |
| 172 if (error) | 172 if (error) |
| 173 response->SetError(error); | 173 response->SetError(error); |
| 174 } | 174 } |
| 175 | 175 |
| 176 SessionStorageKeyCommand::SessionStorageKeyCommand( | 176 SessionStorageKeyCommand::SessionStorageKeyCommand( |
| 177 const std::vector<std::string>& path_segments, | 177 const std::vector<std::string>& path_segments, |
| 178 const base::DictionaryValue* const parameters) | 178 base::DictionaryValue* const parameters) |
| 179 : WebDriverCommand(path_segments, parameters) {} | 179 : WebDriverCommand(path_segments, parameters) {} |
| 180 | 180 |
| 181 SessionStorageKeyCommand::~SessionStorageKeyCommand() {} | 181 SessionStorageKeyCommand::~SessionStorageKeyCommand() {} |
| 182 | 182 |
| 183 bool SessionStorageKeyCommand::DoesGet() { | 183 bool SessionStorageKeyCommand::DoesGet() { |
| 184 return true; | 184 return true; |
| 185 } | 185 } |
| 186 | 186 |
| 187 bool SessionStorageKeyCommand::DoesDelete() { | 187 bool SessionStorageKeyCommand::DoesDelete() { |
| 188 return true; | 188 return true; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 207 Error* error = session_->RemoveStorageItem(kSessionStorageType, key, &value); | 207 Error* error = session_->RemoveStorageItem(kSessionStorageType, key, &value); |
| 208 if (error) { | 208 if (error) { |
| 209 response->SetError(error); | 209 response->SetError(error); |
| 210 return; | 210 return; |
| 211 } | 211 } |
| 212 response->SetValue(new base::StringValue(value)); | 212 response->SetValue(new base::StringValue(value)); |
| 213 } | 213 } |
| 214 | 214 |
| 215 SessionStorageSizeCommand::SessionStorageSizeCommand( | 215 SessionStorageSizeCommand::SessionStorageSizeCommand( |
| 216 const std::vector<std::string>& path_segments, | 216 const std::vector<std::string>& path_segments, |
| 217 const base::DictionaryValue* const parameters) | 217 base::DictionaryValue* const parameters) |
| 218 : WebDriverCommand(path_segments, parameters) {} | 218 : WebDriverCommand(path_segments, parameters) {} |
| 219 | 219 |
| 220 SessionStorageSizeCommand::~SessionStorageSizeCommand() {} | 220 SessionStorageSizeCommand::~SessionStorageSizeCommand() {} |
| 221 | 221 |
| 222 bool SessionStorageSizeCommand::DoesGet() { | 222 bool SessionStorageSizeCommand::DoesGet() { |
| 223 return true; | 223 return true; |
| 224 } | 224 } |
| 225 | 225 |
| 226 void SessionStorageSizeCommand::ExecuteGet(Response* const response) { | 226 void SessionStorageSizeCommand::ExecuteGet(Response* const response) { |
| 227 int size; | 227 int size; |
| 228 Error* error = session_->GetStorageSize(kSessionStorageType, &size); | 228 Error* error = session_->GetStorageSize(kSessionStorageType, &size); |
| 229 if (error) { | 229 if (error) { |
| 230 response->SetError(error); | 230 response->SetError(error); |
| 231 return; | 231 return; |
| 232 } | 232 } |
| 233 response->SetValue(new base::FundamentalValue(size)); | 233 response->SetValue(new base::FundamentalValue(size)); |
| 234 } | 234 } |
| 235 | 235 |
| 236 } // namespace webdriver | 236 } // namespace webdriver |
| OLD | NEW |