Esempio n. 1
0
        /// Pass a GameObject to receive the newly-created singleton BrushCatalog
        /// Useful for unit tests because a ton of Tilt Brush uses GetBrush(Guid).
        /// TODO: change TB to use BrushDescriptor directly rather than indirect through Guids
        public static void UnitTestSetUp(GameObject container)
        {
            Debug.Assert(m_Instance == null);
            m_Instance = container.AddComponent <BrushCatalog>();

            // For unit testing, probably best to have all the descriptors available,
            // rather than just a subset of them that are in a manifest.
            m_Instance.m_GuidToBrush = UnityEditor.AssetDatabase.FindAssets("t:BrushDescriptor")
                                       .Select(name => UnityEditor.AssetDatabase.LoadAssetAtPath <BrushDescriptor>(
                                                   UnityEditor.AssetDatabase.GUIDToAssetPath(name)))
                                       .ToDictionary(desc => (Guid)desc.m_Guid);
        }
Esempio n. 2
0
        public void RunAfterAllTests()
        {
            Assert.IsTrue(m_container != null);

            if (m_needSingletonTeardown)
            {
                BrushCatalog.UnitTestTearDown(m_container);
                DevOptions.I            = null;
                Config.m_SingletonState = null;
                App.Instance            = null;
                m_needSingletonTeardown = false;
            }

            UnityEngine.Object.DestroyImmediate(m_container);
        }
Esempio n. 3
0
        void Awake()
        {
            m_Instance        = this;
            m_GuidToBrush     = new Dictionary <Guid, Brush>();
            m_MaterialToBrush = new Dictionary <Material, Brush>();
            m_AllBrushes      = new HashSet <Brush>();
            m_GuiBrushList    = new List <Brush>();

            // Move blocks materials in to a dictionary for quick lookup.
            for (int i = 0; i < m_BlocksMaterials.Length; ++i)
            {
                m_MaterialToBrush.Add(m_BlocksMaterials[i].brushDescriptor.Material,
                                      m_BlocksMaterials[i].brushDescriptor);
            }

            Shader.SetGlobalTexture("_GlobalNoiseTexture", m_GlobalNoiseTexture);
        }
Esempio n. 4
0
        public void RunBeforeAnyTests()
        {
            m_container = new GameObject("Singletons for TestBrush");
            Coords.AsLocal[m_container.transform] = TrTransform.identity;

            var path = Path.Combine(Application.dataPath, "../Support/Sketches/PerfTest/Simple.tilt");

            m_testStrokes = GetStrokesFromTilt(path);

            if (DevOptions.I == null)
            {
                m_needSingletonTeardown = true;
                App.Instance            = GameObject.Find("/App").GetComponent <App>();
                Config.m_SingletonState = GameObject.Find("/App/Config").GetComponent <Config>();
                DevOptions.I            = App.Instance.GetComponent <DevOptions>();
                // A lot of code needs access to BrushCatalog.Instance.m_guidToBrush.
                // We could avoid having to depend on this global state, if only Tilt Brush
                // directly referenced BrushDescriptor instead of indirecting through Guid.
                BrushCatalog.UnitTestSetUp(m_container);
            }
        }
Esempio n. 5
0
 /// The inverse of UnitTestSetUp
 public static void UnitTestTearDown(GameObject container)
 {
     Debug.Assert(m_Instance == container.GetComponent <BrushCatalog>());
     m_Instance = null;
 }