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

Unified Diff: chrome/browser/accessibility/accessibility_win_browsertest.cc

Issue 12210082: content: convert accessibility notifications to observer usage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: windows 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/accessibility/cross_platform_accessibility_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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");
« no previous file with comments | « no previous file | content/browser/accessibility/cross_platform_accessibility_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698