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

Unified Diff: content/browser/frame_host/frame_tree_unittest.cc

Issue 30323002: [DRAFT] Create RenderFrameHostManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Misc fixes Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/frame_host/frame_tree_node.cc ('k') | content/browser/frame_host/interstitial_page_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/frame_tree_unittest.cc
diff --git a/content/browser/frame_host/frame_tree_unittest.cc b/content/browser/frame_host/frame_tree_unittest.cc
index ede3513ab68f71aa419dc56331ff371213a99109..61374fc5f8463103a2bcd7bb8f4b478b1438439c 100644
--- a/content/browser/frame_host/frame_tree_unittest.cc
+++ b/content/browser/frame_host/frame_tree_unittest.cc
@@ -31,7 +31,9 @@ class FrameTreeTest : public RenderViewHostTestHarness {
private:
void AppendTreeNodeState(FrameTreeNode* node, std::string* result) {
- result->append(base::Int64ToString(node->frame_id()));
+ int frame_id = node->current_frame_host()->render_view_host()->
+ GetFrameIDForTesting(node->frame_tree_node_id());
+ result->append(base::Int64ToString(frame_id));
if (!node->frame_name().empty()) {
result->append(" '");
result->append(node->frame_name());
@@ -48,25 +50,6 @@ class FrameTreeTest : public RenderViewHostTestHarness {
}
};
-// Test that swapping the main frame resets the renderer-assigned frame id.
-// - On creation, frame id is unassigned.
-// - After a swap, frame id is unassigned.
-TEST_F(FrameTreeTest, FirstNavigationAfterSwap) {
- FrameTree frame_tree(new NavigatorImpl(NULL, NULL), NULL, NULL, NULL, NULL);
-
- EXPECT_TRUE(frame_tree.IsFirstNavigationAfterSwap());
- EXPECT_EQ(FrameTreeNode::kInvalidFrameId,
- frame_tree.root()->frame_id());
- frame_tree.OnFirstNavigationAfterSwap(1);
- EXPECT_FALSE(frame_tree.IsFirstNavigationAfterSwap());
- EXPECT_EQ(1, frame_tree.root()->frame_id());
-
- frame_tree.ResetForMainFrameSwap();
- EXPECT_TRUE(frame_tree.IsFirstNavigationAfterSwap());
- EXPECT_EQ(FrameTreeNode::kInvalidFrameId,
- frame_tree.root()->frame_id());
-}
-
// Exercise tree manipulation routines.
// - Add a series of nodes and verify tree structure.
// - Remove a series of nodes and verify tree structure.
@@ -76,71 +59,94 @@ TEST_F(FrameTreeTest, Shape) {
FrameTree* frame_tree =
static_cast<WebContentsImpl*>(web_contents())->GetFrameTree();
+ // Navigate to a URL to register the frame ID.
+ NavigateAndCommit(GURL("about:blank"));
+
std::string no_children_node("no children node");
std::string deep_subtree("node with deep subtree");
- frame_tree->OnFirstNavigationAfterSwap(5);
+ // Ensure the top-level node of the FrameTree is initialized by simulating a
+ // main frame swap here.
+ RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh());
- ASSERT_EQ("5: []", GetTreeState(frame_tree));
+ // kFrameId in TestRenderViewHost is 13.
+ ASSERT_EQ("13: []", GetTreeState(frame_tree));
// Simulate attaching a series of frames to build the frame tree.
- frame_tree->AddFrame(process()->GetNextRoutingID(), 5, 14, std::string());
- frame_tree->AddFrame(process()->GetNextRoutingID(), 5, 15, std::string());
- frame_tree->AddFrame(process()->GetNextRoutingID(), 5, 16, std::string());
-
- frame_tree->AddFrame(process()->GetNextRoutingID(), 14, 244, std::string());
- frame_tree->AddFrame(process()->GetNextRoutingID(), 15, 255,
+ frame_tree->AddFrame(rvhi, process()->GetNextRoutingID(), 13, 14,
+ std::string());
+ frame_tree->AddFrame(rvhi, process()->GetNextRoutingID(), 13, 15,
+ std::string());
+ frame_tree->AddFrame(rvhi, process()->GetNextRoutingID(), 13, 16,
+ std::string());
+
+ frame_tree->AddFrame(rvhi, process()->GetNextRoutingID(), 14, 244,
+ std::string());
+ frame_tree->AddFrame(rvhi, process()->GetNextRoutingID(), 15, 255,
no_children_node);
- frame_tree->AddFrame(process()->GetNextRoutingID(), 14, 245, std::string());
+ frame_tree->AddFrame(rvhi, process()->GetNextRoutingID(), 14, 245,
+ std::string());
- ASSERT_EQ("5: [14: [244: [], 245: []], "
- "15: [255 'no children node': []], "
- "16: []]",
+ ASSERT_EQ("13: [14: [244: [], 245: []], "
+ "15: [255 'no children node': []], "
+ "16: []]",
GetTreeState(frame_tree));
- frame_tree->AddFrame(process()->GetNextRoutingID(), 16, 264, std::string());
- frame_tree->AddFrame(process()->GetNextRoutingID(), 16, 265, std::string());
- frame_tree->AddFrame(process()->GetNextRoutingID(), 16, 266, std::string());
- frame_tree->AddFrame(process()->GetNextRoutingID(), 16, 267, deep_subtree);
- frame_tree->AddFrame(process()->GetNextRoutingID(), 16, 268, std::string());
-
- frame_tree->AddFrame(process()->GetNextRoutingID(), 267, 365, std::string());
- frame_tree->AddFrame(process()->GetNextRoutingID(), 365, 455, std::string());
- frame_tree->AddFrame(process()->GetNextRoutingID(), 455, 555, std::string());
- frame_tree->AddFrame(process()->GetNextRoutingID(), 555, 655, std::string());
+ frame_tree->AddFrame(rvhi, process()->GetNextRoutingID(), 16, 264,
+ std::string());
+ frame_tree->AddFrame(rvhi, process()->GetNextRoutingID(), 16, 265,
+ std::string());
+ frame_tree->AddFrame(rvhi, process()->GetNextRoutingID(), 16, 266,
+ std::string());
+ frame_tree->AddFrame(rvhi, process()->GetNextRoutingID(), 16, 267,
+ deep_subtree);
+ frame_tree->AddFrame(rvhi, process()->GetNextRoutingID(), 16, 268,
+ std::string());
+
+ frame_tree->AddFrame(rvhi, process()->GetNextRoutingID(), 267, 365,
+ std::string());
+ frame_tree->AddFrame(rvhi, process()->GetNextRoutingID(), 365, 455,
+ std::string());
+ frame_tree->AddFrame(rvhi, process()->GetNextRoutingID(), 455, 555,
+ std::string());
+ frame_tree->AddFrame(rvhi, process()->GetNextRoutingID(), 555, 655,
+ std::string());
// Now that's it's fully built, verify the tree structure is as expected.
- ASSERT_EQ("5: [14: [244: [], 245: []], "
- "15: [255 'no children node': []], "
- "16: [264: [], 265: [], 266: [], "
- "267 'node with deep subtree': "
- "[365: [455: [555: [655: []]]]], 268: []]]",
+ ASSERT_EQ("13: [14: [244: [], 245: []], "
+ "15: [255 'no children node': []], "
+ "16: [264: [], 265: [], 266: [], "
+ "267 'node with deep subtree': "
+ "[365: [455: [555: [655: []]]]], 268: []]]",
GetTreeState(frame_tree));
// Test removing of nodes. Clear the frame removal listener so we can pass a
// NULL RFH here.
frame_tree->ClearFrameRemoveListenerForTesting();
- frame_tree->RemoveFrame(NULL, 555, 655);
- ASSERT_EQ("5: [14: [244: [], 245: []], "
- "15: [255 'no children node': []], "
- "16: [264: [], 265: [], 266: [], "
- "267 'node with deep subtree': "
- "[365: [455: [555: []]]], 268: []]]",
+ frame_tree->RemoveFrame(NULL, rvhi->GetFrameTreeNodeID(555),
+ rvhi->GetFrameTreeNodeID(655), 655);
+ ASSERT_EQ("13: [14: [244: [], 245: []], "
+ "15: [255 'no children node': []], "
+ "16: [264: [], 265: [], 266: [], "
+ "267 'node with deep subtree': "
+ "[365: [455: [555: []]]], 268: []]]",
GetTreeState(frame_tree));
- frame_tree->RemoveFrame(NULL, 16, 265);
- ASSERT_EQ("5: [14: [244: [], 245: []], "
- "15: [255 'no children node': []], "
- "16: [264: [], 266: [], "
- "267 'node with deep subtree': "
- "[365: [455: [555: []]]], 268: []]]",
+ frame_tree->RemoveFrame(NULL, rvhi->GetFrameTreeNodeID(16),
+ rvhi->GetFrameTreeNodeID(265), 265);
+ ASSERT_EQ("13: [14: [244: [], 245: []], "
+ "15: [255 'no children node': []], "
+ "16: [264: [], 266: [], "
+ "267 'node with deep subtree': "
+ "[365: [455: [555: []]]], 268: []]]",
GetTreeState(frame_tree));
- frame_tree->RemoveFrame(NULL, 5, 15);
- ASSERT_EQ("5: [14: [244: [], 245: []], "
- "16: [264: [], 266: [], "
- "267 'node with deep subtree': "
- "[365: [455: [555: []]]], 268: []]]",
+ frame_tree->RemoveFrame(NULL, rvhi->GetFrameTreeNodeID(13),
+ rvhi->GetFrameTreeNodeID(15), 15);
+ ASSERT_EQ("13: [14: [244: [], 245: []], "
+ "16: [264: [], 266: [], "
+ "267 'node with deep subtree': "
+ "[365: [455: [555: []]]], 268: []]]",
GetTreeState(frame_tree));
}
« no previous file with comments | « content/browser/frame_host/frame_tree_node.cc ('k') | content/browser/frame_host/interstitial_page_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698