예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="timeout"></param>
        /// <returns></returns>
        public TestResult WaitForSignal(string name, int timeout)
        {
            TimeoutFrame frame  = new TimeoutFrame();
            AutoSignal   signal = signals[name];

            signal.Frame = frame;

            FrameTimer timeoutTimer = new FrameTimer(frame, timeout, new DispatcherOperationCallback(TimeoutFrameOperation), DispatcherPriority.Send);

            timeoutTimer.Start();

            //Pump the dispatcher
            DispatcherHelper.PushFrame(frame);

            //abort the operations that did not get processed
            signal.Frame = null;
            if (!timeoutTimer.IsCompleted)
            {
                timeoutTimer.Stop();
            }

            if (frame.TimedOut)
            {
                GlobalLog.LogStatus("A Timeout occurred.");
            }

            TestResult result = signal.Result;

            signal.Reset();
            return(result);
        }
예제 #2
0
        /// <summary>
        /// Constructor for Vscan Common
        /// Master and Master Path are spcified by caller.
        /// </summary>
        /// <param name="testwin">Window to capture image of</param>
        /// <param name="master">Master Name</param>
        /// <param name="masterpath">Relative Path to Master</param>
        public VScanCommon(Window testwin, string master, string masterpath)
        {
            if (testwin != null)
            {
                masterPath = masterpath;

                Index = new LayoutMasterIndex(null);

                if (master != null && master != string.Empty)
                {
                    index.FileName = master;
                }

                GlobalLog.LogStatus("Master Name : {0}", index.FileName);

                if (masterpath != null && masterpath != string.Empty)
                {
                    index.Path = masterpath;
                }

                GlobalLog.LogStatus("Master Path : {0}", index.Path);

                SetWindow(testwin);
            }
        }
예제 #3
0
        ///<summary>
        ///</summary>
        public void ExecuteTests(int start, int end)
        {
            if (_testCases.Count == 0)
            {
                return;
            }

            if (start < -1 || end < -1 || end >= _testCases.Count)
            {
                throw new IndexOutOfRangeException();
            }

            if (start == -1)
            {
                start = 0;
            }

            if (end == -1)
            {
                end = _testCases.Count - 1;
            }


            for (int index = start; index <= end; index++)
            {
                GlobalLog.LogStatus("*************** Starting Test Case # " + index.ToString() + "***************");

                CommonStorage.CleanAll();
                TestCases[index].Execute();

                GlobalLog.LogStatus("*************** End Test Case # " + index.ToString() + "***************");
                GlobalLog.LogStatus("");
                GlobalLog.LogStatus("");
            }
        }
예제 #4
0
        /// <summary>
        /// Compares dump and master
        /// </summary>
        /// <param name="masterPath"></param>
        /// <param name="renderedPath"></param>
        /// <returns></returns>
        public bool CompareXmlFiles(string masterPath, string renderedPath)
        {
            bool result = false;

            GlobalLog.LogStatus("MASTER     : " + masterPath);
            GlobalLog.LogStatus("RENDERED   : " + renderedPath);

            // check if master exist, if not bail out.
            if (!File.Exists(masterPath))
            {
                GlobalLog.LogEvidence("MASTER NOT FOUND");
                result = false;
                return(result);
            }

            // Load master xml
            XmlDocument masterDoc = new XmlDocument();

            masterDoc.PreserveWhitespace = false;
            masterDoc.Load(masterPath);

            // Load rendered xml
            XmlDocument renderedDoc = new XmlDocument();

            renderedDoc.PreserveWhitespace = false;
            renderedDoc.Load(renderedPath);

            // Compare master and rendered
            result = CompareXmlFiles(masterDoc.DocumentElement, renderedDoc.DocumentElement);

            return(result);
        }
예제 #5
0
 /// <summary>
 /// Logs only if verbose parameter is true.
 /// </summary>
 /// <param name="log"></param>
 /// <param name="verbose"></param>
 private static void LogIfVerbose(string log, bool verbose)
 {
     if (verbose)
     {
         GlobalLog.LogStatus(log);
     }
 }
예제 #6
0
        /// <summary>
        /// Execture test actions.
        /// </summary>
        /// <param name="activeTest"></param>
        /// <param name="log"></param>
        void ExecuteTestActions(LayoutTest activeTest, TestLog log)
        {
            GlobalLog.LogStatus("BEGIN LAYOUT TEST");

            try
            {
                if (activeTest is CodeTest)
                {
                    RunCodeTest(activeTest, log);
                }
                if (activeTest is PropertyDumpTest)
                {
                    RunPropertyDumpTest(activeTest, log);
                }
                if (activeTest is VisualScanTest)
                {
                    RunVisualScanTest(activeTest, log);
                }
            }
            catch (Exception ex)
            {
                GlobalLog.LogEvidence(ex);
            }

            GlobalLog.LogStatus("END LAYOUT TEST");
        }
예제 #7
0
        /// <summary>
        /// Target applications should call this method to notify the AppMonitor that it should shutdown the application
        /// </summary>
        public static void NotifyStopMonitoring()
        {
            GlobalLog.LogStatus("Notifying ApplicationMonitor to stop monitoring");

            if (abortSignal == null)
            {
                GlobalLog.LogStatus("Abort signal not available, trying to find existing wait handle by name...");

                try
                {
                    abortSignal = EventWaitHandle.OpenExisting("ApplicationMonitorAbortSignal");
                }
                catch (WaitHandleCannotBeOpenedException)
                {
                    GlobalLog.LogStatus("Abort signal did not exist, so cross-proc NotifyStopMonitoring may fail.");
                }
            }

            if (abortSignal != null)
            {
                abortSignal.Set();
                GlobalLog.LogStatus("Abort signal set.");
            }
            else
            {
                GlobalLog.LogStatus("WARNING: Could not get Abort Signal to use!");
            }
        }
예제 #8
0
        public void RoundTripTest(Stream originalStream, XamlWriterMode expressionMode, bool attemptDisplay)
        {
            if (originalStream == null)
            {
                throw new ArgumentNullException("originalStream");
            }

            Dispatcher dispatcher = Dispatcher.CurrentDispatcher;


            if (dispatcher == null)
            {
                throw new InvalidOperationException("The current thread has not entered a Dispatcher.");
            }

            object firstTreeRoot = null;

            //
            // Parse original xaml.
            // We create a ParserContext here. It will be reused by subsequent parsing
            // operations.
            //

            GlobalLog.LogStatus("Constructing object tree using LoadXml...");
            _parserContext         = new ParserContext();
            _parserContext.BaseUri = PackUriHelper.Create(new Uri("siteoforigin://"));
            firstTreeRoot          = ParseXaml(originalStream);

            RoundTripTestObject(firstTreeRoot, expressionMode, attemptDisplay);
        }
예제 #9
0
        /// <summary>
        /// Compares to bitmaps based on tolerance criteria
        /// </summary>
        /// <param name='sourceImage'>Master image for comparison.</param>
        /// <param name='targetImage'>Sampled image for comparison.</param>
        /// <param name='differenceImage'>On return, bitmap with differences highlighted
        /// if any were found, null otherwise.</param>
        /// <param name='criteria'>Criteria for image comparison.</param>
        /// <param name='logBitmaps'>Log bitmaps if comparison fails</param>
        /// <returns>true if master and sample are equal, false otherwise.</returns>
        public static bool AreBitmapsEqualUsingCriteria(Bitmap sourceImage, Bitmap targetImage, out Bitmap differenceImage, ComparisonCriteria criteria, bool logBitmaps)
        {
            ComparisonOperation operation;
            ComparisonResult    result;

            operation             = new ComparisonOperation();
            operation.Criteria    = criteria;
            operation.MasterImage = sourceImage;
            operation.SampleImage = targetImage;
            result          = operation.Execute();
            differenceImage = null;
            if ((result.CriteriaMet == false))
            {
                AreBitmapsEqual(sourceImage, targetImage, out differenceImage);
                result.HighlightDifferences(differenceImage);
                if (logBitmaps)
                {
                    GlobalLog.LogStatus("Logging Images: sourceImage targetImage differencesImage:\r\n");
                    GlobalLog.LogDebug(result.ToString());
                    LogImageOnDisk(sourceImage, "sourceImage" + _combinationIndex.ToString() + ".png");
                    LogImageOnDisk(targetImage, "targetImage" + _combinationIndex.ToString() + ".png");
                    LogImageOnDisk(differenceImage, "differencesImage" + _combinationIndex.ToString() + ".png");
                    _combinationIndex++;
                }
            }
            return(result.CriteriaMet);
        }
예제 #10
0
        /// <summary>
        ///
        /// </summary>
        public override void Execute()
        {
            Type type = TypeName.GetCurrentType();

            GlobalLog.LogStatus("Type (" + type.FullName + ") is store int CommonStorage under the name Type");
            CommonStorage.Current.Store("Type", type);
        }
예제 #11
0
        /// <summary>
        /// Compares XML files and logs result.
        /// </summary>
        /// <returns></returns>
        public bool CompareLogShow(Arguments arguments)
        {
            bool comparison = false;

            if (File.Exists(arguments.FilterPath))
            {
                this.Core.Filter.XmlFilterPath = arguments.FilterPath;
            }
            else if (File.Exists(arguments.DefaultFilterPath))
            {
                this.Core.Filter.XmlFilterPath = arguments.DefaultFilterPath;
            }
            else
            {
                GlobalLog.LogEvidence(new FileNotFoundException("Could not find " + arguments.FilterFile));
                return(false);
            }

            this.Core.SaveXmlDump(arguments.RenderedPath);

            GlobalLog.LogStatus(string.Format("Searching for {0}.....", arguments.MasterFile));

            arguments.MissingMaster = !SearchMaster(arguments);

            if (!arguments.MissingMaster)
            {
                comparison = this.Core.CompareXmlFiles(arguments.ComparePath, arguments.RenderedPath);

                if (comparison)
                {
                    GlobalLog.LogStatus("XML COMPARE SUCCEEDED.");
                }
                else
                {
                    GlobalLog.LogEvidence("XML COMPARE FAILED.");
                }
            }
            else
            {
                GlobalLog.LogEvidence("NO MASTER FOUND");
                arguments.MissingMaster = true;
                comparison = false;
            }

            if (!comparison)
            {
                DiffPackage failurePackage  = new DiffPackage(arguments.RenderedPath, arguments.ComparePath, arguments.MasterSdPath);
                string      packageLocation = failurePackage.Save(arguments);

                if (!arguments.MissingMaster)
                {
                    GlobalLog.LogEvidence(string.Format("FAILED MASTER : {0}", arguments.ComparePath));
                }

                GlobalLog.LogFile(packageLocation);
            }

            return(comparison);
        }
예제 #12
0
        private XmlNode DefaultTolerance()
        {
            //
            GlobalLog.LogStatus("Default tolerance being applied.");
            XmlDocument defaultTolerance = new XmlDocument();

            defaultTolerance.LoadXml("<Tolerances>" + dpi96Tolerance + dpi120Tolerance + "</Tolerances>");
            return((XmlNode)defaultTolerance.DocumentElement);
        }
예제 #13
0
        /// <summary>
        ///
        /// </summary>
        public override void Execute()
        {
            if (!File.Exists(FileName))
            {
                throw new InvalidOperationException("The XamlFile cannot be found. " + FileName);
            }

            CommonStorage.Current.Store("FileName", FileName);
            GlobalLog.LogStatus("The file use is: " + FileName);
        }
예제 #14
0
        /// <summary>
        /// Intiailize the TestSuite for running a specific variation, e.g. parse arguments
        /// and set the proper properties.
        /// </summary>
        private void InitializeVariation()
        {
            GlobalLog.LogStatus("Starting Setup Stage");
            CurrentSuite.ProcessArgs(CurrentVariation.Parameters);

            if (CurrentVariation.TestCase.SetupMethod != null)
            {
                Invoke(CurrentVariation.TestCase.SetupMethod);
            }
        }
예제 #15
0
        /// <summary>
        /// Executes the comparison operation with supporting services.
        /// </summary>
        /// <param name="prefixName">
        /// Prefix name for criteria and operation configuration arguments.
        /// </param>
        /// <returns>The results of the comparison operation.</returns>
        /// <remarks><p>
        /// This method implements the typical wrapping around
        /// the comparison API, where services are available to help
        /// with configuration and logging.
        /// </p><p>
        /// The operation is configured, and a new criteria object is
        /// configured and assigned unless the current criteria has
        /// already been modified in some way. If the criteria is not
        /// met, an exception is thrown. If LogImagesOnUnmet is true and
        /// the criteria is not met, the images will be logged.
        /// </p><p>
        /// The ComparisonOperation object and the ComparisonResult
        /// object are configured with the
        /// ConfigurationSettings.SetObjectProperties method; see
        /// this API for more information.
        /// </p></remarks>
        public ComparisonResult ExecuteServiced(string prefixName)
        {
#if (IGNORE_IMAGE_LOGGING)
            throw new NotImplementedException("ComparisonOperation.ExecuteServiced is not implemented when IGNORE_IMAGE_LOGGING is defined.");
#else
            if (prefixName == null)
            {
                throw new ArgumentNullException("prefixName");
            }
            GlobalLog.LogStatus("Performing {" + prefixName + "} comparison...");

            if (Criteria.Equals(ComparisonCriteria.PerfectMatch))
            {
                // Doing a SetObjectProperties call on this.criteria
                // would modify the properties of the shared perfect match
                // instance.
                ComparisonCriteria newCriteria = new ComparisonCriteria();
                //ConfigurationSettings.Current
                //    .SetObjectProperties(newCriteria, prefixName);
                Criteria = newCriteria;
                GlobalLog.LogStatus(criteria.ToString());
            }

            ComparisonResult result = Execute();

            if (!result.CriteriaMet)
            {
                if (LogImagesOnCriteriaUnmet)
                {
                    masterImage.Save(prefixName + "master", System.Drawing.Imaging.ImageFormat.Png);
                    GlobalLog.LogFile(prefixName + "master");
                    //l.LogImage(masterImage, prefixName + "master");
                    sampleImage.Save(prefixName + "sample", System.Drawing.Imaging.ImageFormat.Png);
                    GlobalLog.LogFile(prefixName + "sample");

                    //l.LogImage(sampleImage, prefixName + "sample");
                    Bitmap differences = new Bitmap(sampleImage);
                    result.HighlightDifferences(differences);

                    differences.Save(prefixName + "differences", System.Drawing.Imaging.ImageFormat.Png);
                    GlobalLog.LogFile(prefixName + "differences");
                    //l.LogImage(differences, prefixName + "differences");
                }

                string message = criteria.MismatchDescription +
                                 Environment.NewLine + result.ToString();
                throw new Exception(message);
            }
            else
            {
                GlobalLog.LogStatus(result.ToStringBrief());
            }
            return(result);
#endif
        }
예제 #16
0
        private static Bitmap CreateBitmapFromWindowHandle(IntPtr windowHandle,
                                                           Microsoft.Test.Win32.NativeStructs.RECT r)
        {
            WaitForCompleteRender();
            //System.Diagnostics.Trace.WriteLine(String.Format(
            //    "Capturing bitmap for window in rectangle [{0};{1} - {2};{3}]",
            //    r.left, r.top, r.right, r.bottom));
            GlobalLog.LogStatus(String.Format(
                                    "Capturing bitmap for window in rectangle [{0};{1} - {2};{3}]",
                                    r.left, r.top, r.right, r.bottom));
            new SecurityPermission(PermissionState.Unrestricted).Assert();
            int cx = r.Width;
            int cy = r.Height;

            if (cx <= 0)
            {
                throw new Exception("Window to create bitmap for has <= 0 width.");
            }
            if (cy <= 0)
            {
                throw new Exception("Window to create bitmap for has <= 0 height.");
            }

            IntPtr sourceDC = NativeMethods.GetDC(new HandleRef(new object(), (IntPtr)null));

            Microsoft.Test.Win32.NativeStructs.POINT topLeft = new Microsoft.Test.Win32.NativeStructs.POINT(0, 0); //Get the screen co-ordinates of the client origin.
            NativeMethods.ClientToScreen(windowHandle, ref topLeft);

            if ((int)sourceDC == 0)
            {
                string message = String.Format(
                    "Unable to retrieve device context for window handle {0}.",
                    (int)windowHandle);
                throw new Exception(message);
            }
            try
            {
                Bitmap bitmap = new Bitmap(cx, cy,
                                           System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                Graphics graphics    = Graphics.FromImage(bitmap);
                IntPtr   destination = graphics.GetHdc();

                const int SRCCOPY = 0x00CC0020;
                NativeMethods.SafeBitBlt(destination, 0, 0, cx, cy, sourceDC, topLeft.x, topLeft.y,
                                         SRCCOPY);
                graphics.ReleaseHdc(destination);
                graphics.Dispose();
                return(bitmap);
            }
            finally
            {
//                Win32.ReleaseDC(windowHandle, sourceDC);
                NativeMethods.ReleaseDC(new HandleRef(new object(), windowHandle), new HandleRef(new object(), sourceDC));
            }
        }
예제 #17
0
        // Start function for the controller thread.
        // Depending on the ApplicationType, runs the controller directly or starts its process.
        private void _ControllerThreadStart()
        {
            try
            {
                // Run controller directly if ApplicationType is normal clr exe.
                if (_appType == ApplicationType.ClrExe)
                {
                    ThreadController controller = new ThreadController();
                    controller.RunVariationLoop();
                }
                // Run controller directly if ApplicationType is WinForms application.
                else if (_appType == ApplicationType.WinFormsApplication)
                {
                    WinFormsController controller = new WinFormsController();
                    controller.RunVariationLoop();
                }
                // Run controller on separate process via ActivationStep if
                // if ApplicationType is an Avalon application.
                else
                {
                    ActivationStep activationStep = new ActivationStep();

                    if (_appType == ApplicationType.Xbap)
                    {
                        activationStep.FileName = "ControllerBrowserApp.xbap";
                    }
                    else
                    {
                        activationStep.FileName = "ControllerWpfApp.exe";
                    }

                    activationStep.DoStep();
                }
            }
            catch (Exception exception)
            {
                if (TestLog.Current != null)
                {
                    TestLog.Current.LogEvidence("Unexpected exception:\r\n" + exception.ToString());
                    TestLog.Current.Result = TestResult.Fail;
                }
                else
                {
                    GlobalLog.LogStatus("Unexpected exception:\r\n" + exception.ToString());
                }
            }
            finally
            {
                // Let the Controller know that we're done.
                _IsControllerProxyDone = true;
            }
        }
예제 #18
0
        private void SetWindow(Window testwin)
        {
            GlobalLog.LogStatus("VISUAL COMPARE");

            WindowInteropHelper iwh = new WindowInteropHelper(testwin);

            HWND = iwh.Handle;

            if (iwh == null || HWND == IntPtr.Zero)
            {
                GlobalLog.LogEvidence(new Exception("Could not find the hwnd of the main window"));
            }
        }
예제 #19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="test"></param>
        /// <param name="masterDimensions"></param>
        public VScanCommon(LayoutTest test, IMasterDimension[] masterDimensions)
        {
            if (test != null)
            {
                index          = new LayoutMasterIndex(masterDimensions);
                index.FileName = Common.ResolveName(test);
                index.Path     = Common.ResolvePath(test);

                GlobalLog.LogStatus("Master Name : {0}", index.FileName);
                GlobalLog.LogStatus("Master Path : {0}", index.Path);

                SetWindow(test.window);
            }
        }
예제 #20
0
        /// <summary>
        /// Starts a new process using the specified ProcessStartInfo and monitors it
        /// </summary>
        /// <param name="startInfo">ProcessStartInfo to start</param>
        public void StartProcess(ProcessStartInfo startInfo)
        {
            if (processMonitor != null)
            {
                throw new InvalidOperationException("You must call Close() before Starting a new Process");
            }

            InitProcessMonitor(startInfo);

            //Ignore any of the process that are currently running
            processMonitor.IgnoreRunningProcesses();

            //An error occurs if we pass arguments to .xbap files.  Some tests are passing arguments
            //so we are omitting these to get the change in
            if ((Path.GetExtension(startInfo.FileName) == ApplicationDeploymentHelper.STANDALONE_APPLICATION_EXTENSION) ||
                (Path.GetExtension(startInfo.FileName) == ApplicationDeploymentHelper.BROWSER_APPLICATION_EXTENSION))
            {
                startInfo.Arguments = "";
            }

            //Open .xbap file in new browser process if ApplicationMonitorStartNewProcessForXbap
            //has been set to be true.
            string startNewProcessForXbap = DriverState.DriverParameters["ApplicationMonitorStartNewProcessForXbap"];

            if (!string.IsNullOrEmpty(startNewProcessForXbap) &&
                (string.Compare(startNewProcessForXbap.Trim(), "true", true, System.Globalization.CultureInfo.InvariantCulture) == 0) &&
                startInfo.FileName.EndsWith(ApplicationDeploymentHelper.BROWSER_APPLICATION_EXTENSION, true, System.Globalization.CultureInfo.InvariantCulture))
            {
                string registeredBrowser = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet", string.Empty, string.Empty) as string;
                if (!string.IsNullOrEmpty(registeredBrowser))
                {
                    startInfo.Arguments = startInfo.FileName;
                    startInfo.FileName  = registeredBrowser;
                    GlobalLog.LogStatus("ApplicationMonitorStartNewProcessForXbap is true, starting a new process for XBAP file...");
                }
            }

            //Execute the Application
            GlobalLog.LogStatus(string.Format("Executing: {0} {1}", startInfo.FileName, startInfo.Arguments));
            Process proc = Process.Start(startInfo);

            if (proc != null)
            {
                processMonitor.AddProcess(proc);
            }

            //Begin Monitoring processes for UI
            processMonitor.Start();
        }
예제 #21
0
        /// <summary>
        /// XML Dump
        /// </summary>
        /// <returns></returns>
        public XmlNode DumpXml()
        {
            GlobalLog.LogStatus("START XML DUMP");

            XmlNode      xmldump   = PropertyDumpCore.xmldoc.CreateElement("PropertyDump");
            MemoryStream memStream = new MemoryStream();

            xmlWriter = new XmlTextWriter((MemoryStream)memStream, UTF8Encoding.UTF8);

            InternalXmlDump(visualRoot, xmldump);

            GlobalLog.LogStatus("END XML DUMP");

            return(xmldump);
        }
예제 #22
0
        /// <summary>
        /// Effectively closes the window by shutting down the dispatcher.
        /// </summary>
        static private object _QuitDispatcher()
        {
            try
            {
                GlobalLog.LogStatus("Calling SerializationHelper.CloseDisplayedTree...");
                SerializationHelper.CloseDisplayedTree();
            }
            catch (Exception err)
            {
                GlobalLog.LogStatus("Storing exception...");
                SerializationHelper.StoreException(err);
            }

            return(null);
        }
예제 #23
0
        /// <summary>
        /// Constructor for Vscan Common
        /// </summary>
        ///<param name="test">Test of type LayoutTest that is currently running</param>
        public VScanCommon(LayoutTest test)
        {
            //HACK: Visual Verification technology should not be taking a dependency on layout technology.
            if (test != null)
            {
                index          = new LayoutMasterIndex(null);
                index.FileName = Common.ResolveName(test);
                index.Path     = Common.ResolvePath(test);

                GlobalLog.LogStatus("Master Name : {0}", index.FileName);
                GlobalLog.LogStatus("Master Path : {0}", index.Path);

                SetWindow(test.window);
            }
        }
예제 #24
0
        /// <summary>
        /// Constructor for Vscan Common
        /// </summary>
        /// <param name="testwin">Window to capture image of</param>
        /// <param name="test">Calling Test</param>
        public VScanCommon(Window testwin, object test)
        {
            if (test != null && testwin != null)
            {
                masterPath = Common.ResolvePath(test);

                Index          = new LayoutMasterIndex(null);
                index.FileName = Common.ResolveName(test);;
                GlobalLog.LogStatus("Master Name : {0}", index.FileName);
                index.Path = masterPath;
                GlobalLog.LogStatus("Master Path : {0}", index.Path);

                SetWindow(testwin);
            }
        }
예제 #25
0
        /// <summary>
        /// Calls RenderedEvent handlers, calls verify routine, closes the window,
        /// and initiates quitting the dispatcher if the verify routine did not
        /// return false.
        /// </summary>
        static private object _InvokeAfterRender(object obj)
        {
            bool   shouldQuit = true;
            object element    = null;
            bool   verify     = false;

            object[] vars = (object[])obj;

            _postedCount--;

            try
            {
                element = vars[0];
                verify  = (bool)vars[1];

                if (verify)
                {
                    shouldQuit = _Verify(element);
                }
            }
            catch (Exception err)
            {
                GlobalLog.LogStatus("Storing exception...");
                SerializationHelper.StoreException(err);
            }


            // If the return value is 'false', that means
            // it is not done yet. We must not quit the dispatcher.
            // Instead, we must queue up again to enable
            // the verifier routine another shot.
            if (shouldQuit)
            {
                if (_postedCount <= 0)
                {
                    _QuitDispatcher();
                }
            }
            else
            {
                // Enqueue self to call the verify routine again.
                Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new DispatcherOperationCallback(_InvokeAfterRender), new object[] { element, verify });
                _postedCount++;
            }

            return(null);
        }
예제 #26
0
        /// <summary>
        /// Print out help information on how to use this TestSuite implementation:
        /// </summary>
        private void PrintUsage()
        {
            IList <string> parameters    = UsageParameters();
            IList <string> usageExamples = UsageExamples();

            GlobalLog.LogStatus("Usage:");
            foreach (string param in parameters)
            {
                GlobalLog.LogStatus("\t" + param);
            }

            GlobalLog.LogStatus("");
            GlobalLog.LogStatus("Examples:");
            foreach (string example in usageExamples)
            {
                GlobalLog.LogStatus("\t" + example);
            }
        }
예제 #27
0
파일: Common.cs 프로젝트: dotnet/wpf-test
        /// <summary>
        /// Finds VScan Master Path in TestAttribute Variables.
        /// </summary>
        /// <param name="test"></param>
        /// <returns></returns>
        public static string ResolvePath(object test)
        {
            object[] attributes = test.GetType().GetCustomAttributes(typeof(TestAttribute), false);

            string value = string.Empty;

            foreach (object o in attributes)
            {
                if (o.GetType().Name == "TestAttribute")
                {
                    if (((TestAttribute)o).Name != null)
                    {
                        if (DriverState.TestName.Contains(((TestAttribute)o).Name))
                        {
                            //Variables Property is obsolete
                            #pragma warning disable 0618
                            if (((TestAttribute)o).Variables != null)
                            {
                                char[]   firstSplitter = new char[] { '/' };
                                string[] variables     = ((TestAttribute)o).Variables.Split(firstSplitter);
                                if (variables != null && variables.Length > 0)
                                {
                                    foreach (string variable in variables)
                                    {
                                        char[]   secondSplitter = new char[] { '=' };
                                        string[] values         = variable.Split(secondSplitter);
                                        if (values != null && values.Length > 1)
                                        {
                                            if (values[0].ToLower() == "vscanmasterpath")
                                            {
                                                value = values[1];
                                            }
                                        }
                                    }
                                }
                            }
                            #pragma warning restore 0618
                        }
                    }
                }
            }
            GlobalLog.LogStatus("VALUE ::: {0}", value);
            return(value);
        }
예제 #28
0
        /// <summary>
        /// Loads a TestExterderGraph or TestExtenderOutput file string.
        /// </summary>
        /// <param name="file"></param>
        /// <param name="createCache"></param>
        /// <returns>
        /// Microsoft.Test.TestExterderOutput object. Null if the file is not a TXRO or TXR.
        /// </returns>
        public static TestExtenderOutput LoadFile(ref string file, bool createCache)
        {
            if (string.IsNullOrEmpty(file))
            {
                throw new ArgumentException("Argument cannot be null or empty string.", "file");
            }

            if (!File.Exists(file))
            {
                throw new ArgumentException("The file does not exist.", "file");
            }

            TestExtenderOutput txro = null;

            try
            {
                TestExtenderFileTypes fileType = GetTypeOfFile(file);

                if (fileType == TestExtenderFileTypes.TestExtenderOutput)
                {
                    txro = TestExtenderOutput.Load(file);
                }
                else if (fileType == TestExtenderFileTypes.TestExtenderGraph)
                {
                    TestExtenderGraph txr = TestExtenderGraph.Load(file);
                    txro = txr.Generate();
                    // file = WriteCache(file, txro);
                }
            }
            catch (Exception e)
            {
                GlobalLog.LogStatus(e.ToString());
                txro = null;
            }

            if (txro == null)
            {
                GlobalLog.LogStatus("A TestExtender cannot be loaded. There could be missing test cases. File: " + file);
            }

            return(txro);
        }
예제 #29
0
        /// <summary>
        /// Load from xaml
        /// </summary>
        /// <param name="xaml"></param>
        /// <returns></returns>
        public static object ParseXaml(string xaml)
        {
            Stream stream    = null;
            object loadedObj = null;

            try
            {
                stream = IOHelper.ConvertTextToStream(xaml);
                GlobalLog.LogStatus("Constructing object tree using LoadXml()...");
                loadedObj = ParseXaml(stream);
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                }
            }

            return(loadedObj);
        }
예제 #30
0
        /// <summary>
        /// Executes child variations in specified container.
        /// </summary>
        public override void Execute()
        {
            GlobalLog.LogStatus("In ContainerVariationItem.Execute()...");
            GlobalLog.LogStatus("ContainerVariationItem.ApplicationType: " + this.ApplicationType);

            ApplicationType appType = (ApplicationType)Enum.Parse(typeof(ApplicationType), this.ApplicationType);

            //
            // Runs all child variations within single app, i.e. Controller.
            // When ControllerProxy is created, it automatically starts the Dispatcher
            // thread, whether that's a simple call to Dispatcher.Run() or starting an app.
            //
            using (ControllerProxy controller = new ControllerProxy(appType))
            {
                foreach (VariationItem variation in Children)
                {
                    controller.Perform(variation);
                }

                controller.WaitUntilDone();
            }
        }