Unnamed: 0 int64 0 305k | body stringlengths 7 52.9k | name stringlengths 1 185 |
|---|---|---|
272,400 | void (@NotNull Function<? super JBCefClient, Void> setProperty) { CountDownLatch latchBefore = new CountDownLatch(1); CountDownLatch latchAfter = new CountDownLatch(1); JBCefBrowser browser = new JBCefBrowser("chrome:version"); setProperty.apply(browser.getJBCefClient()); JBCefJSQuery jsQuery_before = JBCefJSQuery.create((JBCefBrowserBase)browser); jsQuery_before.addHandler(result -> { System.out.println("JBCefJSQuery [before] result: " + result); latchBefore.countDown(); return null; }); invokeAndWaitForLoad(browser, () -> { JFrame frame = new JFrame(JBCefLoadHtmlTest.class.getName()); frame.setSize(640, 480); frame.setLocationRelativeTo(null); frame.add(browser.getComponent(), BorderLayout.CENTER); frame.setVisible(true); }); JBCefJSQuery jsQuery_after = JBCefJSQuery.create((JBCefBrowserBase)browser); jsQuery_after.addHandler(result -> { System.out.println("JBCefJSQuery [after] result: " + result); latchAfter.countDown(); return null; }); invokeAndWaitForLatch(latchBefore, () -> { browser.getCefBrowser().executeJavaScript(jsQuery_before.inject("'query_before'"), "about:blank", 0); }); invokeAndWaitForLatch(latchAfter, () -> { browser.getCefBrowser().executeJavaScript(jsQuery_after.inject("'query_after'"), "about:blank", 0); }); } | test |
272,401 | void () { TestScaleHelper.assumeStandalone(); var proxySettings = System.getProperty("idea.test.proxy.settings"); assumeTrue("'idea.test.proxy.settings' not set", proxySettings != null); var matcher = Pattern.compile("(\\w+):([^@]+)@([^:]+):(\\d+)").matcher(proxySettings); // 'user:pass@host:port' assertTrue("cannot parse proxy settings: '" + proxySettings + "'", matcher.matches() && matcher.groupCount() == 4); var proxyPort = Integer.parseInt(matcher.group(4)); JBCefProxySettings.setTestInstance(true, false, false, false, null, matcher.group(3), proxyPort, null, true, matcher.group(1), matcher.group(2)); } | before |
272,402 | void () { TestScaleHelper.restoreSystemProperties(); } | after |
272,403 | void (CefBrowser browser, CefFrame frame, int httpStatusCode) { System.out.println("JBCefProxyTest.onLoadEnd: " + browser.getURL() + ", status: " + httpStatusCode); if (frame.getURL().contains(TEST_HOST)) { statusCode.set(httpStatusCode); latch.countDown(); } } | onLoadEnd |
272,404 | void (CefBrowser browser, CefFrame frame, ErrorCode errorCode, String errorText, String failedUrl) { System.out.println("JBCefProxyTest.onLoadError: " + failedUrl + ", error: " + errorText); } | onLoadError |
272,405 | void () { TestScaleHelper.assumeStandalone(); } | before |
272,406 | void () { TestScaleHelper.restoreSystemProperties(); } | after |
272,407 | void () { CountDownLatch latch = new CountDownLatch(1); JBCefBrowser jbCefBrowser = new JBCefBrowser("http://maps.google.com"); // heavy page jbCefBrowser.setErrorPage(JBCefBrowserBase.ErrorPage.DEFAULT); jbCefBrowser.getJBCefClient().addLoadHandler(new CefLoadHandlerAdapter() { @Override public void onLoadStart(CefBrowser browser, CefFrame frame, CefRequest.TransitionType transitionType) { System.out.println("JBCefLoadHtmlTest.onLoadStarted: " + browser.getURL()); if (browser.getURL().contains("google")) { // cancel loading and start another one jbCefBrowser.getCefBrowser().stopLoad(); jbCefBrowser.loadURL("chrome:version"); } } @Override public void onLoadEnd(CefBrowser browser, CefFrame frame, int httpStatusCode) { System.out.println("JBCefLoadHtmlTest.onLoadEnd: " + browser.getURL()); if (frame.getURL().contains("version")) { latch.countDown(); } } @Override public void onLoadError(CefBrowser browser, CefFrame frame, ErrorCode errorCode, String errorText, String failedUrl) { System.out.println("JBCefLoadHtmlTest.onLoadError: " + browser.getURL()); } }, jbCefBrowser.getCefBrowser()); invokeAndWaitForLoad(jbCefBrowser, () -> { JFrame frame = new JFrame(JBCefLoadHtmlTest.class.getName()); frame.setSize(640, 480); frame.setLocationRelativeTo(null); frame.add(jbCefBrowser.getComponent()); frame.setVisible(true); }); await(latch); assertThat(jbCefBrowser.getCefBrowser().getURL()).contains("version"); } | test |
272,408 | void (CefBrowser browser, CefFrame frame, CefRequest.TransitionType transitionType) { System.out.println("JBCefLoadHtmlTest.onLoadStarted: " + browser.getURL()); if (browser.getURL().contains("google")) { // cancel loading and start another one jbCefBrowser.getCefBrowser().stopLoad(); jbCefBrowser.loadURL("chrome:version"); } } | onLoadStart |
272,409 | void (CefBrowser browser, CefFrame frame, int httpStatusCode) { System.out.println("JBCefLoadHtmlTest.onLoadEnd: " + browser.getURL()); if (frame.getURL().contains("version")) { latch.countDown(); } } | onLoadEnd |
272,410 | void (CefBrowser browser, CefFrame frame, ErrorCode errorCode, String errorText, String failedUrl) { System.out.println("JBCefLoadHtmlTest.onLoadError: " + browser.getURL()); } | onLoadError |
272,411 | void () { TestScaleHelper.assumeStandalone(); } | before |
272,412 | void () { TestScaleHelper.restoreProperties(); } | after |
272,413 | void (CefBrowser browser, boolean isLoading, boolean canGoBack, boolean canGoForward) { System.out.println("JBCefLoadHtmlTest.onLoadingStateChange"); } | onLoadingStateChange |
272,414 | void (CefBrowser browser, CefFrame frame, CefRequest.TransitionType transitionType) { System.out.println("JBCefLoadHtmlTest.onLoadStart"); } | onLoadStart |
272,415 | void (CefBrowser browser, CefFrame frame, int httpStatusCode) { System.out.println("JBCefLoadHtmlTest.onLoadEnd"); } | onLoadEnd |
272,416 | void (CefBrowser browser, CefFrame frame, ErrorCode errorCode, String errorText, String failedUrl) { System.out.println("JBCefLoadHtmlTest.onLoadError"); } | onLoadError |
272,417 | void (WindowEvent e) { browser.loadHTML(HTML, HTML_URL); } | windowOpened |
272,418 | void () { TestScaleHelper.assumeStandalone(); TestScaleHelper.setSystemProperty("java.awt.headless", "false"); } | before |
272,419 | void () { TestScaleHelper.restoreProperties(); } | after |
272,420 | void () { new MyBrowser(); new MyBrowser(); } | test |
272,421 | void () { TestScaleHelper.assumeStandalone(); TestScaleHelper.setSystemProperty("ide.browser.jcef.jsQueryPoolSize", "1"); } | before |
272,422 | void () { TestScaleHelper.restoreProperties(); } | after |
272,423 | void () { JBCefJSQueryPoolSizePropTest.test(b -> null); } | test1 |
272,424 | void () { CategoryLineDataset<Double> dataset = LineDataset.of(-1.0, 0.0, 1.0, 2.0, 3.0); Iterable<Coordinates<Integer, Double>> data = dataset.getData(); Iterator<Coordinates<Integer, Double>> iterator = data.iterator(); Assert.assertTrue(data instanceof ArrayList); Assert.assertEquals(Coordinates.of(0, -1.0), iterator.next()); Assert.assertEquals(Coordinates.of(1, 0.0), iterator.next()); Assert.assertEquals(Coordinates.of(2, 1.0), iterator.next()); Assert.assertEquals(Coordinates.of(3, 2.0), iterator.next()); Assert.assertEquals(Coordinates.of(4, 3.0), iterator.next()); Assert.assertFalse(iterator.hasNext()); } | createCategoryDatasetTest |
272,425 | void () { Integer[] xs = {-1, 0, 1}; Double[] ys = {-100.0, 0.0, 100.0}; XYLineDataset<Integer, Double> dataset = LineDataset.of(xs, ys); Iterable<Coordinates<Integer, Double>> data = dataset.getData(); Iterator<Coordinates<Integer, Double>> iterator = data.iterator(); Assert.assertTrue(data instanceof ArrayList); Assert.assertEquals(Coordinates.of(-1, -100.0), iterator.next()); Assert.assertEquals(Coordinates.of(0, 0.0), iterator.next()); Assert.assertEquals(Coordinates.of(1, 100.0), iterator.next()); Assert.assertFalse(iterator.hasNext()); } | createXYDatasetTest |
272,426 | void () { CategoryLineChart<Double> chart = LineChart.of(1.0, 2.0, 3.0, 4.0, 5.0); CategoryLineDataset<Double> negativeValues = LineDataset.of(-1.0, -2.0, -3.0, -4.0, -5.0); chart.getDatasets().add(negativeValues); MinMax<Integer, Double> xy = chart.findMinMax(); Assert.assertEquals(2, chart.getDatasets().size()); Assert.assertTrue(chart.getComponent() instanceof JComponent); Assert.assertEquals(Integer.valueOf(0), xy.xMin); Assert.assertEquals(Integer.valueOf(4), xy.xMax); Assert.assertEquals(Double.valueOf(-5.0), xy.yMin); Assert.assertEquals(Double.valueOf(5.0), xy.yMax); } | fastCreateLineChartTest |
272,427 | void () { Double[] doubles = {1.0, 2.0, 3.0, 4.0, 5.0}; CategoryLineChart<Double> chart = LineChart.of(doubles); AtomicInteger counter = new AtomicInteger(); final Consumer<GridLine<Integer, Double, ?>> common = gridline -> { MinMax<Integer, Double> xy = gridline.getXY(); Assert.assertEquals(Integer.valueOf(0), xy.xMin); Assert.assertEquals(Integer.valueOf(4), xy.xMax); Assert.assertEquals(Double.valueOf(1.0), xy.yMin); Assert.assertEquals(Double.valueOf(5.0), xy.yMax); // mutations: xy.setXMin(-1); xy.setXMax(60000); xy.setYMin(-1.0); xy.setYMax(-60000.0); Assert.assertEquals(doubles[counter.getAndIncrement()], gridline.getValue()); }; chart.getGrid().setXPainter(gridline -> { Assert.assertEquals(Integer.valueOf(counter.getAndIncrement()), gridline.getValue()); common.consume(gridline); }); counter.set(0); chart.getGrid().setYPainter(gridline -> { Assert.assertEquals(doubles[counter.getAndIncrement()], gridline.getValue()); common.consume(gridline); }); } | gridLineChartTest |
272,428 | void () { XYLineDataset<Double, Double> maxValuesDataset = new XYLineDataset<>(); maxValuesDataset.setLabel("MAX VALUES"); XYLineDataset<Double, Double> minValuesDataset = new XYLineDataset<>(); minValuesDataset.setLabel("MIN VALUES"); XYLineChart<Double, Double> chart = LineChart.of(maxValuesDataset, minValuesDataset); Assert.assertFalse(chart.getDataset("MAX VALUES").getData().iterator().hasNext()); Assert.assertFalse(chart.getDataset("MIN VALUES").getData().iterator().hasNext()); for (int i = 1; i < 1000; i++) { chart.getDataset("MAX VALUES").add(Coordinates.of( Double.valueOf(i), Double.valueOf(i))); Assert.assertEquals(i, ((List<?>) chart.getDataset("MAX VALUES").getData()).size()); Assert.assertFalse(chart.getDataset("MIN VALUES").getData().iterator().hasNext()); } } | dynamicUpdateTest |
272,429 | void () { XYLineChart<Integer, Double> chart = LineChart.of(new XYLineDataset<>()); ChartUtils.generator(45).prepare(-360, 360).forEach(value -> { chart.getDataset().add(Coordinates.of(value, Math.sin(Math.toRadians(value)))); }); MinMax<Integer, Double> xy = chart.findMinMax(); Assert.assertEquals(Integer.valueOf(-360), xy.xMin); Assert.assertEquals(Integer.valueOf(360), xy.xMax); Iterator<Coordinates<Integer, Double>> iterator = chart.getDataset().getData().iterator(); for (int i = -360; i <= 360; i += 45) { Coordinates<Integer, Double> next = iterator.next(); Assert.assertEquals(Integer.valueOf(i), next.getX()); Assert.assertEquals(Double.valueOf(Math.sin(Math.toRadians(i))), next.getY()); } Assert.assertFalse(iterator.hasNext()); } | customGeneratorDataset |
272,430 | void () { super.test(); } | test |
272,431 | ScalableIcon (ScaleContext ctx, Icon... cellIcons) { LayeredIcon icon = new LayeredIcon(2); icon.setIcon(cellIcons[0], 0); icon.setIcon(cellIcons[1], 1, JBUIScale.scale(10), JBUIScale.scale(6)); return icon; } | createCompositeIcon |
272,432 | String (ScaleContext ctx) { return PlatformTestUtil.getPlatformTestDataPath() + "ui/gold_LayeredIcon@" + (int)ctx.getScale(PIX_SCALE) + "x.png"; } | getGoldImagePath |
272,433 | boolean () { return false; } | shouldSaveGoldImage |
272,434 | String[] () { String platformTestDataPath = PlatformTestUtil.getPlatformTestDataPath(); return new String[] { platformTestDataPath + "ui/db_set_breakpoint.png", platformTestDataPath + "ui/question_badge.png" }; } | getCellIconsPaths |
272,435 | void (float scale) { JBUIScale.setUserScaleFactor(scale); // 1) create unscaled EmptyIcon icon = EmptyIcon.create(SIZE); assertEquals(SIZE, icon.getIconWidth(), MSG); // 2) created scaled icon = EmptyIcon.create(JBUIScale.scale(SIZE)); assertEquals(JBUIScale.scale(SIZE), icon.getIconWidth(), MSG); // 3) create unscaled and then scale icon = JBUIScale.scaleIcon(EmptyIcon.create(SIZE)); assertEquals(JBUIScale.scale(SIZE), icon.getIconWidth(), MSG); // 4) create unscaled again icon = EmptyIcon.create(SIZE); assertEquals(SIZE, icon.getIconWidth(), MSG); } | test |
272,436 | String () { return PlatformTestUtil.getPlatformTestDataPath() + "ui/run.svg"; } | getSvgIconPath |
272,437 | Path () { return Path.of(PlatformTestUtil.getPlatformTestDataPath() + "ui/gold_run@2.4x.png"); } | getGoldImagePath |
272,438 | void (@NotNull Icon icon, @NotNull UserScaleContext iconUserContext) { //((ScaleContextAware)icon).updateScaleContext(iconUserContext); ScaleContext iconContext = ScaleContext.Companion.create(iconUserContext); /* * (A) normal conditions */ //noinspection UnnecessaryLocalVariable Icon iconA = icon; double usrSize2D = iconContext.apply(ICON_BASE_SIZE, EFF_USR_SCALE); int usrSize = (int)Math.round(usrSize2D); int devSize = (int)Math.round(iconContext.apply(usrSize2D, DEV_SCALE)); assertIcon(iconA, iconContext, usrSize, devSize, "Test (A) normal conditions"); /* * (C) scale icon */ Function<ScaleContext, Pair<Integer /*scaled user size*/, Integer /*scaled dev size*/>> calcScales = (ctx) -> { double scaledUsrSize2D = ctx.apply(ICON_BASE_SIZE, EFF_USR_SCALE); int scaledUsrSize = (int)Math.round(scaledUsrSize2D); int scaledDevSize = (int)Math.round(iconContext.apply(scaledUsrSize2D, DEV_SCALE)); return new Pair<>(scaledUsrSize, scaledDevSize); }; Icon iconC = IconUtil.scale(icon, null, ICON_OBJ_SCALE); assertThat(iconC).isNotSameAs(icon); //assertThat(((ScaleContextAware)icon).getScaleContext()).isEqualTo(iconContext); ScaleContext contextC = ScaleContext.create(OBJ_SCALE.of(ICON_OBJ_SCALE)); Pair<Integer, Integer> scales = calcScales.apply(contextC); assertIcon(iconC, contextC, scales.first, scales.second, "Test (C) scale icon"); // Additionally, check that the original image hasn't changed after scaling var pair = createImageAndGraphics(iconContext.getScale(DEV_SCALE), icon.getIconWidth(), icon.getIconHeight()); BufferedImage iconImage = pair.first; Graphics2D g2d = pair.second; icon.paintIcon(null, g2d, 0, 0); BufferedImage goldImage = loadImage(getIconPath(), iconContext); ImageComparator.compareAndAssert( new ImageComparator.AASmootherComparator(0.1, 0.1, new Color(0, 0, 0, 0)), goldImage, iconImage, null); /* * (D) scale icon in iconContext */ Consumer<Float> scaleInContext = scale -> { ScaleContext contextD = ScaleContext.create(OBJ_SCALE.of(scale)); Icon iconD = IconUtil.scale(icon, contextD); // the new instance is returned assertThat(iconD).isNotSameAs(icon); // the original icon's iconContext has not changed //assertThat(((ScaleContextAware)icon).getScaleContext()).isEqualTo(iconContext); Pair<Integer, Integer> _scales = calcScales.apply(contextD); assertIcon(iconD, contextD, _scales.first, _scales.second, "Test (D) scale icon in iconContext"); }; scaleInContext.accept(1f); scaleInContext.accept(1.5f); } | test |
272,439 | void (@NotNull Icon icon, @Nullable ScaleContext ctx, int usrSize, int devSize, @NotNull String testDescription) { assertThat(icon.getIconWidth()).describedAs(testDescription + ": unexpected icon user width").isEqualTo(usrSize); assertThat(icon.getIconHeight()).describedAs(testDescription + ": unexpected icon user height").isEqualTo(usrSize); Image image = IconLoader.toImage(icon, ctx); assertThat(ImageUtil.getRealWidth(image)).describedAs(testDescription + ": unexpected icon real width").isEqualTo(devSize); assertThat(ImageUtil.getRealHeight(image)).describedAs(testDescription + ": unexpected icon real height").isEqualTo(devSize); } | assertIcon |
272,440 | Path () { return Path.of(PlatformTestUtil.getPlatformTestDataPath() + "ui/abstractClass.svg"); } | getIconPath |
272,441 | void (BufferedImage bi, int x, int y) { Color dstColor = new Color(bi.getRGB(x, y)); assertEquals("color mismatch at [" + x + ", " + y + "]", expectedColor, dstColor); } | test |
272,442 | void () { for (double scale : new double[] {1, 2, 2.5}) { overrideJreHiDPIEnabled(true); JBUIScale.setUserScaleFactor((float)1); test(scale); overrideJreHiDPIEnabled(false); JBUIScale.setUserScaleFactor((float)scale); test(scale); } } | test |
272,443 | void (double scale) { source = RetinaImage.createFrom(supplyImage(scale, IMAGE_SIZE, IMAGE_SIZE, IMAGE_QUARTER_COLORS, false).first, JreHiDpiUtil.isJreHiDPIEnabled() ? scale : 1, null); // // 1) draw one to one // TestColor[] colors = new TestColor[] { new TestColor(0, 0), new TestColor(1, 0), new TestColor(0, 1), new TestColor(1, 1), }; testDrawImage(dest = new Dest(scale), bounds(), bounds(), colors); testDrawImage(dest = new Dest(scale), null, bounds(), colors); testDrawImage(dest = new Dest(scale), bounds(), null, colors); testDrawImage(dest = new Dest(scale), null, null, colors); testDrawImage(dest = new Dest(scale), new Rectangle(0, 0, -1, -1), new Rectangle(0, 0, -1, -1), colors); // // 2) scale the 4th quarter to the whole dest // colors = new TestColor[] { new TestColor(IMAGE_QUARTER_COLORS[3], 0, 0), new TestColor(IMAGE_QUARTER_COLORS[3], 1, 0), new TestColor(IMAGE_QUARTER_COLORS[3], 0, 1), new TestColor(IMAGE_QUARTER_COLORS[3], 1, 1), }; testDrawImage(dest = new Dest(scale), new Rectangle(0, 0, -1, -1), new Rectangle(JBUIScale.scale(IMAGE_QUARTER_SIZE), JBUIScale.scale(IMAGE_QUARTER_SIZE), -1, -1), colors); // // 3) draw random quarter to random quarter, all the rest quarter colors should remain DEST_SURFACE_COLOR // colors = new TestColor[] { new TestColor(DEST_SURFACE_COLOR, 0, 0), new TestColor(DEST_SURFACE_COLOR, 1, 0), new TestColor(DEST_SURFACE_COLOR, 0, 1), new TestColor(DEST_SURFACE_COLOR, 1, 1), }; int srcCol = (int)floor(Math.random() + 0.5); int srcRow = (int)floor(Math.random() + 0.5); int dstCol = (int)floor(Math.random() + 0.5); int dstRow = (int)floor(Math.random() + 0.5); colors[dstRow * 2 + dstCol] = new TestColor(srcCol, srcRow, dstCol, dstRow); // replace the random quarter testDrawImage(dest = new Dest(scale), bounds(dstCol, dstRow), bounds(srcCol, srcRow), colors); } | test |
272,444 | void (Dest dest, Rectangle dstBounds, Rectangle srcBounds, TestColor[] testColors) { UIUtil.drawImage(dest.gr, source, dstBounds, srcBounds, null); for (TestColor t : testColors) t.test(); dest.dispose(); } | testDrawImage |
272,445 | Rectangle () { return bounds(0, 0, JBUIScale.scale(IMAGE_SIZE)); } | bounds |
272,446 | Rectangle (int col, int row) { return bounds(col, row, JBUIScale.scale(IMAGE_QUARTER_SIZE)); } | bounds |
272,447 | Rectangle (int col, int row, int size) { return new Rectangle(col * size, row * size, size, size); } | bounds |
272,448 | void () { JBUIScale.setUserScaleFactor((float)1); JBValue value1 = JBUI.value(2); JBValue value2 = JBUI.value(2.6f); JBValue value3 = JBUI.value(2.9f); JBUIScale.setUserScaleFactor((float)2); assertEquals(JBUIScale.scale(2), value1.get()); assertEquals(Math.round(JBUIScale.scale(2.6f)), value2.get()); assertEquals(JBUIScale.scale(2.6f), value2.getFloat()); assertEquals((int)Math.ceil(JBUIScale.scale(2.6f)), value2.get(RoundingMode.CEIL)); assertEquals((int)Math.floor(JBUIScale.scale(2.6f)), value3.get(RoundingMode.FLOOR)); } | testSeparateValue |
272,449 | void () { JBUIScale.setUserScaleFactor((float)1); JBValueGroup group = new JBValueGroup(); JBValue value1 = group.value(1); JBValue value2 = group.value(2); JBValue value3 = group.value(3.6f); JBUIScale.setUserScaleFactor((float)2); assertEquals(JBUIScale.scale(1), value1.get()); assertEquals(JBUIScale.scale(2), value2.get()); assertEquals(Math.round(JBUIScale.scale(3.6f)), value3.get()); assertEquals(JBUIScale.scale(3.6f), value3.getFloat()); group.dispose(); int scale = JBUIScale.scale(1); JBUIScale.setUserScaleFactor((float)1); assertEquals(scale, value1.get()); assertEquals(scale * 2, value2.get()); assertEquals(Math.round(scale * 3.6f), value3.get()); assertEquals(scale * 3.6f, value3.getFloat()); } | testGroup |
272,450 | void () { JBUIScale.setUserScaleFactor((float)1); String key = "JBValue.int"; String absentKey = "JBValue.absent"; UIManager.put(key, 2); JBValue value1 = JBUI.uiIntValue(key, 1); JBValue value2 = JBUI.uiIntValue(absentKey, 1); JBUIScale.setUserScaleFactor((float)2); assertEquals(JBUIScale.scale(2), value1.get()); assertEquals(JBUIScale.scale(1), value2.get()); UIManager.put(key, 3); assertEquals(JBUIScale.scale(3), value1.get()); UIManager.put(key, null); } | testUIInteger |
272,451 | void () { super.test(); } | test |
272,452 | ScalableIcon (ScaleContext ctx, Icon... cellIcons) { return (ScalableIcon)IconUtil.textToIcon(TEXT, TestScaleHelper.createComponent(ctx), JBUIScale.scale(FONT_SIZE)); } | createCompositeIcon |
272,453 | void (ScaleContext ctx) { // The test may depend on a physical font which may vary b/w platforms. By this reason, there's a preset map // b/w ScaleContext's and the tested string with. If the font on this platform doesn't fit the preset, // then the test silently interrupts. Font font = JBFont.create(JBFont.label().deriveFont((float)ctx.apply(FONT_SIZE, DerivedScaleType.EFF_USR_SCALE))); int width = TestScaleHelper.createComponent(ctx).getFontMetrics(font).stringWidth(TEXT); assumeTrue(CTX_TO_SIZE.containsKey(ctx), "unexpected ScaleContext: " + ctx); assumeTrue(CTX_TO_SIZE.get(ctx) == width, "unexpected text width: " + width); } | assume |
272,454 | String (ScaleContext ctx) { int usrScale = (int)(ctx.apply(1, DerivedScaleType.EFF_USR_SCALE)); int sysScale = (int)(ctx.getScale(ScaleType.SYS_SCALE)); return PlatformTestUtil.getPlatformTestDataPath() + "ui/gold_TextIcon@" + usrScale + "x" + sysScale + "x.png"; } | getGoldImagePath |
272,455 | boolean () { return false; } | shouldSaveGoldImage |
272,456 | String[] () { return ArrayUtil.EMPTY_STRING_ARRAY; // just pretends to be composite } | getCellIconsPaths |
272,457 | void () { final ScaleContext origContext = ScaleContext.create(); Consumer<ScaleType> test = type -> { double overriddenScale = origContext.getScale(type) + 1; origContext.overrideScale(type.of(overriddenScale)); // Test (A) 'setScale' origContext.setScale(type.of(overriddenScale + 1)); assertThat(origContext.getScale(type)). describedAs("overridden scale is not preserved on 'ScaleContext.setScale': " + type). isEqualTo(overriddenScale); // Test (B) 'copy' ScaleContext contextCopy = origContext.copy(); assertThat(contextCopy).isNotSameAs(origContext); assertContext(origContext, contextCopy); contextCopy.setScale(type.of(overriddenScale + 1)); assertThat(contextCopy.getScale(type)). describedAs("overridden scale is not preserved on 'ScaleContext.copy': " + type). isEqualTo(overriddenScale); }; test.accept(USR_SCALE); test.accept(SYS_SCALE); test.accept(OBJ_SCALE); } | testOverrideScale |
272,458 | void (@NotNull ScaleContext context1, @NotNull ScaleContext context2) { Consumer<ScaleType> test = type -> { assertThat(context1.getScale(type)). describedAs("the scale type: " + type). isEqualTo(context2.getScale(type)); }; test.accept(USR_SCALE); test.accept(SYS_SCALE); test.accept(OBJ_SCALE); } | assertContext |
272,459 | void () { super.test(); } | test |
272,460 | ScalableIcon (ScaleContext ctx, Icon... cellIcons) { return new OffsetIcon(cellIcons[0].getIconWidth(), cellIcons[0]); } | createCompositeIcon |
272,461 | String (ScaleContext ctx) { return PlatformTestUtil.getPlatformTestDataPath() + "ui/gold_OffsetIcon@" + (int)ctx.getScale(DerivedScaleType.PIX_SCALE) + "x.png"; } | getGoldImagePath |
272,462 | boolean () { return false; } | shouldSaveGoldImage |
272,463 | String[] () { return new String[] { PlatformTestUtil.getPlatformTestDataPath() + "ui/db_set_breakpoint.png" }; } | getCellIconsPaths |
272,464 | ScalableIcon (ScaleContext ctx, Icon... cellIcons) { RowIcon icon = new RowIcon(2); icon.setIcon(cellIcons[0], 0); icon.setIcon(cellIcons[1], 1); return icon; } | createCompositeIcon |
272,465 | String (ScaleContext ctx) { return PlatformTestUtil.getPlatformTestDataPath() + "ui/gold_RowIcon@" + (int)ctx.getScale(PIX_SCALE) + "x.png"; } | getGoldImagePath |
272,466 | void () { overrideJreHiDPIEnabled(true); BiFunction<Integer, Integer, Integer> bit2scale = (mask, bit) -> ((mask >> bit) & 0x1) + 1; for (int mask = 0; mask < 7; mask++) { int iconScale = bit2scale.apply(mask, 2); int usrScale = bit2scale.apply(mask, 1); int sysScale = bit2scale.apply(mask, 0); assert iconScale * usrScale * sysScale <= 4; test(ScaleContext.Companion.of(new Scale[]{SYS_SCALE.of(sysScale), USR_SCALE.of(usrScale), OBJ_SCALE.of(iconScale)})); } } | test |
272,467 | void (final ScaleContext ctx) { assume(ctx); JBUIScale.setUserScaleFactor((float)ctx.getScale(USR_SCALE)); ScaleContext ctx_noObjScale = ctx.copy(); ctx_noObjScale.setScale(OBJ_SCALE.of(1)); String[] cellIconsPaths = getCellIconsPaths(); int count = cellIconsPaths.length; CachedImageIcon[] cellIcons = new CachedImageIcon[count]; for (int i = 0; i < count; i++) { cellIcons[i] = CachedImageIconKt.createCachedIcon(Path.of(cellIconsPaths[i]), ctx_noObjScale); } Icon scaledIcon = createCompositeIcon(ctx_noObjScale, cellIcons).scale((float)ctx.getScale(OBJ_SCALE)); test(scaledIcon, ctx); } | test |
272,468 | void (Icon icon, ScaleContext ctx) { Pair<BufferedImage, Graphics2D> pair = createImageAndGraphics(ctx.getScale(SYS_SCALE), icon.getIconWidth(), icon.getIconHeight()); BufferedImage iconImage = pair.first; Graphics2D g2d = pair.second; icon.paintIcon(null, g2d, 0, 0); if (shouldSaveGoldImage()) { saveImage(iconImage, getGoldImagePath(ctx)); } BufferedImage goldImage = loadImage(Path.of(getGoldImagePath(ctx))); ImageComparator.compareAndAssert( new ImageComparator.AASmootherComparator(0.1, 0.1, new Color(0, 0, 0, 0)), goldImage, iconImage, null); } | test |
272,469 | void (ScaleContext ctx) { } | assume |
272,470 | void () { } | beforeClass |
272,471 | String () { return PlatformTestUtil.getPlatformTestDataPath() + "ui/abstractClass.svg"; } | getSvgIconPath |
272,472 | Path () { return Path.of(PlatformTestUtil.getPlatformTestDataPath() + "ui/gold_abstractClass@2x.png"); } | getGoldImagePath |
272,473 | void (float userScale) { JBUIScale.setUserScaleFactor(userScale); test(ScaleContext.create(ScaleType.SYS_SCALE.of(2))); test(ScaleContext.create(ScaleType.SYS_SCALE.of(3))); } | test |
272,474 | void (ScaleContext ctx) { System.out.println("ScaleContext: " + ctx); BufferedImage image = TestScaleHelper.loadImage(Path.of(PlatformTestUtil.getPlatformTestDataPath() + "ui/myIcon_20x10_dataScaled@2x.svg"), ctx); assertNotNull(image); double scale = ctx.getScale(DerivedScaleType.PIX_SCALE) / 2 /* count the icon's @2x format */; assertEquals("wrong image width", PaintUtil.RoundingMode.ROUND.round(20 * scale), image.getWidth()); assertEquals("wrong image height", PaintUtil.RoundingMode.ROUND.round(10 * scale), image.getHeight()); } | test |
272,475 | void () { overrideJreHiDPIEnabled(true); @SuppressWarnings("UndesirableClassUsage") Graphics2D g = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB).createGraphics(); try { g.scale(2, 2); assertTrue(PaintUtil.getParityMode(1, g).even()); assertTrue(PaintUtil.getParityMode(1.1, ScaleContext.create(g), null).even()); assertTrue(PaintUtil.getParityMode(1.1, ScaleContext.create(g), RoundingMode.FLOOR).even()); assertTrue(PaintUtil.getParityMode(1.1, ScaleContext.create(g), RoundingMode.ROUND).even()); assertTrue(!PaintUtil.getParityMode(1.1, ScaleContext.create(g), RoundingMode.CEIL).even()); assertEquals(1.0, PaintUtil.alignToInt(1, g, (RoundingMode)null)); assertEquals(1.0, PaintUtil.alignToInt(1, g, (ParityMode)null)); assertEquals(1.0, PaintUtil.alignToInt(1.1, g, RoundingMode.FLOOR)); assertEquals(1.0, PaintUtil.alignToInt(1.1, g, RoundingMode.ROUND)); assertEquals(1.5, PaintUtil.alignToInt(1.1, g, RoundingMode.CEIL)); assertEquals(1.5, PaintUtil.alignToInt(1.1, ScaleContext.create(g), null, ParityMode.ODD)); assertEquals(1.5, PaintUtil.alignToInt(1.1, ScaleContext.create(g), RoundingMode.ROUND, ParityMode.ODD)); assertEquals(0.5, PaintUtil.alignToInt(1.1, ScaleContext.create(g), RoundingMode.FLOOR, ParityMode.ODD)); assertEquals(1.5, PaintUtil.alignToInt(1.1, ScaleContext.create(g), RoundingMode.CEIL, ParityMode.ODD)); assertEquals(1.0, PaintUtil.alignToInt(1.1, ScaleContext.create(g), null, ParityMode.EVEN)); assertEquals(1.0, PaintUtil.alignToInt(1.1, ScaleContext.create(g), RoundingMode.ROUND, ParityMode.EVEN)); assertEquals(1.0, PaintUtil.alignToInt(1.1, ScaleContext.create(g), RoundingMode.FLOOR, ParityMode.EVEN)); assertEquals(2.0, PaintUtil.alignToInt(1.1, ScaleContext.create(g), RoundingMode.CEIL, ParityMode.EVEN)); } finally { g.dispose(); } } | test |
272,476 | void () { ImageComparator comparator = new ImageComparator( new AASmootherComparator(0.15, 0.5, Color.BLACK)); // 1) IDE-HiDPI for (int scale : getScales()) testGolden(comparator, scale, false); // 2) JRE-HiDPI for (int scale : getScales()) testGolden(comparator, scale, true); // 3) Boundary values supplyGraphics(2, 10, 10, this::testBoundaries); } | testGoldenImages |
272,477 | void (ImageComparator comparator, int scale, boolean jreHiDPIEnabled) { overrideJreHiDPIEnabled(jreHiDPIEnabled); float scale1 = jreHiDPIEnabled ? 1 : scale; JBUIScale.setUserScaleFactor(scale1); BufferedImage image = supplyGraphics(scale, getImageSize().width, getImageSize().height, this::paint); //saveImage(image, getGoldenImagePath(scale)); // uncomment to recreate golden image compare(image, loadImage(getGoldenImagePath(scale)), comparator, scale); } | testGolden |
272,478 | BufferedImage (double scale, int width, int height, Function<? super Graphics2D, Void> consumeGraphics) { @SuppressWarnings("UndesirableClassUsage") BufferedImage image = new BufferedImage((int)ceil(width * scale), (int)ceil(height * scale), BufferedImage.TYPE_INT_ARGB); Graphics2D g = image.createGraphics(); try { double gScale = JreHiDpiUtil.isJreHiDPIEnabled() ? scale : 1; g.scale(gScale, gScale); g.setColor(Color.white); g.fillRect(0, 0, image.getWidth(), image.getHeight()); g.setColor(Color.black); consumeGraphics.apply(g); return image; } finally { g.dispose(); } } | supplyGraphics |
272,479 | Void (Graphics2D g) { double[][] values = { {0, 0, 0, 0}, {Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE}, {-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE}, }; for (double[] v : values) paintBoundaries(g, v); return null; } | testBoundaries |
272,480 | void (BufferedImage img1, BufferedImage img2, ImageComparator comparator, double scale) { comparator.compareAndAssert(img1, img2, "images mismatch: JreHiDPIEnabled=" + JreHiDpiUtil.isJreHiDPIEnabled() + "; scale=" + scale + "; "); } | compare |
272,481 | Path (int scale) { return Path.of(PlatformTestUtil.getPlatformTestDataPath() + "ui/paint/" + getGoldenImageName() + (scale > 1 && JreHiDpiUtil.isJreHiDPIEnabled() ? "_hd@" : "@") + scale + "x.png"); } | getGoldenImagePath |
272,482 | boolean (int argb1, int argb2) { if (argb1 == argb2) return true; if (argb1 == backgroundRGB || argb2 == backgroundRGB) { return dist(argb1, argb2) <= backgroundColorsDist; } return dist(argb1, argb2) <= inputColorsDist; } | compare |
272,483 | double (int argb1, int argb2) { double[] comp = diff(argb1, argb2); // normalize dist to [0..1] return Math.sqrt((comp[0] * comp[0] + comp[1] * comp[1] + comp[2] * comp[2] + comp[3] * comp[3]) / comp.length); } | dist |
272,484 | double[] (int argb1, int argb2) { double a1 = a(argb1); double a2 = a(argb2); return new double[] { Math.abs(a1 * a1 - a2 * a2), Math.abs(r(argb1) * a1 - r(argb2) * a2), Math.abs(g(argb1) * a1 - g(argb2) * a2), Math.abs(b(argb1) * a1 - b(argb2) * a2) }; } | diff |
272,485 | double (int argb) { return ((argb >> 24) & 0xFF) / 255d; } | a |
272,486 | double (int argb) { return ((argb >> 16) & 0xFF) / 255d; } | r |
272,487 | double (int argb) { return ((argb >> 8) & 0xFF) / 255d; } | g |
272,488 | double (int argb) { return (argb & 0xFF) / 255d; } | b |
272,489 | void (@Nullable ColorComparator colorComparator, @NotNull Image img1, @NotNull Image img2, @Nullable String errMsgPrefix) { new ImageComparator(colorComparator).compareAndAssert(img1, img2, errMsgPrefix); } | compareAndAssert |
272,490 | void (@NotNull Image img1, @NotNull Image img2, @Nullable String errMsgPrefix) { StringBuilder sb = new StringBuilder(errMsgPrefix == null ? "images mismatch: " : errMsgPrefix); if (!compare(img1, img2, sb)) { throw new AssertionError(sb.toString()); } } | compareAndAssert |
272,491 | boolean (@NotNull Image img1, @NotNull Image img2, @Nullable /*OUT*/StringBuilder reason) { int[] d1 = getArgbData(img1); int[] d2 = getArgbData(img2); if (d1.length != d2.length) { if (reason != null) //noinspection StringConcatenationInsideStringBufferAppend reason.append("size mismatch: " + "[" + img1.getWidth(null) + "x" + img1.getHeight(null) + "] vs " + "[" + img2.getWidth(null) + "x" + img2.getHeight(null) + "]"); return false; } for (int i = 0; i < d1.length; i++) { if (!colorComparator.compare(d1[i], d2[i])) { int y = i / img1.getWidth(null); int x = i - y * img1.getWidth(null); if (reason != null) //noinspection StringConcatenationInsideStringBufferAppend reason.append("colors differ at [" + x + "," + y + "]; " + "0x" + Integer.toHexString(d1[i]) + " vs 0x" + Integer.toHexString(d2[i])); return false; } } return true; } | compare |
272,492 | int[] (@NotNull Image image) { DataBuffer buffer = image instanceof BufferedImage ? ((BufferedImage)image).getRaster().getDataBuffer() : null; if (buffer instanceof DataBufferInt) { return ((DataBufferInt)buffer).getData(); } else { @SuppressWarnings("UndesirableClassUsage") BufferedImage convertedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); convertedImage.getGraphics().drawImage(image, 0, 0, null); return getArgbData(convertedImage); } } | getArgbData |
272,493 | void () { super.testGoldenImages(); } | testGoldenImages |
272,494 | void () { JBUIScale.setUserScaleFactor((float)1); overrideJreHiDPIEnabled(false); supplyGraphics(1, 1, 1, LinePainter2DTest::testAlign); overrideJreHiDPIEnabled(true); supplyGraphics(2, 1, 1, LinePainter2DTest::testAlign); } | testAlign |
272,495 | Void (Graphics2D g) { double scale = ScaleContext.create(g).getScale(PIX_SCALE); String msg = "LinePainter2D.align is incorrect (JreHiDPIEnabled: " + JreHiDpiUtil.isJreHiDPIEnabled() + "; scale: " + scale + ")"; double delta = 0.000001; boolean jhd = JreHiDpiUtil.isJreHiDPIEnabled(); // HORIZONTAL Line2D line = LinePainter2D.align(g, EnumSet.of(Align.CENTER_X, Align.CENTER_Y), 2.5, 2.5, 5, false, StrokeType.CENTERED, 1); TestCase.assertEquals(msg, 0, line.getX1(), delta); TestCase.assertEquals(msg, 2, line.getY1(), delta); TestCase.assertEquals(msg, 4, line.getX2(), delta); TestCase.assertEquals(msg, 2, line.getY2(), delta); line = LinePainter2D.align(g, EnumSet.of(Align.CENTER_X, Align.CENTER_Y), 2.5, 2, 5, false, StrokeType.CENTERED, 2); TestCase.assertEquals(msg, 0, line.getX1(), delta); TestCase.assertEquals(msg, jhd ? 1.5 : 2, line.getY1(), delta); TestCase.assertEquals(msg, 4, line.getX2(), delta); TestCase.assertEquals(msg, jhd ? 1.5 : 2, line.getY2(), delta); line = LinePainter2D.align(g, EnumSet.of(Align.CENTER_X, Align.CENTER_Y), 3, 1.5, 6, false, StrokeType.CENTERED, 3); TestCase.assertEquals(msg, 0, line.getX1(), delta); TestCase.assertEquals(msg, 1, line.getY1(), delta); TestCase.assertEquals(msg, 5, line.getX2(), delta); TestCase.assertEquals(msg, 1, line.getY2(), delta); // VERTICAL line = LinePainter2D.align(g, EnumSet.of(Align.CENTER_X, Align.CENTER_Y), 2.5, 2.5, 5, true, StrokeType.CENTERED, 1); TestCase.assertEquals(msg, 2, line.getX1(), delta); TestCase.assertEquals(msg, 0, line.getY1(), delta); TestCase.assertEquals(msg, 2, line.getX2(), delta); TestCase.assertEquals(msg, 4, line.getY2(), delta); line = LinePainter2D.align(g, EnumSet.of(Align.CENTER_X, Align.CENTER_Y), 2, 2.5, 5, true, StrokeType.CENTERED, 2); TestCase.assertEquals(msg, jhd ? 1.5 : 2, line.getX1(), delta); TestCase.assertEquals(msg, 0, line.getY1(), delta); TestCase.assertEquals(msg, jhd ? 1.5 : 2, line.getX2(), delta); TestCase.assertEquals(msg, 4, line.getY2(), delta); line = LinePainter2D.align(g, EnumSet.of(Align.CENTER_X, Align.CENTER_Y), 1.5, 3, 6, true, StrokeType.CENTERED, 3); TestCase.assertEquals(msg, 1, line.getX1(), delta); TestCase.assertEquals(msg, 0, line.getY1(), delta); TestCase.assertEquals(msg, 1, line.getX2(), delta); TestCase.assertEquals(msg, 5, line.getY2(), delta); return null; } | testAlign |
272,496 | Void (Graphics2D g) { paintLines(g, StrokeType.CENTERED, LINE_LEN + 2, LINE_LEN + 2); paintLines(g, StrokeType.CENTERED_CAPS_SQUARE, LINE_LEN * 2 + 2, 0); paintLines(g, StrokeType.INSIDE, LINE_LEN * 2 + 2, 0); paintLines(g, StrokeType.OUTSIDE, LINE_LEN * 2 + 2, 0); return null; } | paint |
272,497 | void (Graphics2D g, StrokeType type, float trX, float trY) { g.translate(JBUIScale.scale(trX), JBUIScale.scale(trY)); Object aa = RenderingHints.VALUE_ANTIALIAS_ON; paintLine(g, 0, 0, 0, 0, type, 1, aa); // a dot paintLine(g, 0, -2, 0, -LINE_LEN, type, 1, aa); paintLine(g, 2, -2, LINE_LEN, -LINE_LEN, type, 1, aa); paintLine(g, 2, 0, LINE_LEN, 0, type, 1, aa); paintLine(g, 2, 2, LINE_LEN, LINE_LEN, type, 1, aa); paintLine(g, 0, 2, 0, LINE_LEN, type, 1, aa); paintLine(g, -2, 2, -LINE_LEN, LINE_LEN, type, 1, aa); paintLine(g, -2, 0, -LINE_LEN, 0, type, 1, aa); paintLine(g, -2, -2, -LINE_LEN, -LINE_LEN, type, 1, aa); } | paintLines |
272,498 | void (Graphics2D g, double x1, double y1, double x2, double y2, StrokeType strokeType, double strokeWidth, Object valueAA) { strokeWidth = JBUIScale.scale((float)strokeWidth); x1 = JBUIScale.scale((float)x1); y1 = JBUIScale.scale((float)y1); x2 = JBUIScale.scale((float)x2); y2 = JBUIScale.scale((float)y2); LinePainter2D.paint(g, x1, y1, x2, y2, strokeType, strokeWidth, valueAA); } | paintLine |
272,499 | void (Graphics2D g, double[] values) { LinePainter2D.paint(g, values[0], values[1], values[2], values[3]); } | paintBoundaries |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.