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

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: Applied Feedback Created 5 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
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..bf1e09147ebf8d198741f3e9e228352c5a5bb74b 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 char kPassHTML[] = "chrome/test/data/accessibility_pass.html";
+const char kFailHTML[] = "chrome/test/data/accessibility_fail.html";
+
+/*
+ * This class is meant as a test for the accessibility audit in the
+ * InProcessBrowserTest. These tests do NOT validate the accessibility audit,
+ * 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 char* file_path) {
+ base::FilePath source_root;
+ if (!PathService::Get(base::DIR_SOURCE_ROOT, &source_root))
+ return base::FilePath();
+ return source_root.Append(file_path);
+ }
+
+ bool NavigateToURL(const char* address) {
+ 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;
+ EXPECT_TRUE(RunAccessibilityChecks(&test_result));
+
+ // No error message on success.
+ EXPECT_EQ("", 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;
+ EXPECT_FALSE(RunAccessibilityChecks(&test_result));
+
+ // Error should NOT be empty on failure.
+ EXPECT_NE("", test_result);
+}
+
} // namespace

Powered by Google App Engine
This is Rietveld 408576698