Exemple #1
0
    public static void StaticAnalysisExecute(StaticAnalysisEntry entry)
    {
        var buildReportJob = (AsyncBuildReportJob)EditorShaderTools.GenerateBuildReportAsyncGeneric(ShaderAnalysisReport.New(entry.asset, entry.buildTarget, entry.filter));

        buildReportJob.throwOnError = true;

        var time      = Time.realtimeSinceStartup;
        var startTime = time;

        while (!buildReportJob.IsComplete())
        {
            if (Time.realtimeSinceStartup - time > 3)
            {
                Debug.Log($"[Build Report] {entry.asset} {buildReportJob.progress:P} {buildReportJob.message}");
                time = Time.realtimeSinceStartup;
            }

            if (Time.realtimeSinceStartup - startTime > entry.timeout)
            {
                buildReportJob.Cancel();
                throw new Exception($"Timeout {entry.timeout} s");
            }

            try
            {
                if (buildReportJob.Tick())
                {
                    buildReportJob.SetProgress(1, "Completed");
                }
                EditorUpdateManager.Tick();
            }
            catch (Exception e)
            {
                buildReportJob.Cancel();
                Debug.LogException(e);
                Assert.Fail(e.Message);
            }
        }

        var report = buildReportJob.builtReport;

        // Evaluate the number of metrics to send
        // We fail if we exceed the allowed number of metrics per test
        var numberOfMetrics = 0;

        foreach (var program in report.programs)
        {
            numberOfMetrics += k_MesureCount * program.performanceUnits.Count();
        }
        Assert.LessOrEqual(numberOfMetrics, k_MaxMeasurePerTest, $"We are trying to send {numberOfMetrics} metrics while the capacity is {k_MaxMeasurePerTest}." +
                           $"Please reduce the number of variants to evaluate for this test.");

        foreach (var program in report.programs)
        {
            foreach (var performanceUnit in program.performanceUnits)
            {
                SendMeasure(performanceUnit);
            }
        }
    }
Exemple #2
0
        public IEnumerator QueuePreviewImageLoadTask()
        {
            EditorUpdateManager.ResetImageLoading();
            const string PKG_PATH = "Packages/com.unity.streaming-image-sequence/Tests/Data/png/A_00000.png";
            string       fullPath = Path.GetFullPath(PKG_PATH);

            Assert.IsTrue(File.Exists(fullPath));

            //Loading preview type would also load the full type
            const int IMAGE_TYPE = C.IMAGE_TYPE_PREVIEW;

            AssertReadStatus(fullPath, IMAGE_TYPE, C.READ_STATUS_UNAVAILABLE, "Texture is already available ?");

            const int WIDTH  = 256;
            const int HEIGHT = 128;

            ImageLoader.RequestLoadPreviewImage(fullPath, WIDTH, HEIGHT);
            yield return(new WaitForSeconds(LOAD_TIMEOUT));

            ImageData r = AssertReadStatus(fullPath, IMAGE_TYPE, C.READ_STATUS_SUCCESS, "Loading texture is not successful.");

            Assert.AreEqual(WIDTH, r.Width);
            Assert.AreEqual(HEIGHT, r.Height);

            ResetAndAssert(fullPath, IMAGE_TYPE);
        }
        public IEnumerator QueueFullImageLoadTask()
        {
            EditorUpdateManager.ResetImageLoading();
            const string PKG_PATH = "Packages/com.unity.streaming-image-sequence/Tests/Data/png/A_00000.png";
            string       fullPath = Path.GetFullPath(PKG_PATH);

            Assert.IsTrue(File.Exists(fullPath));

            const int IMAGE_TYPE = StreamingImageSequenceConstants.IMAGE_TYPE_FULL;

            ImageLoader.GetImageDataInto(fullPath, IMAGE_TYPE, out ImageData readResult);
            Assert.AreEqual(StreamingImageSequenceConstants.READ_STATUS_UNAVAILABLE, readResult.ReadStatus,
                            "Texture is already or currently being loaded"
                            );

            ImageLoader.RequestLoadFullImage(fullPath);
            yield return(new WaitForSeconds(LOAD_TIMEOUT));

            ImageLoader.GetImageDataInto(fullPath, IMAGE_TYPE, out readResult);
            Assert.AreEqual(StreamingImageSequenceConstants.READ_STATUS_SUCCESS, readResult.ReadStatus,
                            "Loading texture is not successful."
                            );

            AssertUnloaded(fullPath, IMAGE_TYPE);
            ResetAndAssert(fullPath, IMAGE_TYPE);
        }
Exemple #4
0
        public IEnumerator LoadUnavailableImages()
        {
            EditorUpdateManager.ResetImageLoading();
            const string PKG_PATH = "ThisImageDoesNotExist.png";
            string       fullPath = Path.GetFullPath(PKG_PATH);

            Assert.IsFalse(File.Exists(fullPath));

            ImageLoader.RequestLoadFullImage(fullPath);
            yield return(new WaitForSeconds(LOAD_TIMEOUT));

            ImageLoader.RequestLoadPreviewImage(fullPath, /*width= */ 256, /* height= */ 128);
            yield return(new WaitForSeconds(LOAD_TIMEOUT));

            AssertReadStatus(fullPath, C.IMAGE_TYPE_FULL, C.READ_STATUS_FAIL, "Unavailable texture was loaded.");
            AssertReadStatus(fullPath, C.IMAGE_TYPE_PREVIEW, C.READ_STATUS_UNAVAILABLE,
                             "The preview was loaded even though the full version failed.");

            ResetAndAssert(fullPath, C.IMAGE_TYPE_PREVIEW);
            ResetAndAssert(fullPath, C.IMAGE_TYPE_FULL);
        }
Exemple #5
0
        public IEnumerator QueueFullImageLoadTask()
        {
            EditorUpdateManager.ResetImageLoading();
            const string PKG_PATH = "Packages/com.unity.streaming-image-sequence/Tests/Data/png/A_00000.png";
            string       fullPath = Path.GetFullPath(PKG_PATH);

            Assert.IsTrue(File.Exists(fullPath));

            const int IMAGE_TYPE = C.IMAGE_TYPE_FULL;

            AssertReadStatus(fullPath, IMAGE_TYPE, C.READ_STATUS_UNAVAILABLE, "Texture is already available ?");

            ImageLoader.RequestLoadFullImage(fullPath);
            yield return(new WaitForSeconds(LOAD_TIMEOUT));

            AssertReadStatus(fullPath, IMAGE_TYPE, C.READ_STATUS_SUCCESS, "Loading texture is not successful.");


            AssertUnloaded(fullPath, IMAGE_TYPE);
            ResetAndAssert(fullPath, IMAGE_TYPE);
        }
 private static void Reset()
 {
     EditorUpdateManager.ResetImageLoading();
     PreviewTextureFactory.Reset();
 }