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

Side by Side Diff: chrome/test/chromedriver/commands_unittest.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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 <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 10 matching lines...) Expand all
21 #include "chrome/test/chromedriver/fake_session_accessor.h" 21 #include "chrome/test/chromedriver/fake_session_accessor.h"
22 #include "chrome/test/chromedriver/session_commands.h" 22 #include "chrome/test/chromedriver/session_commands.h"
23 #include "chrome/test/chromedriver/window_commands.h" 23 #include "chrome/test/chromedriver/window_commands.h"
24 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
25 #include "third_party/webdriver/atoms.h" 25 #include "third_party/webdriver/atoms.h"
26 26
27 TEST(CommandsTest, GetStatus) { 27 TEST(CommandsTest, GetStatus) {
28 base::DictionaryValue params; 28 base::DictionaryValue params;
29 scoped_ptr<base::Value> value; 29 scoped_ptr<base::Value> value;
30 std::string session_id; 30 std::string session_id;
31 ASSERT_EQ(kOk, ExecuteGetStatus(params, "", &value, &session_id).code()); 31 ASSERT_EQ(
32 kOk, ExecuteGetStatus(params, std::string(), &value, &session_id).code());
32 base::DictionaryValue* dict; 33 base::DictionaryValue* dict;
33 ASSERT_TRUE(value->GetAsDictionary(&dict)); 34 ASSERT_TRUE(value->GetAsDictionary(&dict));
34 base::Value* unused; 35 base::Value* unused;
35 ASSERT_TRUE(dict->Get("os.name", &unused)); 36 ASSERT_TRUE(dict->Get("os.name", &unused));
36 ASSERT_TRUE(dict->Get("os.version", &unused)); 37 ASSERT_TRUE(dict->Get("os.version", &unused));
37 ASSERT_TRUE(dict->Get("os.arch", &unused)); 38 ASSERT_TRUE(dict->Get("os.arch", &unused));
38 ASSERT_TRUE(dict->Get("build.version", &unused)); 39 ASSERT_TRUE(dict->Get("build.version", &unused));
39 } 40 }
40 41
41 namespace { 42 namespace {
(...skipping 23 matching lines...) Expand all
65 scoped_refptr<SessionAccessor>(new FakeSessionAccessor(&session))); 66 scoped_refptr<SessionAccessor>(new FakeSessionAccessor(&session)));
66 map.Set(session2.id, 67 map.Set(session2.id,
67 scoped_refptr<SessionAccessor>(new FakeSessionAccessor(&session2))); 68 scoped_refptr<SessionAccessor>(new FakeSessionAccessor(&session2)));
68 69
69 int count = 0; 70 int count = 0;
70 Command cmd = base::Bind(&ExecuteStubQuit, &count); 71 Command cmd = base::Bind(&ExecuteStubQuit, &count);
71 base::DictionaryValue params; 72 base::DictionaryValue params;
72 scoped_ptr<base::Value> value; 73 scoped_ptr<base::Value> value;
73 std::string session_id; 74 std::string session_id;
74 Status status = 75 Status status =
75 ExecuteQuitAll(cmd, &map, params, "", &value, &session_id); 76 ExecuteQuitAll(cmd, &map, params, std::string(), &value, &session_id);
76 ASSERT_EQ(kOk, status.code()); 77 ASSERT_EQ(kOk, status.code());
77 ASSERT_FALSE(value.get()); 78 ASSERT_FALSE(value.get());
78 ASSERT_EQ(2, count); 79 ASSERT_EQ(2, count);
79 } 80 }
80 81
81 TEST(CommandsTest, Quit) { 82 TEST(CommandsTest, Quit) {
82 SessionMap map; 83 SessionMap map;
83 Session session("id", scoped_ptr<Chrome>(new StubChrome())); 84 Session session("id", scoped_ptr<Chrome>(new StubChrome()));
84 ASSERT_TRUE(session.thread.Start()); 85 ASSERT_TRUE(session.thread.Start());
85 scoped_refptr<FakeSessionAccessor> session_accessor( 86 scoped_refptr<FakeSessionAccessor> session_accessor(
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 scoped_ptr<base::ListValue> args_; 237 scoped_ptr<base::ListValue> args_;
237 scoped_ptr<base::Value> result_; 238 scoped_ptr<base::Value> result_;
238 }; 239 };
239 240
240 } // namespace 241 } // namespace
241 242
242 TEST(CommandsTest, SuccessfulFindElement) { 243 TEST(CommandsTest, SuccessfulFindElement) {
243 FindElementWebView web_view(true, kElementExistsQueryTwice); 244 FindElementWebView web_view(true, kElementExistsQueryTwice);
244 Session session("id"); 245 Session session("id");
245 session.implicit_wait = 1000; 246 session.implicit_wait = 1000;
246 session.SwitchToSubFrame("frame_id1", ""); 247 session.SwitchToSubFrame("frame_id1", std::string());
247 base::DictionaryValue params; 248 base::DictionaryValue params;
248 params.SetString("using", "id"); 249 params.SetString("using", "id");
249 params.SetString("value", "a"); 250 params.SetString("value", "a");
250 scoped_ptr<base::Value> result; 251 scoped_ptr<base::Value> result;
251 ASSERT_EQ(kOk, 252 ASSERT_EQ(kOk,
252 ExecuteFindElement(1, &session, &web_view, params, &result).code()); 253 ExecuteFindElement(1, &session, &web_view, params, &result).code());
253 base::DictionaryValue param; 254 base::DictionaryValue param;
254 param.SetString("id", "a"); 255 param.SetString("id", "a");
255 base::ListValue expected_args; 256 base::ListValue expected_args;
256 expected_args.Append(param.DeepCopy()); 257 expected_args.Append(param.DeepCopy());
257 web_view.Verify("frame_id1", &expected_args, result.get()); 258 web_view.Verify("frame_id1", &expected_args, result.get());
258 } 259 }
259 260
260 TEST(CommandsTest, FailedFindElement) { 261 TEST(CommandsTest, FailedFindElement) {
261 FindElementWebView web_view(true, kElementNotExistsQueryOnce); 262 FindElementWebView web_view(true, kElementNotExistsQueryOnce);
262 Session session("id"); 263 Session session("id");
263 base::DictionaryValue params; 264 base::DictionaryValue params;
264 params.SetString("using", "id"); 265 params.SetString("using", "id");
265 params.SetString("value", "a"); 266 params.SetString("value", "a");
266 scoped_ptr<base::Value> result; 267 scoped_ptr<base::Value> result;
267 ASSERT_EQ(kNoSuchElement, 268 ASSERT_EQ(kNoSuchElement,
268 ExecuteFindElement(1, &session, &web_view, params, &result).code()); 269 ExecuteFindElement(1, &session, &web_view, params, &result).code());
269 } 270 }
270 271
271 TEST(CommandsTest, SuccessfulFindElements) { 272 TEST(CommandsTest, SuccessfulFindElements) {
272 FindElementWebView web_view(false, kElementExistsQueryTwice); 273 FindElementWebView web_view(false, kElementExistsQueryTwice);
273 Session session("id"); 274 Session session("id");
274 session.implicit_wait = 1000; 275 session.implicit_wait = 1000;
275 session.SwitchToSubFrame("frame_id2", ""); 276 session.SwitchToSubFrame("frame_id2", std::string());
276 base::DictionaryValue params; 277 base::DictionaryValue params;
277 params.SetString("using", "name"); 278 params.SetString("using", "name");
278 params.SetString("value", "b"); 279 params.SetString("value", "b");
279 scoped_ptr<base::Value> result; 280 scoped_ptr<base::Value> result;
280 ASSERT_EQ( 281 ASSERT_EQ(
281 kOk, 282 kOk,
282 ExecuteFindElements(1, &session, &web_view, params, &result).code()); 283 ExecuteFindElements(1, &session, &web_view, params, &result).code());
283 base::DictionaryValue param; 284 base::DictionaryValue param;
284 param.SetString("name", "b"); 285 param.SetString("name", "b");
285 base::ListValue expected_args; 286 base::ListValue expected_args;
(...skipping 13 matching lines...) Expand all
299 ExecuteFindElements(1, &session, &web_view, params, &result).code()); 300 ExecuteFindElements(1, &session, &web_view, params, &result).code());
300 base::ListValue* list; 301 base::ListValue* list;
301 ASSERT_TRUE(result->GetAsList(&list)); 302 ASSERT_TRUE(result->GetAsList(&list));
302 ASSERT_EQ(0U, list->GetSize()); 303 ASSERT_EQ(0U, list->GetSize());
303 } 304 }
304 305
305 TEST(CommandsTest, SuccessfulFindChildElement) { 306 TEST(CommandsTest, SuccessfulFindChildElement) {
306 FindElementWebView web_view(true, kElementExistsQueryTwice); 307 FindElementWebView web_view(true, kElementExistsQueryTwice);
307 Session session("id"); 308 Session session("id");
308 session.implicit_wait = 1000; 309 session.implicit_wait = 1000;
309 session.SwitchToSubFrame("frame_id3", ""); 310 session.SwitchToSubFrame("frame_id3", std::string());
310 base::DictionaryValue params; 311 base::DictionaryValue params;
311 params.SetString("using", "tag name"); 312 params.SetString("using", "tag name");
312 params.SetString("value", "div"); 313 params.SetString("value", "div");
313 std::string element_id = "1"; 314 std::string element_id = "1";
314 scoped_ptr<base::Value> result; 315 scoped_ptr<base::Value> result;
315 ASSERT_EQ( 316 ASSERT_EQ(
316 kOk, 317 kOk,
317 ExecuteFindChildElement( 318 ExecuteFindChildElement(
318 1, &session, &web_view, element_id, params, &result).code()); 319 1, &session, &web_view, element_id, params, &result).code());
319 base::DictionaryValue locator_param; 320 base::DictionaryValue locator_param;
(...skipping 17 matching lines...) Expand all
337 ASSERT_EQ( 338 ASSERT_EQ(
338 kNoSuchElement, 339 kNoSuchElement,
339 ExecuteFindChildElement( 340 ExecuteFindChildElement(
340 1, &session, &web_view, element_id, params, &result).code()); 341 1, &session, &web_view, element_id, params, &result).code());
341 } 342 }
342 343
343 TEST(CommandsTest, SuccessfulFindChildElements) { 344 TEST(CommandsTest, SuccessfulFindChildElements) {
344 FindElementWebView web_view(false, kElementExistsQueryTwice); 345 FindElementWebView web_view(false, kElementExistsQueryTwice);
345 Session session("id"); 346 Session session("id");
346 session.implicit_wait = 1000; 347 session.implicit_wait = 1000;
347 session.SwitchToSubFrame("frame_id4", ""); 348 session.SwitchToSubFrame("frame_id4", std::string());
348 base::DictionaryValue params; 349 base::DictionaryValue params;
349 params.SetString("using", "class name"); 350 params.SetString("using", "class name");
350 params.SetString("value", "c"); 351 params.SetString("value", "c");
351 std::string element_id = "1"; 352 std::string element_id = "1";
352 scoped_ptr<base::Value> result; 353 scoped_ptr<base::Value> result;
353 ASSERT_EQ( 354 ASSERT_EQ(
354 kOk, 355 kOk,
355 ExecuteFindChildElements( 356 ExecuteFindChildElements(
356 1, &session, &web_view, element_id, params, &result).code()); 357 1, &session, &web_view, element_id, params, &result).code());
357 base::DictionaryValue locator_param; 358 base::DictionaryValue locator_param;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 scoped_ptr<base::Value> result; 440 scoped_ptr<base::Value> result;
440 ASSERT_EQ( 441 ASSERT_EQ(
441 kStaleElementReference, 442 kStaleElementReference,
442 ExecuteFindChildElement( 443 ExecuteFindChildElement(
443 1, &session, &web_view, element_id, params, &result).code()); 444 1, &session, &web_view, element_id, params, &result).code());
444 ASSERT_EQ( 445 ASSERT_EQ(
445 kStaleElementReference, 446 kStaleElementReference,
446 ExecuteFindChildElements( 447 ExecuteFindChildElements(
447 1, &session, &web_view, element_id, params, &result).code()); 448 1, &session, &web_view, element_id, params, &result).code());
448 } 449 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/command_executor_impl_unittest.cc ('k') | chrome/test/chromedriver/key_converter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698