1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/browser/renderer_host/render_view_host_impl.h"
6 #include "content/browser/renderer_host/render_widget_host_impl.h"
7 #include "content/browser/renderer_host/render_widget_host_view_base.h"
8 #include "content/browser/web_contents/web_contents_impl.h"
9 #include "content/public/browser/render_view_host.h"
10 #include "content/public/browser/render_widget_host.h"
11 #include "content/public/browser/render_widget_host_view.h"
12 #include "content/public/browser/web_contents.h"
13 #include "content/public/common/url_constants.h"
14 #include "content/public/test/content_browser_test.h"
15 #include "content/public/test/content_browser_test_utils.h"
16 #include "content/shell/browser/shell.h"
17 #include "content/test/accessibility_browser_test_utils.h"
18 #include "testing/gtest/include/gtest/gtest.h"
22 const char kMinimalPageDataURL
[] =
23 "data:text/html,<html><head></head><body>Hello, world</body></html>";
25 class AccessibilityModeTest
: public ContentBrowserTest
{
27 WebContentsImpl
* web_contents() {
28 return static_cast<WebContentsImpl
*>(shell()->web_contents());
31 void ExpectBrowserAccessibilityManager(bool expect_bam
,
32 std::string message
= "") {
35 (BrowserAccessibilityManager
*)NULL
,
36 web_contents()->GetRootBrowserAccessibilityManager()) << message
;
39 (BrowserAccessibilityManager
*)NULL
,
40 web_contents()->GetRootBrowserAccessibilityManager()) << message
;
45 IN_PROC_BROWSER_TEST_F(AccessibilityModeTest
, AccessibilityModeOff
) {
46 NavigateToURL(shell(), GURL(kMinimalPageDataURL
));
48 EXPECT_EQ(AccessibilityModeOff
, web_contents()->GetAccessibilityMode());
49 ExpectBrowserAccessibilityManager(false);
52 IN_PROC_BROWSER_TEST_F(AccessibilityModeTest
, AccessibilityModeComplete
) {
53 NavigateToURL(shell(), GURL(kMinimalPageDataURL
));
54 ASSERT_EQ(AccessibilityModeOff
, web_contents()->GetAccessibilityMode());
56 AccessibilityNotificationWaiter
waiter(shell());
57 web_contents()->AddAccessibilityMode(AccessibilityModeComplete
);
58 EXPECT_EQ(AccessibilityModeComplete
, web_contents()->GetAccessibilityMode());
59 waiter
.WaitForNotification();
60 ExpectBrowserAccessibilityManager(true);
63 IN_PROC_BROWSER_TEST_F(AccessibilityModeTest
, AccessibilityModeTreeOnly
) {
64 NavigateToURL(shell(), GURL(kMinimalPageDataURL
));
65 ASSERT_EQ(AccessibilityModeOff
, web_contents()->GetAccessibilityMode());
67 AccessibilityNotificationWaiter
waiter(shell());
68 web_contents()->AddAccessibilityMode(AccessibilityModeTreeOnly
);
69 EXPECT_EQ(AccessibilityModeTreeOnly
, web_contents()->GetAccessibilityMode());
70 waiter
.WaitForNotification();
71 // No BrowserAccessibilityManager expected for AccessibilityModeTreeOnly
72 ExpectBrowserAccessibilityManager(false);
75 IN_PROC_BROWSER_TEST_F(AccessibilityModeTest
, AddingModes
) {
76 NavigateToURL(shell(), GURL(kMinimalPageDataURL
));
78 AccessibilityNotificationWaiter
waiter(shell());
79 web_contents()->AddAccessibilityMode(AccessibilityModeTreeOnly
);
80 EXPECT_EQ(AccessibilityModeTreeOnly
, web_contents()->GetAccessibilityMode());
81 waiter
.WaitForNotification();
82 ExpectBrowserAccessibilityManager(false,
83 "Should be no BrowserAccessibilityManager "
84 "for AccessibilityModeTreeOnly");
86 AccessibilityNotificationWaiter
waiter2(shell());
87 web_contents()->AddAccessibilityMode(AccessibilityModeComplete
);
88 EXPECT_EQ(AccessibilityModeComplete
, web_contents()->GetAccessibilityMode());
89 waiter2
.WaitForNotification();
90 ExpectBrowserAccessibilityManager(true,
91 "Should be a BrowserAccessibilityManager "
92 "for AccessibilityModeComplete");
95 } // namespace content