| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/string16.h" | 11 #include "base/string16.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/test/base/in_process_browser_test.h" | 14 #include "chrome/test/base/in_process_browser_test.h" |
| 15 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
| 16 #include "content/browser/accessibility/browser_accessibility.h" | 16 #include "content/browser/accessibility/browser_accessibility.h" |
| 17 #include "content/browser/accessibility/browser_accessibility_manager.h" | 17 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 18 #include "content/browser/accessibility/dump_accessibility_tree_helper.h" | 18 #include "content/browser/accessibility/dump_accessibility_tree_helper.h" |
| 19 #include "content/browser/renderer_host/render_view_host_impl.h" | 19 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 20 #include "content/port/browser/render_widget_host_view_port.h" |
| 20 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
| 21 #include "content/public/browser/notification_types.h" | 22 #include "content/public/browser/notification_types.h" |
| 22 #include "content/public/browser/render_widget_host_view.h" | |
| 23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 24 #include "content/public/common/content_paths.h" | 24 #include "content/public/common/content_paths.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 26 |
| 27 using content::OpenURLParams; | 27 using content::OpenURLParams; |
| 28 using content::RenderViewHostImpl; | 28 using content::RenderViewHostImpl; |
| 29 using content::RenderWidgetHostImpl; | 29 using content::RenderWidgetHostImpl; |
| 30 using content::RenderWidgetHost; | 30 using content::RenderWidgetHost; |
| 31 using content::RenderWidgetHostViewPort; |
| 31 using content::Referrer; | 32 using content::Referrer; |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| 34 // Required to enter html content into a url. | 35 // Required to enter html content into a url. |
| 35 static const std::string kUrlPreamble = "data:text/html,\n<!doctype html>"; | 36 static const std::string kUrlPreamble = "data:text/html,\n<!doctype html>"; |
| 36 static const char kCommentToken = '#'; | 37 static const char kCommentToken = '#'; |
| 37 } // namespace | 38 } // namespace |
| 38 | 39 |
| 39 // This test takes a snapshot of the platform BrowserAccessibility tree and | 40 // This test takes a snapshot of the platform BrowserAccessibility tree and |
| 40 // tests it against an expected baseline. | 41 // tests it against an expected baseline. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 69 | 70 |
| 70 // Actual file has been fully checked. | 71 // Actual file has been fully checked. |
| 71 return i < 0; | 72 return i < 0; |
| 72 } | 73 } |
| 73 | 74 |
| 74 DumpAccessibilityTreeHelper helper_; | 75 DumpAccessibilityTreeHelper helper_; |
| 75 }; | 76 }; |
| 76 | 77 |
| 77 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, | 78 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, |
| 78 PlatformTreeDifferenceTest) { | 79 PlatformTreeDifferenceTest) { |
| 79 content::RenderWidgetHostView* host_view = | 80 RenderWidgetHostViewPort* host_view = static_cast<RenderWidgetHostViewPort*>( |
| 80 browser()->GetSelectedWebContents()->GetRenderWidgetHostView(); | 81 browser()->GetSelectedWebContents()->GetRenderWidgetHostView()); |
| 81 RenderWidgetHost* host = host_view->GetRenderWidgetHost(); | 82 RenderWidgetHost* host = host_view->GetRenderWidgetHost(); |
| 82 // TODO(joi): Remove this dependency | |
| 83 RenderViewHostImpl* view_host = | 83 RenderViewHostImpl* view_host = |
| 84 static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(host)); | 84 static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(host)); |
| 85 view_host->set_save_accessibility_tree_for_testing(true); | 85 view_host->set_save_accessibility_tree_for_testing(true); |
| 86 view_host->EnableRendererAccessibility(); | 86 view_host->EnableRendererAccessibility(); |
| 87 | 87 |
| 88 // Setup test paths. | 88 // Setup test paths. |
| 89 FilePath dir_test_data; | 89 FilePath dir_test_data; |
| 90 EXPECT_TRUE(PathService::Get(content::DIR_TEST_DATA, &dir_test_data)); | 90 EXPECT_TRUE(PathService::Get(content::DIR_TEST_DATA, &dir_test_data)); |
| 91 FilePath test_path(dir_test_data.Append(FILE_PATH_LITERAL("accessibility"))); | 91 FilePath test_path(dir_test_data.Append(FILE_PATH_LITERAL("accessibility"))); |
| 92 EXPECT_TRUE(file_util::PathExists(test_path)) | 92 EXPECT_TRUE(file_util::PathExists(test_path)) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 EXPECT_TRUE(file_util::WriteFile( | 158 EXPECT_TRUE(file_util::WriteFile( |
| 159 actual_file, actual_contents.c_str(), actual_contents.size())); | 159 actual_file, actual_contents.c_str(), actual_contents.size())); |
| 160 | 160 |
| 161 ADD_FAILURE() << "No expectation found. Create it by doing:\n" | 161 ADD_FAILURE() << "No expectation found. Create it by doing:\n" |
| 162 << "mv " << actual_file.LossyDisplayName() << " " | 162 << "mv " << actual_file.LossyDisplayName() << " " |
| 163 << expected_file.LossyDisplayName(); | 163 << expected_file.LossyDisplayName(); |
| 164 } | 164 } |
| 165 } while (!(html_file = file_enumerator.Next()).empty()); | 165 } while (!(html_file = file_enumerator.Next()).empty()); |
| 166 } | 166 } |
| 167 | 167 |
| OLD | NEW |