Parcourir la source

commit: update tests

Local il y a 5 ans
Parent
commit
341eb524b6

+ 8 - 8
Cbdx.Tests.BridgeNet/App.cs

@@ -1,6 +1,6 @@
-using System;
-using Bridge;
+using Bridge;
 using Bridge.Html5;
+using System;
 
 namespace Cbdx.Tests
 {
@@ -32,15 +32,15 @@ namespace Cbdx.Tests
 
             Window.OnResize += delegate { label.TextContent = windowControlService.GetWindowState().ToString(); };
 
-            new HTMLInputElement { Type = InputType.Button, Value = "F12" }
-                .With(p => p.OnClick += delegate { cefDevService.ShowF12(); })
+            new HTMLInputElement { Type = InputType.Button, Value = "Reload" }
+                .With(p => p.OnClick += delegate { windowControlService.Reload(); })
                 .With(p => Document.Body.AppendChild(p));
 
-            new HTMLInputElement { Type = InputType.Button, Value = "Refresh" }
-                .With(p => p.OnClick += delegate { cefDevService.Refresh(); })
+            new HTMLInputElement { Type = InputType.Button, Value = "F12" }
+                .With(p => p.OnClick += delegate { cefDevService.ShowF12(); })
                 .With(p => Document.Body.AppendChild(p));
 
-            new HTMLInputElement { Type = InputType.Button, Value = "Move" }
+            new HTMLInputElement { Type = InputType.Button, Value = "DragMove" }
                 .With(p => p.OnMouseDown += delegate { windowControlService.DragMove(); })
                 .With(p => Document.Body.AppendChild(p));
 
@@ -72,4 +72,4 @@ namespace Cbdx.Tests
             return me;
         }
     }
-}
+}

+ 0 - 1
Cbdx.Tests.Shared/ICefDevService.cs

@@ -4,6 +4,5 @@
     internal interface ICefDevService
     {
         void ShowF12();
-        void Refresh();
     }
 }

+ 2 - 2
Cbdx.Tests.Shared/IWindowControlService.cs

@@ -7,6 +7,6 @@
         void SetWindowTitle(string title);
         void DragMove();
         void CloseWindow();
-
+        void Reload();
     }
-}
+}

+ 2 - 9
Cbdx.Tests/Services/CefDevService.cs

@@ -1,5 +1,4 @@
-using System;
-using CefSharp;
+using CefSharp;
 using CefSharp.WinForms;
 
 namespace Cbdx.Tests.Services
@@ -17,11 +16,5 @@ namespace Cbdx.Tests.Services
         {
             _browser.ShowDevTools();
         }
-
-        void ICefDevService.Refresh()
-        {
-            if (_browser.InvokeRequired) _browser.Invoke(new Action(() => _browser.Refresh()));
-            else _browser.Refresh();
-        }
     }
-}
+}

+ 9 - 3
Cbdx.Tests/Services/WindowControlService.cs

@@ -5,9 +5,9 @@ namespace Cbdx.Tests.Services
 {
     internal class WindowControlService : IWindowControlService
     {
-        private readonly Form _form;
+        private readonly TestForm _form;
 
-        public WindowControlService(Form form)
+        public WindowControlService(TestForm form)
         {
             _form = form;
         }
@@ -35,6 +35,12 @@ namespace Cbdx.Tests.Services
             else _form.Close();
         }
 
+        void IWindowControlService.Reload()
+        {
+            if (_form.InvokeRequired) _form.Invoke(new Action(() => _form.CreateOrReloadCefBrowserControl()));
+            else _form.CreateOrReloadCefBrowserControl();
+        }
+
         void IWindowControlService.DragMove()
         {
             if (_form.InvokeRequired)
@@ -61,4 +67,4 @@ namespace Cbdx.Tests.Services
         [System.Runtime.InteropServices.DllImportAttribute("user32.dll")]
         public static extern bool ReleaseCapture();
     }
-}
+}

+ 23 - 9
Cbdx.Tests/TestForm.Designer.cs

@@ -31,6 +31,7 @@
             this.MainToolStrip = new System.Windows.Forms.ToolStrip();
             this.F12ToolStripButton = new System.Windows.Forms.ToolStripButton();
             this.MainPanel = new System.Windows.Forms.Panel();
+            this.ReloadToolStripButton = new System.Windows.Forms.ToolStripButton();
             this.MainToolStrip.SuspendLayout();
             this.SuspendLayout();
             // 
@@ -38,10 +39,11 @@
             // 
             this.MainToolStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
             this.MainToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.ReloadToolStripButton,
             this.F12ToolStripButton});
             this.MainToolStrip.Location = new System.Drawing.Point(0, 0);
             this.MainToolStrip.Name = "MainToolStrip";
-            this.MainToolStrip.Size = new System.Drawing.Size(1336, 27);
+            this.MainToolStrip.Size = new System.Drawing.Size(1002, 25);
             this.MainToolStrip.TabIndex = 0;
             this.MainToolStrip.Text = "toolStrip1";
             // 
@@ -50,27 +52,38 @@
             this.F12ToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
             this.F12ToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
             this.F12ToolStripButton.Name = "F12ToolStripButton";
-            this.F12ToolStripButton.Size = new System.Drawing.Size(39, 24);
+            this.F12ToolStripButton.Size = new System.Drawing.Size(32, 22);
             this.F12ToolStripButton.Text = "F12";
             this.F12ToolStripButton.Click += new System.EventHandler(this.F12ToolStripButton_Click);
             // 
             // MainPanel
             // 
             this.MainPanel.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.MainPanel.Location = new System.Drawing.Point(0, 27);
+            this.MainPanel.Location = new System.Drawing.Point(0, 25);
+            this.MainPanel.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
             this.MainPanel.Name = "MainPanel";
-            this.MainPanel.Size = new System.Drawing.Size(1336, 649);
+            this.MainPanel.Size = new System.Drawing.Size(1002, 516);
             this.MainPanel.TabIndex = 1;
             // 
-            // DemoForm
+            // ReloadToolStripButton
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
+            this.ReloadToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
+            this.ReloadToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
+            this.ReloadToolStripButton.Name = "ReloadToolStripButton";
+            this.ReloadToolStripButton.Size = new System.Drawing.Size(53, 22);
+            this.ReloadToolStripButton.Text = "Reload";
+            this.ReloadToolStripButton.Click += new System.EventHandler(this.ReloadToolStripButton_Click);
+            // 
+            // TestForm
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(1336, 676);
+            this.ClientSize = new System.Drawing.Size(1002, 541);
             this.Controls.Add(this.MainPanel);
             this.Controls.Add(this.MainToolStrip);
-            this.Name = "DemoForm";
-            this.Text = "Form1";
+            this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+            this.Name = "TestForm";
+            this.Text = "Tests Form";
             this.Shown += new System.EventHandler(this.DemoForm_Shown);
             this.MainToolStrip.ResumeLayout(false);
             this.MainToolStrip.PerformLayout();
@@ -84,6 +97,7 @@
         private System.Windows.Forms.ToolStrip MainToolStrip;
         private System.Windows.Forms.ToolStripButton F12ToolStripButton;
         private System.Windows.Forms.Panel MainPanel;
+        private System.Windows.Forms.ToolStripButton ReloadToolStripButton;
     }
 }
 

+ 7 - 2
Cbdx.Tests/TestForm.cs

@@ -20,10 +20,10 @@ namespace Cbdx.Tests
 
         private void DemoForm_Shown(object sender, System.EventArgs e)
         {
-            CreateCefBrowserControl();
+            CreateOrReloadCefBrowserControl();
         }
 
-        private void CreateCefBrowserControl()
+        public void CreateOrReloadCefBrowserControl()
         {
             if (null != _browser)
             {
@@ -46,5 +46,10 @@ namespace Cbdx.Tests
         {
             _browser.ShowDevTools();
         }
+
+        private void ReloadToolStripButton_Click(object sender, System.EventArgs e)
+        {
+            CreateOrReloadCefBrowserControl();
+        }
     }
 }

+ 5 - 2
Cbdx.sln

@@ -1,7 +1,7 @@
 
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.28307.539
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.28803.352
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "@", "@", "{FDF3BEAD-34A7-4597-AFDE-2A6018883F5D}"
 	ProjectSection(SolutionItems) = preProject
@@ -25,6 +25,9 @@ EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cbdx.Tests.BridgeNet", "Cbdx.Tests.BridgeNet\Cbdx.Tests.BridgeNet.csproj", "{F1921674-67DD-4663-AA0E-30CFE94BA8E5}"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cbdx.Tests", "Cbdx.Tests\Cbdx.Tests.csproj", "{3A74365A-98AE-428A-8985-4944D464E666}"
+	ProjectSection(ProjectDependencies) = postProject
+		{F1921674-67DD-4663-AA0E-30CFE94BA8E5} = {F1921674-67DD-4663-AA0E-30CFE94BA8E5}
+	EndProjectSection
 EndProject
 Global
 	GlobalSection(SharedMSBuildProjectFiles) = preSolution