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

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

Issue 12226026: [ChromeDriver] Select the main frame if a non-existant child frame is targeted. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 10 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
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/chromedriver/devtools_client_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/file_path.h" 10 #include "base/file_path.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/test/chromedriver/chrome.h"
15 #include "chrome/test/chromedriver/command_executor_impl.h" 14 #include "chrome/test/chromedriver/command_executor_impl.h"
16 #include "chrome/test/chromedriver/commands.h" 15 #include "chrome/test/chromedriver/commands.h"
17 #include "chrome/test/chromedriver/fake_session_accessor.h" 16 #include "chrome/test/chromedriver/fake_session_accessor.h"
18 #include "chrome/test/chromedriver/status.h" 17 #include "chrome/test/chromedriver/status.h"
18 #include "chrome/test/chromedriver/stub_chrome.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 #include "third_party/webdriver/atoms.h" 20 #include "third_party/webdriver/atoms.h"
21 21
22 TEST(CommandsTest, GetStatus) { 22 TEST(CommandsTest, GetStatus) {
23 base::DictionaryValue params; 23 base::DictionaryValue params;
24 scoped_ptr<base::Value> value; 24 scoped_ptr<base::Value> value;
25 std::string session_id; 25 std::string session_id;
26 ASSERT_EQ(kOk, ExecuteGetStatus(params, "", &value, &session_id).code()); 26 ASSERT_EQ(kOk, ExecuteGetStatus(params, "", &value, &session_id).code());
27 base::DictionaryValue* dict; 27 base::DictionaryValue* dict;
28 ASSERT_TRUE(value->GetAsDictionary(&dict)); 28 ASSERT_TRUE(value->GetAsDictionary(&dict));
29 base::Value* unused; 29 base::Value* unused;
30 ASSERT_TRUE(dict->Get("os.name", &unused)); 30 ASSERT_TRUE(dict->Get("os.name", &unused));
31 ASSERT_TRUE(dict->Get("os.version", &unused)); 31 ASSERT_TRUE(dict->Get("os.version", &unused));
32 ASSERT_TRUE(dict->Get("os.arch", &unused)); 32 ASSERT_TRUE(dict->Get("os.arch", &unused));
33 ASSERT_TRUE(dict->Get("build.version", &unused)); 33 ASSERT_TRUE(dict->Get("build.version", &unused));
34 } 34 }
35 35
36 namespace { 36 namespace {
37 37
38 class StubChrome : public Chrome {
39 public:
40 StubChrome() {}
41 virtual ~StubChrome() {}
42
43 // Overridden from Chrome:
44 virtual Status Load(const std::string& url) OVERRIDE {
45 return Status(kOk);
46 }
47 virtual Status Reload() OVERRIDE {
48 return Status(kOk);
49 }
50 virtual Status EvaluateScript(const std::string& frame,
51 const std::string& function,
52 scoped_ptr<base::Value>* result) OVERRIDE {
53 return Status(kOk);
54 }
55 virtual Status CallFunction(const std::string& frame,
56 const std::string& function,
57 const base::ListValue& args,
58 scoped_ptr<base::Value>* result) OVERRIDE {
59 return Status(kOk);
60 }
61 virtual Status GetFrameByFunction(const std::string& frame,
62 const std::string& function,
63 const base::ListValue& args,
64 std::string* out_frame) OVERRIDE {
65 return Status(kOk);
66 }
67 virtual Status DispatchMouseEvents(
68 const std::list<MouseEvent>& events) OVERRIDE {
69 return Status(kOk);
70 }
71 virtual Status DispatchKeyEvents(const std::list<KeyEvent>& events) OVERRIDE {
72 return Status(kOk);
73 }
74 virtual Status Quit() OVERRIDE {
75 return Status(kOk);
76 }
77 virtual Status WaitForPendingNavigations(
78 const std::string& frame_id) OVERRIDE {
79 return Status(kOk);
80 }
81 virtual Status GetMainFrame(
82 std::string* frame_id) OVERRIDE {
83 return Status(kOk);
84 }
85 };
86
87 Status ExecuteStubQuit( 38 Status ExecuteStubQuit(
88 int* count, 39 int* count,
89 const base::DictionaryValue& params, 40 const base::DictionaryValue& params,
90 const std::string& session_id, 41 const std::string& session_id,
91 scoped_ptr<base::Value>* value, 42 scoped_ptr<base::Value>* value,
92 std::string* out_session_id) { 43 std::string* out_session_id) {
93 if (*count == 0) { 44 if (*count == 0) {
94 EXPECT_STREQ("id", session_id.c_str()); 45 EXPECT_STREQ("id", session_id.c_str());
95 } else { 46 } else {
96 EXPECT_STREQ("id2", session_id.c_str()); 47 EXPECT_STREQ("id2", session_id.c_str());
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 std::string element_id = "1"; 421 std::string element_id = "1";
471 scoped_ptr<base::Value> result; 422 scoped_ptr<base::Value> result;
472 ASSERT_EQ( 423 ASSERT_EQ(
473 kStaleElementReference, 424 kStaleElementReference,
474 ExecuteFindChildElement(1, &session, element_id, params, &result).code()); 425 ExecuteFindChildElement(1, &session, element_id, params, &result).code());
475 ASSERT_EQ( 426 ASSERT_EQ(
476 kStaleElementReference, 427 kStaleElementReference,
477 ExecuteFindChildElements( 428 ExecuteFindChildElements(
478 1, &session, element_id, params, &result).code()); 429 1, &session, element_id, params, &result).code());
479 } 430 }
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/chromedriver/devtools_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698