Пример #1
0
            public void DumpAndVerifyVisualTree(UIElement root, string verificationFileNamePrefix, string messageOnError = null)
            {
                VisualTreeLog.LogDebugInfo("DumpVisualTreeAndCompareWithverification with verificationFileNamePrefix " + verificationFileNamePrefix);

                string expectedContent = "";
                string content         = DumpVisualTree(root, _translator, _filter, _logger);

                VerificationFileStorage storage        = new VerificationFileStorage(!_shouldLogVerificationFile, verificationFileNamePrefix);
                string bestMatchedVerificationFileName = storage.BestMatchedVerificationFileName;
                string expectedVerificationFileName    = storage.ExpectedVerificationFileName;

                VisualTreeLog.LogDebugInfo("Target verification file: " + expectedVerificationFileName);
                VisualTreeLog.LogDebugInfo("Best matched verification file: " + bestMatchedVerificationFileName);

                if (!string.IsNullOrEmpty(bestMatchedVerificationFileName))
                {
                    expectedContent = VerificationFileStorage.GetVerificationFileContent(bestMatchedVerificationFileName);
                }

                string result = new VisualTreeOutputCompare(content, expectedContent).ToString();

                if (!string.IsNullOrEmpty(result))
                {
                    storage.LogVerificationFile(expectedVerificationFileName, content);
                    storage.LogVerificationFile(expectedVerificationFileName + ".orig", expectedContent);

                    if (!string.IsNullOrEmpty(messageOnError))
                    {
                        _testResult.AppendLine(messageOnError);
                        _testResult.AppendLine(string.Format("{0}.xml and {0}.orig.xaml is logged", expectedVerificationFileName));
                    }
                    _testResult.AppendLine(result);
                }
            }
Пример #2
0
 private string SearchBestMatchedVerificationFileName(string fileNamePrefix)
 {
     for (ushort version = PlatformConfiguration.GetCurrentAPIVersion(); version >= 2; version--)
     {
         string fileName = string.Format("{0}-{1}.xml", fileNamePrefix, version);
         if (VerificationFileStorage.IsVerificationFilePresent(fileName))
         {
             return(fileName);
         }
     }
     {
         string fileName = fileNamePrefix + ".xml";
         if (VerificationFileStorage.IsVerificationFilePresent(fileName))
         {
             return(fileName);
         }
     }
     return(null);
 }