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 <list> | 5 #include <list> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/test/chromedriver/chrome/dom_tracker.h" | 10 #include "chrome/test/chromedriver/chrome/dom_tracker.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 std::string command; | 23 std::string command; |
24 if (!sent_command_queue_.empty()) { | 24 if (!sent_command_queue_.empty()) { |
25 command = sent_command_queue_.front(); | 25 command = sent_command_queue_.front(); |
26 sent_command_queue_.pop_front(); | 26 sent_command_queue_.pop_front(); |
27 } | 27 } |
28 return command; | 28 return command; |
29 } | 29 } |
30 | 30 |
31 // Overridden from DevToolsClient: | 31 // Overridden from DevToolsClient: |
32 virtual Status SendCommand(const std::string& method, | 32 virtual Status SendCommand(const std::string& method, |
33 const base::DictionaryValue& params) OVERRIDE { | 33 const base::DictionaryValue& params) override { |
34 sent_command_queue_.push_back(method); | 34 sent_command_queue_.push_back(method); |
35 return Status(kOk); | 35 return Status(kOk); |
36 } | 36 } |
37 virtual Status SendCommandAndGetResult( | 37 virtual Status SendCommandAndGetResult( |
38 const std::string& method, | 38 const std::string& method, |
39 const base::DictionaryValue& params, | 39 const base::DictionaryValue& params, |
40 scoped_ptr<base::DictionaryValue>* result) OVERRIDE { | 40 scoped_ptr<base::DictionaryValue>* result) override { |
41 return SendCommand(method, params); | 41 return SendCommand(method, params); |
42 } | 42 } |
43 | 43 |
44 private: | 44 private: |
45 std::list<std::string> sent_command_queue_; | 45 std::list<std::string> sent_command_queue_; |
46 }; | 46 }; |
47 | 47 |
48 } // namespace | 48 } // namespace |
49 | 49 |
50 TEST(DomTracker, GetFrameIdForNode) { | 50 TEST(DomTracker, GetFrameIdForNode) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 ASSERT_TRUE(frame_id.empty()); | 86 ASSERT_TRUE(frame_id.empty()); |
87 | 87 |
88 params.Clear(); | 88 params.Clear(); |
89 params.Set("node", base::JSONReader::Read( | 89 params.Set("node", base::JSONReader::Read( |
90 "{\"nodeId\":2,\"frameId\":\"f\"}")); | 90 "{\"nodeId\":2,\"frameId\":\"f\"}")); |
91 ASSERT_EQ(kOk, | 91 ASSERT_EQ(kOk, |
92 tracker.OnEvent(&client, "DOM.childNodeInserted", params).code()); | 92 tracker.OnEvent(&client, "DOM.childNodeInserted", params).code()); |
93 ASSERT_TRUE(tracker.GetFrameIdForNode(2, &frame_id).IsOk()); | 93 ASSERT_TRUE(tracker.GetFrameIdForNode(2, &frame_id).IsOk()); |
94 ASSERT_STREQ("f", frame_id.c_str()); | 94 ASSERT_STREQ("f", frame_id.c_str()); |
95 } | 95 } |
OLD | NEW |