Ejemplo n.º 1
0
        public void TestSimpleLargeObjectArrayArgument()
        {
            using (var form = new BrowserTestForm())
            {
                var bridge = new ScriptingBridge(form.WebBrowser, true);
                var waiter = new WaitForFormsEvent();
                form.WebBrowser.DocumentCompleted += (sender, args) =>
                {
                    var parameter = new List <ParameterObject>();
                    for (int i = 0; i < 1000; i++)
                    {
                        parameter.Add(new ParameterObject());
                    }

                    var result = bridge.InvokeFunction <List <ParameterObject> >("anObject.simpleArgumentFunction", parameter);
                    Assert.Equal(parameter.Count, result.Count);

                    waiter.SetEvent();
                };

                form.Show();
                form.WebBrowser.Url = new Uri(String.Format("file:///{0}/TestPage.html", Directory.GetCurrentDirectory()));

                // Wait for the document to load.
                Assert.True(waiter.WaitForEvent(2000));
            }
        }
Ejemplo n.º 2
0
        public void TestBrowserTestForm()
        {
            using (var form = new BrowserTestForm())
            {
                var waiter = new WaitForFormsEvent();
                form.WebBrowser.DocumentCompleted += (sender, args) => { waiter.SetEvent(); };

                form.Show();
                form.WebBrowser.Url = new Uri(String.Format("file:///{0}/TestPage.html", Directory.GetCurrentDirectory()));

                // Wait for the document to load.
                Assert.True(waiter.WaitForEvent(2000));
            }
        }
Ejemplo n.º 3
0
        public void TestUndefinedContextCall()
        {
            using (var form = new BrowserTestForm())
            {
                var bridge = new ScriptingBridge(form.WebBrowser, true);
                var waiter = new WaitForFormsEvent();
                form.WebBrowser.DocumentCompleted += (sender, args) =>
                {
                    Assert.Throws <Exception>(() => bridge.InvokeFunction <string>("undefinedContext.someFunc"));
                    waiter.SetEvent();
                };

                form.Show();
                form.WebBrowser.Url = new Uri(String.Format("file:///{0}/TestPage.html", Directory.GetCurrentDirectory()));

                // Wait for the document to load.
                Assert.True(waiter.WaitForEvent(2000));
            }
        }
Ejemplo n.º 4
0
        public void TestGlobalFunctionCall()
        {
            using (var form = new BrowserTestForm())
            {
                var bridge = new ScriptingBridge(form.WebBrowser, true);
                var waiter = new WaitForFormsEvent();
                form.WebBrowser.DocumentCompleted += (sender, args) =>
                {
                    var result = bridge.InvokeFunction <string>("globalFunction");
                    Assert.Equal("globalFunction", result);

                    waiter.SetEvent();
                };

                form.Show();
                form.WebBrowser.Url = new Uri(String.Format("file:///{0}/TestPage.html", Directory.GetCurrentDirectory()));

                // Wait for the document to load.
                Assert.True(waiter.WaitForEvent(2000));
            }
        }
Ejemplo n.º 5
0
        public void TestAutoInitialization()
        {
            using (var form = new BrowserTestForm())
            {
                var bridge = new ScriptingBridge(form.WebBrowser, true);
                var waiter = new WaitForFormsEvent();
                form.WebBrowser.DocumentCompleted += (sender, args) =>
                {
                    // Check that the bridge is initialized.
                    Assert.True(bridge.IsInitialized);

                    waiter.SetEvent();
                };

                form.Show();
                form.WebBrowser.Url = new Uri(String.Format("file:///{0}/TestPage.html", Directory.GetCurrentDirectory()));

                // Wait for the document to load.
                Assert.True(waiter.WaitForEvent(2000));
            }
        }
Ejemplo n.º 6
0
        public void TestSimpleFunctionArrayArgument()
        {
            using (var form = new BrowserTestForm())
            {
                var bridge = new ScriptingBridge(form.WebBrowser, true);
                var waiter = new WaitForFormsEvent();
                form.WebBrowser.DocumentCompleted += (sender, args) =>
                {
                    var parameter = new int[] { 1, 2, 3, 4, 5 };
                    var result    = bridge.InvokeFunction <int[]>("anObject.simpleArgumentFunction", parameter);
                    Assert.Equal(parameter, result);

                    waiter.SetEvent();
                };

                form.Show();
                form.WebBrowser.Url = new Uri(String.Format("file:///{0}/TestPage.html", Directory.GetCurrentDirectory()));

                // Wait for the document to load.
                Assert.True(waiter.WaitForEvent(2000));
            }
        }