2017-05-12 20:28:25 +02:00
|
|
|
// Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "include/base/cef_bind.h"
|
|
|
|
#include "include/cef_accessibility_handler.h"
|
|
|
|
#include "include/cef_parser.h"
|
|
|
|
#include "include/cef_waitable_event.h"
|
|
|
|
#include "include/wrapper/cef_closure_task.h"
|
|
|
|
#include "tests/ceftests/test_handler.h"
|
|
|
|
#include "tests/ceftests/test_util.h"
|
|
|
|
#include "tests/gtest/include/gtest/gtest.h"
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
const char kTestUrl[] = "https://tests/AccessibilityTestHandler";
|
|
|
|
const char kTipText[] = "Also known as User ID";
|
|
|
|
|
2017-07-05 20:51:46 +02:00
|
|
|
// Default OSR widget size.
|
2017-05-12 20:28:25 +02:00
|
|
|
const int kOsrWidth = 600;
|
|
|
|
const int kOsrHeight = 400;
|
|
|
|
|
2017-07-05 20:51:46 +02:00
|
|
|
// Test type.
|
2017-05-12 20:28:25 +02:00
|
|
|
enum AccessibilityTestType {
|
|
|
|
// Enabling Accessibility should trigger the AccessibilityHandler callback
|
|
|
|
// with Accessibility tree details
|
2017-07-05 20:51:46 +02:00
|
|
|
TEST_ENABLE,
|
2017-05-12 20:28:25 +02:00
|
|
|
// Disabling Accessibility should disable accessibility notification changes
|
2017-07-05 20:51:46 +02:00
|
|
|
TEST_DISABLE,
|
2017-05-12 20:28:25 +02:00
|
|
|
// Focus change on element should trigger Accessibility focus event
|
|
|
|
TEST_FOCUS_CHANGE,
|
|
|
|
// Hide/Show etc should trigger Location Change callbacks
|
|
|
|
TEST_LOCATION_CHANGE
|
|
|
|
};
|
|
|
|
|
|
|
|
class AccessibilityTestHandler : public TestHandler,
|
|
|
|
public CefRenderHandler,
|
|
|
|
public CefAccessibilityHandler {
|
|
|
|
public:
|
|
|
|
AccessibilityTestHandler(const AccessibilityTestType& type)
|
2017-05-17 11:29:28 +02:00
|
|
|
: test_type_(type), edit_box_id_(-1), accessibility_disabled_(false) {}
|
2017-05-12 20:28:25 +02:00
|
|
|
|
|
|
|
CefRefPtr<CefAccessibilityHandler> GetAccessibilityHandler() override {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2017-07-05 20:51:46 +02:00
|
|
|
CefRefPtr<CefRenderHandler> GetRenderHandler() override { return this; }
|
2017-05-12 20:28:25 +02:00
|
|
|
|
|
|
|
// Cef Renderer Handler Methods
|
2018-09-25 15:40:02 +02:00
|
|
|
void GetViewRect(CefRefPtr<CefBrowser> browser, CefRect& rect) override {
|
2017-05-12 20:28:25 +02:00
|
|
|
rect = CefRect(0, 0, kOsrWidth, kOsrHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetScreenInfo(CefRefPtr<CefBrowser> browser,
|
2017-05-17 11:29:28 +02:00
|
|
|
CefScreenInfo& screen_info) override {
|
|
|
|
screen_info.rect = CefRect(0, 0, kOsrWidth, kOsrHeight);
|
|
|
|
screen_info.available_rect = screen_info.rect;
|
|
|
|
return true;
|
2017-05-12 20:28:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void OnPaint(CefRefPtr<CefBrowser> browser,
|
2017-05-17 11:29:28 +02:00
|
|
|
CefRenderHandler::PaintElementType type,
|
|
|
|
const CefRenderHandler::RectList& dirtyRects,
|
|
|
|
const void* buffer,
|
|
|
|
int width,
|
2017-07-05 20:51:46 +02:00
|
|
|
int height) override {
|
2017-05-12 20:28:25 +02:00
|
|
|
// Do nothing.
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunTest() override {
|
|
|
|
std::string html =
|
|
|
|
"<html><head><title>AccessibilityTest</title></head>"
|
|
|
|
"<body><span id='tipspan' role='tooltip' style='color:red;"
|
|
|
|
"margin:20px'>";
|
|
|
|
html += kTipText;
|
2017-05-17 11:29:28 +02:00
|
|
|
html +=
|
|
|
|
"</span>"
|
2017-05-12 20:28:25 +02:00
|
|
|
"<input id='editbox' type='text' aria-describedby='tipspan' "
|
|
|
|
"value='editbox' size='25px'/><input id='button' type='button' "
|
|
|
|
"value='button' style='margin:20px'/></body></html>";
|
|
|
|
AddResource(kTestUrl, html, "text/html");
|
|
|
|
|
|
|
|
// Create the browser
|
|
|
|
CreateOSRBrowser(kTestUrl);
|
|
|
|
|
|
|
|
// Time out the test after a reasonable period of time.
|
|
|
|
SetTestTimeout(5000);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnLoadEnd(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
int httpStatusCode) override {
|
|
|
|
// Enable Accessibility
|
|
|
|
browser->GetHost()->SetAccessibilityState(STATE_ENABLED);
|
2017-05-17 11:29:28 +02:00
|
|
|
switch (test_type_) {
|
2017-07-05 20:51:46 +02:00
|
|
|
case TEST_ENABLE: {
|
2017-05-12 20:28:25 +02:00
|
|
|
// This should trigger OnAccessibilityTreeChange
|
|
|
|
// And update will be validated
|
|
|
|
} break;
|
2017-07-05 20:51:46 +02:00
|
|
|
case TEST_DISABLE: {
|
2017-05-12 20:28:25 +02:00
|
|
|
// Post a delayed task to disable Accessibility
|
2017-05-17 11:29:28 +02:00
|
|
|
CefPostDelayedTask(
|
|
|
|
TID_UI,
|
|
|
|
base::Bind(&AccessibilityTestHandler::DisableAccessibility, this,
|
|
|
|
browser),
|
|
|
|
200);
|
2017-05-12 20:28:25 +02:00
|
|
|
} break;
|
|
|
|
// Delayed task will posted later after we have initial details
|
|
|
|
case TEST_FOCUS_CHANGE: {
|
|
|
|
} break;
|
|
|
|
case TEST_LOCATION_CHANGE: {
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-05 20:51:46 +02:00
|
|
|
void OnAccessibilityTreeChange(CefRefPtr<CefValue> value) override {
|
2017-05-17 11:29:28 +02:00
|
|
|
switch (test_type_) {
|
2017-07-05 20:51:46 +02:00
|
|
|
case TEST_ENABLE: {
|
2017-05-12 20:28:25 +02:00
|
|
|
TestEnableAccessibilityUpdate(value);
|
|
|
|
} break;
|
2017-07-05 20:51:46 +02:00
|
|
|
case TEST_DISABLE: {
|
2017-05-12 20:28:25 +02:00
|
|
|
// Once Accessibility is disabled in the delayed Task
|
|
|
|
// We should not reach here
|
|
|
|
EXPECT_FALSE(accessibility_disabled_);
|
|
|
|
} break;
|
|
|
|
case TEST_LOCATION_CHANGE: {
|
|
|
|
// find accessibility id of the edit box, before setting focus
|
|
|
|
if (edit_box_id_ == -1) {
|
2018-06-08 18:53:10 +02:00
|
|
|
CefRefPtr<CefDictionaryValue> update, event;
|
|
|
|
GetFirstUpdateAndEvent(value, update, event);
|
|
|
|
EXPECT_TRUE(update.get());
|
2017-05-12 20:28:25 +02:00
|
|
|
|
2017-12-12 21:57:38 +01:00
|
|
|
// Ignore other events.
|
2018-06-08 18:53:10 +02:00
|
|
|
if (!event.get() ||
|
|
|
|
event->GetString("event_type") != "layoutComplete") {
|
2017-05-12 20:28:25 +02:00
|
|
|
break;
|
2018-06-08 18:53:10 +02:00
|
|
|
}
|
2017-05-12 20:28:25 +02:00
|
|
|
|
2018-06-08 18:53:10 +02:00
|
|
|
SetEditBoxIdAndRect(update);
|
|
|
|
EXPECT_NE(edit_box_id_, -1);
|
2017-05-12 20:28:25 +02:00
|
|
|
// Post a delayed task to hide the span and trigger location change
|
|
|
|
CefPostDelayedTask(TID_UI,
|
|
|
|
base::Bind(&AccessibilityTestHandler::HideEditBox,
|
2017-05-17 11:29:28 +02:00
|
|
|
this, GetBrowser()),
|
|
|
|
200);
|
2017-05-12 20:28:25 +02:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
case TEST_FOCUS_CHANGE: {
|
|
|
|
// find accessibility id of the edit box, before setting focus
|
|
|
|
if (edit_box_id_ == -1) {
|
2018-06-08 18:53:10 +02:00
|
|
|
CefRefPtr<CefDictionaryValue> update, event;
|
|
|
|
GetFirstUpdateAndEvent(value, update, event);
|
|
|
|
EXPECT_TRUE(update.get());
|
2017-05-12 20:28:25 +02:00
|
|
|
|
2017-12-12 21:57:38 +01:00
|
|
|
// Ignore other events.
|
2018-06-08 18:53:10 +02:00
|
|
|
if (!event.get() ||
|
|
|
|
event->GetString("event_type") != "layoutComplete") {
|
2017-05-12 20:28:25 +02:00
|
|
|
break;
|
2018-06-08 18:53:10 +02:00
|
|
|
}
|
2017-05-12 20:28:25 +02:00
|
|
|
|
|
|
|
// Now post a delayed task to trigger focus to edit box
|
2018-06-08 18:53:10 +02:00
|
|
|
SetEditBoxIdAndRect(update);
|
|
|
|
EXPECT_NE(edit_box_id_, -1);
|
2017-05-12 20:28:25 +02:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
CefPostDelayedTask(
|
|
|
|
TID_UI,
|
|
|
|
base::Bind(&AccessibilityTestHandler::SetFocusOnEditBox, this,
|
|
|
|
GetBrowser()),
|
|
|
|
200);
|
2017-05-12 20:28:25 +02:00
|
|
|
} else {
|
2018-06-08 18:53:10 +02:00
|
|
|
CefRefPtr<CefDictionaryValue> update, event;
|
|
|
|
GetFirstUpdateAndEvent(value, update, event);
|
|
|
|
EXPECT_TRUE(update.get());
|
2017-05-12 20:28:25 +02:00
|
|
|
|
2017-12-12 21:57:38 +01:00
|
|
|
// Ignore other events.
|
2018-06-08 18:53:10 +02:00
|
|
|
if (!event.get() || event->GetString("event_type") != "focus") {
|
2017-12-12 21:57:38 +01:00
|
|
|
return;
|
2018-06-08 18:53:10 +02:00
|
|
|
}
|
2017-05-12 20:28:25 +02:00
|
|
|
|
|
|
|
// And Focus is set to expected element edit_box
|
2018-06-08 18:53:10 +02:00
|
|
|
EXPECT_EQ(edit_box_id_, event->GetInt("id"));
|
2017-05-12 20:28:25 +02:00
|
|
|
|
|
|
|
// Now Post a delayed task to destroy the test giving
|
|
|
|
// sufficient time for any accessibility updates to come through
|
2017-05-17 11:29:28 +02:00
|
|
|
CefPostDelayedTask(
|
|
|
|
TID_UI, base::Bind(&AccessibilityTestHandler::DestroyTest, this),
|
|
|
|
500);
|
2017-05-12 20:28:25 +02:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-05 20:51:46 +02:00
|
|
|
void OnAccessibilityLocationChange(CefRefPtr<CefValue> value) override {
|
2017-05-12 20:28:25 +02:00
|
|
|
if (test_type_ == TEST_LOCATION_CHANGE) {
|
2018-06-08 18:53:10 +02:00
|
|
|
EXPECT_NE(edit_box_id_, -1);
|
2017-05-12 20:28:25 +02:00
|
|
|
EXPECT_TRUE(value.get());
|
|
|
|
|
|
|
|
// Change has a valid list
|
2018-06-08 18:53:10 +02:00
|
|
|
EXPECT_EQ(VTYPE_LIST, value->GetType());
|
2017-05-12 20:28:25 +02:00
|
|
|
CefRefPtr<CefListValue> list = value->GetList();
|
|
|
|
EXPECT_TRUE(list.get());
|
2018-07-24 00:32:02 +02:00
|
|
|
|
|
|
|
got_accessibility_location_change_.yes();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (got_hide_edit_box_) {
|
|
|
|
// Now destroy the test.
|
|
|
|
CefPostTask(TID_UI,
|
|
|
|
base::Bind(&AccessibilityTestHandler::DestroyTest, this));
|
2017-05-12 20:28:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2017-07-05 20:51:46 +02:00
|
|
|
void CreateOSRBrowser(const CefString& url) {
|
|
|
|
CefWindowInfo windowInfo;
|
|
|
|
CefBrowserSettings settings;
|
|
|
|
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
windowInfo.SetAsWindowless(GetDesktopWindow());
|
|
|
|
#elif defined(OS_MACOSX)
|
|
|
|
windowInfo.SetAsWindowless(kNullWindowHandle);
|
|
|
|
#elif defined(OS_LINUX)
|
|
|
|
windowInfo.SetAsWindowless(kNullWindowHandle);
|
|
|
|
#else
|
|
|
|
#error "Unsupported platform"
|
|
|
|
#endif
|
2019-03-19 10:42:54 +01:00
|
|
|
CefBrowserHost::CreateBrowser(windowInfo, this, url, settings, NULL, NULL);
|
2017-07-05 20:51:46 +02:00
|
|
|
}
|
|
|
|
|
2017-05-12 20:28:25 +02:00
|
|
|
void HideEditBox(CefRefPtr<CefBrowser> browser) {
|
2018-07-24 00:32:02 +02:00
|
|
|
// Hide the edit box.
|
2017-05-12 20:28:25 +02:00
|
|
|
// This should trigger Location update if enabled
|
|
|
|
browser->GetMainFrame()->ExecuteJavaScript(
|
2017-05-17 11:29:28 +02:00
|
|
|
"document.getElementById('editbox').style.display = 'none';", kTestUrl,
|
|
|
|
0);
|
2018-07-24 00:32:02 +02:00
|
|
|
|
|
|
|
got_hide_edit_box_.yes();
|
2017-05-12 20:28:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetFocusOnEditBox(CefRefPtr<CefBrowser> browser) {
|
|
|
|
// Set focus on edit box
|
|
|
|
// This should trigger accessibility update if enabled
|
|
|
|
browser->GetMainFrame()->ExecuteJavaScript(
|
|
|
|
"document.getElementById('editbox').focus();", kTestUrl, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisableAccessibility(CefRefPtr<CefBrowser> browser) {
|
|
|
|
browser->GetHost()->SetAccessibilityState(STATE_DISABLED);
|
|
|
|
accessibility_disabled_ = true;
|
|
|
|
// Set focus on edit box
|
|
|
|
SetFocusOnEditBox(browser);
|
|
|
|
|
|
|
|
// Now Post a delayed task to destroy the test
|
|
|
|
// giving sufficient time for any accessibility updates to come through
|
2017-05-17 11:29:28 +02:00
|
|
|
CefPostDelayedTask(
|
|
|
|
TID_UI, base::Bind(&AccessibilityTestHandler::DestroyTest, this), 500);
|
2017-05-12 20:28:25 +02:00
|
|
|
}
|
|
|
|
|
2018-06-08 18:53:10 +02:00
|
|
|
void GetFirstUpdateAndEvent(CefRefPtr<CefValue> value,
|
|
|
|
CefRefPtr<CefDictionaryValue>& update,
|
|
|
|
CefRefPtr<CefDictionaryValue>& event) {
|
|
|
|
EXPECT_TRUE(value.get());
|
|
|
|
EXPECT_EQ(value->GetType(), VTYPE_DICTIONARY);
|
|
|
|
CefRefPtr<CefDictionaryValue> topLevel = value->GetDictionary();
|
|
|
|
EXPECT_TRUE(topLevel.get());
|
|
|
|
|
|
|
|
// Get the first update dict.
|
|
|
|
CefRefPtr<CefListValue> updates = topLevel->GetList("updates");
|
|
|
|
if (updates.get()) {
|
|
|
|
EXPECT_GT(updates->GetSize(), 0U);
|
|
|
|
update = updates->GetDictionary(0);
|
|
|
|
EXPECT_TRUE(update.get());
|
|
|
|
}
|
2017-05-12 20:28:25 +02:00
|
|
|
|
2018-06-08 18:53:10 +02:00
|
|
|
// Get the first event dict.
|
|
|
|
CefRefPtr<CefListValue> events = topLevel->GetList("events");
|
|
|
|
if (events.get()) {
|
|
|
|
EXPECT_GT(events->GetSize(), 0U);
|
|
|
|
event = events->GetDictionary(0);
|
|
|
|
EXPECT_TRUE(event.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestEnableAccessibilityUpdate(CefRefPtr<CefValue> value) {
|
|
|
|
CefRefPtr<CefDictionaryValue> update, event;
|
|
|
|
GetFirstUpdateAndEvent(value, update, event);
|
|
|
|
EXPECT_TRUE(update.get());
|
2017-12-12 21:57:38 +01:00
|
|
|
|
|
|
|
// Ignore other events.
|
2018-06-08 18:53:10 +02:00
|
|
|
if (!event.get() || event->GetString("event_type") != "layoutComplete") {
|
2017-12-12 21:57:38 +01:00
|
|
|
return;
|
2018-06-08 18:53:10 +02:00
|
|
|
}
|
2017-05-12 20:28:25 +02:00
|
|
|
|
|
|
|
// Get update and validate it has tree data
|
|
|
|
EXPECT_TRUE(update->GetBool("has_tree_data"));
|
2017-05-17 11:29:28 +02:00
|
|
|
CefRefPtr<CefDictionaryValue> treeData = update->GetDictionary("tree_data");
|
2017-05-12 20:28:25 +02:00
|
|
|
|
|
|
|
// Validate title and Url
|
|
|
|
EXPECT_STREQ("AccessibilityTest",
|
|
|
|
treeData->GetString("title").ToString().c_str());
|
|
|
|
EXPECT_STREQ(kTestUrl, treeData->GetString("url").ToString().c_str());
|
|
|
|
|
|
|
|
// Validate node data
|
|
|
|
CefRefPtr<CefListValue> nodes = update->GetList("nodes");
|
|
|
|
EXPECT_TRUE(nodes.get());
|
2018-06-08 18:53:10 +02:00
|
|
|
EXPECT_GT(nodes->GetSize(), 0U);
|
2017-05-12 20:28:25 +02:00
|
|
|
|
|
|
|
// Update has a valid root
|
|
|
|
CefRefPtr<CefDictionaryValue> root;
|
2017-05-17 11:29:28 +02:00
|
|
|
for (size_t index = 0; index < nodes->GetSize(); index++) {
|
2017-05-12 20:28:25 +02:00
|
|
|
CefRefPtr<CefDictionaryValue> node = nodes->GetDictionary(index);
|
|
|
|
if (node->GetString("role").ToString() == "rootWebArea") {
|
|
|
|
root = node;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPECT_TRUE(root.get());
|
|
|
|
|
|
|
|
// One div containing the tree elements.
|
|
|
|
CefRefPtr<CefListValue> childIDs = root->GetList("child_ids");
|
|
|
|
EXPECT_TRUE(childIDs.get());
|
2018-06-08 18:53:10 +02:00
|
|
|
EXPECT_EQ(1U, childIDs->GetSize());
|
2017-05-12 20:28:25 +02:00
|
|
|
|
|
|
|
// A parent Group div containing the child.
|
|
|
|
CefRefPtr<CefDictionaryValue> group;
|
2017-05-17 11:29:28 +02:00
|
|
|
for (size_t index = 0; index < nodes->GetSize(); index++) {
|
2017-05-12 20:28:25 +02:00
|
|
|
CefRefPtr<CefDictionaryValue> node = nodes->GetDictionary(index);
|
2017-05-31 17:33:30 +02:00
|
|
|
if (node->GetString("role").ToString() == "genericContainer") {
|
2017-05-12 20:28:25 +02:00
|
|
|
group = node;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPECT_TRUE(group.get());
|
|
|
|
// Validate Group is child of root WebArea.
|
|
|
|
EXPECT_EQ(group->GetInt("id"), childIDs->GetInt(0));
|
|
|
|
|
|
|
|
CefRefPtr<CefListValue> parentdiv = group->GetList("child_ids");
|
|
|
|
EXPECT_TRUE(parentdiv.get());
|
2018-06-08 18:53:10 +02:00
|
|
|
EXPECT_EQ(3U, parentdiv->GetSize());
|
2017-05-12 20:28:25 +02:00
|
|
|
|
|
|
|
int tipId = parentdiv->GetInt(0);
|
|
|
|
int editBoxId = parentdiv->GetInt(1);
|
|
|
|
int buttonId = parentdiv->GetInt(2);
|
|
|
|
|
|
|
|
// A parent Group div containing the child.
|
|
|
|
CefRefPtr<CefDictionaryValue> tip, editbox, button;
|
2017-05-17 11:29:28 +02:00
|
|
|
for (size_t index = 0; index < nodes->GetSize(); index++) {
|
2017-05-12 20:28:25 +02:00
|
|
|
CefRefPtr<CefDictionaryValue> node = nodes->GetDictionary(index);
|
|
|
|
if (node->GetInt("id") == tipId) {
|
|
|
|
tip = node;
|
|
|
|
}
|
|
|
|
if (node->GetInt("id") == editBoxId) {
|
|
|
|
editbox = node;
|
|
|
|
}
|
|
|
|
if (node->GetInt("id") == buttonId) {
|
|
|
|
button = node;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPECT_TRUE(tip.get());
|
|
|
|
EXPECT_STREQ("tooltip", tip->GetString("role").ToString().c_str());
|
|
|
|
CefRefPtr<CefDictionaryValue> tipattr = tip->GetDictionary("attributes");
|
|
|
|
EXPECT_TRUE(tipattr.get());
|
|
|
|
|
|
|
|
EXPECT_TRUE(editbox.get());
|
2017-05-17 11:29:28 +02:00
|
|
|
EXPECT_STREQ("textField", editbox->GetString("role").ToString().c_str());
|
2017-05-12 20:28:25 +02:00
|
|
|
CefRefPtr<CefDictionaryValue> editattr =
|
2017-05-17 11:29:28 +02:00
|
|
|
editbox->GetDictionary("attributes");
|
2017-05-12 20:28:25 +02:00
|
|
|
// Validate ARIA Description tags for tipIdare associated with editbox.
|
|
|
|
EXPECT_TRUE(editattr.get());
|
|
|
|
EXPECT_EQ(tipId, editattr->GetList("describedbyIds")->GetInt(0));
|
|
|
|
EXPECT_STREQ(kTipText,
|
|
|
|
editattr->GetString("description").ToString().c_str());
|
|
|
|
|
|
|
|
EXPECT_TRUE(button.get());
|
|
|
|
EXPECT_STREQ("button", button->GetString("role").ToString().c_str());
|
|
|
|
|
|
|
|
// Now Post a delayed task to destroy the test
|
|
|
|
// giving sufficient time for any accessibility updates to come through
|
2017-05-17 11:29:28 +02:00
|
|
|
CefPostDelayedTask(
|
|
|
|
TID_UI, base::Bind(&AccessibilityTestHandler::DestroyTest, this), 500);
|
2017-05-12 20:28:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Find Edit box Id in accessibility tree.
|
|
|
|
void SetEditBoxIdAndRect(CefRefPtr<CefDictionaryValue> value) {
|
|
|
|
EXPECT_TRUE(value.get());
|
|
|
|
// Validate node data.
|
|
|
|
CefRefPtr<CefListValue> nodes = value->GetList("nodes");
|
|
|
|
EXPECT_TRUE(nodes.get());
|
2018-06-08 18:53:10 +02:00
|
|
|
EXPECT_GT(nodes->GetSize(), 0U);
|
2017-05-12 20:28:25 +02:00
|
|
|
|
|
|
|
// Find accessibility id for the text field.
|
2017-05-17 11:29:28 +02:00
|
|
|
for (size_t index = 0; index < nodes->GetSize(); index++) {
|
2017-05-12 20:28:25 +02:00
|
|
|
CefRefPtr<CefDictionaryValue> node = nodes->GetDictionary(index);
|
|
|
|
if (node->GetString("role").ToString() == "textField") {
|
|
|
|
edit_box_id_ = node->GetInt("id");
|
|
|
|
CefRefPtr<CefDictionaryValue> loc = node->GetDictionary("location");
|
|
|
|
EXPECT_TRUE(loc.get());
|
2018-07-24 00:32:02 +02:00
|
|
|
EXPECT_GT(loc->GetDouble("x"), 0);
|
|
|
|
EXPECT_GT(loc->GetDouble("y"), 0);
|
|
|
|
EXPECT_GT(loc->GetDouble("width"), 0);
|
|
|
|
EXPECT_GT(loc->GetDouble("height"), 0);
|
2017-05-12 20:28:25 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-24 00:32:02 +02:00
|
|
|
void DestroyTest() override {
|
|
|
|
if (test_type_ == TEST_LOCATION_CHANGE) {
|
|
|
|
EXPECT_GT(edit_box_id_, 0);
|
|
|
|
EXPECT_TRUE(got_hide_edit_box_);
|
|
|
|
EXPECT_TRUE(got_accessibility_location_change_);
|
|
|
|
}
|
|
|
|
TestHandler::DestroyTest();
|
|
|
|
}
|
|
|
|
|
2017-05-12 20:28:25 +02:00
|
|
|
AccessibilityTestType test_type_;
|
|
|
|
int edit_box_id_;
|
|
|
|
bool accessibility_disabled_;
|
2018-07-24 00:32:02 +02:00
|
|
|
TrackCallback got_hide_edit_box_;
|
|
|
|
TrackCallback got_accessibility_location_change_;
|
2017-05-12 20:28:25 +02:00
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(AccessibilityTestHandler);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2017-07-05 20:51:46 +02:00
|
|
|
TEST(OSRTest, AccessibilityEnable) {
|
2017-05-12 20:28:25 +02:00
|
|
|
CefRefPtr<AccessibilityTestHandler> handler =
|
2017-07-05 20:51:46 +02:00
|
|
|
new AccessibilityTestHandler(TEST_ENABLE);
|
2017-05-12 20:28:25 +02:00
|
|
|
handler->ExecuteTest();
|
|
|
|
ReleaseAndWaitForDestructor(handler);
|
|
|
|
}
|
|
|
|
|
2017-07-05 20:51:46 +02:00
|
|
|
TEST(OSRTest, AccessibilityDisable) {
|
2017-05-12 20:28:25 +02:00
|
|
|
CefRefPtr<AccessibilityTestHandler> handler =
|
2017-07-05 20:51:46 +02:00
|
|
|
new AccessibilityTestHandler(TEST_DISABLE);
|
2017-05-12 20:28:25 +02:00
|
|
|
handler->ExecuteTest();
|
|
|
|
ReleaseAndWaitForDestructor(handler);
|
|
|
|
}
|
|
|
|
|
2017-07-05 20:51:46 +02:00
|
|
|
TEST(OSRTest, AccessibilityFocusChange) {
|
2017-05-12 20:28:25 +02:00
|
|
|
CefRefPtr<AccessibilityTestHandler> handler =
|
2017-05-17 11:29:28 +02:00
|
|
|
new AccessibilityTestHandler(TEST_FOCUS_CHANGE);
|
2017-05-12 20:28:25 +02:00
|
|
|
handler->ExecuteTest();
|
|
|
|
ReleaseAndWaitForDestructor(handler);
|
|
|
|
}
|
|
|
|
|
2017-07-05 20:51:46 +02:00
|
|
|
TEST(OSRTest, AccessibilityLocationChange) {
|
2017-05-12 20:28:25 +02:00
|
|
|
CefRefPtr<AccessibilityTestHandler> handler =
|
2017-05-17 11:29:28 +02:00
|
|
|
new AccessibilityTestHandler(TEST_LOCATION_CHANGE);
|
2017-05-12 20:28:25 +02:00
|
|
|
handler->ExecuteTest();
|
|
|
|
ReleaseAndWaitForDestructor(handler);
|
|
|
|
}
|