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

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

Issue 11639019: [chromedriver] Implement SwitchToFrame command. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 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/test/chromedriver/dom_tracker.cc ('k') | chrome/test/chromedriver/run_py_tests.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <string>
6
7 #include "base/json/json_reader.h"
8 #include "base/values.h"
9 #include "chrome/test/chromedriver/dom_tracker.h"
10 #include "chrome/test/chromedriver/status.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 TEST(DomTracker, GetFrameIdForNode) {
14 DomTracker tracker;
15 std::string frame_id;
16 ASSERT_TRUE(tracker.GetFrameIdForNode(101, &frame_id).IsError());
17 ASSERT_TRUE(frame_id.empty());
18
19 const char nodes[] =
20 "[{\"nodeId\":100,\"children\":"
21 " [{\"nodeId\":101},"
22 " {\"nodeId\":102,\"frameId\":\"f\"}]"
23 "}]";
24 base::DictionaryValue params;
25 params.Set("nodes", base::JSONReader::Read(nodes));
26 tracker.OnEvent("DOM.setChildNodes", params);
27 ASSERT_TRUE(tracker.GetFrameIdForNode(101, &frame_id).IsError());
28 ASSERT_TRUE(frame_id.empty());
29 ASSERT_TRUE(tracker.GetFrameIdForNode(102, &frame_id).IsOk());
30 ASSERT_STREQ("f", frame_id.c_str());
31
32 tracker.OnEvent("DOM.documentUpdated", params);
33 ASSERT_TRUE(tracker.GetFrameIdForNode(102, &frame_id).IsError());
34 }
35
36 TEST(DomTracker, GetContextIdForFrame) {
37 DomTracker tracker;
38 int context_id = -1;
39 ASSERT_TRUE(tracker.GetContextIdForFrame("f", &context_id).IsError());
40 ASSERT_EQ(-1, context_id);
41
42 const char context[] = "{\"id\":100,\"frameId\":\"f\"}";
43 base::DictionaryValue params;
44 params.Set("context", base::JSONReader::Read(context));
45 tracker.OnEvent("Runtime.executionContextCreated", params);
46 ASSERT_TRUE(tracker.GetContextIdForFrame("foo", &context_id).IsError());
47 ASSERT_EQ(-1, context_id);
48 ASSERT_TRUE(tracker.GetContextIdForFrame("f", &context_id).IsOk());
49 ASSERT_EQ(100, context_id);
50
51 tracker.OnEvent("DOM.documentUpdated", params);
52 ASSERT_TRUE(tracker.GetContextIdForFrame("f", &context_id).IsError());
53 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/dom_tracker.cc ('k') | chrome/test/chromedriver/run_py_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698