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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "base/test/test_timeouts.h" | 14 #include "base/test/test_timeouts.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "components/mus/public/cpp/tests/window_server_test_base.h" | 16 #include "components/mus/public/cpp/tests/window_server_test_base.h" |
17 #include "components/mus/public/cpp/window.h" | 17 #include "components/mus/public/cpp/window.h" |
18 #include "components/mus/public/cpp/window_tree_connection.h" | 18 #include "components/mus/public/cpp/window_tree_connection.h" |
19 #include "components/web_view/public/interfaces/frame.mojom.h" | 19 #include "components/web_view/public/interfaces/frame.mojom.h" |
20 #include "mojo/converters/network/network_type_converters.h" | 20 #include "mojo/converters/network/network_type_converters.h" |
21 #include "mojo/services/accessibility/public/interfaces/accessibility.mojom.h" | 21 #include "mojo/services/accessibility/public/interfaces/accessibility.mojom.h" |
22 #include "mojo/shell/public/cpp/application_impl.h" | |
23 #include "mojo/shell/public/cpp/application_test_base.h" | 22 #include "mojo/shell/public/cpp/application_test_base.h" |
24 #include "net/test/embedded_test_server/embedded_test_server.h" | 23 #include "net/test/embedded_test_server/embedded_test_server.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
26 | 25 |
27 namespace mojo { | 26 namespace mojo { |
28 | 27 |
29 namespace { | 28 namespace { |
30 | 29 |
31 // Returns true if the tree contains a text node with contents matching |text|. | 30 // Returns true if the tree contains a text node with contents matching |text|. |
32 bool AxTreeContainsText(const Array<AxNodePtr>& tree, const String& text) { | 31 bool AxTreeContainsText(const Array<AxNodePtr>& tree, const String& text) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 using AXProviderTest = mus::WindowServerTestBase; | 76 using AXProviderTest = mus::WindowServerTestBase; |
78 | 77 |
79 TEST_F(AXProviderTest, HelloWorld) { | 78 TEST_F(AXProviderTest, HelloWorld) { |
80 // Start a test server for net/data/test.html access. | 79 // Start a test server for net/data/test.html access. |
81 net::EmbeddedTestServer server; | 80 net::EmbeddedTestServer server; |
82 server.ServeFilesFromSourceDirectory("net/data"); | 81 server.ServeFilesFromSourceDirectory("net/data"); |
83 ASSERT_TRUE(server.Start()); | 82 ASSERT_TRUE(server.Start()); |
84 | 83 |
85 // Connect to the URL through the mojo:html_viewer content handler. | 84 // Connect to the URL through the mojo:html_viewer content handler. |
86 scoped_ptr<ApplicationConnection> connection = | 85 scoped_ptr<ApplicationConnection> connection = |
87 application_impl()->ConnectToApplication( | 86 shell()->ConnectToApplication(server.GetURL("/test.html").spec()); |
88 server.GetURL("/test.html").spec()); | |
89 | 87 |
90 // Embed the html_viewer in a Window. | 88 // Embed the html_viewer in a Window. |
91 mus::mojom::WindowTreeClientPtr tree_client; | 89 mus::mojom::WindowTreeClientPtr tree_client; |
92 connection->ConnectToService(&tree_client); | 90 connection->ConnectToService(&tree_client); |
93 mus::Window* embed_window = window_manager()->NewWindow(); | 91 mus::Window* embed_window = window_manager()->NewWindow(); |
94 embed_window->Embed(std::move(tree_client)); | 92 embed_window->Embed(std::move(tree_client)); |
95 | 93 |
96 TestFrame frame; | 94 TestFrame frame; |
97 web_view::mojom::FramePtr frame_ptr; | 95 web_view::mojom::FramePtr frame_ptr; |
98 mojo::Binding<web_view::mojom::Frame> frame_binding(&frame); | 96 mojo::Binding<web_view::mojom::Frame> frame_binding(&frame); |
(...skipping 20 matching lines...) Expand all Loading... |
119 EXPECT_TRUE(QuitRunLoop()); | 117 EXPECT_TRUE(QuitRunLoop()); |
120 }); | 118 }); |
121 ASSERT_TRUE(DoRunLoopWithTimeout()); | 119 ASSERT_TRUE(DoRunLoopWithTimeout()); |
122 | 120 |
123 EXPECT_TRUE(AxTreeContainsText(ax_tree, "Hello ")); | 121 EXPECT_TRUE(AxTreeContainsText(ax_tree, "Hello ")); |
124 EXPECT_TRUE(AxTreeContainsText(ax_tree, "World!")); | 122 EXPECT_TRUE(AxTreeContainsText(ax_tree, "World!")); |
125 EXPECT_FALSE(AxTreeContainsText(ax_tree, "foo")); | 123 EXPECT_FALSE(AxTreeContainsText(ax_tree, "foo")); |
126 } | 124 } |
127 | 125 |
128 } // namespace mojo | 126 } // namespace mojo |
OLD | NEW |