public void Dispose_CHECK_REFERENCE_COUNT_WHEN_IMAGEURL_CLASS_DISPOSE_IMAGEURL() { /* TEST CODE */ var win = NUIApplication.GetDefaultWindow(); View testView = win.GetDefaultLayer().FindChildByName("testImageUrl"); var expectedValue = 0; if (testView) { if (imageUrl) { //check imagUrl expectedValue = RefCountWhenNew; Assert.AreEqual(expectedValue, imageUrl.RefCnt(), $"reference count should be {expectedValue}"); } testView.Dispose(); //check imagUrl expectedValue = RefCountWhenNew; Assert.AreEqual(expectedValue, imageUrl.RefCnt(), $"reference count should be {expectedValue}"); } }
public void Dispose_CHECK_REFERENCE_COUNT_WHEN_IMAGEURL_CLASS() { /* TEST CODE */ path = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "picture.png"; Stream stream = File.OpenRead(path); EncodedImageBuffer buffer = new EncodedImageBuffer(stream); imageUrl = buffer.GenerateUrl(); //check imagUrl var expectedValue = RefCountWhenNew; Assert.AreEqual(expectedValue, imageUrl.RefCnt(), $"reference count should be {expectedValue}"); View testView = new View { Name = "testImageUrl", Size = new Size(testSize, testSize, 0), Position = new Position(testPosition, testPosition, 0), BackgroundImage = imageUrl.ToString(), }; // new EventThreadCallback( new EventThreadCallback.CallbackDelegate // ( // ()=> // { // NUIApplication.GetDefaultWindow().Add(testView); // } // ) // ).Trigger(); // test1(testView); // await Task.Delay(300); //check imagUrl expectedValue = RefCountWhenNew; Assert.AreEqual(expectedValue, imageUrl.RefCnt(), $"reference count should be {expectedValue}"); NUIApplication.GetDefaultWindow().Add(testView); //await Task.Delay(300); //check imagUrl expectedValue = RefCountWhenNew; Assert.AreEqual(expectedValue, imageUrl.RefCnt(), $"reference count should be {expectedValue}"); //imageUrl.Dispose(); //check testView expectedValue = RefCountWhenNew + RefCountWhenAdd; Assert.AreEqual(expectedValue, testView.RefCnt(), $"reference count should be {expectedValue}"); View sameImageUrlView = new View { Name = "testImageUrl2", Size = new Size(testSize, testSize, 0), Position = new Position(testPosition * 2, testPosition * 2, 0), BackgroundImage = imageUrl.ToString(), }; //check imagUrl expectedValue = RefCountWhenNew; Assert.AreEqual(expectedValue, imageUrl.RefCnt(), $"reference count should be {expectedValue}"); NUIApplication.GetDefaultWindow().Add(sameImageUrlView); //check imagUrl expectedValue = RefCountWhenNew; Assert.AreEqual(expectedValue, imageUrl.RefCnt(), $"reference count should be {expectedValue}"); }