OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/frame_host/frame_tree.h" | 5 #include "content/browser/frame_host/frame_tree.h" |
6 | 6 |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "content/browser/frame_host/navigator_impl.h" | 9 #include "content/browser/frame_host/navigator_impl.h" |
10 #include "content/browser/frame_host/render_frame_host_factory.h" | 10 #include "content/browser/frame_host/render_frame_host_factory.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 103 |
104 std::string no_children_node("no children node"); | 104 std::string no_children_node("no children node"); |
105 std::string deep_subtree("node with deep subtree"); | 105 std::string deep_subtree("node with deep subtree"); |
106 | 106 |
107 // Ensure the top-level node of the FrameTree is initialized by simulating a | 107 // Ensure the top-level node of the FrameTree is initialized by simulating a |
108 // main frame swap here. | 108 // main frame swap here. |
109 scoped_ptr<RenderFrameHostImpl> render_frame_host = | 109 scoped_ptr<RenderFrameHostImpl> render_frame_host = |
110 RenderFrameHostFactory::Create(static_cast<RenderViewHostImpl*>(rvh()), | 110 RenderFrameHostFactory::Create(static_cast<RenderViewHostImpl*>(rvh()), |
111 NULL, | 111 NULL, |
112 &frame_tree, | 112 &frame_tree, |
| 113 frame_tree.root(), |
113 process()->GetNextRoutingID(), | 114 process()->GetNextRoutingID(), |
114 false); | 115 false); |
115 frame_tree.SwapMainFrame(render_frame_host.get()); | 116 frame_tree.SwapMainFrame(render_frame_host.get()); |
116 frame_tree.OnFirstNavigationAfterSwap(5); | 117 frame_tree.OnFirstNavigationAfterSwap(5); |
117 | 118 |
118 ASSERT_EQ("5: []", GetTreeState(&frame_tree)); | 119 ASSERT_EQ("5: []", GetTreeState(&frame_tree)); |
119 | 120 |
120 // Simulate attaching a series of frames to build the frame tree. | 121 // Simulate attaching a series of frames to build the frame tree. |
121 frame_tree.AddFrame(process()->GetNextRoutingID(), 5, 14, std::string()); | 122 frame_tree.AddFrame(process()->GetNextRoutingID(), 5, 14, std::string()); |
122 frame_tree.AddFrame(process()->GetNextRoutingID(), 5, 15, std::string()); | 123 frame_tree.AddFrame(process()->GetNextRoutingID(), 5, 15, std::string()); |
(...skipping 21 matching lines...) Expand all Loading... |
144 | 145 |
145 // Now that's it's fully built, verify the tree structure is as expected. | 146 // Now that's it's fully built, verify the tree structure is as expected. |
146 ASSERT_EQ("5: [14: [244: [], 245: []], " | 147 ASSERT_EQ("5: [14: [244: [], 245: []], " |
147 "15: [255 'no children node': []], " | 148 "15: [255 'no children node': []], " |
148 "16: [264: [], 265: [], 266: [], " | 149 "16: [264: [], 265: [], 266: [], " |
149 "267 'node with deep subtree': " | 150 "267 'node with deep subtree': " |
150 "[365: [455: [555: [655: []]]]], 268: []]]", | 151 "[365: [455: [555: [655: []]]]], 268: []]]", |
151 GetTreeState(&frame_tree)); | 152 GetTreeState(&frame_tree)); |
152 | 153 |
153 // Test removing of nodes. | 154 // Test removing of nodes. |
154 frame_tree.RemoveFrame(555, 655); | 155 frame_tree.RemoveFrame(NULL, 555, 655); |
155 ASSERT_EQ("5: [14: [244: [], 245: []], " | 156 ASSERT_EQ("5: [14: [244: [], 245: []], " |
156 "15: [255 'no children node': []], " | 157 "15: [255 'no children node': []], " |
157 "16: [264: [], 265: [], 266: [], " | 158 "16: [264: [], 265: [], 266: [], " |
158 "267 'node with deep subtree': " | 159 "267 'node with deep subtree': " |
159 "[365: [455: [555: []]]], 268: []]]", | 160 "[365: [455: [555: []]]], 268: []]]", |
160 GetTreeState(&frame_tree)); | 161 GetTreeState(&frame_tree)); |
161 | 162 |
162 frame_tree.RemoveFrame(16, 265); | 163 frame_tree.RemoveFrame(NULL, 16, 265); |
163 ASSERT_EQ("5: [14: [244: [], 245: []], " | 164 ASSERT_EQ("5: [14: [244: [], 245: []], " |
164 "15: [255 'no children node': []], " | 165 "15: [255 'no children node': []], " |
165 "16: [264: [], 266: [], " | 166 "16: [264: [], 266: [], " |
166 "267 'node with deep subtree': " | 167 "267 'node with deep subtree': " |
167 "[365: [455: [555: []]]], 268: []]]", | 168 "[365: [455: [555: []]]], 268: []]]", |
168 GetTreeState(&frame_tree)); | 169 GetTreeState(&frame_tree)); |
169 | 170 |
170 frame_tree.RemoveFrame(5, 15); | 171 frame_tree.RemoveFrame(NULL, 5, 15); |
171 ASSERT_EQ("5: [14: [244: [], 245: []], " | 172 ASSERT_EQ("5: [14: [244: [], 245: []], " |
172 "16: [264: [], 266: [], " | 173 "16: [264: [], 266: [], " |
173 "267 'node with deep subtree': " | 174 "267 'node with deep subtree': " |
174 "[365: [455: [555: []]]], 268: []]]", | 175 "[365: [455: [555: []]]], 268: []]]", |
175 GetTreeState(&frame_tree)); | 176 GetTreeState(&frame_tree)); |
176 } | 177 } |
177 | 178 |
178 } // namespace | 179 } // namespace |
179 } // namespace content | 180 } // namespace content |
OLD | NEW |