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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "components/html_viewer/public/interfaces/test_html_viewer.mojom.h" | 21 #include "components/html_viewer/public/interfaces/test_html_viewer.mojom.h" |
22 #include "components/mus/public/cpp/tests/window_server_test_base.h" | 22 #include "components/mus/public/cpp/tests/window_server_test_base.h" |
23 #include "components/mus/public/cpp/window.h" | 23 #include "components/mus/public/cpp/window.h" |
24 #include "components/mus/public/cpp/window_tree_connection.h" | 24 #include "components/mus/public/cpp/window_tree_connection.h" |
25 #include "components/web_view/frame.h" | 25 #include "components/web_view/frame.h" |
26 #include "components/web_view/frame_connection.h" | 26 #include "components/web_view/frame_connection.h" |
27 #include "components/web_view/frame_tree.h" | 27 #include "components/web_view/frame_tree.h" |
28 #include "components/web_view/public/interfaces/frame.mojom.h" | 28 #include "components/web_view/public/interfaces/frame.mojom.h" |
29 #include "components/web_view/test_frame_tree_delegate.h" | 29 #include "components/web_view/test_frame_tree_delegate.h" |
30 #include "mojo/services/accessibility/public/interfaces/accessibility.mojom.h" | 30 #include "mojo/services/accessibility/public/interfaces/accessibility.mojom.h" |
31 #include "mojo/shell/public/cpp/application_impl.h" | |
32 #include "net/test/embedded_test_server/embedded_test_server.h" | 31 #include "net/test/embedded_test_server/embedded_test_server.h" |
33 | 32 |
34 using mus::mojom::WindowTreeClientPtr; | 33 using mus::mojom::WindowTreeClientPtr; |
35 using mus::WindowServerTestBase; | 34 using mus::WindowServerTestBase; |
36 using web_view::Frame; | 35 using web_view::Frame; |
37 using web_view::FrameConnection; | 36 using web_view::FrameConnection; |
38 using web_view::FrameTree; | 37 using web_view::FrameTree; |
39 using web_view::FrameTreeDelegate; | 38 using web_view::FrameTreeDelegate; |
40 using web_view::mojom::FrameClient; | 39 using web_view::mojom::FrameClient; |
41 | 40 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 ASSERT_TRUE(WindowServerTestBase::QuitRunLoop()); | 81 ASSERT_TRUE(WindowServerTestBase::QuitRunLoop()); |
83 }); | 82 }); |
84 if (!WindowServerTestBase::DoRunLoopWithTimeout()) | 83 if (!WindowServerTestBase::DoRunLoopWithTimeout()) |
85 ADD_FAILURE() << "Timed out waiting for execute to complete"; | 84 ADD_FAILURE() << "Timed out waiting for execute to complete"; |
86 return result; | 85 return result; |
87 } | 86 } |
88 | 87 |
89 // FrameTreeDelegate that can block waiting for navigation to start. | 88 // FrameTreeDelegate that can block waiting for navigation to start. |
90 class TestFrameTreeDelegateImpl : public web_view::TestFrameTreeDelegate { | 89 class TestFrameTreeDelegateImpl : public web_view::TestFrameTreeDelegate { |
91 public: | 90 public: |
92 explicit TestFrameTreeDelegateImpl(mojo::ApplicationImpl* app) | 91 explicit TestFrameTreeDelegateImpl(mojo::Shell* shell) |
93 : TestFrameTreeDelegate(app), frame_tree_(nullptr) {} | 92 : TestFrameTreeDelegate(shell), frame_tree_(nullptr) {} |
94 ~TestFrameTreeDelegateImpl() override {} | 93 ~TestFrameTreeDelegateImpl() override {} |
95 | 94 |
96 void set_frame_tree(FrameTree* frame_tree) { frame_tree_ = frame_tree; } | 95 void set_frame_tree(FrameTree* frame_tree) { frame_tree_ = frame_tree; } |
97 | 96 |
98 // Resets the navigation state for |frame|. | 97 // Resets the navigation state for |frame|. |
99 void ClearGotNavigate(Frame* frame) { frames_navigated_.erase(frame); } | 98 void ClearGotNavigate(Frame* frame) { frames_navigated_.erase(frame); } |
100 | 99 |
101 // Waits until |frame| has |count| children and the last child has navigated. | 100 // Waits until |frame| has |count| children and the last child has navigated. |
102 bool WaitForChildFrameCount(Frame* frame, size_t count) { | 101 bool WaitForChildFrameCount(Frame* frame, size_t count) { |
103 if (DidChildNavigate(frame, count)) | 102 if (DidChildNavigate(frame, count)) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 class HTMLFrameTest : public WindowServerTestBase { | 168 class HTMLFrameTest : public WindowServerTestBase { |
170 public: | 169 public: |
171 HTMLFrameTest() {} | 170 HTMLFrameTest() {} |
172 ~HTMLFrameTest() override {} | 171 ~HTMLFrameTest() override {} |
173 | 172 |
174 protected: | 173 protected: |
175 // Creates the frame tree showing an empty page at the root and adds (via | 174 // Creates the frame tree showing an empty page at the root and adds (via |
176 // script) a frame showing the same empty page. | 175 // script) a frame showing the same empty page. |
177 Frame* LoadEmptyPageAndCreateFrame() { | 176 Frame* LoadEmptyPageAndCreateFrame() { |
178 mus::Window* embed_window = window_manager()->NewWindow(); | 177 mus::Window* embed_window = window_manager()->NewWindow(); |
179 frame_tree_delegate_.reset( | 178 frame_tree_delegate_.reset(new TestFrameTreeDelegateImpl(shell())); |
180 new TestFrameTreeDelegateImpl(application_impl())); | |
181 FrameConnection* root_connection = InitFrameTree( | 179 FrameConnection* root_connection = InitFrameTree( |
182 embed_window, "http://127.0.0.1:%u/empty_page2.html"); | 180 embed_window, "http://127.0.0.1:%u/empty_page2.html"); |
183 if (!root_connection) { | 181 if (!root_connection) { |
184 ADD_FAILURE() << "unable to establish root connection"; | 182 ADD_FAILURE() << "unable to establish root connection"; |
185 return nullptr; | 183 return nullptr; |
186 } | 184 } |
187 const std::string frame_text = | 185 const std::string frame_text = |
188 GetFrameText(root_connection->application_connection()); | 186 GetFrameText(root_connection->application_connection()); |
189 if (frame_text != "child2") { | 187 if (frame_text != "child2") { |
190 ADD_FAILURE() << "unexpected text " << frame_text; | 188 ADD_FAILURE() << "unexpected text " << frame_text; |
(...skipping 23 matching lines...) Expand all Loading... |
214 } | 212 } |
215 | 213 |
216 mojo::URLRequestPtr BuildRequestForURL(const std::string& url_string) { | 214 mojo::URLRequestPtr BuildRequestForURL(const std::string& url_string) { |
217 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 215 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
218 request->url = mojo::String::From(AddPortToString(url_string)); | 216 request->url = mojo::String::From(AddPortToString(url_string)); |
219 return request; | 217 return request; |
220 } | 218 } |
221 | 219 |
222 FrameConnection* InitFrameTree(mus::Window* view, | 220 FrameConnection* InitFrameTree(mus::Window* view, |
223 const std::string& url_string) { | 221 const std::string& url_string) { |
224 frame_tree_delegate_.reset( | 222 frame_tree_delegate_.reset(new TestFrameTreeDelegateImpl(shell())); |
225 new TestFrameTreeDelegateImpl(application_impl())); | |
226 scoped_ptr<FrameConnection> frame_connection(new FrameConnection); | 223 scoped_ptr<FrameConnection> frame_connection(new FrameConnection); |
227 bool got_callback = false; | 224 bool got_callback = false; |
228 frame_connection->Init( | 225 frame_connection->Init( |
229 application_impl(), BuildRequestForURL(url_string), | 226 shell(), BuildRequestForURL(url_string), |
230 base::Bind(&OnGotContentHandlerForRoot, &got_callback)); | 227 base::Bind(&OnGotContentHandlerForRoot, &got_callback)); |
231 ignore_result(WindowServerTestBase::DoRunLoopWithTimeout()); | 228 ignore_result(WindowServerTestBase::DoRunLoopWithTimeout()); |
232 if (!got_callback) | 229 if (!got_callback) |
233 return nullptr; | 230 return nullptr; |
234 FrameConnection* result = frame_connection.get(); | 231 FrameConnection* result = frame_connection.get(); |
235 FrameClient* frame_client = frame_connection->frame_client(); | 232 FrameClient* frame_client = frame_connection->frame_client(); |
236 WindowTreeClientPtr tree_client = frame_connection->GetWindowTreeClient(); | 233 WindowTreeClientPtr tree_client = frame_connection->GetWindowTreeClient(); |
237 frame_tree_.reset(new FrameTree( | 234 frame_tree_.reset(new FrameTree( |
238 result->GetContentHandlerID(), view, std::move(tree_client), | 235 result->GetContentHandlerID(), view, std::move(tree_client), |
239 frame_tree_delegate_.get(), frame_client, std::move(frame_connection), | 236 frame_tree_delegate_.get(), frame_client, std::move(frame_connection), |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 script_value_as_list->GetString(0u, &message_in_child); | 488 script_value_as_list->GetString(0u, &message_in_child); |
492 } | 489 } |
493 } | 490 } |
494 } while (message_in_child != "hello from parent" && | 491 } while (message_in_child != "hello from parent" && |
495 base::TimeTicks::Now() - start_time < | 492 base::TimeTicks::Now() - start_time < |
496 TestTimeouts::action_timeout()); | 493 TestTimeouts::action_timeout()); |
497 EXPECT_EQ("hello from parent", message_in_child); | 494 EXPECT_EQ("hello from parent", message_in_child); |
498 } | 495 } |
499 | 496 |
500 } // namespace mojo | 497 } // namespace mojo |
OLD | NEW |