Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UIA Tree Dump Tests to E2E Tests for Fabric #12250

Merged
merged 23 commits into from
Oct 18, 2023
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5c93812
Save State: Dump UIA with No Children
chiaramooney Oct 11, 2023
dc7a89a
Save State: Add More Data
chiaramooney Oct 11, 2023
76f6806
Save State: Add Tree Traversal
chiaramooney Oct 12, 2023
9f884cf
Save State:Adjust Traversal Format
chiaramooney Oct 12, 2023
b3c9a1d
Save State: Working UIA Dump
chiaramooney Oct 12, 2023
fa460bc
Add Dumps for Page Tiles
chiaramooney Oct 12, 2023
e66e3f8
Save State: UIA Dump Tests
chiaramooney Oct 13, 2023
b28807e
Save State: Add Touchables
chiaramooney Oct 13, 2023
7ecdaba
Add Text Page
chiaramooney Oct 13, 2023
4519549
Merge branch 'main' of https://github.com/microsoft/react-native-wind…
chiaramooney Oct 16, 2023
13912a8
Change files
chiaramooney Oct 16, 2023
3454d62
Format
chiaramooney Oct 17, 2023
857f396
Merge branch 'main' into cm-uia-dump
chiaramooney Oct 17, 2023
9f1d360
Revert Lock Changes
chiaramooney Oct 17, 2023
cfbc899
Merge branch 'cm-uia-dump' of https://github.com/chiaramooney/react-n…
chiaramooney Oct 17, 2023
5e7742e
Fix Lint
chiaramooney Oct 17, 2023
ae944d1
Test Text
chiaramooney Oct 17, 2023
ac96f15
Add Test Stability
chiaramooney Oct 17, 2023
37992aa
Try: Stabilize View Tests
chiaramooney Oct 17, 2023
502569b
Merge branch 'main' into cm-uia-dump
chiaramooney Oct 17, 2023
3b15173
Add Stability
chiaramooney Oct 18, 2023
fbe34f0
Merge branch 'cm-uia-dump' of https://github.com/chiaramooney/react-n…
chiaramooney Oct 18, 2023
8dffea9
Merge branch 'main' into cm-uia-dump
chiaramooney Oct 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Save State: Add Tree Traversal
  • Loading branch information
chiaramooney committed Oct 12, 2023
commit 76f680614c6da301b33d8c67727506ffa1a2d896
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`dumpUIA Search Bar UIA Dump 1`] = `
{
"AutomationId": "components-tab",
"Child": {
"AutomationId": "",
"ControlType": 50020,
"HelpText": "",
"IsEnabled": true,
"IsKeyboardFocusable": false,
"LocalizedControlType": "text",
"Name": "Components",
},
"ControlType": 50026,
"HelpText": "",
"IsEnabled": true,
"IsKeyboardFocusable": true,
"LocalizedControlType": "group",
"Name": "",
}
`;

exports[`dumpUIA control 1`] = `
{
"AutomationId": "explorer_search",
4 changes: 2 additions & 2 deletions packages/e2e-test-app-fabric/test/dumpUIA.test.ts
Original file line number Diff line number Diff line change
@@ -14,10 +14,10 @@ afterEach(async () => {
});

describe('dumpUIA', () => {
test('control', async () => {
test('Search Bar UIA Dump', async () => {
const componentsTabButton = await app.findElementByTestID('components-tab');
await componentsTabButton.waitForDisplayed({timeout: 20000});
const dump = await dumpVisualTree('components-tab');
const dump = await dumpVisualTree('explorer-search');
expect(dump).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -313,9 +313,46 @@ winrt::Windows::Data::Json::JsonObject ListErrors(winrt::Windows::Data::Json::Js
return result;
}

winrt::Windows::Data::Json::JsonObject DumpUIATree(IUIAutomationElement *pTarget, IUIAutomationTreeWalker *pWalker) {
winrt::Windows::Data::Json::JsonObject result;
BSTR automationId;
CONTROLTYPEID controlType;
BSTR helpText;
BOOL isEnabled;
BOOL isKeyboardFocusable;
BSTR localizedControlType;
BSTR name;

pTarget->get_CurrentAutomationId(&automationId);
pTarget->get_CurrentControlType(&controlType);
pTarget->get_CurrentHelpText(&helpText);
pTarget->get_CurrentIsEnabled(&isEnabled);
pTarget->get_CurrentIsKeyboardFocusable(&isKeyboardFocusable);
pTarget->get_CurrentLocalizedControlType(&localizedControlType);
pTarget->get_CurrentName(&name);
result.Insert(L"AutomationId", winrt::Windows::Data::Json::JsonValue::CreateStringValue(automationId));
result.Insert(L"ControlType", winrt::Windows::Data::Json::JsonValue::CreateNumberValue(controlType));
result.Insert(L"HelpText", winrt::Windows::Data::Json::JsonValue::CreateStringValue(helpText));
result.Insert(L"IsEnabled", winrt::Windows::Data::Json::JsonValue::CreateBooleanValue(isEnabled));
result.Insert(L"IsKeyboardFocusable", winrt::Windows::Data::Json::JsonValue::CreateBooleanValue(isKeyboardFocusable));
result.Insert(
L"LocalizedControlType", winrt::Windows::Data::Json::JsonValue::CreateStringValue(localizedControlType));
result.Insert(L"Name", winrt::Windows::Data::Json::JsonValue::CreateStringValue(name));

IUIAutomationElement *pChild;
IUIAutomationElement *pSibling;
pWalker->GetFirstChildElement(pTarget, &pChild);
while (pChild != nullptr) {
result.Insert(L"Child", DumpUIATree(pChild, pWalker));
pWalker->GetNextSiblingElement(pChild, &pSibling);
pChild = pSibling;
pSibling = nullptr;
}
return result;
}

winrt::Windows::Data::Json::JsonObject DumpVisualTree(winrt::Windows::Data::Json::JsonValue payload) {
winrt::Windows::Data::Json::JsonObject result;
// TODO: Method should return a JSON of the Composition Visual Tree
// Initialize
IUIAutomation* pAutomation;
IUIAutomationElement* pRootElement;
@@ -328,43 +365,27 @@ winrt::Windows::Data::Json::JsonObject DumpVisualTree(winrt::Windows::Data::Json
//pWalker->GetFirstChildElement(pRootElement, &pChild);

//Find Element with Matching AutomationID'
IUIAutomationElement* pChild;
IUIAutomationElement* pTarget;
IUIAutomationCondition *pCondition;
VARIANT varAutomationId;
VariantInit(&varAutomationId);

varAutomationId.vt = VT_BSTR;
varAutomationId.bstrVal = SysAllocString(L"explorer_search");
varAutomationId.bstrVal = SysAllocString(L"components-tab");
pAutomation->CreatePropertyCondition(UIA_AutomationIdPropertyId, varAutomationId, &pCondition);
pRootElement->FindFirst(TreeScope_Descendants, pCondition, &pChild);
if (pChild == nullptr) {
pRootElement->FindFirst(TreeScope_Descendants, pCondition, &pTarget);
if (pTarget == nullptr) {
return result;
}

//Make Recursive
// Dump Current Node Contents to Json object
// If node has children, for each child add Json object field and recurse on the child.
// Base Case: node is null

// Converting to JSON
BSTR automationId;
CONTROLTYPEID controlType;
BSTR helpText;
BOOL isEnabled;
BOOL isKeyboardFocusable;
BSTR localizedControlType;
BSTR name;

pChild->get_CurrentAutomationId(&automationId);
pChild->get_CurrentControlType(&controlType);
pChild->get_CurrentHelpText(&helpText);
pChild->get_CurrentIsEnabled(&isEnabled);
pChild->get_CurrentIsKeyboardFocusable(&isKeyboardFocusable);
pChild->get_CurrentLocalizedControlType(&localizedControlType);
pChild->get_CurrentName(&name);
result.Insert(L"AutomationId", winrt::Windows::Data::Json::JsonValue::CreateStringValue(automationId));
result.Insert(L"ControlType", winrt::Windows::Data::Json::JsonValue::CreateNumberValue(controlType));
result.Insert(L"HelpText", winrt::Windows::Data::Json::JsonValue::CreateStringValue(helpText));
result.Insert(L"IsEnabled", winrt::Windows::Data::Json::JsonValue::CreateBooleanValue(isEnabled));
result.Insert(L"IsKeyboardFocusable", winrt::Windows::Data::Json::JsonValue::CreateBooleanValue(isKeyboardFocusable));
result.Insert(L"LocalizedControlType", winrt::Windows::Data::Json::JsonValue::CreateStringValue(localizedControlType));
result.Insert(L"Name", winrt::Windows::Data::Json::JsonValue::CreateStringValue(name));
return result;
return DumpUIATree(pTarget, pWalker);
}

winrt::Windows::Foundation::IAsyncAction LoopServer(winrt::AutomationChannel::Server &server) {