Beispiel #1
0
 /// <summary>
 /// Adds selected feature to a list of features for test log. Uses default display name.
 /// </summary>
 /// <param name="features">List of features.</param>
 /// <param name="log">Certification log.</param>
 /// <param name="feature">Feature</param>
 /// <param name="displayName">Description to be used (it can be different from feature display name
 /// e.g. for nodes in PTZ subtree.)</param>
 public static void AddIfSelected(this List <string> features, TestLogFull log, Feature feature, string displayName)
 {
     if (log.DeviceEnvironment.Features.Contains(feature))
     {
         features.Add(displayName);
     }
 }
        /// <summary>
        /// Saves test results.
        /// </summary>
        /// <param name="filename">Path to the file to write.</param>
        public void SaveTestResults(string filename)
        {
            Utils.PdfReportGenerator reportGenerator = new PdfReportGenerator();
            reportGenerator.OnException   += reportGenerator_OnException;
            reportGenerator.OnReportSaved += reportGenerator_OnReportSaved;

            Data.TestLogFull testLog = new TestLogFull();
            Data.TestLog     log     = ContextController.GetTestLog();
            testLog.TestResults = log.TestResults;
            testLog.Tests       = log.Tests;
            if (log.TestExecutionTime != DateTime.MinValue)
            {
                testLog.TestExecutionTime = log.TestExecutionTime;
            }
            else
            {
                testLog.TestExecutionTime = DateTime.Now;
            }
            SetupInfo info = ContextController.GetSetupInfo();

            testLog.TesterInfo       = info.TesterInfo;
            testLog.Application      = ContextController.GetApplicationInfo();
            testLog.DeviceInfo       = info.DevInfo;
            testLog.OtherInformation = info.OtherInfo;

            testLog.DeviceEnvironment = ContextController.GetDeviceEnvironment();

            reportGenerator.CreateReport(filename, testLog);
        }
        /// <summary>
        /// Colllects log data.
        /// </summary>
        /// <returns></returns>
        private Data.TestLogFull GetFullTestData()
        {
            Data.TestLogFull testLog = new TestLogFull();
            Data.TestLog     log     = ContextController.GetTestLog();
            testLog.TestResults           = log.TestResults;
            testLog.Features              = log.Features;
            testLog.InitializationData    = log.InitializationData;
            testLog.FeaturesDefinitionLog = log.FeaturesDefinitionLog;

            testLog.DeviceInformation = _conformanceTestingInfo;

            if (log.TestExecutionTime != DateTime.MinValue)
            {
                testLog.TestExecutionTime = log.TestExecutionTime;
            }
            else
            {
                testLog.TestExecutionTime = DateTime.Now;
            }

            SetupInfo info = ContextController.GetSetupInfo();

            testLog.TesterInfo       = info.TesterInfo;
            testLog.Application      = ContextController.GetApplicationInfo();
            testLog.DeviceInfo       = info.DevInfo;
            testLog.OtherInformation = info.OtherInfo;
            testLog.MemberInfo       = info.MemberInfo;

            testLog.DeviceEnvironment = ContextController.GetDeviceEnvironment();
            return(testLog);
        }
Beispiel #4
0
        /// <summary>
        /// Creates list of selected features display names. Skips features which are under
        /// unselected parent features.
        /// </summary>
        /// <param name="log">Tests execution information.</param>
        /// <returns>List of features selected for tests execution.</returns>
        /// <remarks>When new features addded, they should be added in this method also.</remarks>
        public static List <string> SelectedFeatures(TestLogFull log)
        {
            List <string> features = new List <string>();

            features.AddIfSelected(log, Feature.NTP);
            features.AddIfSelected(log, Feature.IPv6);
            // mandatory
            features.AddIfSelected(log, Feature.JPEG);
            features.AddIfSelected(log, Feature.H264, GetDisplayName(Feature.H264));
            features.AddIfSelected(log, Feature.MPEG4);
            // add only if top-level feature is selected
            if (log.DeviceEnvironment.Features.Contains(Feature.Audio))
            {
                features.AddIfSelected(log, Feature.G711);
                features.AddIfSelected(log, Feature.G726);
                features.AddIfSelected(log, Feature.AAC);
            }
            // mandatory
            features.AddIfSelected(log, Feature.RTPUDP);
            features.AddIfSelected(log, Feature.RTPRTSPHTTP);
            features.AddIfSelected(log, Feature.RTPRTSPTCP);

            features.AddIfSelected(log, Feature.RTPMulticastUDP);
            features.AddIfSelected(log, Feature.BiDirectional);
            features.AddIfSelected(log, Feature.BiDirectionalG711);
            features.AddIfSelected(log, Feature.BiDirectionalG726);
            features.AddIfSelected(log, Feature.BiDirectionalAAC);

            // add only if top-level feature is selected
            if (log.DeviceEnvironment.Features.Contains(Feature.PTZ))
            {
                //
                // here low-level features are cleared if top-level feature is cleared, so
                //  "PTZAbsoluteZoom" does not depen on "Absolute" node selection
                //
                features.AddIfSelected(log, Feature.PTZAbsolutePanTilt, "Absolute move - Pan/Tilt movement");
                features.AddIfSelected(log, Feature.PTZAbsoluteZoom, "Absolute move - Zoom movement");
                features.AddIfSelected(log, Feature.PTZRelativePanTilt, "Relative move - Pan/Tilt movement");
                features.AddIfSelected(log, Feature.PTZRelativeZoom, "Relative move - Zoom movement");
                features.AddIfSelected(log, Feature.PTZContiniousPanTilt,
                                       "Continous move - Pan/Tilt speed configuration");
                features.AddIfSelected(log, Feature.PTZContiniousZoom, "Continous move - Zoom speed configuration");
                features.AddIfSelected(log, Feature.PTZPresets, "Presets");
                features.AddIfSelected(log, Feature.PTZConfigurableHome, "Configurable home position");
                features.AddIfSelected(log, Feature.PTZFixedHome, "Fixed home position");
                features.AddIfSelected(log, Feature.PTZAuxiliary, "Auxiliary operation");
            }

            features.AddIfSelected(log, Feature.Imaging);
            features.AddIfSelected(log, Feature.IO);
            features.AddIfSelected(log, Feature.RelayOutputs);

            return(features);
        }
        private TestLogFull GetTestLog(TestSuiteParameters testSuiteParameters,
                                       SerializableTestingParameters parameters,
                                       TestController controller)
        {
            controller.UpdateTestLog();

            TestLogFull testLog = new TestLogFull();

            Data.TestLog log = ContextController.GetTestLog();
            testLog.TestResults           = log.TestResults;
            testLog.Features              = log.Features;
            testLog.InitializationData    = log.InitializationData;
            testLog.FeaturesDefinitionLog = log.FeaturesDefinitionLog;

            testLog.DeviceInformation = controller.DeviceInformation;

            if (log.TestExecutionTime != DateTime.MinValue)
            {
                testLog.TestExecutionTime = log.TestExecutionTime;
            }
            else
            {
                testLog.TestExecutionTime = DateTime.Now;
            }

            testLog.Application = new ApplicationInfo();

            testLog.DeviceEnvironment                      = new DeviceEnvironment();
            testLog.DeviceEnvironment.Credentials          = new Credentials();
            testLog.DeviceEnvironment.Credentials.UserName = testSuiteParameters.UserName;
            // password not used for REPORTS
            testLog.DeviceEnvironment.TestSettings = new TestSettings();
            // only two values are user for log
            testLog.DeviceEnvironment.TestSettings.OperationDelay = testSuiteParameters.OperationDelay;
            testLog.DeviceEnvironment.TestSettings.RecoveryDelay  = testSuiteParameters.RecoveryDelay;
            testLog.DeviceEnvironment.Timeouts.InterTests         = testSuiteParameters.TimeBetweenTests;
            testLog.DeviceEnvironment.Timeouts.Message            = testSuiteParameters.MessageTimeout;
            testLog.DeviceEnvironment.Timeouts.Reboot             = testSuiteParameters.RebootTimeout;

            if (parameters.Device != null)
            {
                testLog.ProductName = parameters.Device.Model;
            }

            if (parameters.SessionInfo != null)
            {
                testLog.TesterInfo       = parameters.SessionInfo.TesterInfo;
                testLog.OtherInformation = parameters.SessionInfo.OtherInformation;
                testLog.MemberInfo       = parameters.SessionInfo.MemberInfo;
            }

            return(testLog);
        }
        public void CreateReport(string fileName, TestLogFull log)
        {
            try
            {
                var data = new Datasheet();
                data.Features = log.Features;

                if (log.DeviceInfo != null)
                {
                    data.Capabilities = log.DeviceInformation.Capabilities;

                    data.DeviceInformation = new Tests.Engine.DeviceInformation();
                    data.DeviceInformation.FirmwareVersion = log.DeviceInformation.FirmwareVersion;
                    data.DeviceInformation.HardwareID      = log.DeviceInformation.HardwareID;
                    data.DeviceInformation.Manufacturer    = log.DeviceInformation.Manufacturer;
                    data.DeviceInformation.Model           = log.DeviceInformation.Model;
                    data.DeviceInformation.SerialNumber    = log.DeviceInformation.SerialNumber;
                }
                data.TestInformation          = new TestInformation();
                data.TestInformation.TestDate = log.TestExecutionTime;
                if (log.DeviceInfo != null)
                {
                    data.TestInformation.ProductName = log.DeviceInfo.ProductName;
                }
                if (log.Application != null)
                {
                    data.TestInformation.ToolVersion = log.Application.ToolVersion;
                }

                using (var fileStream = new FileStream(fileName, FileMode.Create, FileAccess.Write))
                {
                    var serializer = new XmlSerializer(typeof(Datasheet));
                    serializer.Serialize(fileStream, data);
                }
                RaiseOnReportSaved();
            }
            catch (Exception ex)
            {
                RaiseOnException(ex);
            }
        }
        public void Run(string[] args)
        {
            if (args.Contains(CommandLineArgs.PARAMETERSFILE))
            {
                LoadOptions(args);

                SerializableTestingParameters parameters = LoadParameters();
                if (parameters == null)
                {
                    return;
                }

                // get test suite parameters;
                // get operator's etc. data
                // get info about files where to save data;

                Controllers.TestController controller = new TestController(_view);
                _controller = controller;

                AutoResetEvent completed = new AutoResetEvent(false);

                bool completedOk = true;
                controller.TestSuiteCompleted +=
                    (normally) =>
                {
                    completedOk = normally;
                    completed.Set();
                };

                controller.ConformanceInitializationCompleted += controller_ConformanceInitializationCompleted;

                controller.LoadTests();

                TestSuiteParameters testSuiteParameters = parameters.GetTestSuiteParameters();

                testSuiteParameters.AdvancedParameters = new Dictionary <string, object>();
                if (parameters.Advanced != null)
                {
                    List <object> advanced = AdvancedParametersUtils.Deserialize(parameters.Advanced, controller.AdvancedSettingsTypes);
                    foreach (object p in advanced)
                    {
                        testSuiteParameters.AdvancedParameters.Add(p.GetType().GUID.ToString(), p);
                    }
                }

                UpdateDeviceContext(testSuiteParameters);

                controller.RunConformanceSilent(testSuiteParameters);
                completed.WaitOne();

                if (!completedOk)
                {
                    return;
                }

                try
                {
                    // Save documents

                    Output output = parameters.Output;

                    // Get directory
                    string folder = string.Empty;

                    if (output != null)
                    {
                        folder = output.Directory;
                    }
                    if (string.IsNullOrEmpty(folder))
                    {
                        folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                        folder = Path.Combine(folder, "ONVIF Device Test Tool");
                    }
                    string path = folder;
                    if (!Directory.Exists(folder))
                    {
                        Directory.CreateDirectory(folder);
                    }

                    // Create nested folder if necessary
                    if (output != null && output.CreateNestedFolder)
                    {
                        string name = DateTime.Now.ToString("yyyy-MM-dd hh-mm");
                        path = Path.Combine(folder, name);
                        Directory.CreateDirectory(path);
                    }

                    TestLogFull log = GetTestLog(testSuiteParameters, parameters, controller);

                    // Save Report

                    string reportFileName = null;
                    if (output != null)
                    {
                        reportFileName = output.Report;
                    }
                    if (string.IsNullOrEmpty(reportFileName))
                    {
                        if (log.DeviceInformation != null)
                        {
                            reportFileName = string.Format("{0} - report.pdf", log.ProductName);
                        }
                    }

                    if (string.IsNullOrEmpty(reportFileName))
                    {
                        reportFileName = "report.pdf";
                    }

                    reportFileName = Path.Combine(path, reportFileName);
                    Utils.PdfReportGenerator reportGenerator = new PdfReportGenerator();
                    reportGenerator.CreateReport(reportFileName, log);

                    // Save DoC

                    string docFileName = null;
                    if (output != null)
                    {
                        docFileName = output.DeclarationOfConformance;
                    }
                    if (string.IsNullOrEmpty(docFileName))
                    {
                        if (log.DeviceInformation != null)
                        {
                            docFileName = string.Format("{0} - DoC.pdf", log.ProductName);
                        }
                    }

                    if (string.IsNullOrEmpty(docFileName))
                    {
                        docFileName = "DoC.pdf";
                    }

                    docFileName = Path.Combine(path, docFileName);
                    Utils.DoCGenerator docGenerator = new DoCGenerator();
                    docGenerator.CreateReport(docFileName, log);

                    // Save log, if required
                    if (output != null)
                    {
                        if (!string.IsNullOrEmpty(output.TestLog))
                        {
                            string fileName = Path.Combine(path, output.TestLog);

                            List <TestResult> results = new List <TestResult>();
                            foreach (TestTool.Tests.Definitions.Data.TestInfo ti in controller.TestInfos)
                            {
                                TestResult tr = controller.GetTestResult(ti);
                                if (tr != null)
                                {
                                    results.Add(tr);
                                }
                            }
                            controller.Save(fileName, results);
                        }

                        if (!string.IsNullOrEmpty(output.FeatureDefinitionLog))
                        {
                            string     fileName = Path.Combine(path, output.FeatureDefinitionLog);
                            TestResult tr       = new TestResult();
                            tr.Log          = _controller.GetFeaturesDefinitionLog().Log;
                            tr.PlainTextLog = _controller.GetFeaturesDefinitionLog().PlainTextLog;
                            controller.Save(fileName, tr);
                        }
                    }
                }
                catch (Exception exc)
                {
                    SaveErrorLog(string.Format("Failed to create documents: {0}", exc.Message));
                }
            }
        }
Beispiel #8
0
 /// <summary>
 /// Adds selected feature to a list of features for test log. Uses default display name.
 /// </summary>
 /// <param name="features">List of features.</param>
 /// <param name="log">Certification log.</param>
 /// <param name="feature">Feature</param>
 public static void AddIfSelected(this List <string> features, TestLogFull log, Feature feature)
 {
     AddIfSelected(features, log, feature, GetDisplayName(feature));
 }
Beispiel #9
0
        public void CreateReport(string fileName, TestLogFull log)
        {
            try
            {
                var data = new Datasheet();
                data.Features = log.Features;

                if (log.DeviceInformation != null)
                {
                    data.Capabilities = log.DeviceInformation.Capabilities;

                    data.DeviceInformation = new DeviceInformation();
                    data.DeviceInformation.FirmwareVersion = log.DeviceInformation.FirmwareVersion;
                    data.DeviceInformation.HardwareID      = log.DeviceInformation.HardwareID;
                    data.DeviceInformation.Manufacturer    = log.DeviceInformation.Manufacturer;
                    data.DeviceInformation.Model           = log.DeviceInformation.Model;
                    data.DeviceInformation.SerialNumber    = log.DeviceInformation.SerialNumber;
                }
                data.TestInformation             = new TestInformation();
                data.TestInformation.TestDate    = log.TestExecutionTime;
                data.TestInformation.ProductName = log.ProductName;

                // this code block is commented until full list of product type will be available

                /*
                 * if (!string.IsNullOrEmpty(log.ProductTypes))
                 * {
                 *  string[] delimiters = { ", " };
                 *  string[] types = log.ProductTypes.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
                 *
                 *  if (types != null && types.Length != 0)
                 *  {
                 *      data.TestInformation.ProductType = new List<TestInformation.Type>();
                 *      foreach (var type in types)
                 *      {
                 *          switch (type)
                 *          {
                 *              case "Camera":
                 *                  data.TestInformation.ProductType.Add(TestInformation.Type.Camera);
                 *                  break;
                 *              case "Encoder":
                 *                  data.TestInformation.ProductType.Add(TestInformation.Type.Encoder);
                 *                  break;
                 *              case "Recorder":
                 *                  data.TestInformation.ProductType.Add(TestInformation.Type.Recorder);
                 *                  break;
                 *              case "VMS":
                 *                  data.TestInformation.ProductType.Add(TestInformation.Type.VMS);
                 *                  break;
                 *              case "Display":
                 *                  data.TestInformation.ProductType.Add(TestInformation.Type.Display);
                 *                  break;
                 *              case "Dome":
                 *                  data.TestInformation.ProductType.Add(TestInformation.Type.Dome);
                 *                  break;
                 *          }
                 *      }
                 *  }
                 * }
                 */

                if (!string.IsNullOrEmpty(log.ProductTypes))
                {
                    string[] delimiters = { ", " };
                    string[] types      = log.ProductTypes.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

                    if (types != null && types.Length != 0)
                    {
                        data.TestInformation.ProductType = new List <string>(types);
                    }
                }

                // conformance information
                var countOfFailedTests  = log.TestResults.Count(item => item.Value.Log.TestStatus == TestTool.Tests.Definitions.Trace.TestStatus.Failed);
                var isConformanceFailed = (countOfFailedTests > 0) ||
                                          !log.InitializationData.SupportedProfiles.Any(e => ProfileVersionStatus.Release == e.GetProfileVersionStatus()) ||
                                          log.InitializationData.FailedProfiles.Any(e => ProfileVersionStatus.Release == e.GetProfileVersionStatus());
                isConformanceFailed = isConformanceFailed || log.InitializationData.UndefinedFeatures.Any();

                if (!isConformanceFailed && (log.InitializationData.SupportedProfiles != null || log.InitializationData.SupportedProfiles.Count != 0))
                {
                    data.ConformanceInformation = new ConformanceInformation();
                    data.ConformanceInformation.SupportedProfile = new List <ConformanceInformation.Profile>();
                    foreach (var profile in log.InitializationData.SupportedProfiles)
                    {
                        if (profile.GetProfileVersionStatus() == ProfileVersionStatus.Release)
                        {
                            switch (profile.GetProfileName())
                            {
                            case "Profile S":
                                data.ConformanceInformation.SupportedProfile.Add(ConformanceInformation.Profile.S);
                                break;

                            case "Profile G":
                                data.ConformanceInformation.SupportedProfile.Add(ConformanceInformation.Profile.G);
                                break;

                            case "Profile C":
                                data.ConformanceInformation.SupportedProfile.Add(ConformanceInformation.Profile.C);
                                break;
                            }
                        }
                    }
                }

                if (log.SupportInfo != null)
                {
                    data.SupportInformation = new SupportInfo();

                    data.SupportInformation.InternationalAddress =
                        string.IsNullOrEmpty(log.SupportInfo.InternationalAddress) ? null : log.SupportInfo.InternationalAddress;

                    data.SupportInformation.RegionalAddress =
                        string.IsNullOrEmpty(log.SupportInfo.RegionalAddress) ? null : log.SupportInfo.RegionalAddress;

                    data.SupportInformation.SupportUrl =
                        string.IsNullOrEmpty(log.SupportInfo.SupportUrl) ? null : log.SupportInfo.SupportUrl;

                    data.SupportInformation.SupportEmail =
                        string.IsNullOrEmpty(log.SupportInfo.SupportEmail) ? null : log.SupportInfo.SupportEmail;

                    data.SupportInformation.SupportPhone =
                        string.IsNullOrEmpty(log.SupportInfo.SupportPhone) ? null : log.SupportInfo.SupportPhone;
                }

                data.RequestsTimeouts = log.Timeouts;

                if (log.Application != null)
                {
                    data.TestInformation.ToolVersion = log.Application.ToolVersion;
                }

                data.ManagementSettings = log.ManagementSettings;

                using (var fileStream = new FileStream(fileName, FileMode.Create, FileAccess.Write))
                {
                    var serializer = new XmlSerializer(typeof(Datasheet));
                    serializer.Serialize(fileStream, data);
                }
                RaiseOnReportSaved();
            }
            catch (Exception ex)
            {
                RaiseOnException(ex);
            }
        }