13
13
*******************************************************************************/
14
14
package org .eclipse .ui .tests .browser .internal ;
15
15
16
+ import static org .junit .Assert .assertEquals ;
17
+
16
18
import java .net .URL ;
17
19
20
+ import org .eclipse .swt .SWT ;
21
+ import org .eclipse .swt .widgets .Composite ;
18
22
import org .eclipse .swt .widgets .Display ;
19
23
import org .eclipse .swt .widgets .Shell ;
20
24
import org .eclipse .ui .PlatformUI ;
21
25
import org .eclipse .ui .browser .IWebBrowser ;
22
26
import org .eclipse .ui .browser .IWorkbenchBrowserSupport ;
27
+ import org .eclipse .ui .internal .browser .BrowserViewer ;
23
28
import org .eclipse .ui .internal .browser .WebBrowserPreference ;
24
29
import org .junit .Test ;
25
30
@@ -68,4 +73,42 @@ public void run() {
68
73
Display display = Display .getCurrent ();
69
74
while (!exit [0 ] && !shell .isDisposed ()) if (!display .readAndDispatch ()) display .sleep ();
70
75
}
76
+
77
+ @ Test
78
+ public void testDefaultBrowserStyle () {
79
+ class TestBrowserViewer extends BrowserViewer {
80
+ public TestBrowserViewer (Composite parent , int style ) {
81
+ super (parent , style );
82
+ }
83
+
84
+ @ Override
85
+ protected int getBrowserStyle () {
86
+ return super .getBrowserStyle ();
87
+ }
88
+ }
89
+
90
+ TestBrowserViewer browserViewer = new TestBrowserViewer (shell , SWT .NONE );
91
+ int browserStyle = browserViewer .getBrowserStyle ();
92
+ // Assert: Verify the returned style is SWT.NONE
93
+ assertEquals ("The default browser style should be SWT.NONE" , SWT .NONE , browserStyle );
94
+ }
95
+
96
+ @ Test
97
+ public void testCustomBrowserStyle () {
98
+ class CustomBrowserViewer extends BrowserViewer {
99
+ public CustomBrowserViewer (Composite parent , int style ) {
100
+ super (parent , style );
101
+ }
102
+
103
+ @ Override
104
+ protected int getBrowserStyle () {
105
+ return SWT .EDGE ; // Custom style
106
+ }
107
+ }
108
+
109
+ CustomBrowserViewer customBrowserViewer = new CustomBrowserViewer (shell , SWT .NONE );
110
+ int browserStyle = customBrowserViewer .getBrowserStyle ();
111
+ // Assert: Verify the returned style is SWT.EDGE
112
+ assertEquals ("The custom browser style should be SWT.EDGE" , SWT .EDGE , browserStyle );
113
+ }
71
114
}
0 commit comments