Remove PlatformFile from profile_browsertest
[chromium-blink-merge.git] / content / browser / accessibility / accessibility_mode_browsertest.cc
blob6a0ae02542b1415f8c2db4686ef76ac928a845a4
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/port/browser/render_widget_host_view_port.h"
8 #include "content/public/browser/render_view_host.h"
9 #include "content/public/browser/render_widget_host.h"
10 #include "content/public/browser/render_widget_host_view.h"
11 #include "content/public/browser/web_contents.h"
12 #include "content/public/common/url_constants.h"
13 #include "content/public/test/content_browser_test.h"
14 #include "content/public/test/content_browser_test_utils.h"
15 #include "content/shell/browser/shell.h"
16 #include "content/test/accessibility_browser_test_utils.h"
17 #include "testing/gtest/include/gtest/gtest.h"
19 namespace content {
21 const char kMinimalPageDataURL[] =
22 "data:text/html,<html><head></head><body>Hello, world</body></html>";
24 class AccessibilityModeTest : public ContentBrowserTest {
25 protected:
26 content::WebContents* web_contents() {
27 return shell()->web_contents();
30 content::RenderWidgetHostImpl* rwhi() {
31 content::RenderWidgetHost* rwh =
32 web_contents()->GetRenderWidgetHostView()->GetRenderWidgetHost();
33 return content::RenderWidgetHostImpl::From(rwh);
36 content::RenderWidgetHostViewPort* host_view() {
37 return RenderWidgetHostViewPort::FromRWHV(
38 shell()->web_contents()->GetRenderWidgetHostView());
41 void ExpectBrowserAccessibilityManager(bool expect_bam,
42 std::string message = "") {
43 if (expect_bam) {
44 EXPECT_NE((BrowserAccessibilityManager*)NULL,
45 host_view()->GetBrowserAccessibilityManager()) << message;
46 } else {
47 EXPECT_EQ((BrowserAccessibilityManager*)NULL,
48 host_view()->GetBrowserAccessibilityManager()) << message;
53 IN_PROC_BROWSER_TEST_F(AccessibilityModeTest, AccessibilityModeOff) {
54 NavigateToURL(shell(), GURL(kMinimalPageDataURL));
56 EXPECT_EQ(AccessibilityModeOff, rwhi()->accessibility_mode());
57 ExpectBrowserAccessibilityManager(false);
60 IN_PROC_BROWSER_TEST_F(AccessibilityModeTest, AccessibilityModeComplete) {
61 NavigateToURL(shell(), GURL(kMinimalPageDataURL));
62 ASSERT_EQ(AccessibilityModeOff, rwhi()->accessibility_mode());
64 AccessibilityNotificationWaiter waiter(shell());
65 rwhi()->AddAccessibilityMode(AccessibilityModeComplete);
66 EXPECT_EQ(AccessibilityModeComplete, rwhi()->accessibility_mode());
67 waiter.WaitForNotification();
68 ExpectBrowserAccessibilityManager(true);
71 IN_PROC_BROWSER_TEST_F(AccessibilityModeTest, AccessibilityModeTreeOnly) {
72 NavigateToURL(shell(), GURL(kMinimalPageDataURL));
73 ASSERT_EQ(AccessibilityModeOff, rwhi()->accessibility_mode());
75 AccessibilityNotificationWaiter waiter(shell());
76 rwhi()->AddAccessibilityMode(AccessibilityModeTreeOnly);
77 EXPECT_EQ(AccessibilityModeTreeOnly, rwhi()->accessibility_mode());
78 waiter.WaitForNotification();
79 // No BrowserAccessibilityManager expected for AccessibilityModeTreeOnly
80 ExpectBrowserAccessibilityManager(false);
83 IN_PROC_BROWSER_TEST_F(AccessibilityModeTest, AddingModes) {
84 NavigateToURL(shell(), GURL(kMinimalPageDataURL));
86 AccessibilityNotificationWaiter waiter(shell());
87 rwhi()->AddAccessibilityMode(AccessibilityModeTreeOnly);
88 EXPECT_EQ(AccessibilityModeTreeOnly, rwhi()->accessibility_mode());
89 waiter.WaitForNotification();
90 ExpectBrowserAccessibilityManager(false,
91 "Should be no BrowserAccessibilityManager "
92 "for AccessibilityModeTreeOnly");
94 AccessibilityNotificationWaiter waiter2(shell());
95 rwhi()->AddAccessibilityMode(AccessibilityModeComplete);
96 EXPECT_EQ(AccessibilityModeComplete, rwhi()->accessibility_mode());
97 waiter2.WaitForNotification();
98 ExpectBrowserAccessibilityManager(true,
99 "Should be a BrowserAccessibilityManager "
100 "for AccessibilityModeComplete");
103 } // namespace content