Index: chrome/browser/accessibility/accessibility_win_browsertest.cc |
diff --git a/chrome/browser/accessibility/accessibility_win_browsertest.cc b/chrome/browser/accessibility/accessibility_win_browsertest.cc |
index 5b980a1282a484b1faffb66de44513f70d9b74da..d354a231bec1b279da6b1c61cbd3c22c5b92ac58 100644 |
--- a/chrome/browser/accessibility/accessibility_win_browsertest.cc |
+++ b/chrome/browser/accessibility/accessibility_win_browsertest.cc |
@@ -220,11 +220,14 @@ void AccessibilityWinBrowserTest::LoadInitialAccessibilityTreeFromHtml( |
// the renderer switches accessibility on, it will send a Layout Complete |
// accessibility notification containing the full accessibility tree, which |
// we can wait for. |
- content::WindowedNotificationObserver tree_updated_observer( |
- content::NOTIFICATION_ACCESSIBILITY_LAYOUT_COMPLETE, |
- content::NotificationService::AllSources()); |
+ scoped_refptr<MessageLoopRunner> loop_runner(new MessageLoopRunner); |
+ content::WebContents* web_contents = |
dmazzoni
2013/02/15 19:34:19
How about a helper method to get view_host since t
|
+ browser()->tab_strip_model()->GetActiveWebContents(); |
+ content::RenderViewHost* view_host = web_contents->GetRenderViewHost(); |
+ view_host->SetAccessibilityLayoutCompleteCallbackForTesting( |
+ loop_runner->QuitClosure()); |
GetRendererAccessible(); |
- tree_updated_observer.Wait(); |
+ loop_runner->Run(); |
} |
// Retrieve the MSAA client accessibility object for the Render Widget Host View |
@@ -491,11 +494,14 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
document_checker.CheckAccessible(GetRendererAccessible()); |
// Set focus to the radio group. |
- content::WindowedNotificationObserver tree_updated_observer( |
- content::NOTIFICATION_ACCESSIBILITY_OTHER, |
- content::NotificationService::AllSources()); |
+ scoped_refptr<MessageLoopRunner> loop_runner(new MessageLoopRunner); |
+ content::WebContents* web_contents = |
+ browser()->tab_strip_model()->GetActiveWebContents(); |
+ content::RenderViewHost* view_host = web_contents->GetRenderViewHost(); |
+ view_host->SetAccessibilityOtherCallbackForTesting( |
+ loop_runner->QuitClosure()); |
ExecuteScript(L"document.body.children[0].focus()"); |
- tree_updated_observer.Wait(); |
+ loop_runner->Run(); |
// Check that the accessibility tree of the browser has been updated. |
radio_group_checker.SetExpectedState( |
@@ -503,12 +509,12 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
document_checker.CheckAccessible(GetRendererAccessible()); |
// Set the active descendant of the radio group |
- content::WindowedNotificationObserver tree_updated_observer3( |
- content::NOTIFICATION_ACCESSIBILITY_OTHER, |
- content::NotificationService::AllSources()); |
+ loop_runner = new MessageLoopRunner; |
+ view_host->SetAccessibilityOtherCallbackForTesting( |
+ loop_runner->QuitClosure()); |
ExecuteScript( |
L"document.body.children[0].setAttribute('aria-activedescendant', 'li')"); |
- tree_updated_observer3.Wait(); |
+ loop_runner->Run(); |
// Check that the accessibility tree of the browser has been updated. |
list_item_checker.SetExpectedState( |
@@ -532,11 +538,14 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
document_checker.CheckAccessible(GetRendererAccessible()); |
// Check the checkbox. |
- content::WindowedNotificationObserver tree_updated_observer( |
- content::NOTIFICATION_ACCESSIBILITY_OTHER, |
- content::NotificationService::AllSources()); |
+ scoped_refptr<MessageLoopRunner> loop_runner(new MessageLoopRunner); |
+ content::WebContents* web_contents = |
+ browser()->tab_strip_model()->GetActiveWebContents(); |
+ content::RenderViewHost* view_host = web_contents->GetRenderViewHost(); |
+ view_host->SetAccessibilityOtherCallbackForTesting( |
+ loop_runner->QuitClosure()); |
ExecuteScript(L"document.body.children[0].checked=true"); |
- tree_updated_observer.Wait(); |
+ loop_runner->Run(); |
// Check that the accessibility tree of the browser has been updated. |
checkbox_checker.SetExpectedState( |
@@ -556,11 +565,14 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
document_checker.CheckAccessible(GetRendererAccessible()); |
// Change the children of the document body. |
- content::WindowedNotificationObserver tree_updated_observer( |
- content::NOTIFICATION_ACCESSIBILITY_OTHER, |
- content::NotificationService::AllSources()); |
+ scoped_refptr<MessageLoopRunner> loop_runner(new MessageLoopRunner); |
+ content::WebContents* web_contents = |
+ browser()->tab_strip_model()->GetActiveWebContents(); |
+ content::RenderViewHost* view_host = web_contents->GetRenderViewHost(); |
+ view_host->SetAccessibilityOtherCallbackForTesting( |
+ loop_runner->QuitClosure()); |
ExecuteScript(L"document.body.innerHTML='<b>new text</b>'"); |
- tree_updated_observer.Wait(); |
+ loop_runner->Run(); |
// Check that the accessibility tree of the browser has been updated. |
AccessibleChecker text_checker(L"new text", ROLE_SYSTEM_TEXT, L""); |
@@ -579,11 +591,14 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
document_checker.CheckAccessible(GetRendererAccessible()); |
// Change the children of the document body. |
- content::WindowedNotificationObserver tree_updated_observer2( |
- content::NOTIFICATION_ACCESSIBILITY_OTHER, |
- content::NotificationService::AllSources()); |
+ scoped_refptr<MessageLoopRunner> loop_runner(new MessageLoopRunner); |
+ content::WebContents* web_contents = |
+ browser()->tab_strip_model()->GetActiveWebContents(); |
+ content::RenderViewHost* view_host = web_contents->GetRenderViewHost(); |
+ view_host->SetAccessibilityOtherCallbackForTesting( |
+ loop_runner->QuitClosure()); |
ExecuteScript(L"document.body.children[0].style.visibility='visible'"); |
- tree_updated_observer2.Wait(); |
+ loop_runner->Run(); |
// Check that the accessibility tree of the browser has been updated. |
AccessibleChecker static_text_checker(L"text", ROLE_SYSTEM_TEXT, L""); |
@@ -608,11 +623,13 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
document_checker.CheckAccessible(GetRendererAccessible()); |
// Focus the div in the document |
- content::WindowedNotificationObserver tree_updated_observer( |
- content::NOTIFICATION_ACCESSIBILITY_OTHER, |
- content::NotificationService::AllSources()); |
- ExecuteScript(L"document.body.children[0].focus()"); |
- tree_updated_observer.Wait(); |
+ scoped_refptr<MessageLoopRunner> loop_runner(new MessageLoopRunner); |
+ content::WebContents* web_contents = |
+ browser()->tab_strip_model()->GetActiveWebContents(); |
+ content::RenderViewHost* view_host = web_contents->GetRenderViewHost(); |
+ view_host->SetAccessibilityOtherCallbackForTesting( |
+ loop_runner->QuitClosure()); |
+ loop_runner->Run(); |
// Check that the accessibility tree of the browser has been updated. |
SCOPED_TRACE("Check updated tree after focusing div"); |
@@ -621,16 +638,16 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
document_checker.CheckAccessible(GetRendererAccessible()); |
// Focus the document accessible. This will un-focus the current node. |
- content::WindowedNotificationObserver tree_updated_observer2( |
- content::NOTIFICATION_ACCESSIBILITY_OTHER, |
- content::NotificationService::AllSources()); |
+ loop_runner = new MessageLoopRunner; |
+ view_host->SetAccessibilityOtherCallbackForTesting( |
+ loop_runner->QuitClosure()); |
base::win::ScopedComPtr<IAccessible> document_accessible( |
GetRendererAccessible()); |
ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL)); |
HRESULT hr = document_accessible->accSelect( |
SELFLAG_TAKEFOCUS, CreateI4Variant(CHILDID_SELF)); |
ASSERT_EQ(S_OK, hr); |
- tree_updated_observer2.Wait(); |
+ loop_runner->Run(); |
// Check that the accessibility tree of the browser has been updated. |
SCOPED_TRACE("Check updated tree after focusing document again"); |
@@ -653,11 +670,14 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
document_checker.CheckAccessible(GetRendererAccessible()); |
// Set the value of the text control |
- content::WindowedNotificationObserver tree_updated_observer( |
- content::NOTIFICATION_ACCESSIBILITY_OTHER, |
- content::NotificationService::AllSources()); |
+ scoped_refptr<MessageLoopRunner> loop_runner(new MessageLoopRunner); |
+ content::WebContents* web_contents = |
+ browser()->tab_strip_model()->GetActiveWebContents(); |
+ content::RenderViewHost* view_host = web_contents->GetRenderViewHost(); |
+ view_host->SetAccessibilityOtherCallbackForTesting( |
+ loop_runner->QuitClosure()); |
ExecuteScript(L"document.body.children[0].value='new value'"); |
- tree_updated_observer.Wait(); |
+ loop_runner->Run(); |
// Check that the accessibility tree of the browser has been updated. |
text_field_checker.SetExpectedValue(L"new value"); |