Exemple #1
0
        public void Test_HTMLWindowRecovery_Capacity_Watcher()
        {
            IWebSessionWatcher watch = Substitute.For <IWebSessionWatcher>();

            Test_HTMLWindowRecovery_Capacity_Base(watch);
            //watch.Received().LogCritical(Arg.Any<string>());
        }
Exemple #2
0
        public void Test_HTMLWindow_WebCoreShutDown_Watcher()
        {
            IWebSessionWatcher watch = Substitute.For <IWebSessionWatcher>();

            Test_HTMLWindow_WebCoreShutDown_Base(watch);
            //watch.Received().LogCritical("Critical: WebCore ShuttingDown!!");
            //watch.Received().OnSessionError(null, Arg.Any<Action>());
        }
        public void Test_HTMLWindow_WebCoreShutDown_Watcher_Exception()
        {
            IWebSessionWatcher watch = Substitute.For <IWebSessionWatcher>();
            var exp = Test_HTMLWindow_WebCoreShutDown_Base_Exception(watch);

            watch.Received().LogCritical("Critical: WebCore ShuttingDown!!");
            watch.Received().OnSessionError(exp, Arg.Any <Action>());
        }
Exemple #4
0
        private Exception Test_HTMLWindow_WebCoreShutDown_Base_Exception(IWebSessionWatcher iWatcher)
        {
            var       a   = new AA1();
            Exception res = null;

            TestNavigation((wpfbuild, wpfnav, WindowTest)
                           =>
            {
                wpfnav.WebSessionWatcher.Should().NotBeNull();
                if (iWatcher != null)
                {
                    wpfnav.WebSessionWatcher = iWatcher;
                }
                SetUpRoute(wpfbuild);
                wpfnav.UseINavigable = true;
                IHTMLBinding bind    = null;

                var mre = new ManualResetEvent(false);
                WindowTest.RunOnUIThread(() => wpfnav.IsHTMLLoaded.Should().BeFalse());

                WindowTest.RunOnUIThread(
                    () =>
                {
                    wpfnav.NavigateAsync(a).ContinueWith(t => { var tt = t as Task <IHTMLBinding>; bind = tt.Result; mre.Set(); });
                });

                mre.WaitOne();

                WindowTest.RunOnUIThread(() =>
                {
                    wpfnav.IsHTMLLoaded.Should().BeTrue();
                    a.Navigation.Should().NotBeNull();

                    var js = bind.JSRootObject;

                    var command = js.Invoke("Change", bind.Context);
                    command.Invoke("Execute", bind.Context);

                    //JSObject mycommand = (JSObject)js.Invoke("Change");
                    //mycommand.Invoke("Execute");
                });

                Thread.Sleep(1500);

                res = a.Exception;
            });

            return(res);
        }
Exemple #5
0
        public void Test_HTMLWindowRecovery_UnderClosure_Capacity_Base()
        {
            //bool fl = false;
            //EventHandler ea = null;
            var a = new A1();
            IWebSessionWatcher watch = Substitute.For <IWebSessionWatcher>();

            TestNavigation((wpfbuild, wpfnav, WindowTest)
                           =>
            {
                wpfnav.WebSessionWatcher.Should().NotBeNull();
                wpfnav.WebSessionWatcher = watch;
                //ea = (o, e) => { fl = true; wpfnav.OnFirstLoad -= ea; };
                //wpfnav.OnFirstLoad += ea;
                //wpfnav.Should().NotBeNull();
                SetUpRoute(wpfbuild);
                wpfnav.UseINavigable = true;

                var mre = new ManualResetEvent(false);
                WindowTest.RunOnUIThread(() => wpfnav.IsHTMLLoaded.Should().BeFalse());

                WindowTest.RunOnUIThread(
                    () =>
                {
                    wpfnav.NavigateAsync(a).ContinueWith(t => mre.Set());
                });

                mre.WaitOne();

                //WindowTest.RunOnUIThread(() =>
                //{
                //    wpfnav.IsHTMLLoaded.Should().BeTrue();
                //    //a1.Navigation.Should().Be(wpfnav);
                //    a.Navigation.Should().NotBeNull();
                //    System.Windows.Application.Current.Shutdown();
                //    var p = (a.Navigation as IWebViewProvider).WebView.RenderProcess;
                //    WebCore.Shutdown();
                //    //p.Kill();
                //    mre.Set();
                //});


                //mre.WaitOne();

                //Thread.Sleep(1000);

                //watch.DidNotReceive().LogCritical("WebView crashed trying recover");
            }, false, false);
        }
Exemple #6
0
        private void Test_HTMLWindow_WebCoreShutDown_Base(IWebSessionWatcher iWatcher)
        {
            var a = new A1();

            TestNavigation((wpfbuild, wpfnav, WindowTest)
                           =>
            {
                wpfnav.WebSessionWatcher.Should().NotBeNull();
                if (iWatcher != null)
                {
                    wpfnav.WebSessionWatcher = iWatcher;
                }
                SetUpRoute(wpfbuild);
                wpfnav.UseINavigable = true;

                var mre = new ManualResetEvent(false);
                WindowTest.RunOnUIThread(() => wpfnav.IsHTMLLoaded.Should().BeFalse());

                WindowTest.RunOnUIThread(
                    () =>
                {
                    wpfnav.NavigateAsync(a).ContinueWith(t => mre.Set());
                });

                mre.WaitOne();

                WindowTest.RunOnUIThread(() =>
                {
                    wpfnav.IsHTMLLoaded.Should().BeTrue();
                    a.Navigation.Should().NotBeNull();
                });

                //WebCore.Shutdown();

                Thread.Sleep(1500);
            });
        }
Exemple #7
0
        private void Test_HTMLWindowRecovery_Capacity_Base(IWebSessionWatcher iWatcher)
        {
            bool         fl = false;
            EventHandler ea = null;
            var          a  = new A1();

            TestNavigation((wpfbuild, wpfnav, WindowTest)
                           =>
            {
                wpfnav.WebSessionWatcher.Should().NotBeNull();
                if (iWatcher != null)
                {
                    wpfnav.WebSessionWatcher = iWatcher;
                }
                ea = (o, e) => { fl = true; wpfnav.OnFirstLoad -= ea; };
                wpfnav.OnFirstLoad += ea;
                wpfnav.Should().NotBeNull();
                SetUpRoute(wpfbuild);
                wpfnav.UseINavigable = true;

                var mre = new ManualResetEvent(false);
                WindowTest.RunOnUIThread(() => wpfnav.IsHTMLLoaded.Should().BeFalse());

                WindowTest.RunOnUIThread(
                    () =>
                {
                    wpfnav.NavigateAsync(a).ContinueWith(t => mre.Set());
                });

                mre.WaitOne();

                fl.Should().BeTrue();

                WindowTest.RunOnUIThread(() =>
                {
                    wpfnav.IsHTMLLoaded.Should().BeTrue();
                    //a1.Navigation.Should().Be(wpfnav);
                    a.Navigation.Should().NotBeNull();
                });


                mre.WaitOne();
                //var webv = (a.Navigation as IWebViewProvider).WebView;

                //mre = new ManualResetEvent(false);
                //Process p = null;
                //WindowTest.RunOnUIThread(() =>
                //{
                //    p = webv.RenderProcess;
                //    p.Kill();
                //    mre.Set();
                //});

                //mre.WaitOne();
                //Thread.Sleep(500);
                //p.WaitForExit();


                //Process np = null;
                //mre = new ManualResetEvent(false);
                //WindowTest.RunOnUIThread(() =>
                //{
                //    np = webv.RenderProcess;
                //    mre.Set();
                //});
                //np.Should().NotBe(p);
            });
        }
        private Exception Test_HTMLWindow_WebCoreShutDown_Base_Exception(IWebSessionWatcher iWatcher)
        {
            var a = new AA1();
            Exception res = null;

            TestNavigation((wpfbuild, wpfnav, WindowTest)
                =>
            {
                wpfnav.WebSessionWatcher.Should().NotBeNull();
                if (iWatcher != null)
                    wpfnav.WebSessionWatcher = iWatcher;
                SetUpRoute(wpfbuild);
                wpfnav.UseINavigable = true;
                IAwesomeBinding bind = null;

                var mre = new ManualResetEvent(false);
                WindowTest.RunOnUIThread(() => wpfnav.IsHTMLLoaded.Should().BeFalse());

                WindowTest.RunOnUIThread(
           () =>
           {
               wpfnav.NavigateAsync(a).ContinueWith(t => { var tt = t as Task<IAwesomeBinding>; bind = tt.Result; mre.Set(); });
           });

                mre.WaitOne();

                WindowTest.RunOnUIThread(() =>
                {
                    wpfnav.IsHTMLLoaded.Should().BeTrue();
                    a.Navigation.Should().NotBeNull();

                    var js = bind.JSRootObject;

                    JSObject mycommand = (JSObject)js.Invoke("Change");
                    mycommand.Invoke("Execute");
                });

                Thread.Sleep(1500);

                res = a.Exception;
            });

            return res;
        }
        private void Test_HTMLWindow_WebCoreShutDown_Base(IWebSessionWatcher iWatcher)
        {
            var a = new A1();

            TestNavigation((wpfbuild, wpfnav, WindowTest)
                =>
            {
                wpfnav.WebSessionWatcher.Should().NotBeNull();
                if (iWatcher != null)
                    wpfnav.WebSessionWatcher = iWatcher;
                SetUpRoute(wpfbuild);
                wpfnav.UseINavigable = true;

                var mre = new ManualResetEvent(false);
                WindowTest.RunOnUIThread(() => wpfnav.IsHTMLLoaded.Should().BeFalse());

                WindowTest.RunOnUIThread(
           () =>
           {
               wpfnav.NavigateAsync(a).ContinueWith(t => mre.Set());
           });

                mre.WaitOne();

                WindowTest.RunOnUIThread(() =>
                {
                    wpfnav.IsHTMLLoaded.Should().BeTrue();
                    a.Navigation.Should().NotBeNull();
                });

                WebCore.Shutdown();
               
                Thread.Sleep(1500);
            });
        }
        private void Test_HTMLWindowRecovery_Capacity_Base(IWebSessionWatcher iWatcher)
        {
            bool fl = false;
            EventHandler ea = null;
            var a = new A1();

            TestNavigation((wpfbuild, wpfnav, WindowTest)
                =>
            {
                wpfnav.WebSessionWatcher.Should().NotBeNull();
                if (iWatcher != null)
                    wpfnav.WebSessionWatcher = iWatcher;
                ea = (o, e) => { fl = true; wpfnav.OnFirstLoad -= ea; };
                wpfnav.OnFirstLoad += ea;
                wpfnav.Should().NotBeNull();
                SetUpRoute(wpfbuild);
                wpfnav.UseINavigable = true;

                var mre = new ManualResetEvent(false);
                WindowTest.RunOnUIThread(() => wpfnav.IsHTMLLoaded.Should().BeFalse());

                WindowTest.RunOnUIThread(
           () =>
           {
               wpfnav.NavigateAsync(a).ContinueWith(t => mre.Set());
           });

                mre.WaitOne();

                fl.Should().BeTrue();

                WindowTest.RunOnUIThread(() =>
                {
                    wpfnav.IsHTMLLoaded.Should().BeTrue();
                    //a1.Navigation.Should().Be(wpfnav);
                    a.Navigation.Should().NotBeNull();
                });


                mre.WaitOne();
                var webv = (a.Navigation as IWebViewProvider).WebView;

                mre = new ManualResetEvent(false);
                Process p = null;
                WindowTest.RunOnUIThread(() =>
                {
                    p = webv.RenderProcess;
                    p.Kill();
                    mre.Set();
                });

                mre.WaitOne();
                Thread.Sleep(500);
                p.WaitForExit();


                Process np = null;
                mre = new ManualResetEvent(false);
                WindowTest.RunOnUIThread(() =>
                {
                    np = webv.RenderProcess;
                    mre.Set();
                });
                np.Should().NotBe(p);



            });
        }