| 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/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/test/test_timeouts.h" | 8 #include "base/test/test_timeouts.h" |
| 9 #include "mojo/application/public/cpp/application_impl.h" | 9 #include "mojo/application/public/cpp/application_impl.h" |
| 10 #include "mojo/application/public/cpp/application_test_base.h" | 10 #include "mojo/application/public/cpp/application_test_base.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 TEST_F(AXProviderTest, HelloWorld) { | 61 TEST_F(AXProviderTest, HelloWorld) { |
| 62 // Start a test server for net/data/test.html access. | 62 // Start a test server for net/data/test.html access. |
| 63 net::SpawnedTestServer server( | 63 net::SpawnedTestServer server( |
| 64 net::SpawnedTestServer::TYPE_HTTP, net::SpawnedTestServer::kLocalhost, | 64 net::SpawnedTestServer::TYPE_HTTP, net::SpawnedTestServer::kLocalhost, |
| 65 base::FilePath(FILE_PATH_LITERAL("net/data"))); | 65 base::FilePath(FILE_PATH_LITERAL("net/data"))); |
| 66 ASSERT_TRUE(server.Start()); | 66 ASSERT_TRUE(server.Start()); |
| 67 | 67 |
| 68 // Connect to the URL through the mojo:html_viewer content handler. | 68 // Connect to the URL through the mojo:html_viewer content handler. |
| 69 const uint16_t assigned_port = server.host_port_pair().port(); | 69 const uint16_t assigned_port = server.host_port_pair().port(); |
| 70 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 71 request->url = mojo::String::From( |
| 72 base::StringPrintf("http://127.0.0.1:%u/files/test.html", assigned_port)); |
| 70 ApplicationConnection* connection = application_impl()->ConnectToApplication( | 73 ApplicationConnection* connection = application_impl()->ConnectToApplication( |
| 71 base::StringPrintf("http://127.0.0.1:%u/files/test.html", assigned_port)); | 74 request.Pass()); |
| 72 | 75 |
| 73 // Connect to the AxProvider of the HTML document and get the AxTree. | 76 // Connect to the AxProvider of the HTML document and get the AxTree. |
| 74 AxProviderPtr ax_provider; | 77 AxProviderPtr ax_provider; |
| 75 connection->ConnectToService(&ax_provider); | 78 connection->ConnectToService(&ax_provider); |
| 76 Array<AxNodePtr> ax_tree; | 79 Array<AxNodePtr> ax_tree; |
| 77 ax_provider->GetTree([&ax_tree](Array<AxNodePtr> tree) { | 80 ax_provider->GetTree([&ax_tree](Array<AxNodePtr> tree) { |
| 78 ax_tree = tree.Pass(); | 81 ax_tree = tree.Pass(); |
| 79 QuitRunLoop(); | 82 QuitRunLoop(); |
| 80 }); | 83 }); |
| 81 ASSERT_TRUE(DoRunLoopWithTimeout()); | 84 ASSERT_TRUE(DoRunLoopWithTimeout()); |
| 82 | 85 |
| 83 EXPECT_TRUE(AxTreeContainsText(ax_tree, "Hello ")); | 86 EXPECT_TRUE(AxTreeContainsText(ax_tree, "Hello ")); |
| 84 EXPECT_TRUE(AxTreeContainsText(ax_tree, "World!")); | 87 EXPECT_TRUE(AxTreeContainsText(ax_tree, "World!")); |
| 85 EXPECT_FALSE(AxTreeContainsText(ax_tree, "foo")); | 88 EXPECT_FALSE(AxTreeContainsText(ax_tree, "foo")); |
| 86 } | 89 } |
| 87 | 90 |
| 88 } // namespace mojo | 91 } // namespace mojo |
| OLD | NEW |