Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: content/browser/accessibility/dump_accessibility_events_browsertest.cc

Issue 815463006: Separating ARIA, HTML & event AX test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <set> 5 #include <set>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/path_service.h"
9 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
10 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "content/browser/accessibility/accessibility_event_recorder.h" 13 #include "content/browser/accessibility/accessibility_event_recorder.h"
13 #include "content/browser/accessibility/accessibility_tree_formatter.h" 14 #include "content/browser/accessibility/accessibility_tree_formatter.h"
14 #include "content/browser/accessibility/browser_accessibility.h" 15 #include "content/browser/accessibility/browser_accessibility.h"
15 #include "content/browser/accessibility/browser_accessibility_manager.h" 16 #include "content/browser/accessibility/browser_accessibility_manager.h"
16 #include "content/browser/accessibility/dump_accessibility_browsertest_base.h" 17 #include "content/browser/accessibility/dump_accessibility_browsertest_base.h"
17 #include "content/browser/web_contents/web_contents_impl.h" 18 #include "content/browser/web_contents/web_contents_impl.h"
19 #include "content/public/common/content_paths.h"
18 #include "content/shell/browser/shell.h" 20 #include "content/shell/browser/shell.h"
19 #include "content/test/accessibility_browser_test_utils.h" 21 #include "content/test/accessibility_browser_test_utils.h"
20 22
21 namespace content { 23 namespace content {
22 24
23 typedef AccessibilityTreeFormatter::Filter Filter; 25 typedef AccessibilityTreeFormatter::Filter Filter;
24 26
25 // Tests that the right platform-specific accessibility events are fired 27 // Tests that the right platform-specific accessibility events are fired
26 // in response to things that happen in a web document. 28 // in response to things that happen in a web document.
27 // 29 //
(...skipping 25 matching lines...) Expand all
53 // the test framework calls "go()" and then sends a sentinel event signaling 55 // the test framework calls "go()" and then sends a sentinel event signaling
54 // the end of the test; anything received after that is too late. 56 // the end of the test; anything received after that is too late.
55 class DumpAccessibilityEventsTest : public DumpAccessibilityTestBase { 57 class DumpAccessibilityEventsTest : public DumpAccessibilityTestBase {
56 public: 58 public:
57 void AddDefaultFilters(std::vector<Filter>* filters) override { 59 void AddDefaultFilters(std::vector<Filter>* filters) override {
58 } 60 }
59 61
60 std::vector<std::string> Dump() override; 62 std::vector<std::string> Dump() override;
61 63
62 void OnDiffFailed() override; 64 void OnDiffFailed() override;
65 void RunEventTest(const base::FilePath::CharType* file_path);
63 66
64 private: 67 private:
65 base::string16 initial_tree_; 68 base::string16 initial_tree_;
66 base::string16 final_tree_; 69 base::string16 final_tree_;
67 }; 70 };
68 71
69 std::vector<std::string> DumpAccessibilityEventsTest::Dump() { 72 std::vector<std::string> DumpAccessibilityEventsTest::Dump() {
70 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( 73 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
71 shell()->web_contents()); 74 shell()->web_contents());
72 scoped_ptr<AccessibilityEventRecorder> event_recorder( 75 scoped_ptr<AccessibilityEventRecorder> event_recorder(
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 void DumpAccessibilityEventsTest::OnDiffFailed() { 127 void DumpAccessibilityEventsTest::OnDiffFailed() {
125 printf("\n"); 128 printf("\n");
126 printf("Initial accessibility tree (after load complete):\n"); 129 printf("Initial accessibility tree (after load complete):\n");
127 printf("%s\n", base::UTF16ToUTF8(initial_tree_).c_str()); 130 printf("%s\n", base::UTF16ToUTF8(initial_tree_).c_str());
128 printf("\n"); 131 printf("\n");
129 printf("Final accessibility tree after events fired:\n"); 132 printf("Final accessibility tree after events fired:\n");
130 printf("%s\n", base::UTF16ToUTF8(final_tree_).c_str()); 133 printf("%s\n", base::UTF16ToUTF8(final_tree_).c_str());
131 printf("\n"); 134 printf("\n");
132 } 135 }
133 136
137 void DumpAccessibilityEventsTest::RunEventTest(
138 const base::FilePath::CharType* file_path) {
139 base::FilePath dir_test_data;
140 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &dir_test_data));
141 base::FilePath test_path(
142 dir_test_data.AppendASCII("accessibility/event"));
143 ASSERT_TRUE(base::PathExists(test_path))
144 << test_path.LossyDisplayName();
145
146 base::FilePath event_file = test_path.Append(base::FilePath(file_path));
147 RunTest(event_file, "accessibility/event");
148 }
149
134 // TODO(dmazzoni): port these tests to run on all platforms. 150 // TODO(dmazzoni): port these tests to run on all platforms.
135 #if defined(OS_WIN) || defined(OS_MACOSX) 151 #if defined(OS_WIN) || defined(OS_MACOSX)
136 152
137 IN_PROC_BROWSER_TEST_F(DumpAccessibilityEventsTest, 153 IN_PROC_BROWSER_TEST_F(DumpAccessibilityEventsTest,
138 AccessibilityEventsCheckedStateChanged) { 154 AccessibilityEventsCheckedStateChanged) {
139 RunTest(FILE_PATH_LITERAL("events-checked-state-changed.html")); 155 RunEventTest(FILE_PATH_LITERAL("events-checked-state-changed.html"));
140 } 156 }
141 157
142 IN_PROC_BROWSER_TEST_F(DumpAccessibilityEventsTest, 158 IN_PROC_BROWSER_TEST_F(DumpAccessibilityEventsTest,
143 AccessibilityEventsInputTypeTextValueChanged) { 159 AccessibilityEventsInputTypeTextValueChanged) {
144 RunTest(FILE_PATH_LITERAL("events-input-type-text-value-changed.html")); 160 RunEventTest(FILE_PATH_LITERAL("events-input-type-text-value-changed.html"));
145 } 161 }
146 162
147 #endif // defined(OS_WIN) 163 #endif // defined(OS_WIN)
148 164
149 } // namespace content 165 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698