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

Unified Diff: chrome/test/base/in_process_browser_test_browsertest.cc

Issue 582493002: Enable accessibility testing for the bookmark browser test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Apply Feedback Created 5 years, 11 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
Index: chrome/test/base/in_process_browser_test_browsertest.cc
diff --git a/chrome/test/base/in_process_browser_test_browsertest.cc b/chrome/test/base/in_process_browser_test_browsertest.cc
index 33502a4fd9fd8b89665443553660785cd8844df1..a45759327f2d458fda6f9c72aedddf03fecd747e 100644
--- a/chrome/test/base/in_process_browser_test_browsertest.cc
+++ b/chrome/test/base/in_process_browser_test_browsertest.cc
@@ -4,6 +4,8 @@
#include <string.h>
+#include "base/files/file_util.h"
+#include "base/path_service.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/in_process_browser_test.h"
@@ -11,6 +13,7 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
+#include "net/base/filename_util.h"
#include "net/base/net_errors.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -80,4 +83,61 @@ IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, ExternalConnectionFail) {
}
}
+// Paths are to very simple HTML files. One is accessible, the other is not.
+const base::FilePath kPassHTML(
+ FILE_PATH_LITERAL("chrome/test/data/accessibility_pass.html"));
+const base::FilePath kFailHTML(
+ FILE_PATH_LITERAL("chrome/test/data/accessibility_fail.html"));
+
+/*
+ * This class is meant as a test for the accessibility audit in the
+ * InProcessBrowserTest. These test do NOT validate the accessibility audit,
Jay Civelli 2015/02/05 23:29:09 Typo: These tests
hcarmona 2015/02/06 22:50:53 Done.
+ * just the ability to run it.
+ */
+class InProcessAccessibilityBrowsertest : public InProcessBrowserTest {
+ protected:
+ // Construct a URL from a file path that can be used to get to a web page.
+ base::FilePath BuildURLToFile(const base::FilePath file_path) {
Jay Civelli 2015/02/05 23:29:10 const base::FilePath&
hcarmona 2015/02/06 22:50:53 Done.
+ base::FilePath source_root;
+ if (!PathService::Get(base::DIR_SOURCE_ROOT, &source_root))
+ return base::FilePath();
+ return source_root.Append(file_path);
+ }
+
+ bool NavigateToURL(base::FilePath address) {
Jay Civelli 2015/02/05 23:29:09 const base::FilePath&
hcarmona 2015/02/06 22:50:53 Done.
+ GURL url = net::FilePathToFileURL(BuildURLToFile(address));
+
+ if (!url.is_valid() || url.is_empty() || !browser())
+ return false;
+
+ ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
+ browser(), url, 1);
+ return true;
+ }
+};
+
+// Test that an accessible page doesn't fail the accessibility audit.
+IN_PROC_BROWSER_TEST_F(
+ InProcessAccessibilityBrowsertest, VerifyAccessibilityPass) {
+
+ ASSERT_TRUE(NavigateToURL(kPassHTML));
+
+ std::string test_result;
+ RunAccessibilityChecks(&test_result);
Jay Civelli 2015/02/05 23:29:10 Would it make sense for RunAccessibilityChecks to
hcarmona 2015/02/06 22:50:53 Awesome idea. Done.
+
+ EXPECT_EQ(InProcessBrowserTest::kExpectedAccessibilityResults, test_result);
+}
+
+// Test that a page that is not accessible will fail the accessibility audit.
+IN_PROC_BROWSER_TEST_F(
+ InProcessAccessibilityBrowsertest, VerifyAccessibilityFail) {
+
+ ASSERT_TRUE(NavigateToURL(kFailHTML));
+
+ std::string test_result;
+ RunAccessibilityChecks(&test_result);
+
+ EXPECT_NE(InProcessBrowserTest::kExpectedAccessibilityResults, test_result);
+}
+
} // namespace

Powered by Google App Engine
This is Rietveld 408576698