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

Side by Side Diff: content/test/accessibility_browser_test_utils.cc

Issue 63253002: Rename WebKit namespace to blink (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « content/test/accessibility_browser_test_utils.h ('k') | content/test/image_decoder_test.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/test/accessibility_browser_test_utils.h" 5 #include "content/test/accessibility_browser_test_utils.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "content/browser/renderer_host/render_view_host_impl.h" 11 #include "content/browser/renderer_host/render_view_host_impl.h"
12 #include "content/port/browser/render_widget_host_view_port.h" 12 #include "content/port/browser/render_widget_host_view_port.h"
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "content/public/common/url_constants.h" 14 #include "content/public/common/url_constants.h"
15 #include "content/public/test/test_utils.h" 15 #include "content/public/test/test_utils.h"
16 #include "content/shell/browser/shell.h" 16 #include "content/shell/browser/shell.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 AccessibilityNotificationWaiter::AccessibilityNotificationWaiter( 20 AccessibilityNotificationWaiter::AccessibilityNotificationWaiter(
21 Shell* shell, 21 Shell* shell,
22 AccessibilityMode accessibility_mode, 22 AccessibilityMode accessibility_mode,
23 WebKit::WebAXEvent event_type) 23 blink::WebAXEvent event_type)
24 : shell_(shell), 24 : shell_(shell),
25 event_to_wait_for_(event_type), 25 event_to_wait_for_(event_type),
26 loop_runner_(new MessageLoopRunner()), 26 loop_runner_(new MessageLoopRunner()),
27 weak_factory_(this) { 27 weak_factory_(this) {
28 WebContents* web_contents = shell_->web_contents(); 28 WebContents* web_contents = shell_->web_contents();
29 view_host_ = static_cast<RenderViewHostImpl*>( 29 view_host_ = static_cast<RenderViewHostImpl*>(
30 web_contents->GetRenderViewHost()); 30 web_contents->GetRenderViewHost());
31 view_host_->SetAccessibilityCallbackForTesting( 31 view_host_->SetAccessibilityCallbackForTesting(
32 base::Bind(&AccessibilityNotificationWaiter::OnAccessibilityEvent, 32 base::Bind(&AccessibilityNotificationWaiter::OnAccessibilityEvent,
33 weak_factory_.GetWeakPtr())); 33 weak_factory_.GetWeakPtr()));
34 view_host_->SetAccessibilityMode(accessibility_mode); 34 view_host_->SetAccessibilityMode(accessibility_mode);
35 } 35 }
36 36
37 AccessibilityNotificationWaiter::~AccessibilityNotificationWaiter() { 37 AccessibilityNotificationWaiter::~AccessibilityNotificationWaiter() {
38 } 38 }
39 39
40 void AccessibilityNotificationWaiter::WaitForNotification() { 40 void AccessibilityNotificationWaiter::WaitForNotification() {
41 loop_runner_->Run(); 41 loop_runner_->Run();
42 } 42 }
43 43
44 const AccessibilityNodeDataTreeNode& 44 const AccessibilityNodeDataTreeNode&
45 AccessibilityNotificationWaiter::GetAccessibilityNodeDataTree() const { 45 AccessibilityNotificationWaiter::GetAccessibilityNodeDataTree() const {
46 return view_host_->accessibility_tree_for_testing(); 46 return view_host_->accessibility_tree_for_testing();
47 } 47 }
48 48
49 void AccessibilityNotificationWaiter::OnAccessibilityEvent( 49 void AccessibilityNotificationWaiter::OnAccessibilityEvent(
50 WebKit::WebAXEvent event_type) { 50 blink::WebAXEvent event_type) {
51 if (!IsAboutBlank() && event_to_wait_for_ == event_type) 51 if (!IsAboutBlank() && event_to_wait_for_ == event_type)
52 loop_runner_->Quit(); 52 loop_runner_->Quit();
53 } 53 }
54 54
55 bool AccessibilityNotificationWaiter::IsAboutBlank() { 55 bool AccessibilityNotificationWaiter::IsAboutBlank() {
56 // Skip any accessibility notifications related to "about:blank", 56 // Skip any accessibility notifications related to "about:blank",
57 // to avoid a possible race condition between the test beginning 57 // to avoid a possible race condition between the test beginning
58 // listening for accessibility events and "about:blank" loading. 58 // listening for accessibility events and "about:blank" loading.
59 const AccessibilityNodeDataTreeNode& root = GetAccessibilityNodeDataTree(); 59 const AccessibilityNodeDataTreeNode& root = GetAccessibilityNodeDataTree();
60 for (size_t i = 0; i < root.string_attributes.size(); ++i) { 60 for (size_t i = 0; i < root.string_attributes.size(); ++i) {
61 if (root.string_attributes[i].first != AccessibilityNodeData::ATTR_DOC_URL) 61 if (root.string_attributes[i].first != AccessibilityNodeData::ATTR_DOC_URL)
62 continue; 62 continue;
63 const std::string& doc_url = root.string_attributes[i].second; 63 const std::string& doc_url = root.string_attributes[i].second;
64 return doc_url == kAboutBlankURL; 64 return doc_url == kAboutBlankURL;
65 } 65 }
66 return false; 66 return false;
67 } 67 }
68 68
69 } // namespace content 69 } // namespace content
OLDNEW
« no previous file with comments | « content/test/accessibility_browser_test_utils.h ('k') | content/test/image_decoder_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698