Ejemplo n.º 1
0
        public void TestNonSeekable()
        {
            bool failed = false;
            bool opened = false;

            MediaStreamSourceBase mss = new MediaStreamSourceBase();

            mss.InitializeSource(false, 5000000);
            mss.AddVideoStream();

            MediaElement mel = new MediaElement();

            mel.SetSource(mss);
            mel.MediaFailed += new EventHandler <ExceptionRoutedEventArgs> (delegate(object sender, ExceptionRoutedEventArgs e)
            {
                failed = true;
            });
            mel.MediaOpened += new RoutedEventHandler(delegate(object sender, RoutedEventArgs e)
            {
                opened = true;
            });
            TestPanel.Children.Add(mel);
            EnqueueConditional(() => failed || opened);
            Enqueue(delegate()
            {
                Assert.IsFalse(failed, "failed");
                Assert.IsTrue(mss.Log.Count >= 2);
                Assert.AreEqual("OpenMediaAsync", mss.Log [0].Name, "OpenMediaAsync");
                Assert.AreEqual("SeekAsync", mss.Log [1].Name, "SeekAsync");
                Assert.AreEqual((long)0, (long)mss.Log [1].Value, "SeekAsync:Value");
                Assert.IsFalse(mel.CanSeek, "CanSeek");
            });
            EnqueueTestComplete();
        }
Ejemplo n.º 2
0
        public void ThreadPool()
        {
            int  tid    = Thread.CurrentThread.ManagedThreadId;
            bool opened = false;

            OpenMediaOnSameThread  = false;
            CloseMediaOnSameThread = false;

            Enqueue(() => {
                Assert.AreEqual(tid, Thread.CurrentThread.ManagedThreadId, "Different thread ids");

                MediaStreamSourceBase mss = new MediaStreamSourceBase();
                mss.InitializeSource(true, 5000000);
                mss.AddVideoStream();

                MediaElement mel = new MediaElement();
                mel.MediaOpened += new RoutedEventHandler(delegate(object sender, RoutedEventArgs e) {
                    opened = true;
                    Assert.AreEqual(tid, Thread.CurrentThread.ManagedThreadId, "MediaOpened");
                });
                mel.SetSource(mss);
#if false
                Assert.Throws <InvalidOperationException> (delegate {
                    mel.SetSource(mss);                      // 2nd SetSource to get a Close event
                }, "Close");
#endif
                TestPanel.Children.Add(mel);
            });
            EnqueueConditional(() => opened);
            Enqueue(delegate() {
                Assert.IsTrue(OpenMediaOnSameThread, "OpenMediaOnSameThread");
//				Assert.IsTrue (CloseMediaOnSameThread, "CloseMediaOnSameThread");
            });
            EnqueueTestComplete();
        }
Ejemplo n.º 3
0
        public void UserThread()
        {
            int  tid    = Thread.CurrentThread.ManagedThreadId;
            bool opened = false;

            // set them to true to make sure we're not checking the default (false) value later
            OpenMediaOnSameThread  = true;
            CloseMediaOnSameThread = true;

            Dispatcher dispatcher = TestPanel.Dispatcher;

            Thread t = new Thread(delegate() {
                Assert.AreNotEqual(tid, Thread.CurrentThread.ManagedThreadId, "Same thread ids");

                MediaStreamSourceBase mss = new MediaStreamSourceBase();
                mss.InitializeSource(false, 5000000);
                mss.AddVideoStream();

                dispatcher.BeginInvoke(delegate {
                    MediaElement mel = new MediaElement();
                    mel.MediaOpened += new RoutedEventHandler(delegate(object sender, RoutedEventArgs e) {
                        opened = true;
                        Assert.AreEqual(tid, Thread.CurrentThread.ManagedThreadId, "MediaOpened");
                    });
                    mel.SetSource(mss);
#if false
                    Assert.Throws <InvalidOperationException> (delegate {
                        mel.SetSource(mss);                          // 2nd SetSource to get a Close event
                    }, "Close");
#endif
                    TestPanel.Children.Add(mel);
                });
            });

            t.Start();
            EnqueueConditional(() => opened);
            Enqueue(delegate() {
                Assert.IsFalse(OpenMediaOnSameThread, "OpenMediaOnSameThread");
//				Assert.IsFalse (CloseMediaOnSameThread, "CloseMediaOnSameThread");
            });
            EnqueueTestComplete();
        }
Ejemplo n.º 4
0
        private void Test(MediaElement mel, string value, bool can_seek)
        {
            MediaStreamSourceBase mss;

            Enqueue(delegate()
            {
                mediafailed = false;
                mediaopened = false;
                mss         = new MediaStreamSourceBase();
                mss.InitializeSource(value, "5000000");
                mss.AddVideoStream();
                mel.Tag = value;
                mel.SetSource(mss);
            });
            EnqueueConditional(() => mediafailed || mediaopened);
            Enqueue(delegate()
            {
                Assert.AreEqual(can_seek, mel.CanSeek, "CanSeek: " + (string)mel.Tag);
            });
        }
Ejemplo n.º 5
0
		private void Test (MediaElement mel, string value, bool can_seek)
		{
			MediaStreamSourceBase mss;

			Enqueue (delegate ()
			{
				mediafailed = false;
				mediaopened = false;
				mss = new MediaStreamSourceBase ();
				mss.InitializeSource (value, "5000000");
				mss.AddVideoStream ();
				mel.Tag = value;
				mel.SetSource (mss);
			});
			EnqueueConditional (() => mediafailed || mediaopened);
			Enqueue (delegate ()
			{
				Assert.AreEqual (can_seek, mel.CanSeek, "CanSeek: " + (string) mel.Tag);
			});
		}
Ejemplo n.º 6
0
		public void TestNonSeekable ()
		{
			bool failed = false;
			bool opened = false;

			MediaStreamSourceBase mss = new MediaStreamSourceBase ();
			mss.InitializeSource (false, 5000000);
			mss.AddVideoStream ();

			MediaElement mel = new MediaElement ();
			mel.SetSource (mss);
			mel.MediaFailed += new EventHandler<ExceptionRoutedEventArgs> (delegate (object sender, ExceptionRoutedEventArgs e)
			{
				failed = true;
			});
			mel.MediaOpened += new RoutedEventHandler (delegate (object sender, RoutedEventArgs e)
			{
				opened = true;
			});
			TestPanel.Children.Add (mel);
			EnqueueConditional (() => failed || opened);
			Enqueue (delegate ()
			{
				Assert.IsFalse (failed, "failed");
				Assert.IsTrue (mss.Log.Count >= 2);
				Assert.AreEqual ("OpenMediaAsync", mss.Log [0].Name, "OpenMediaAsync");
				Assert.AreEqual ("SeekAsync", mss.Log [1].Name, "SeekAsync");
				Assert.AreEqual ((long) 0, (long) mss.Log [1].Value, "SeekAsync:Value");
				Assert.IsFalse (mel.CanSeek, "CanSeek");
			});
			EnqueueTestComplete ();
		}
Ejemplo n.º 7
0
		public void UserThread ()
		{
			int tid = Thread.CurrentThread.ManagedThreadId;
			bool opened = false;
			// set them to true to make sure we're not checking the default (false) value later
			OpenMediaOnSameThread = true;
			CloseMediaOnSameThread = true;

			Dispatcher dispatcher = TestPanel.Dispatcher;

			Thread t = new Thread (delegate () {
				Assert.AreNotEqual (tid, Thread.CurrentThread.ManagedThreadId, "Same thread ids");

				MediaStreamSourceBase mss = new MediaStreamSourceBase ();
				mss.InitializeSource (false, 5000000);
				mss.AddVideoStream ();

				dispatcher.BeginInvoke (delegate {
					MediaElement mel = new MediaElement ();
					mel.MediaOpened += new RoutedEventHandler (delegate (object sender, RoutedEventArgs e) {
						opened = true;
						Assert.AreEqual (tid, Thread.CurrentThread.ManagedThreadId, "MediaOpened");
					});
					mel.SetSource (mss);
#if false
					Assert.Throws<InvalidOperationException> (delegate {
						mel.SetSource (mss); // 2nd SetSource to get a Close event
					}, "Close");
#endif
					TestPanel.Children.Add (mel);
				});
			});
			t.Start ();
			EnqueueConditional (() => opened);
			Enqueue (delegate () {
				Assert.IsFalse (OpenMediaOnSameThread, "OpenMediaOnSameThread");
//				Assert.IsFalse (CloseMediaOnSameThread, "CloseMediaOnSameThread");
			});
			EnqueueTestComplete ();
		}
Ejemplo n.º 8
0
		public void ThreadPool ()
		{
			int tid = Thread.CurrentThread.ManagedThreadId;
			bool opened = false;
			OpenMediaOnSameThread = false;
			CloseMediaOnSameThread = false;

			Enqueue (() => {
				Assert.AreEqual (tid, Thread.CurrentThread.ManagedThreadId, "Different thread ids");

				MediaStreamSourceBase mss = new MediaStreamSourceBase ();
				mss.InitializeSource (true, 5000000);
				mss.AddVideoStream ();

				MediaElement mel = new MediaElement ();
				mel.MediaOpened += new RoutedEventHandler (delegate (object sender, RoutedEventArgs e) {
					opened = true;
					Assert.AreEqual (tid, Thread.CurrentThread.ManagedThreadId, "MediaOpened");
				});
				mel.SetSource (mss);
#if false
				Assert.Throws<InvalidOperationException> (delegate {
					mel.SetSource (mss); // 2nd SetSource to get a Close event
				}, "Close");
#endif
				TestPanel.Children.Add (mel);
			});
			EnqueueConditional (() => opened);
			Enqueue (delegate () {
				Assert.IsTrue (OpenMediaOnSameThread, "OpenMediaOnSameThread");
//				Assert.IsTrue (CloseMediaOnSameThread, "CloseMediaOnSameThread");
			});
			EnqueueTestComplete ();
		}