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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "components/mus/public/cpp/tests/window_server_test_base.h" | 11 #include "components/mus/public/cpp/tests/window_server_test_base.h" |
12 #include "components/mus/public/cpp/window.h" | 12 #include "components/mus/public/cpp/window.h" |
13 #include "components/mus/public/cpp/window_tree_connection.h" | 13 #include "components/mus/public/cpp/window_tree_connection.h" |
14 #include "components/web_view/public/interfaces/frame.mojom.h" | 14 #include "components/web_view/public/interfaces/frame.mojom.h" |
15 #include "mojo/application/public/cpp/application_impl.h" | 15 #include "mojo/application/public/cpp/application_impl.h" |
16 #include "mojo/application/public/cpp/application_test_base.h" | 16 #include "mojo/application/public/cpp/application_test_base.h" |
| 17 #include "mojo/converters/network/network_type_converters.h" |
17 #include "net/test/embedded_test_server/embedded_test_server.h" | 18 #include "net/test/embedded_test_server/embedded_test_server.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "third_party/mojo_services/src/accessibility/public/interfaces/accessib
ility.mojom.h" | 20 #include "third_party/mojo_services/src/accessibility/public/interfaces/accessib
ility.mojom.h" |
20 | 21 |
21 namespace mojo { | 22 namespace mojo { |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 // Returns true if the tree contains a text node with contents matching |text|. | 26 // Returns true if the tree contains a text node with contents matching |text|. |
26 bool AxTreeContainsText(const Array<AxNodePtr>& tree, const String& text) { | 27 bool AxTreeContainsText(const Array<AxNodePtr>& tree, const String& text) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 71 |
71 using AXProviderTest = mus::WindowServerTestBase; | 72 using AXProviderTest = mus::WindowServerTestBase; |
72 | 73 |
73 TEST_F(AXProviderTest, HelloWorld) { | 74 TEST_F(AXProviderTest, HelloWorld) { |
74 // Start a test server for net/data/test.html access. | 75 // Start a test server for net/data/test.html access. |
75 net::EmbeddedTestServer server; | 76 net::EmbeddedTestServer server; |
76 server.ServeFilesFromSourceDirectory("net/data"); | 77 server.ServeFilesFromSourceDirectory("net/data"); |
77 ASSERT_TRUE(server.Start()); | 78 ASSERT_TRUE(server.Start()); |
78 | 79 |
79 // Connect to the URL through the mojo:html_viewer content handler. | 80 // Connect to the URL through the mojo:html_viewer content handler. |
80 const uint16_t assigned_port = server.host_port_pair().port(); | |
81 mojo::URLRequestPtr request(mojo::URLRequest::New()); | |
82 request->url = mojo::String::From( | |
83 base::StringPrintf("http://127.0.0.1:%u/test.html", assigned_port)); | |
84 scoped_ptr<ApplicationConnection> connection = | 81 scoped_ptr<ApplicationConnection> connection = |
85 application_impl()->ConnectToApplication(request.Pass()); | 82 application_impl()->ConnectToApplication( |
| 83 server.GetURL("/test.html").spec()); |
86 | 84 |
87 // Embed the html_viewer in a Window. | 85 // Embed the html_viewer in a Window. |
88 mus::mojom::WindowTreeClientPtr tree_client; | 86 mus::mojom::WindowTreeClientPtr tree_client; |
89 connection->ConnectToService(&tree_client); | 87 connection->ConnectToService(&tree_client); |
90 mus::Window* embed_window = window_manager()->NewWindow(); | 88 mus::Window* embed_window = window_manager()->NewWindow(); |
91 embed_window->Embed(tree_client.Pass()); | 89 embed_window->Embed(tree_client.Pass()); |
92 | 90 |
93 TestFrame frame; | 91 TestFrame frame; |
94 web_view::mojom::FramePtr frame_ptr; | 92 web_view::mojom::FramePtr frame_ptr; |
95 mojo::Binding<web_view::mojom::Frame> frame_binding(&frame); | 93 mojo::Binding<web_view::mojom::Frame> frame_binding(&frame); |
(...skipping 20 matching lines...) Expand all Loading... |
116 EXPECT_TRUE(QuitRunLoop()); | 114 EXPECT_TRUE(QuitRunLoop()); |
117 }); | 115 }); |
118 ASSERT_TRUE(DoRunLoopWithTimeout()); | 116 ASSERT_TRUE(DoRunLoopWithTimeout()); |
119 | 117 |
120 EXPECT_TRUE(AxTreeContainsText(ax_tree, "Hello ")); | 118 EXPECT_TRUE(AxTreeContainsText(ax_tree, "Hello ")); |
121 EXPECT_TRUE(AxTreeContainsText(ax_tree, "World!")); | 119 EXPECT_TRUE(AxTreeContainsText(ax_tree, "World!")); |
122 EXPECT_FALSE(AxTreeContainsText(ax_tree, "foo")); | 120 EXPECT_FALSE(AxTreeContainsText(ax_tree, "foo")); |
123 } | 121 } |
124 | 122 |
125 } // namespace mojo | 123 } // namespace mojo |
OLD | NEW |