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

Side by Side Diff: content/public/test/browser_test_utils.cc

Issue 1815933002: Fix WebView accessibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename set_browser_plugin_embedder_ax_tree_id Created 4 years, 8 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
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/public/test/browser_test_utils.h" 5 #include "content/public/test/browser_test_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/process/kill.h" 15 #include "base/process/kill.h"
16 #include "base/rand_util.h" 16 #include "base/rand_util.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/string_piece.h" 18 #include "base/strings/string_piece.h"
19 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
20 #include "base/synchronization/waitable_event.h" 20 #include "base/synchronization/waitable_event.h"
21 #include "base/test/test_timeouts.h" 21 #include "base/test/test_timeouts.h"
22 #include "base/values.h" 22 #include "base/values.h"
23 #include "build/build_config.h" 23 #include "build/build_config.h"
24 #include "content/browser/accessibility/accessibility_mode_helper.h"
25 #include "content/browser/accessibility/browser_accessibility.h"
26 #include "content/browser/accessibility/browser_accessibility_manager.h"
24 #include "content/browser/renderer_host/render_widget_host_impl.h" 27 #include "content/browser/renderer_host/render_widget_host_impl.h"
25 #include "content/browser/web_contents/web_contents_impl.h" 28 #include "content/browser/web_contents/web_contents_impl.h"
26 #include "content/browser/web_contents/web_contents_view.h" 29 #include "content/browser/web_contents/web_contents_view.h"
27 #include "content/common/input/synthetic_web_input_event_builders.h" 30 #include "content/common/input/synthetic_web_input_event_builders.h"
28 #include "content/common/input_messages.h" 31 #include "content/common/input_messages.h"
29 #include "content/common/view_messages.h" 32 #include "content/common/view_messages.h"
30 #include "content/public/browser/browser_context.h" 33 #include "content/public/browser/browser_context.h"
31 #include "content/public/browser/histogram_fetcher.h" 34 #include "content/public/browser/histogram_fetcher.h"
32 #include "content/public/browser/navigation_entry.h" 35 #include "content/public/browser/navigation_entry.h"
33 #include "content/public/browser/notification_service.h" 36 #include "content/public/browser/notification_service.h"
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 " window.domAutomationController.send('pageLoadComplete');" 871 " window.domAutomationController.send('pageLoadComplete');"
869 " }" 872 " }"
870 " }" 873 " }"
871 " checkState();" 874 " checkState();"
872 " document.addEventListener('readystatechange', checkState);" 875 " document.addEventListener('readystatechange', checkState);"
873 "})();", 876 "})();",
874 &result)); 877 &result));
875 return result == "pageLoadComplete"; 878 return result == "pageLoadComplete";
876 } 879 }
877 880
881 void EnableAccessibilityForWebContents(WebContents* web_contents) {
882 WebContentsImpl* web_contents_impl =
883 static_cast<WebContentsImpl*>(web_contents);
884 web_contents_impl->SetAccessibilityMode(AccessibilityModeComplete);
885 }
886
887 void WaitForAccessibilityFocusChange() {
888 scoped_refptr<content::MessageLoopRunner> loop_runner(
889 new content::MessageLoopRunner);
890 BrowserAccessibilityManager::SetFocusChangeCallbackForTesting(
891 loop_runner->QuitClosure());
892 loop_runner->Run();
893 }
894
895 ui::AXNodeData GetFocusedAccessibilityNodeInfo(WebContents* web_contents) {
896 WebContentsImpl* web_contents_impl =
897 static_cast<WebContentsImpl*>(web_contents);
898 BrowserAccessibilityManager* manager =
899 web_contents_impl->GetRootBrowserAccessibilityManager();
900 if (!manager)
901 return ui::AXNodeData();
902 BrowserAccessibility* focused_node = manager->GetFocus();
903 return focused_node->GetData();
904 }
905
878 TitleWatcher::TitleWatcher(WebContents* web_contents, 906 TitleWatcher::TitleWatcher(WebContents* web_contents,
879 const base::string16& expected_title) 907 const base::string16& expected_title)
880 : WebContentsObserver(web_contents), 908 : WebContentsObserver(web_contents),
881 message_loop_runner_(new MessageLoopRunner) { 909 message_loop_runner_(new MessageLoopRunner) {
882 EXPECT_TRUE(web_contents != NULL); 910 EXPECT_TRUE(web_contents != NULL);
883 expected_titles_.push_back(expected_title); 911 expected_titles_.push_back(expected_title);
884 } 912 }
885 913
886 void TitleWatcher::AlsoWaitForTitle(const base::string16& expected_title) { 914 void TitleWatcher::AlsoWaitForTitle(const base::string16& expected_title) {
887 expected_titles_.push_back(expected_title); 915 expected_titles_.push_back(expected_title);
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1217 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1190 if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN) 1218 if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN)
1191 return ack_result_; 1219 return ack_result_;
1192 base::RunLoop run_loop; 1220 base::RunLoop run_loop;
1193 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); 1221 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure());
1194 run_loop.Run(); 1222 run_loop.Run();
1195 return ack_result_; 1223 return ack_result_;
1196 } 1224 }
1197 1225
1198 } // namespace content 1226 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698