| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 scoped_ptr<base::ListValue> args_; | 224 scoped_ptr<base::ListValue> args_; |
| 225 scoped_ptr<base::Value> result_; | 225 scoped_ptr<base::Value> result_; |
| 226 }; | 226 }; |
| 227 | 227 |
| 228 } // namespace | 228 } // namespace |
| 229 | 229 |
| 230 TEST(CommandsTest, SuccessfulFindElement) { | 230 TEST(CommandsTest, SuccessfulFindElement) { |
| 231 FindElementWebView web_view(true, kElementExistsQueryTwice); | 231 FindElementWebView web_view(true, kElementExistsQueryTwice); |
| 232 Session session("id"); | 232 Session session("id"); |
| 233 session.implicit_wait = 1000; | 233 session.implicit_wait = 1000; |
| 234 session.frame = "frame_id1"; | 234 session.SwitchToSubFrame("frame_id1", ""); |
| 235 base::DictionaryValue params; | 235 base::DictionaryValue params; |
| 236 params.SetString("using", "id"); | 236 params.SetString("using", "id"); |
| 237 params.SetString("value", "a"); | 237 params.SetString("value", "a"); |
| 238 scoped_ptr<base::Value> result; | 238 scoped_ptr<base::Value> result; |
| 239 ASSERT_EQ(kOk, | 239 ASSERT_EQ(kOk, |
| 240 ExecuteFindElement(1, &session, &web_view, params, &result).code()); | 240 ExecuteFindElement(1, &session, &web_view, params, &result).code()); |
| 241 base::DictionaryValue param; | 241 base::DictionaryValue param; |
| 242 param.SetString("id", "a"); | 242 param.SetString("id", "a"); |
| 243 base::ListValue expected_args; | 243 base::ListValue expected_args; |
| 244 expected_args.Append(param.DeepCopy()); | 244 expected_args.Append(param.DeepCopy()); |
| 245 web_view.Verify("frame_id1", &expected_args, result.get()); | 245 web_view.Verify("frame_id1", &expected_args, result.get()); |
| 246 } | 246 } |
| 247 | 247 |
| 248 TEST(CommandsTest, FailedFindElement) { | 248 TEST(CommandsTest, FailedFindElement) { |
| 249 FindElementWebView web_view(true, kElementNotExistsQueryOnce); | 249 FindElementWebView web_view(true, kElementNotExistsQueryOnce); |
| 250 Session session("id"); | 250 Session session("id"); |
| 251 base::DictionaryValue params; | 251 base::DictionaryValue params; |
| 252 params.SetString("using", "id"); | 252 params.SetString("using", "id"); |
| 253 params.SetString("value", "a"); | 253 params.SetString("value", "a"); |
| 254 scoped_ptr<base::Value> result; | 254 scoped_ptr<base::Value> result; |
| 255 ASSERT_EQ(kNoSuchElement, | 255 ASSERT_EQ(kNoSuchElement, |
| 256 ExecuteFindElement(1, &session, &web_view, params, &result).code()); | 256 ExecuteFindElement(1, &session, &web_view, params, &result).code()); |
| 257 } | 257 } |
| 258 | 258 |
| 259 TEST(CommandsTest, SuccessfulFindElements) { | 259 TEST(CommandsTest, SuccessfulFindElements) { |
| 260 FindElementWebView web_view(false, kElementExistsQueryTwice); | 260 FindElementWebView web_view(false, kElementExistsQueryTwice); |
| 261 Session session("id"); | 261 Session session("id"); |
| 262 session.implicit_wait = 1000; | 262 session.implicit_wait = 1000; |
| 263 session.frame = "frame_id2"; | 263 session.SwitchToSubFrame("frame_id2", ""); |
| 264 base::DictionaryValue params; | 264 base::DictionaryValue params; |
| 265 params.SetString("using", "name"); | 265 params.SetString("using", "name"); |
| 266 params.SetString("value", "b"); | 266 params.SetString("value", "b"); |
| 267 scoped_ptr<base::Value> result; | 267 scoped_ptr<base::Value> result; |
| 268 ASSERT_EQ( | 268 ASSERT_EQ( |
| 269 kOk, | 269 kOk, |
| 270 ExecuteFindElements(1, &session, &web_view, params, &result).code()); | 270 ExecuteFindElements(1, &session, &web_view, params, &result).code()); |
| 271 base::DictionaryValue param; | 271 base::DictionaryValue param; |
| 272 param.SetString("name", "b"); | 272 param.SetString("name", "b"); |
| 273 base::ListValue expected_args; | 273 base::ListValue expected_args; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 287 ExecuteFindElements(1, &session, &web_view, params, &result).code()); | 287 ExecuteFindElements(1, &session, &web_view, params, &result).code()); |
| 288 base::ListValue* list; | 288 base::ListValue* list; |
| 289 ASSERT_TRUE(result->GetAsList(&list)); | 289 ASSERT_TRUE(result->GetAsList(&list)); |
| 290 ASSERT_EQ(0U, list->GetSize()); | 290 ASSERT_EQ(0U, list->GetSize()); |
| 291 } | 291 } |
| 292 | 292 |
| 293 TEST(CommandsTest, SuccessfulFindChildElement) { | 293 TEST(CommandsTest, SuccessfulFindChildElement) { |
| 294 FindElementWebView web_view(true, kElementExistsQueryTwice); | 294 FindElementWebView web_view(true, kElementExistsQueryTwice); |
| 295 Session session("id"); | 295 Session session("id"); |
| 296 session.implicit_wait = 1000; | 296 session.implicit_wait = 1000; |
| 297 session.frame = "frame_id3"; | 297 session.SwitchToSubFrame("frame_id3", ""); |
| 298 base::DictionaryValue params; | 298 base::DictionaryValue params; |
| 299 params.SetString("using", "tag name"); | 299 params.SetString("using", "tag name"); |
| 300 params.SetString("value", "div"); | 300 params.SetString("value", "div"); |
| 301 std::string element_id = "1"; | 301 std::string element_id = "1"; |
| 302 scoped_ptr<base::Value> result; | 302 scoped_ptr<base::Value> result; |
| 303 ASSERT_EQ( | 303 ASSERT_EQ( |
| 304 kOk, | 304 kOk, |
| 305 ExecuteFindChildElement( | 305 ExecuteFindChildElement( |
| 306 1, &session, &web_view, element_id, params, &result).code()); | 306 1, &session, &web_view, element_id, params, &result).code()); |
| 307 base::DictionaryValue locator_param; | 307 base::DictionaryValue locator_param; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 325 ASSERT_EQ( | 325 ASSERT_EQ( |
| 326 kNoSuchElement, | 326 kNoSuchElement, |
| 327 ExecuteFindChildElement( | 327 ExecuteFindChildElement( |
| 328 1, &session, &web_view, element_id, params, &result).code()); | 328 1, &session, &web_view, element_id, params, &result).code()); |
| 329 } | 329 } |
| 330 | 330 |
| 331 TEST(CommandsTest, SuccessfulFindChildElements) { | 331 TEST(CommandsTest, SuccessfulFindChildElements) { |
| 332 FindElementWebView web_view(false, kElementExistsQueryTwice); | 332 FindElementWebView web_view(false, kElementExistsQueryTwice); |
| 333 Session session("id"); | 333 Session session("id"); |
| 334 session.implicit_wait = 1000; | 334 session.implicit_wait = 1000; |
| 335 session.frame = "frame_id4"; | 335 session.SwitchToSubFrame("frame_id4", ""); |
| 336 base::DictionaryValue params; | 336 base::DictionaryValue params; |
| 337 params.SetString("using", "class name"); | 337 params.SetString("using", "class name"); |
| 338 params.SetString("value", "c"); | 338 params.SetString("value", "c"); |
| 339 std::string element_id = "1"; | 339 std::string element_id = "1"; |
| 340 scoped_ptr<base::Value> result; | 340 scoped_ptr<base::Value> result; |
| 341 ASSERT_EQ( | 341 ASSERT_EQ( |
| 342 kOk, | 342 kOk, |
| 343 ExecuteFindChildElements( | 343 ExecuteFindChildElements( |
| 344 1, &session, &web_view, element_id, params, &result).code()); | 344 1, &session, &web_view, element_id, params, &result).code()); |
| 345 base::DictionaryValue locator_param; | 345 base::DictionaryValue locator_param; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 scoped_ptr<base::Value> result; | 427 scoped_ptr<base::Value> result; |
| 428 ASSERT_EQ( | 428 ASSERT_EQ( |
| 429 kStaleElementReference, | 429 kStaleElementReference, |
| 430 ExecuteFindChildElement( | 430 ExecuteFindChildElement( |
| 431 1, &session, &web_view, element_id, params, &result).code()); | 431 1, &session, &web_view, element_id, params, &result).code()); |
| 432 ASSERT_EQ( | 432 ASSERT_EQ( |
| 433 kStaleElementReference, | 433 kStaleElementReference, |
| 434 ExecuteFindChildElements( | 434 ExecuteFindChildElements( |
| 435 1, &session, &web_view, element_id, params, &result).code()); | 435 1, &session, &web_view, element_id, params, &result).code()); |
| 436 } | 436 } |
| OLD | NEW |