mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Javafx: Added tests for JavaFxColorProvider - check that the color component is in the range (EA-96689)
This commit is contained in:
+46
@@ -0,0 +1,46 @@
|
||||
package org.jetbrains.plugins.javaFX
|
||||
|
||||
import com.intellij.openapi.application.PluginPathManager
|
||||
import com.intellij.psi.PsiExpression
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.plugins.javaFX.fxml.AbstractJavaFXTestCase
|
||||
import org.jetbrains.plugins.javaFX.fxml.codeInsight.JavaFxColorProvider
|
||||
|
||||
/**
|
||||
* @author Pavel.Dolgov
|
||||
*/
|
||||
|
||||
class JavaFxColorProviderTest : AbstractJavaFXTestCase() {
|
||||
override fun getTestDataPath() = PluginPathManager.getPluginHomePath("javaFX") + "/testData/colorProvider"
|
||||
|
||||
fun testColor() = doTest()
|
||||
fun testColor2() = doTest(false)
|
||||
|
||||
fun testRgb() = doTest()
|
||||
fun testRgb2() = doTest(false)
|
||||
|
||||
fun testHsb() = doTest()
|
||||
fun testHsb2() = doTest(false)
|
||||
|
||||
|
||||
private fun doTest(isNotNull: Boolean = true) {
|
||||
myFixture.configureByFile(getTestName(false) + ".java")
|
||||
val carets = myFixture.editor.caretModel.allCarets
|
||||
for (caret in carets) {
|
||||
val element = myFixture.file.findElementAt(caret.offset)
|
||||
assertNotNull("Element at caret:$caret", element)
|
||||
|
||||
val expression = PsiTreeUtil.findFirstParent(element, { it?.parent !is PsiExpression }) as? PsiExpression
|
||||
assertNotNull("Expression at caret:${element?.text}", expression)
|
||||
|
||||
val type = expression?.type?.canonicalText
|
||||
assertEquals("Expression type:${expression?.text}", "javafx.scene.paint.Color", type)
|
||||
|
||||
val color = JavaFxColorProvider().getColorFrom(expression ?: return)
|
||||
if (isNotNull)
|
||||
assertNotNull("Color expected:${expression.text}", color)
|
||||
else
|
||||
assertNull("Color is not expected:${expression.text}", color)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import javafx.scene.paint.Color;
|
||||
import static javafx.scene.paint.Color.*;
|
||||
|
||||
public class Main {
|
||||
void foo() {
|
||||
Color color1 = <caret>new Color ( 0, 1, 0.5, 0.65);
|
||||
Color color2 = <caret>Color.color( 1L, 0, 1 );
|
||||
Color color3 = <caret>color (0.8, .3d, 0, 1);
|
||||
Color color4 = <caret>color ( 1, 0.6, 0.5f, 0);
|
||||
|
||||
Color gray1 = <caret>Color.gray( 0.5 );
|
||||
Color gray2 = <caret>Color.gray( 0L, 0.8);
|
||||
Color gray3 = <caret>gray ( 1d, 0);
|
||||
Color gray4 = <caret>gray (0.7f, 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import javafx.scene.paint.Color;
|
||||
import static javafx.scene.paint.Color.*;
|
||||
|
||||
public class Main {
|
||||
void foo() {
|
||||
Color color1 = <caret>new Color (null, 1, 0.5, 0.65);
|
||||
Color color2 = <caret>Color.color( 1L,-.01, 1 );
|
||||
Color color3 = <caret>color (0.8, .3d, 1.01, 1);
|
||||
Color color4 = <caret>color ( 1, 0.6, 0.5f, "s");
|
||||
|
||||
Color gray1 = <caret>Color.gray(int.class);
|
||||
Color gray2 = <caret>Color.gray( -1, 0.8);
|
||||
Color gray3 = <caret>gray ( 2, 0);
|
||||
Color gray4 = <caret>gray (0.7f, -1);
|
||||
Color gray5 = <caret>gray (0.7f, 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import javafx.scene.paint.Color;
|
||||
import static javafx.scene.paint.Color.*;
|
||||
|
||||
public class Main {
|
||||
void foo() {
|
||||
Color hsb1 = Color.<caret>hsb( 0, 1, 0.8);
|
||||
Color hsb2 = <caret>hsb( 0xF, 0, 1, .1/2);
|
||||
Color hsb3 = Color.<caret>hsb(-9.9, 0.6, 0, 1);
|
||||
Color hsb4 = <caret>hsb( 1, .2f, .6, 0);
|
||||
Color hsb5 = <caret>hsb(50*5, 0d, 0.3, 0.95);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import javafx.scene.paint.Color;
|
||||
import static javafx.scene.paint.Color.*;
|
||||
|
||||
public class Main {
|
||||
void foo() {
|
||||
Color hsb1 = Color.<caret>hsb(null, 1, 0.8);
|
||||
Color hsb2 = <caret>hsb( 0xF, 15, 1, .1/2);
|
||||
Color hsb3 = Color.<caret>hsb(-9.9, 0.6,-0.1, 1);
|
||||
Color hsb4 = <caret>hsb( 1, .2f, .6, 2);
|
||||
Color hsb5 = <caret>hsb(50*5, 0d, 0.3, -.95);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import javafx.scene.paint.Color;
|
||||
import static javafx.scene.paint.Color.*;
|
||||
|
||||
public class Main {
|
||||
void foo() {
|
||||
Color rgb1 = <caret>Color.rgb( 0, 255, (150) );
|
||||
Color rgb2 = <caret>rgb (150, 0, 255, 0.12);
|
||||
Color rgb3 = <caret>Color.rgb(0xF, 100, 0, 1d);
|
||||
Color rgb4 = <caret>rgb (255, 100, (int)'a', 0f);
|
||||
|
||||
Color grayRgb1 = <caret>Color.grayRgb(147 );
|
||||
Color grayRgb2 = <caret>grayRgb ( 0, 0.3+0.5);
|
||||
Color grayRgb3 = <caret>Color.grayRgb(255, 0);
|
||||
Color grayRgb4 = <caret>grayRgb (0xF, 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import javafx.scene.paint.Color;
|
||||
import static javafx.scene.paint.Color.*;
|
||||
|
||||
public class Main {
|
||||
void foo() {
|
||||
Color rgb1 = <caret>Color.rgb(500, 255, (150) );
|
||||
Color rgb2 = <caret>rgb (150, -1, 255, 0.12);
|
||||
Color rgb3 = <caret>Color.rgb(0xF, 100, 256, 1d);
|
||||
Color rgb4 = <caret>rgb (255, 100, (int)'a', -.1f);
|
||||
|
||||
Color grayRgb1 = <caret>Color.grayRgb(-147 );
|
||||
Color grayRgb2 = <caret>grayRgb ( 0, 0.3-0.5);
|
||||
Color grayRgb3 = <caret>Color.grayRgb(256, 0);
|
||||
Color grayRgb4 = <caret>grayRgb (0xF, 1.1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user