internal static async Task <bool> MatchTreeDumpFromLayoutUpdateAsync(string dumpID, string uiaId, TextBlock textBlock, IList <string> additionalProperties, DumpTreeMode mode, string dumpExpectedText) { // First find root DependencyObject current = textBlock; DependencyObject parent = VisualTreeHelper.GetParent(current); while (parent != null) { current = parent; parent = VisualTreeHelper.GetParent(current); } DependencyObject dumpRoot = current; // if UIAID is passed in from test, find the matching child as the root to dump if (uiaId != null) { var matchingNode = FindChildWithMatchingUIAID(current, uiaId); if (matchingNode != null) { dumpRoot = matchingNode; } } string dumpText = VisualTreeDumper.DumpTree(dumpRoot, textBlock /* exclude */, additionalProperties, mode); if (dumpText != dumpExpectedText) { return(await MatchDump(dumpText, dumpID)); } return(true); }
private async Task MatchTreeDumpFromLayoutUpdateAsync() { // First find root DependencyObject current = m_textBlock; DependencyObject parent = VisualTreeHelper.GetParent(current); while (parent != null) { current = parent; parent = VisualTreeHelper.GetParent(current); } DependencyObject dumpRoot = current; // if UIAID is passed in from test, find the matching child as the root to dump if (m_uiaID != null) { var matchingNode = FindChildWithMatchingUIAID(current); if (matchingNode != null) { dumpRoot = matchingNode; } } String dumpText = VisualTreeDumper.DumpTree(dumpRoot, m_textBlock /* exclude */); if (dumpText != m_dumpExpectedText) { await MatchDump(dumpText); } }
public async static Task<bool> DoesTreeDumpMatchForRNTester(DependencyObject root) { string json = VisualTreeDumper.DumpTree(root, null, new string[] { }, DumpTreeMode.Json); try { var obj = JsonValue.Parse(json).GetObject(); var element = VisualTreeDumper.FindElementByAutomationId(obj, "PageHeader"); if (element == null) { return false; } var value = element.GetNamedString("Text"); var pageName = new Regex(@"[<|>]").Replace(value, ""); var match = await MatchDump(json, GetMasterFile(pageName), GetOutputFile(pageName)); return match; } catch { Debug.WriteLine("JSON ERROR:\n" + json); throw; } }