Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/debug/leak_annotations.h" | 8 #include "base/debug/leak_annotations.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "content/browser/accessibility/accessibility_tree_formatter.h" | 11 #include "content/browser/accessibility/accessibility_tree_formatter.h" |
| 12 #include "content/browser/site_per_process_browsertest.h" | |
| 12 #include "content/public/test/content_browser_test.h" | 13 #include "content/public/test/content_browser_test.h" |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 | 16 |
| 16 // Base class for an accessibility browsertest that takes an HTML file as | 17 // Base class for an accessibility browsertest that takes an HTML file as |
| 17 // input, loads it into a tab, dumps some accessibility data in text format, | 18 // input, loads it into a tab, dumps some accessibility data in text format, |
| 18 // then compares that text to an expectation file in the same directory. | 19 // then compares that text to an expectation file in the same directory. |
| 19 // | 20 // |
| 20 // The system was inspired by WebKit/Blink LayoutTests, but customized for | 21 // The system was inspired by WebKit/Blink LayoutTests, but customized for |
| 21 // testing accessibility in Chromium. | 22 // testing accessibility in Chromium. |
| 22 class DumpAccessibilityTestBase : public ContentBrowserTest { | 23 class DumpAccessibilityTestBase : public SitePerProcessBrowserTest { |
|
nasko
2016/01/07 00:07:37
nit: It seems that this tests uses only the setup
dmazzoni
2016/01/07 19:19:08
Done.
| |
| 23 public: | 24 public: |
| 24 DumpAccessibilityTestBase(); | 25 DumpAccessibilityTestBase(); |
| 25 ~DumpAccessibilityTestBase() override; | 26 ~DumpAccessibilityTestBase() override; |
| 26 | 27 |
| 27 // Given a path to an HTML file relative to the test directory, | 28 // Given a path to an HTML file relative to the test directory, |
| 28 // loads the HTML, loads the accessibility tree, calls Dump(), then | 29 // loads the HTML, loads the accessibility tree, calls Dump(), then |
| 29 // compares the output to the expected result and has the test succeed | 30 // compares the output to the expected result and has the test succeed |
| 30 // or fail based on the diff. | 31 // or fail based on the diff. |
| 31 void RunTest(const base::FilePath file_path, const char* file_dir); | 32 void RunTest(const base::FilePath file_path, const char* file_dir); |
| 32 | 33 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 // filter specifies strings that should be suppressed. As an example, | 73 // filter specifies strings that should be suppressed. As an example, |
| 73 // @MAC-ALLOW:AXSubrole=* means that the AXSubrole attribute should be | 74 // @MAC-ALLOW:AXSubrole=* means that the AXSubrole attribute should be |
| 74 // printed, while @MAC-ALLOW:AXSubrole=AXList* means that any subrole | 75 // printed, while @MAC-ALLOW:AXSubrole=AXList* means that any subrole |
| 75 // beginning with the text "AXList" should be printed. | 76 // beginning with the text "AXList" should be printed. |
| 76 // | 77 // |
| 77 // The @WAIT-FOR:text directive allows the test to specify that the document | 78 // The @WAIT-FOR:text directive allows the test to specify that the document |
| 78 // may dynamically change after initial load, and the test is to wait | 79 // may dynamically change after initial load, and the test is to wait |
| 79 // until the given string (e.g., "text") appears in the resulting dump. | 80 // until the given string (e.g., "text") appears in the resulting dump. |
| 80 // A test can make some changes to the document, then append a magic string | 81 // A test can make some changes to the document, then append a magic string |
| 81 // indicating that the test is done, and this framework will wait for that | 82 // indicating that the test is done, and this framework will wait for that |
| 82 // string to appear before comparing the results. | 83 // string to appear before comparing the results. There can be multiple |
| 84 // @WAIT-FOR: directives. | |
| 83 void ParseHtmlForExtraDirectives( | 85 void ParseHtmlForExtraDirectives( |
| 84 const std::string& test_html, | 86 const std::string& test_html, |
| 85 std::vector<AccessibilityTreeFormatter::Filter>* filters, | 87 std::vector<AccessibilityTreeFormatter::Filter>* filters, |
| 86 std::string* wait_for); | 88 std::vector<std::string>* wait_for); |
| 87 | 89 |
| 88 // Create the right AccessibilityTreeFormatter subclass. | 90 // Create the right AccessibilityTreeFormatter subclass. |
| 89 AccessibilityTreeFormatter* CreateAccessibilityTreeFormatter(); | 91 AccessibilityTreeFormatter* CreateAccessibilityTreeFormatter(); |
| 90 | 92 |
| 91 void RunTestForPlatform(const base::FilePath file_path, const char* file_dir); | 93 void RunTestForPlatform(const base::FilePath file_path, const char* file_dir); |
| 92 | 94 |
| 93 // The default filters plus the filters loaded from the test file. | 95 // The default filters plus the filters loaded from the test file. |
| 94 std::vector<AccessibilityTreeFormatter::Filter> filters_; | 96 std::vector<AccessibilityTreeFormatter::Filter> filters_; |
| 95 | 97 |
| 96 #if defined(LEAK_SANITIZER) && !defined(OS_NACL) | 98 #if defined(LEAK_SANITIZER) && !defined(OS_NACL) |
| 97 // http://crbug.com/568674 | 99 // http://crbug.com/568674 |
| 98 ScopedLeakSanitizerDisabler lsan_disabler; | 100 ScopedLeakSanitizerDisabler lsan_disabler; |
| 99 #endif | 101 #endif |
| 100 | 102 |
| 101 // The current AccessibilityTreeFormatter. | 103 // The current AccessibilityTreeFormatter. |
| 102 scoped_ptr<AccessibilityTreeFormatter> formatter_; | 104 scoped_ptr<AccessibilityTreeFormatter> formatter_; |
| 103 | 105 |
| 104 // Whether we're doing a native pass or internal/blink tree pass. | 106 // Whether we're doing a native pass or internal/blink tree pass. |
| 105 bool is_blink_pass_; | 107 bool is_blink_pass_; |
| 106 }; | 108 }; |
| 107 | 109 |
| 108 } // namespace content | 110 } // namespace content |
| OLD | NEW |