| 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/run_loop.h" | 7 #include "base/run_loop.h" |
| 7 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 8 #include "base/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
| 9 #include "mojo/public/cpp/application/application_impl.h" | 10 #include "mojo/public/cpp/application/application_impl.h" |
| 10 #include "mojo/public/cpp/application/application_test_base.h" | 11 #include "mojo/public/cpp/application/application_test_base.h" |
| 11 #include "net/test/spawned_test_server/spawned_test_server.h" | 12 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "third_party/mojo_services/src/accessibility/public/interfaces/accessib
ility.mojom.h" | 14 #include "third_party/mojo_services/src/accessibility/public/interfaces/accessib
ility.mojom.h" |
| 14 | 15 |
| 15 namespace mojo { | 16 namespace mojo { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 return true; | 53 return true; |
| 53 } | 54 } |
| 54 return false; | 55 return false; |
| 55 } | 56 } |
| 56 | 57 |
| 57 } // namespace | 58 } // namespace |
| 58 | 59 |
| 59 typedef test::ApplicationTestBase AXProviderTest; | 60 typedef test::ApplicationTestBase AXProviderTest; |
| 60 | 61 |
| 61 TEST_F(AXProviderTest, HelloWorld) { | 62 TEST_F(AXProviderTest, HelloWorld) { |
| 63 printf("MSW Commandline: %s\n", base::CommandLine::ForCurrentProcess()->GetCom
mandLineString().c_str()); |
| 64 printf("MSW application impl Commandline args: "); |
| 65 for (auto& arg : application_impl()->args()) |
| 66 printf("%s ", arg.c_str()); |
| 67 printf("\n"); |
| 68 |
| 62 // Start a test server for net/data/test.html access. | 69 // Start a test server for net/data/test.html access. |
| 63 net::SpawnedTestServer server( | 70 net::SpawnedTestServer server( |
| 64 net::SpawnedTestServer::TYPE_HTTP, net::SpawnedTestServer::kLocalhost, | 71 net::SpawnedTestServer::TYPE_HTTP, net::SpawnedTestServer::kLocalhost, |
| 65 base::FilePath(FILE_PATH_LITERAL("net/data"))); | 72 base::FilePath(FILE_PATH_LITERAL("net/data"))); |
| 66 ASSERT_TRUE(server.Start()); | 73 ASSERT_TRUE(server.Start()); |
| 67 | 74 |
| 68 // Connect to the URL through the mojo:html_viewer content handler. | 75 // Connect to the URL through the mojo:html_viewer content handler. |
| 69 const uint16_t assigned_port = server.host_port_pair().port(); | 76 const uint16_t assigned_port = server.host_port_pair().port(); |
| 70 ApplicationConnection* connection = application_impl()->ConnectToApplication( | 77 ApplicationConnection* connection = application_impl()->ConnectToApplication( |
| 71 base::StringPrintf("http://127.0.0.1:%u/files/test.html", assigned_port)); | 78 base::StringPrintf("http://127.0.0.1:%u/files/test.html", assigned_port)); |
| 72 | 79 |
| 73 // Connect to the AxProvider of the HTML document and get the AxTree. | 80 // Connect to the AxProvider of the HTML document and get the AxTree. |
| 74 AxProviderPtr ax_provider; | 81 AxProviderPtr ax_provider; |
| 75 connection->ConnectToService(&ax_provider); | 82 connection->ConnectToService(&ax_provider); |
| 76 Array<AxNodePtr> ax_tree; | 83 Array<AxNodePtr> ax_tree; |
| 77 ax_provider->GetTree([&ax_tree](Array<AxNodePtr> tree) { | 84 ax_provider->GetTree([&ax_tree](Array<AxNodePtr> tree) { |
| 78 ax_tree = tree.Pass(); | 85 ax_tree = tree.Pass(); |
| 79 QuitRunLoop(); | 86 QuitRunLoop(); |
| 80 }); | 87 }); |
| 81 ASSERT_TRUE(DoRunLoopWithTimeout()); | 88 ASSERT_TRUE(DoRunLoopWithTimeout()); |
| 82 | 89 |
| 83 EXPECT_TRUE(AxTreeContainsText(ax_tree, "Hello ")); | 90 EXPECT_TRUE(AxTreeContainsText(ax_tree, "Hello ")); |
| 84 EXPECT_TRUE(AxTreeContainsText(ax_tree, "World!")); | 91 EXPECT_TRUE(AxTreeContainsText(ax_tree, "World!")); |
| 85 EXPECT_FALSE(AxTreeContainsText(ax_tree, "foo")); | 92 EXPECT_FALSE(AxTreeContainsText(ax_tree, "foo")); |
| 86 } | 93 } |
| 87 | 94 |
| 88 } // namespace mojo | 95 } // namespace mojo |
| OLD | NEW |