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

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

Issue 12212188: Revert "content: convert accessibility notifications to callbacks" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
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 <set> 5 #include <set>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/string_split.h" 12 #include "base/string_split.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/string16.h" 14 #include "base/string16.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.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/port/browser/render_widget_host_view_port.h"
21 #include "content/public/browser/notification_service.h"
22 #include "content/public/browser/notification_types.h"
21 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
22 #include "content/public/common/content_paths.h" 24 #include "content/public/common/content_paths.h"
23 #include "content/public/test/test_utils.h" 25 #include "content/public/test/test_utils.h"
24 #include "content/test/content_browser_test.h" 26 #include "content/test/content_browser_test.h"
25 #include "content/test/content_browser_test_utils.h" 27 #include "content/test/content_browser_test_utils.h"
26 #include "content/shell/shell.h" 28 #include "content/shell/shell.h"
27 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
28 30
31 namespace {
32 static const char kCommentToken = '#';
33 static const char* kMarkSkipFile = "#<skip";
34 static const char* kMarkEndOfFile = "<-- End-of-file -->";
35 static const char* kSignalDiff = "*";
36 } // namespace
37
29 namespace content { 38 namespace content {
30 39
31 namespace {
32
33 const char kCommentToken = '#';
34 const char kMarkSkipFile[] = "#<skip";
35 const char kMarkEndOfFile[] = "<-- End-of-file -->";
36 const char kSignalDiff[] = "*";
37
38 } // namespace
39
40 typedef DumpAccessibilityTreeHelper::Filter Filter; 40 typedef DumpAccessibilityTreeHelper::Filter Filter;
41 41
42 // This test takes a snapshot of the platform BrowserAccessibility tree and 42 // This test takes a snapshot of the platform BrowserAccessibility tree and
43 // tests it against an expected baseline. 43 // tests it against an expected baseline.
44 // 44 //
45 // The flow of the test is as outlined below. 45 // The flow of the test is as outlined below.
46 // 1. Load an html file from chrome/test/data/accessibility. 46 // 1. Load an html file from chrome/test/data/accessibility.
47 // 2. Read the expectation. 47 // 2. Read the expectation.
48 // 3. Browse to the page and serialize the platform specific tree into a human 48 // 3. Browse to the page and serialize the platform specific tree into a human
49 // readable string. 49 // readable string.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // normalize by deleting all \r from the file (if any) to leave only \n. 159 // normalize by deleting all \r from the file (if any) to leave only \n.
160 std::string expected_contents; 160 std::string expected_contents;
161 RemoveChars(expected_contents_raw, "\r", &expected_contents); 161 RemoveChars(expected_contents_raw, "\r", &expected_contents);
162 162
163 if (!expected_contents.compare(0, strlen(kMarkSkipFile), kMarkSkipFile)) { 163 if (!expected_contents.compare(0, strlen(kMarkSkipFile), kMarkSkipFile)) {
164 printf("Skipping this test on this platform.\n"); 164 printf("Skipping this test on this platform.\n");
165 return; 165 return;
166 } 166 }
167 167
168 // Load the page. 168 // Load the page.
169 WindowedNotificationObserver tree_updated_observer(
170 NOTIFICATION_ACCESSIBILITY_LOAD_COMPLETE,
171 NotificationService::AllSources());
169 string16 html_contents16; 172 string16 html_contents16;
170 html_contents16 = UTF8ToUTF16(html_contents); 173 html_contents16 = UTF8ToUTF16(html_contents);
171 GURL url = GetTestUrl("accessibility", 174 GURL url = GetTestUrl("accessibility",
172 html_file.BaseName().MaybeAsASCII().c_str()); 175 html_file.BaseName().MaybeAsASCII().c_str());
173 scoped_refptr<MessageLoopRunner> loop_runner(new MessageLoopRunner);
174 view_host->SetAccessibilityLoadCompleteCallbackForTesting(
175 loop_runner->QuitClosure());
176 NavigateToURL(shell(), url); 176 NavigateToURL(shell(), url);
177 177
178 // Wait for the tree. 178 // Wait for the tree.
179 loop_runner->Run(); 179 tree_updated_observer.Wait();
180 180
181 // Perform a diff (or write the initial baseline). 181 // Perform a diff (or write the initial baseline).
182 string16 actual_contents_utf16; 182 string16 actual_contents_utf16;
183 helper_.DumpAccessibilityTree( 183 helper_.DumpAccessibilityTree(
184 host_view->GetBrowserAccessibilityManager()->GetRoot(), 184 host_view->GetBrowserAccessibilityManager()->GetRoot(),
185 &actual_contents_utf16); 185 &actual_contents_utf16);
186 std::string actual_contents = UTF16ToUTF8(actual_contents_utf16); 186 std::string actual_contents = UTF16ToUTF8(actual_contents_utf16);
187 std::vector<std::string> actual_lines, expected_lines; 187 std::vector<std::string> actual_lines, expected_lines;
188 Tokenize(actual_contents, "\n", &actual_lines); 188 Tokenize(actual_contents, "\n", &actual_lines);
189 Tokenize(expected_contents, "\n", &expected_lines); 189 Tokenize(expected_contents, "\n", &expected_lines);
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 436
437 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityUl) { 437 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityUl) {
438 RunTest(FILE_PATH_LITERAL("ul.html")); 438 RunTest(FILE_PATH_LITERAL("ul.html"));
439 } 439 }
440 440
441 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityWbr) { 441 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityWbr) {
442 RunTest(FILE_PATH_LITERAL("wbr.html")); 442 RunTest(FILE_PATH_LITERAL("wbr.html"));
443 } 443 }
444 444
445 } // namespace content 445 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698