| 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 "net/test/spawned_test_server/spawned_test_server.h" | 17 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "third_party/mojo_services/src/accessibility/public/interfaces/accessib
ility.mojom.h" | 19 #include "third_party/mojo_services/src/accessibility/public/interfaces/accessib
ility.mojom.h" |
| 20 | 20 |
| 21 namespace mojo { | 21 namespace mojo { |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 // Returns true if the tree contains a text node with contents matching |text|. | 25 // Returns true if the tree contains a text node with contents matching |text|. |
| 26 bool AxTreeContainsText(const Array<AxNodePtr>& tree, const String& text) { | 26 bool AxTreeContainsText(const Array<AxNodePtr>& tree, const String& text) { |
| 27 for (size_t i = 0; i < tree.size(); ++i) { | 27 for (size_t i = 0; i < tree.size(); ++i) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 private: | 65 private: |
| 66 DISALLOW_COPY_AND_ASSIGN(TestFrame); | 66 DISALLOW_COPY_AND_ASSIGN(TestFrame); |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 } // namespace | 69 } // namespace |
| 70 | 70 |
| 71 using AXProviderTest = mus::WindowServerTestBase; | 71 using AXProviderTest = mus::WindowServerTestBase; |
| 72 | 72 |
| 73 TEST_F(AXProviderTest, HelloWorld) { | 73 TEST_F(AXProviderTest, HelloWorld) { |
| 74 // Start a test server for net/data/test.html access. | 74 // Start a test server for net/data/test.html access. |
| 75 net::SpawnedTestServer server( | 75 net::EmbeddedTestServer server; |
| 76 net::SpawnedTestServer::TYPE_HTTP, net::SpawnedTestServer::kLocalhost, | 76 server.ServeFilesFromSourceDirectory("net/data"); |
| 77 base::FilePath(FILE_PATH_LITERAL("net/data"))); | |
| 78 ASSERT_TRUE(server.Start()); | 77 ASSERT_TRUE(server.Start()); |
| 79 | 78 |
| 80 // Connect to the URL through the mojo:html_viewer content handler. | 79 // Connect to the URL through the mojo:html_viewer content handler. |
| 81 const uint16_t assigned_port = server.host_port_pair().port(); | 80 const uint16_t assigned_port = server.host_port_pair().port(); |
| 82 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 81 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 83 request->url = mojo::String::From( | 82 request->url = mojo::String::From( |
| 84 base::StringPrintf("http://127.0.0.1:%u/files/test.html", assigned_port)); | 83 base::StringPrintf("http://127.0.0.1:%u/test.html", assigned_port)); |
| 85 scoped_ptr<ApplicationConnection> connection = | 84 scoped_ptr<ApplicationConnection> connection = |
| 86 application_impl()->ConnectToApplication(request.Pass()); | 85 application_impl()->ConnectToApplication(request.Pass()); |
| 87 | 86 |
| 88 // Embed the html_viewer in a Window. | 87 // Embed the html_viewer in a Window. |
| 89 mus::mojom::WindowTreeClientPtr tree_client; | 88 mus::mojom::WindowTreeClientPtr tree_client; |
| 90 connection->ConnectToService(&tree_client); | 89 connection->ConnectToService(&tree_client); |
| 91 mus::Window* embed_window = window_manager()->NewWindow(); | 90 mus::Window* embed_window = window_manager()->NewWindow(); |
| 92 embed_window->Embed(tree_client.Pass()); | 91 embed_window->Embed(tree_client.Pass()); |
| 93 | 92 |
| 94 TestFrame frame; | 93 TestFrame frame; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 117 EXPECT_TRUE(QuitRunLoop()); | 116 EXPECT_TRUE(QuitRunLoop()); |
| 118 }); | 117 }); |
| 119 ASSERT_TRUE(DoRunLoopWithTimeout()); | 118 ASSERT_TRUE(DoRunLoopWithTimeout()); |
| 120 | 119 |
| 121 EXPECT_TRUE(AxTreeContainsText(ax_tree, "Hello ")); | 120 EXPECT_TRUE(AxTreeContainsText(ax_tree, "Hello ")); |
| 122 EXPECT_TRUE(AxTreeContainsText(ax_tree, "World!")); | 121 EXPECT_TRUE(AxTreeContainsText(ax_tree, "World!")); |
| 123 EXPECT_FALSE(AxTreeContainsText(ax_tree, "foo")); | 122 EXPECT_FALSE(AxTreeContainsText(ax_tree, "foo")); |
| 124 } | 123 } |
| 125 | 124 |
| 126 } // namespace mojo | 125 } // namespace mojo |
| OLD | NEW |