예제 #1
0
 public void SourceClockProperty()
 {
     TestRuntime.AssertXcodeVersion(13, 0);
     using var timebase = new CMTimebase(null, CMClock.HostTimeClock);
     Assert.NotNull(timebase.SourceClock, "not null source clock");
     // set and if it throws we fail the test
     timebase.SourceClock = CMClock.HostTimeClock;
 }
        public void SetAnchorTime()
        {
            TestRuntime.AssertSystemVersion(PlatformName.MacOSX, 10, 8, throwIfOtherPlatform: false);

            using (var tb = new CMTimebase(CMClock.HostTimeClock)) {
                Assert.AreEqual(CMTimebaseError.None, tb.SetAnchorTime(new CMTime(1000000, 200), new CMTime(-1, -2)));
                var cmt = tb.GetTime(new CMTimeScale(int.MaxValue), CMTimeRoundingMethod.QuickTime);
                Assert.AreEqual(5000, cmt.Seconds);
            }
        }
예제 #3
0
 public void SourceTimebaseProperty()
 {
     TestRuntime.AssertXcodeVersion(13, 0);
     using var mainTimebase = new CMTimebase(CMClock.HostTimeClock);
     using var timebase     = new CMTimebase(null, mainTimebase);
     Assert.NotNull(timebase.SourceTimebase, "Not null timebase");
     // if we throw we fail test test
     using var secondTimebase = new CMTimebase(CMClock.HostTimeClock);
     timebase.SourceTimebase  = secondTimebase;
 }
예제 #4
0
        public void CMTimebaseConstructor()
        {
            TestRuntime.AssertXcodeVersion(13, 0);
            Assert.Throws <ArgumentNullException>(() => {
                var timebase = new CMTimebase(null, (CMTimebase)null);
            }, "Null clock");

            // if it throws we fail the test
            using var mainTimebase = new CMTimebase(CMClock.HostTimeClock);
            using var timebase     = new CMTimebase(null, mainTimebase);
        }
예제 #5
0
        public void SetAnchorTime()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(6, 0))
            {
                Assert.Inconclusive("CMTimebase is new in 6.0");
            }

            using (var tb = new CMTimebase(CMClock.HostTimeClock)) {
                Assert.AreEqual(CMTimebaseError.None, tb.SetAnchorTime(new CMTime(1000000, 200), new CMTime(-1, -2)));
                var cmt = tb.GetTime(new CMTimeScale(int.MaxValue), CMTimeRoundingMethod.QuickTime);
                Assert.AreEqual(5000, cmt.Seconds);
            }
        }
        public void AddTimer()
        {
            TestRuntime.AssertSystemVersion(PlatformName.MacOSX, 10, 8, throwIfOtherPlatform: false);

            using (var tb = new CMTimebase(CMClock.HostTimeClock)) {
                var timer = NSTimer.CreateRepeatingTimer(CMTimebase.VeryLongTimeInterval, delegate { });

                Assert.AreEqual(CMTimebaseError.None, tb.AddTimer(timer, NSRunLoop.Current), "#1");
                Assert.AreEqual(CMTimebaseError.None, tb.SetTimerNextFireTime(timer, new CMTime(100, 2)), "#2");

                tb.RemoveTimer(timer);
            }
        }
예제 #7
0
        public void AddTimer()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(6, 0))
            {
                Assert.Inconclusive("CMTimebase is new in 6.0");
            }

            using (var tb = new CMTimebase(CMClock.HostTimeClock)) {
                var timer = NSTimer.CreateRepeatingTimer(CMTimebase.VeryLongTimeInterval, delegate { });

                Assert.AreEqual(CMTimebaseError.None, tb.AddTimer(timer, NSRunLoop.Current), "#1");
                Assert.AreEqual(CMTimebaseError.None, tb.SetTimerNextFireTime(timer, new CMTime(100, 2)), "#2");

                tb.RemoveTimer(timer);
            }
        }
        public void CopyMasterTests()
        {
            TestRuntime.AssertSystemVersion(PlatformName.MacOSX, 10, 8, throwIfOtherPlatform: false);

            using (var tb = new CMTimebase(CMClock.HostTimeClock)) {
                var masterTB = tb.CopyMasterTimebase();
                AssertNullOrValidHandle(masterTB, "CopyMasterTimebase");

                var masterClock = tb.CopyMasterClock();
                AssertNullOrValidHandle(masterClock, "CopyMasterClock");

                var master = tb.CopyMaster();
                AssertNullOrValidHandle(master, "CopyMaster");

                var masterUlt = tb.CopyUltimateMasterClock();
                AssertNullOrValidHandle(masterUlt, "CopyUltimateMasterClock");
            }
        }
        public void DefaultValues()
        {
            TestRuntime.AssertSystemVersion(PlatformName.MacOSX, 10, 8, throwIfOtherPlatform: false);

            var htc = CMClock.HostTimeClock;

            using (var tb = new CMTimebase(htc)) {
                Assert.AreEqual(0, tb.EffectiveRate, "EffectiveRate");
                Assert.AreEqual(0, tb.Rate, "Rate");

                using (var m = tb.GetMaster()) {
                    Assert.That(m.Handle, Is.Not.EqualTo(IntPtr.Zero), "GetMaster");
                }
                using (var m = tb.GetMasterClock()) {
                    Assert.That(m.Handle, Is.Not.EqualTo(IntPtr.Zero), "GetMasterClock");
                }
                Assert.Null(tb.GetMasterTimebase(), "GetMasterTimebase");
            }
        }
예제 #10
0
        public void GetMasterTests()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(6, 0))
            {
                Assert.Inconclusive("CMTimebase is new in 6.0");
            }

            using (var tb = new CMTimebase(CMClock.HostTimeClock)) {
                var masterTB = tb.GetMasterTimebase();
                AssertNullOrValidHandle(masterTB, "GetMasterTimebase");

                var masterClock = tb.GetMasterClock();
                AssertNullOrValidHandle(masterClock, "GetMasterClock");

                var master = tb.GetMaster();
                AssertNullOrValidHandle(master, "GetMaster");

                var masterUlt = tb.GetUltimateMasterClock();
                AssertNullOrValidHandle(masterUlt, "GetUltimateMasterClock");
            }
        }
예제 #11
0
        public void DefaultValues()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(6, 0))
            {
                Assert.Inconclusive("CMTimebase is new in 6.0");
            }

            var htc = CMClock.HostTimeClock;

            using (var tb = new CMTimebase(htc)) {
                Assert.AreEqual(0, tb.EffectiveRate, "EffectiveRate");
                Assert.AreEqual(0, tb.Rate, "Rate");

                using (var m = tb.GetMaster()) {
                    Assert.That(m.Handle, Is.Not.EqualTo(IntPtr.Zero), "GetMaster");
                }
                using (var m = tb.GetMasterClock()) {
                    Assert.That(m.Handle, Is.Not.EqualTo(IntPtr.Zero), "GetMasterClock");
                }
                Assert.Null(tb.GetMasterTimebase(), "GetMasterTimebase");
            }
        }