OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/web_view/frame.h" | 5 #include "components/web_view/frame.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 FrameTreeServerPtr server_; | 168 FrameTreeServerPtr server_; |
169 mojo::Array<FrameDataPtr> adds_; | 169 mojo::Array<FrameDataPtr> adds_; |
170 | 170 |
171 DISALLOW_COPY_AND_ASSIGN(TestFrameTreeClient); | 171 DISALLOW_COPY_AND_ASSIGN(TestFrameTreeClient); |
172 }; | 172 }; |
173 | 173 |
174 // Verifies the root gets a connect. | 174 // Verifies the root gets a connect. |
175 TEST_F(FrameTest, RootGetsConnect) { | 175 TEST_F(FrameTest, RootGetsConnect) { |
176 TestFrameTreeDelegate tree_delegate; | 176 TestFrameTreeDelegate tree_delegate; |
177 TestFrameTreeClient root_client; | 177 TestFrameTreeClient root_client; |
178 FrameTree tree(0u, window_manager()->GetRoot(), &tree_delegate, &root_client, | 178 FrameTree tree(0u, window_manager()->GetRoot(), nullptr, &tree_delegate, |
179 nullptr, Frame::ClientPropertyMap()); | 179 &root_client, nullptr, Frame::ClientPropertyMap()); |
180 ASSERT_EQ(1, root_client.connect_count()); | 180 ASSERT_EQ(1, root_client.connect_count()); |
181 mojo::Array<FrameDataPtr> frames = root_client.connect_frames(); | 181 mojo::Array<FrameDataPtr> frames = root_client.connect_frames(); |
182 ASSERT_EQ(1u, frames.size()); | 182 ASSERT_EQ(1u, frames.size()); |
183 EXPECT_EQ(tree.root()->view()->id(), frames[0]->frame_id); | 183 EXPECT_EQ(tree.root()->view()->id(), frames[0]->frame_id); |
184 EXPECT_EQ(0u, frames[0]->parent_id); | 184 EXPECT_EQ(0u, frames[0]->parent_id); |
185 } | 185 } |
186 | 186 |
187 // Verifies adding a child to the root. | 187 // Verifies adding a child to the root. |
188 TEST_F(FrameTest, SingleChild) { | 188 TEST_F(FrameTest, SingleChild) { |
189 TestFrameTreeDelegate tree_delegate; | 189 TestFrameTreeDelegate tree_delegate; |
190 TestFrameTreeClient root_client; | 190 TestFrameTreeClient root_client; |
191 FrameTree tree(0u, window_manager()->GetRoot(), &tree_delegate, &root_client, | 191 FrameTree tree(0u, window_manager()->GetRoot(), nullptr, &tree_delegate, |
192 nullptr, Frame::ClientPropertyMap()); | 192 &root_client, nullptr, Frame::ClientPropertyMap()); |
193 | 193 |
194 View* child = window_manager()->CreateView(); | 194 View* child = window_manager()->CreateView(); |
195 EXPECT_EQ(nullptr, Frame::FindFirstFrameAncestor(child)); | 195 EXPECT_EQ(nullptr, Frame::FindFirstFrameAncestor(child)); |
196 window_manager()->GetRoot()->AddChild(child); | 196 window_manager()->GetRoot()->AddChild(child); |
197 EXPECT_EQ(tree.root(), Frame::FindFirstFrameAncestor(child)); | 197 EXPECT_EQ(tree.root(), Frame::FindFirstFrameAncestor(child)); |
198 | 198 |
199 TestFrameTreeClient child_client; | 199 TestFrameTreeClient child_client; |
200 Frame* child_frame = | 200 Frame* child_frame = |
201 tree.CreateAndAddFrame(child, tree.root(), 0u, &child_client, nullptr); | 201 tree.CreateAndAddFrame(child, tree.root(), 0u, &child_client, nullptr); |
202 EXPECT_EQ(tree.root(), child_frame->parent()); | 202 EXPECT_EQ(tree.root(), child_frame->parent()); |
203 | 203 |
204 ASSERT_EQ(1, child_client.connect_count()); | 204 ASSERT_EQ(1, child_client.connect_count()); |
205 mojo::Array<FrameDataPtr> frames_in_child = child_client.connect_frames(); | 205 mojo::Array<FrameDataPtr> frames_in_child = child_client.connect_frames(); |
206 // We expect 2 frames. One for the root, one for the child. | 206 // We expect 2 frames. One for the root, one for the child. |
207 ASSERT_EQ(2u, frames_in_child.size()); | 207 ASSERT_EQ(2u, frames_in_child.size()); |
208 EXPECT_EQ(tree.root()->view()->id(), frames_in_child[0]->frame_id); | 208 EXPECT_EQ(tree.root()->view()->id(), frames_in_child[0]->frame_id); |
209 EXPECT_EQ(0u, frames_in_child[0]->parent_id); | 209 EXPECT_EQ(0u, frames_in_child[0]->parent_id); |
210 EXPECT_EQ(child_frame->view()->id(), frames_in_child[1]->frame_id); | 210 EXPECT_EQ(child_frame->view()->id(), frames_in_child[1]->frame_id); |
211 EXPECT_EQ(tree.root()->view()->id(), frames_in_child[1]->parent_id); | 211 EXPECT_EQ(tree.root()->view()->id(), frames_in_child[1]->parent_id); |
212 | 212 |
213 // We should have gotten notification of the add. | 213 // We should have gotten notification of the add. |
214 EXPECT_EQ(1u, root_client.adds().size()); | 214 EXPECT_EQ(1u, root_client.adds().size()); |
215 } | 215 } |
216 | 216 |
217 } // namespace web_view | 217 } // namespace web_view |
OLD | NEW |