|
| 1 | +/* |
| 2 | + * Copyright (C) 2025 DiffPlug |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package com.diffplug.common.swt; |
| 17 | + |
| 18 | +import org.eclipse.jface.resource.ImageDescriptor; |
| 19 | +import org.eclipse.swt.SWT; |
| 20 | +import org.eclipse.swt.widgets.Composite; |
| 21 | +import org.eclipse.swt.widgets.Label; |
| 22 | +import org.junit.Test; |
| 23 | +import org.junit.experimental.categories.Category; |
| 24 | + |
| 25 | +@Category(InteractiveTest.class) |
| 26 | +public class Issue_2228 { |
| 27 | + @Test |
| 28 | + public void recreate() { |
| 29 | + // testCoat probably takes a title and a lambda that receives the parent Composite |
| 30 | + InteractiveTest.testCoat( |
| 31 | + "Show the difference between `.svg` and `@x2.png` rendering", |
| 32 | + (Composite parent) -> { |
| 33 | + // two-column grid |
| 34 | + Layouts.setGrid(parent).numColumns(2); |
| 35 | + |
| 36 | + // “.svg” label + image |
| 37 | + Label svgLabel = new Label(parent, SWT.NONE); |
| 38 | + svgLabel.setText(".svg"); |
| 39 | + |
| 40 | + Label svgImage = new Label(parent, SWT.NONE); |
| 41 | + ImageDescriptor svgDesc = ImageDescriptor.createFromFile( |
| 42 | + Issue_2228.class, "/issue_2228/strikethrough.svg"); |
| 43 | + svgImage.setImage(svgDesc.createImage()); |
| 44 | + |
| 45 | + // “.png” label + image |
| 46 | + Label pngLabel = new Label(parent, SWT.NONE); |
| 47 | + pngLabel.setText(".png"); |
| 48 | + |
| 49 | + Label pngImage = new Label(parent, SWT.NONE); |
| 50 | + ImageDescriptor pngDesc = ImageDescriptor.createFromFile( |
| 51 | + Issue_2228.class, "/issue_2228/strikethrough.png"); |
| 52 | + pngImage.setImage(pngDesc.createImage()); |
| 53 | + }); |
| 54 | + } |
| 55 | +} |
0 commit comments