Esempio n. 1
0
        public void CustomRequestsInterceptionTimeouts()
        {
            var requestHandlerCalled = false;

            TargetView.CustomResourceRequested += (req) => {
                requestHandlerCalled = true;
                Thread.Sleep(1000000);
                return(null);
            };

            var originalTimeout = ReactViewRender.CustomRequestTimeout;

            try {
                ReactViewRender.CustomRequestTimeout = TimeSpan.FromMilliseconds(500);

                var exceptionThrown = false;
                WithUnhandledExceptionHandling(() => {
                    TargetView.ExecuteMethodOnRoot("loadCustomResource", "custom://webview/test.png");
                    WaitFor(() => requestHandlerCalled && exceptionThrown, TimeSpan.FromSeconds(10), "exception thrown");
                }, (e) => {
                    exceptionThrown = true;
                    return(true);
                });

                Assert.IsTrue(requestHandlerCalled, "Request handler was called");
                Assert.IsTrue(exceptionThrown, "Exception was thrown");
            } finally {
                ReactViewRender.CustomRequestTimeout = originalTimeout;
            }
        }
Esempio n. 2
0
        public void PropertiesAreInjected()
        {
            var eventCalled = false;

            TargetView.Event += (args) => eventCalled = true;
            TargetView.ExecuteMethodOnRoot("callEvent");
            WaitFor(() => eventCalled, TimeSpan.FromSeconds(10), "event call");
        }
        public void PluginModuleIsLoaded()
        {
            var pluginModuleLoaded = false;

            TargetView.Event += (args) => {
                pluginModuleLoaded = args == "PluginModuleLoaded";
            };

            TargetView.ExecuteMethodOnRoot("checkPluginModuleLoaded");

            WaitFor(() => pluginModuleLoaded, "plugin module load");
        }
Esempio n. 4
0
        public void EventsAreNotHandledInDispatcherThread()
        {
            bool?canAccessDispatcher = null;

            TargetView.Event += (args) => {
                canAccessDispatcher = TargetView.Dispatcher.CheckAccess();
            };

            TargetView.ExecuteMethodOnRoot("callEvent");

            WaitFor(() => canAccessDispatcher != null, TimeSpan.FromSeconds(10), "event call");
            Assert.IsFalse(canAccessDispatcher, "Can access dispatcher");
        }
Esempio n. 5
0
        public void DefaultStylesheetIsLoaded()
        {
            string stylesheet = null;

            TargetView.Event += (args) => {
                stylesheet = args;
            };

            TargetView.ExecuteMethodOnRoot("checkStyleSheetLoaded", "2");

            WaitFor(() => stylesheet != null, TimeSpan.FromSeconds(10), "stylesheet load");

            Assert.IsTrue(stylesheet.Contains(".bar"));
        }
Esempio n. 6
0
        public void StylesheetsAreLoaded()
        {
            string stylesheet = null;

            TargetView.Event += (args) => {
                stylesheet = args;
            };

            TargetView.ExecuteMethodOnRoot("checkStyleSheetLoaded", "1");

            WaitFor(() => stylesheet != null, TimeSpan.FromSeconds(10), "stylesheet load");

            Assert.IsTrue(stylesheet.Contains(".foo"));
            Assert.IsTrue(stylesheet.Contains(".baz")); // from dependency
        }
Esempio n. 7
0
        public void DisposeDoesNotHang()
        {
            var disposed = false;

            TargetView.Event += (args) => {
                TargetView.Dispatcher.Invoke((() => {
                    TargetView.Dispose();
                    disposed = true;
                }));
            };

            TargetView.ExecuteMethodOnRoot("callEvent");

            WaitFor(() => disposed, TimeSpan.FromSeconds(10), "view disposed");
        }