OLD | NEW |
---|---|
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" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 | 76 |
77 void AccessibilityNotificationWaiter::WaitForNotification() { | 77 void AccessibilityNotificationWaiter::WaitForNotification() { |
78 loop_runner_->Run(); | 78 loop_runner_->Run(); |
79 | 79 |
80 // Each loop runner can only be called once. Create a new one in case | 80 // Each loop runner can only be called once. Create a new one in case |
81 // the caller wants to call this again to wait for the next notification. | 81 // the caller wants to call this again to wait for the next notification. |
82 loop_runner_ = new MessageLoopRunner(); | 82 loop_runner_ = new MessageLoopRunner(); |
83 } | 83 } |
84 | 84 |
85 const ui::AXTree& AccessibilityNotificationWaiter::GetAXTree() const { | 85 const ui::AXTree& AccessibilityNotificationWaiter::GetAXTree() const { |
86 return *frame_host_->GetAXTreeForTesting(); | 86 CR_DEFINE_STATIC_LOCAL(ui::AXTree, empty_tree, ()); |
87 const ui::AXTree* tree = frame_host_->GetAXTreeForTesting(); | |
88 if (tree) | |
89 return *tree; | |
90 else | |
sky
2016/01/05 23:23:49
nit: no else after a return (see style guide).
dmazzoni
2016/01/07 19:19:08
Done.
| |
91 return empty_tree; | |
87 } | 92 } |
88 | 93 |
89 void AccessibilityNotificationWaiter::OnAccessibilityEvent( | 94 void AccessibilityNotificationWaiter::OnAccessibilityEvent( |
90 ui::AXEvent event_type, int event_target_id) { | 95 ui::AXEvent event_type, int event_target_id) { |
91 if (!IsAboutBlank() && (event_to_wait_for_ == ui::AX_EVENT_NONE || | 96 if (!IsAboutBlank() && (event_to_wait_for_ == ui::AX_EVENT_NONE || |
92 event_to_wait_for_ == event_type)) { | 97 event_to_wait_for_ == event_type)) { |
93 event_target_id_ = event_target_id; | 98 event_target_id_ = event_target_id; |
94 loop_runner_->Quit(); | 99 loop_runner_->Quit(); |
95 } | 100 } |
96 } | 101 } |
97 | 102 |
98 bool AccessibilityNotificationWaiter::IsAboutBlank() { | 103 bool AccessibilityNotificationWaiter::IsAboutBlank() { |
99 // Skip any accessibility notifications related to "about:blank", | 104 // Skip any accessibility notifications related to "about:blank", |
100 // to avoid a possible race condition between the test beginning | 105 // to avoid a possible race condition between the test beginning |
101 // listening for accessibility events and "about:blank" loading. | 106 // listening for accessibility events and "about:blank" loading. |
102 return GetAXTree().data().url == url::kAboutBlankURL; | 107 return GetAXTree().data().url == url::kAboutBlankURL; |
103 } | 108 } |
104 | 109 |
105 } // namespace content | 110 } // namespace content |
OLD | NEW |