Commit 1201ebc4 authored by jam@chromium.org's avatar jam@chromium.org

Move accessibility browser tests to content_browsertests.

BUG=90448
Review URL: https://chromiumcodereview.appspot.com/10834034

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148568 0039d316-1c4b-4281-b951-d872f2087c98
parent adda8951
......@@ -3034,12 +3034,6 @@
# TODO(craig): Rename this and run from base_unittests when the test
# is safe to run there. See http://crbug.com/78722 for details.
'../base/files/file_path_watcher_browsertest.cc',
'../content/browser/accessibility/cross_platform_accessibility_browsertest.cc',
'../content/browser/accessibility/dump_accessibility_tree_browsertest.cc',
'../content/browser/accessibility/dump_accessibility_tree_helper.cc',
'../content/browser/accessibility/dump_accessibility_tree_helper.h',
'../content/browser/accessibility/dump_accessibility_tree_helper_mac.mm',
'../content/browser/accessibility/dump_accessibility_tree_helper_win.cc',
'../content/browser/renderer_host/render_process_host_browsertest.cc',
'../content/browser/renderer_host/render_view_host_manager_browsertest.cc',
'../content/browser/renderer_host/resource_dispatcher_host_browsertest.cc',
......@@ -3173,12 +3167,6 @@
'browser/ui/gtk/view_id_util_browsertest.cc',
],
}],
['OS=="linux"', {
'sources!': [
'../content/browser/accessibility/dump_accessibility_tree_browsertest.cc',
'../content/browser/accessibility/dump_accessibility_tree_helper.cc',
],
}],
['OS!="win" and OS!="mac"', {
'sources!': [
'browser/rlz/rlz_extension_apitest.cc',
......@@ -3319,13 +3307,7 @@
'../content/common/socket_stream_dispatcher.cc',
]},
],
['use_aura==1', {
'sources!': [
'../content/browser/accessibility/dump_accessibility_tree_browsertest.cc',
'../content/browser/accessibility/dump_accessibility_tree_helper_win.cc',
'../content/browser/accessibility/dump_accessibility_tree_helper.cc',
]
}, { # else: use_aura == 0
['use_aura==0', {
'sources!': [
'browser/ui/views/frame/app_non_client_frame_view_aura_browsertest.cc',
],
......
......@@ -6,15 +6,15 @@
#include <vector>
#include "base/utf_string_conversions.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/test_utils.h"
#include "content/test/content_browser_test.h"
#include "content/test/content_browser_test_utils.h"
#include "content/shell/shell.h"
#if defined(OS_WIN)
#include <atlbase.h>
......@@ -22,15 +22,9 @@
#include "ui/base/win/atl_module.h"
#endif
using content::AccessibilityNodeData;
using content::OpenURLParams;
using content::RenderViewHostImpl;
using content::RenderWidgetHostImpl;
using content::Referrer;
namespace content {
namespace {
class CrossPlatformAccessibilityBrowserTest : public InProcessBrowserTest {
class CrossPlatformAccessibilityBrowserTest : public ContentBrowserTest {
public:
CrossPlatformAccessibilityBrowserTest() {}
......@@ -38,11 +32,11 @@ class CrossPlatformAccessibilityBrowserTest : public InProcessBrowserTest {
// notification that it's been received.
const AccessibilityNodeData& GetAccessibilityNodeDataTree(
AccessibilityMode accessibility_mode = AccessibilityModeComplete) {
content::WindowedNotificationObserver tree_updated_observer(
content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
content::NotificationService::AllSources());
content::RenderWidgetHostView* host_view =
chrome::GetActiveWebContents(browser())->GetRenderWidgetHostView();
WindowedNotificationObserver tree_updated_observer(
NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
NotificationService::AllSources());
RenderWidgetHostView* host_view =
shell()->web_contents()->GetRenderWidgetHostView();
RenderWidgetHostImpl* host =
RenderWidgetHostImpl::From(host_view->GetRenderWidgetHost());
RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>(host);
......@@ -61,9 +55,9 @@ class CrossPlatformAccessibilityBrowserTest : public InProcessBrowserTest {
RecursiveAssertUniqueIds(node.children[i], ids);
}
// InProcessBrowserTest
void SetUpInProcessBrowserTestFixture();
void TearDownInProcessBrowserTestFixture();
// ContentBrowserTest
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE;
virtual void TearDownInProcessBrowserTestFixture() OVERRIDE;
protected:
std::string GetAttr(const AccessibilityNodeData& node,
......@@ -138,8 +132,7 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
"<body><input type='button' value='push' /><input type='checkbox' />"
"</body></html>";
GURL url(url_str);
browser()->OpenURL(OpenURLParams(
url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
NavigateToURL(shell(), url);
const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree();
// Check properties of the root element of the tree.
......@@ -206,8 +199,7 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
"<input value=\"Hello, world.\"/>"
"</body></html>";
GURL url(url_str);
browser()->OpenURL(OpenURLParams(
url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
NavigateToURL(shell(), url);
const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree();
ASSERT_EQ(1U, tree.children.size());
......@@ -236,8 +228,7 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
"<input value=\"Hello, world.\"/>"
"</body></html>";
GURL url(url_str);
browser()->OpenURL(OpenURLParams(
url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
NavigateToURL(shell(), url);
const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree();
ASSERT_EQ(1U, tree.children.size());
......@@ -264,8 +255,7 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
"<!doctype html>"
"<table border=1><tr><td>1</td><td>2</td></tr></table>";
GURL url(url_str);
browser()->OpenURL(OpenURLParams(
url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
NavigateToURL(shell(), url);
const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree();
ASSERT_EQ(1U, tree.children.size());
......@@ -304,8 +294,7 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
" }, 1);\n"
"</script>";
GURL url(url_str);
browser()->OpenURL(OpenURLParams(
url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
NavigateToURL(shell(), url);
const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree();
base::hash_set<int> ids;
......@@ -325,8 +314,7 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
"<button>Button 3</button>"
"</body></html>";
GURL url(url_str);
browser()->OpenURL(OpenURLParams(
url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
NavigateToURL(shell(), url);
const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree();
ASSERT_EQ(1U, tree.children.size());
......@@ -372,8 +360,7 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
"<!doctype html>"
"<em><code ><h4 ></em>";
GURL url(url_str);
browser()->OpenURL(OpenURLParams(
url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
NavigateToURL(shell(), url);
const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree();
base::hash_set<int> ids;
......@@ -400,8 +387,7 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
" </tr>"
"</table>";
GURL url(url_str);
browser()->OpenURL(OpenURLParams(
url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
NavigateToURL(shell(), url);
const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree();
const AccessibilityNodeData& table = tree.children[0];
......@@ -460,8 +446,7 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
" Some text"
"</div>";
GURL url(url_str);
browser()->OpenURL(OpenURLParams(
url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
NavigateToURL(shell(), url);
const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree();
ASSERT_EQ(1U, tree.children.size());
......@@ -471,4 +456,4 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
true, GetBoolAttr(textbox, AccessibilityNodeData::ATTR_CAN_SET_VALUE));
}
} // namespace
} // namespace content
......@@ -10,9 +10,6 @@
#include "base/string_util.h"
#include "base/string16.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/browser/accessibility/browser_accessibility.h"
#include "content/browser/accessibility/browser_accessibility_manager.h"
#include "content/browser/accessibility/dump_accessibility_tree_helper.h"
......@@ -23,15 +20,11 @@
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_paths.h"
#include "content/public/test/test_utils.h"
#include "content/test/content_browser_test.h"
#include "content/test/content_browser_test_utils.h"
#include "content/shell/shell.h"
#include "testing/gtest/include/gtest/gtest.h"
using content::OpenURLParams;
using content::RenderViewHostImpl;
using content::RenderWidgetHostImpl;
using content::RenderWidgetHost;
using content::RenderWidgetHostViewPort;
using content::Referrer;
namespace {
// Required to enter html content into a url.
static const std::string kUrlPreamble = "data:text/html,\n<!doctype html>";
......@@ -41,6 +34,8 @@ namespace {
static const char* kSignalDiff = "*";
} // namespace
namespace content {
// This test takes a snapshot of the platform BrowserAccessibility tree and
// tests it against an expected baseline.
//
......@@ -51,7 +46,7 @@ namespace {
// readable string.
// 4. Perform a comparison between actual and expected and fail if they do not
// exactly match.
class DumpAccessibilityTreeTest : public InProcessBrowserTest {
class DumpAccessibilityTreeTest : public ContentBrowserTest {
public:
// Utility helper that does a comment aware equality check.
// Returns array of lines from expected file which are different.
......@@ -85,7 +80,7 @@ class DumpAccessibilityTreeTest : public InProcessBrowserTest {
IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
DISABLED_PlatformTreeDifferenceTest) {
RenderWidgetHostViewPort* host_view = static_cast<RenderWidgetHostViewPort*>(
chrome::GetActiveWebContents(browser())->GetRenderWidgetHostView());
shell()->web_contents()->GetRenderWidgetHostView());
RenderWidgetHost* host = host_view->GetRenderWidgetHost();
RenderViewHostImpl* view_host =
static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(host));
......@@ -94,7 +89,7 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
// Setup test paths.
FilePath dir_test_data;
EXPECT_TRUE(PathService::Get(content::DIR_TEST_DATA, &dir_test_data));
EXPECT_TRUE(PathService::Get(DIR_TEST_DATA, &dir_test_data));
FilePath test_path(dir_test_data.Append(FILE_PATH_LITERAL("accessibility")));
EXPECT_TRUE(file_util::PathExists(test_path))
<< test_path.LossyDisplayName();
......@@ -138,14 +133,13 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
printf("Testing %s\n", html_file.BaseName().MaybeAsASCII().c_str());
// Load the page.
content::WindowedNotificationObserver tree_updated_observer(
content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
content::NotificationService::AllSources());
WindowedNotificationObserver tree_updated_observer(
NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
NotificationService::AllSources());
string16 html_contents16;
html_contents16 = UTF8ToUTF16(html_contents);
GURL url(UTF8ToUTF16(kUrlPreamble) + html_contents16);
browser()->OpenURL(OpenURLParams(
url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
NavigateToURL(shell(), url);
// Wait for the tree.
tree_updated_observer.Wait();
......@@ -202,3 +196,5 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
}
} while (!(html_file = file_enumerator.Next()).empty());
}
} // namespace content
......@@ -549,6 +549,12 @@
'HAS_OUT_OF_PROC_TEST_RUNNER',
],
'sources': [
'browser/accessibility/cross_platform_accessibility_browsertest.cc',
'browser/accessibility/dump_accessibility_tree_browsertest.cc',
'browser/accessibility/dump_accessibility_tree_helper.cc',
'browser/accessibility/dump_accessibility_tree_helper.h',
'browser/accessibility/dump_accessibility_tree_helper_mac.mm',
'browser/accessibility/dump_accessibility_tree_helper_win.cc',
'browser/appcache/appcache_browsertest.cc',
'browser/audio_browsertest.cc',
'browser/child_process_security_policy_browsertest.cc',
......@@ -603,6 +609,7 @@
],
'dependencies': [
'<(DEPTH)/net/net.gyp:net_resources',
'<(DEPTH)/third_party/iaccessible2/iaccessible2.gyp:iaccessible2',
'<(DEPTH)/webkit/support/webkit_support.gyp:webkit_resources',
'<(DEPTH)/webkit/support/webkit_support.gyp:webkit_strings',
],
......@@ -621,6 +628,12 @@
'../base/allocator/allocator.gyp:allocator',
],
}],
['OS=="linux"', {
'sources!': [
'browser/accessibility/dump_accessibility_tree_browsertest.cc',
'browser/accessibility/dump_accessibility_tree_helper.cc',
],
}],
['OS=="mac"', {
'dependencies': [
'content_shell', # Needed for Content Shell.app's Helper.
......@@ -628,6 +641,9 @@
}],
['use_aura==1', {
'sources!': [
'browser/accessibility/dump_accessibility_tree_browsertest.cc',
'browser/accessibility/dump_accessibility_tree_helper_win.cc',
'browser/accessibility/dump_accessibility_tree_helper.cc',
'browser/plugin_browsertest.cc',
],
}],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment