Split default action tests in language-specific parts

GitOrigin-RevId: 4bcaf8c390fae1f20aa7c70fe78af95f57ab5ea8
This commit is contained in:
Dmitry Jemerov
2022-05-16 14:00:40 +02:00
committed by intellij-monorepo-bot
parent eedeaadc79
commit b231892391
125 changed files with 825 additions and 30 deletions

View File

@@ -0,0 +1,3 @@
class A {
private int[][] data = new int[][] {<caret>}
}

View File

@@ -0,0 +1,3 @@
class Foo {
int[] a = <caret>
}

View File

@@ -0,0 +1,3 @@
class Foo {
int[] a = {<caret>}
}

View File

@@ -0,0 +1,3 @@
class Foo {
int[] a = new int[]<caret>
}

View File

@@ -0,0 +1,3 @@
class Foo {
int[] a = new int[]{<caret>}
}

View File

@@ -0,0 +1,3 @@
class A {
private int[][] data = new int[][]{<caret>}
}

View File

@@ -0,0 +1,3 @@
class A {
private int[][] data = new int[][]{{<caret>}}
}

View File

@@ -0,0 +1,3 @@
class A {
private int[][] data = new int[][] {{<caret>}}
}

View File

@@ -0,0 +1,7 @@
public class A {
void f(int i) {
if (i == 0)
<caret>
}
}

View File

@@ -0,0 +1,7 @@
public class A {
void f(int i) {
if (i == 0)
{<caret>
}
}

View File

@@ -0,0 +1,5 @@
class A {
void foo() {
if (true) <caret>
}
}

View File

@@ -0,0 +1,5 @@
class A {
void foo() {
if (true) {<caret>
}
}

View File

@@ -0,0 +1,3 @@
class A {
void foo() <caret>
}

View File

@@ -0,0 +1,3 @@
class A {
void foo() {<caret>}
}

View File

@@ -0,0 +1,5 @@
class A{
{
f<caret>
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
f[<caret>]
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
<caret>f]
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
[<caret>f]
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
f<caret>a
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
f[a
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
f<caret>
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
f(<caret>)
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
<caret>f)
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
(<caret>f)
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
f<caret>a
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
f(a
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
f<caret>)
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
f(<caret>)
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
(f<caret>)
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
(f(<caret>))
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
// f<caret>
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
// f(<caret>
}
}

View File

@@ -0,0 +1,4 @@
class A{
{
<caret>
}

View File

@@ -0,0 +1,4 @@
class A{
{
}<caret>
}

View File

@@ -0,0 +1,3 @@
class Foo {
int[] abc = new int[]{<caret>}
}

View File

@@ -0,0 +1,3 @@
class Foo {
int[] abc = new int[]{}<caret>
}

View File

@@ -0,0 +1,6 @@
class Foo {
void foo() {
{System.out.println();
<caret>
}
}

View File

@@ -0,0 +1,7 @@
class Foo {
void foo() {
{
System.out.println();
}<caret>
}
}

View File

@@ -0,0 +1,3 @@
class Foo {
int[] abc = new int[]{{<caret>}}
}

View File

@@ -0,0 +1,3 @@
class Foo {
int[] abc = new int[]{{}<caret>}
}

View File

@@ -0,0 +1,3 @@
class Foo {
void foo() {<caret>}
}

View File

@@ -0,0 +1,3 @@
class Foo {
void foo() {}<caret>
}

View File

@@ -0,0 +1,5 @@
class A{
{
f[<caret>]
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
f[]<caret>
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
arr[f[<caret>] = 0;
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
arr[f[]<caret>] = 0;
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
f(<caret>)
}
}

View File

@@ -0,0 +1,5 @@
class A{
{
f()<caret>
}
}

View File

@@ -0,0 +1,6 @@
class A{
{
if (f(<caret>){
}
}
}

View File

@@ -0,0 +1,6 @@
class A{
{
if (f()<caret>){
}
}
}

View File

@@ -0,0 +1,8 @@
class A{
{
if (f(<caret>){
}
}
)
}

View File

@@ -0,0 +1,8 @@
class A{
{
if (f()<caret>){
}
}
)
}

View File

@@ -0,0 +1,5 @@
class A {
{
System.out.println("aaa(<caret>");
}
}

View File

@@ -0,0 +1,5 @@
class A {
{
System.out.println("aaa()<caret>");
}
}

View File

@@ -0,0 +1,5 @@
class A {
{
if( <caret>)
}
}

View File

@@ -0,0 +1,5 @@
class A {
{
if( )<caret>
}
}

View File

@@ -0,0 +1,3 @@
@Anno(
param
<caret>

View File

@@ -0,0 +1,3 @@
@Anno(
param
)<caret>

View File

@@ -0,0 +1,30 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInsight.defaultAction;
import com.intellij.JavaTestUtil;
import org.jetbrains.annotations.NotNull;
public class JavaLBraceTest extends DefaultActionTestCase {
@Override
protected @NotNull String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
}
public void testArrayInitializer() { doTest(); }
public void testArrayInitializerNoSpace() { doTest(); }
public void testInsideCodeBlock() { doTest(); }
public void testOutsideCodeBlock() { doTest(); }
public void testArrayInitializerBegins() { doTest(); }
public void testArrayInitializer1_5Style() { doTest(); }
public void testIndentLBrace() { doTest(); }
private void doTest() {
configureByFile(getTestPath() + ".java");
performAction('{');
checkResultByFile(getTestPath() + "_after.java");
}
private String getTestPath() {
return "/codeInsight/defaultAction/lbrace/" + getTestName(false);
}
}

View File

@@ -0,0 +1,26 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInsight.defaultAction;
import com.intellij.JavaTestUtil;
import org.jetbrains.annotations.NotNull;
public class JavaLBracketTest extends DefaultActionTestCase {
@Override
protected @NotNull String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
}
public void test1() { doTest(); }
public void test2() { doTest(); }
public void test3() { doTest(); }
private void doTest() {
String path = "/codeInsight/defaultAction/lbracket/";
configureByFile(path + getTestName(false) + ".java");
performAction('[');
checkResultByFile(path + getTestName(false) + "_after.java");
}
}

View File

@@ -0,0 +1,27 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInsight.defaultAction;
import com.intellij.JavaTestUtil;
import org.jetbrains.annotations.NotNull;
public class JavaLParenthTest extends DefaultActionTestCase {
@Override
protected @NotNull String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
}
public void test1() { doTest(); }
public void test2() { doTest(); }
public void test3() { doTest(); }
public void test4() { doTest(); }
public void test5() { doTest(); }
public void test6() { doTest(); }
private void doTest() {
String path = "/codeInsight/defaultAction/lparenth/";
configureByFile(path + getTestName(false) + ".java");
performAction('(');
checkResultByFile(path + getTestName(false) + "_after.java");
}
}

View File

@@ -0,0 +1,28 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInsight.defaultAction;
import com.intellij.JavaTestUtil;
import org.jetbrains.annotations.NotNull;
public class JavaRBraceTest extends DefaultActionTestCase {
@Override
protected @NotNull String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
}
public void test1() { doTest(); }
public void testMethodClosingBrace() { doTest(); }
public void testClosingBraceReformatsBlock() { doTest(); }
private void doTest() {
String path = "/codeInsight/defaultAction/rbrace/";
configureByFile(path + getTestName(false) + ".java");
performAction('}');
checkResultByFile(path + getTestName(false) + "_after.java");
}
public void testClosingNestedArrayInitializer() { doTest(); }
public void testClosingArrayInitializer() { doTest(); }
}

View File

@@ -0,0 +1,23 @@
package com.intellij.codeInsight.defaultAction;
import com.intellij.JavaTestUtil;
import org.jetbrains.annotations.NotNull;
public class JavaRBracketTest extends DefaultActionTestCase {
@Override
protected @NotNull String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
}
public void test1() { doTest(); }
public void test2() { doTest(); }
private void doTest() {
String path = "/codeInsight/defaultAction/rbracket/";
configureByFile(path + getTestName(false) + ".java");
performAction(']');
checkResultByFile(path + getTestName(false) + "_after.java");
}
}

View File

@@ -0,0 +1,32 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInsight.defaultAction;
import com.intellij.JavaTestUtil;
import org.jetbrains.annotations.NotNull;
public class JavaRParenthTest extends DefaultActionTestCase {
private static final String BASE_PATH = "/codeInsight/defaultAction/rparenth/";
@Override
protected @NotNull String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
}
public void test1() { doTest(); }
public void test2() { doTest(); }
public void test3() { doTest(); }
public void test4() { doTest(); }
public void test5() { doTest(); }
public void test6() { doTest(); }
private void doTest() {
configureByFile(BASE_PATH + getTestName(false) + ".java");
performAction(')');
checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
}
}

View File

@@ -1,30 +0,0 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.java.codeInsight.defaultAction;
import com.intellij.ide.DataManager;
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
import com.intellij.openapi.editor.actionSystem.TypedAction;
import com.intellij.testFramework.LightJavaCodeInsightTestCase;
public abstract class DefaultActionTestCase extends LightJavaCodeInsightTestCase {
protected void performAction(char c) {
EditorActionManager.getInstance();
TypedAction action = TypedAction.getInstance();
action.actionPerformed(getEditor(), c, DataManager.getInstance().getDataContext());
}
}

View File

@@ -0,0 +1,15 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInsight.defaultAction;
import com.intellij.ide.DataManager;
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
import com.intellij.openapi.editor.actionSystem.TypedAction;
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
public abstract class DefaultActionTestCase extends LightPlatformCodeInsightTestCase {
protected void performAction(char c) {
EditorActionManager.getInstance();
TypedAction action = TypedAction.getInstance();
action.actionPerformed(getEditor(), c, DataManager.getInstance().getDataContext());
}
}

View File

@@ -0,0 +1,108 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInsight.defaultAction;
import com.intellij.codeInsight.XmlTestUtil;
import org.jetbrains.annotations.NotNull;
public class XmlGreaterTest extends DefaultActionTestCase {
@Override
protected @NotNull String getTestDataPath() {
return XmlTestUtil.getXmlTestDataPath();
}
public void testHtmlGreater() {
String path = "/codeInsight/defaultAction/greater/";
configureByFile(path + "1.html");
performAction('>');
checkResultByFile(path + "1_after.html");
configureByFile(path + "2.html");
performAction('>');
checkResultByFile(path + "2_after.html");
configureByFile(path + "3.html");
performAction('>');
checkResultByFile(path + "3_after.html");
configureByFile(path + "4.html");
performAction('>');
checkResultByFile(path + "4_after.html");
configureByFile(path + "5.html");
performAction('>');
checkResultByFile(path + "5_after.html");
configureByFile(path + "6.html");
performAction('>');
checkResultByFile(path + "6_after.html");
}
public void testXHtmlGreater() {
String path = "/codeInsight/defaultAction/greater/";
configureByFile(path + "1.xhtml");
performAction('>');
checkResultByFile(path + "1_after.xhtml");
}
public void testXmlGreater() {
String path = "/codeInsight/defaultAction/greater/";
configureByFile(path + "1.xml");
performAction('>');
checkResultByFile(path + "1_after.xml");
configureByFile(path + "2.xml");
performAction('>');
checkResultByFile(path + "2_after.xml");
configureByFile(path + "3.xml");
performAction('>');
checkResultByFile(path + "3_after.xml");
configureByFile(path + "4.xml");
performAction('>');
checkResultByFile(path + "4_after.xml");
configureByFile(path + "5.xml");
performAction('>');
checkResultByFile(path + "5_after.xml");
configureByFile(path + "6.xml");
performAction('>');
checkResultByFile(path + "6_after.xml");
configureByFile(path + "7.xml");
performAction('>');
checkResultByFile(path + "7_after.xml");
configureByFile(path + "8.xml");
performAction('>');
checkResultByFile(path + "8_after.xml");
configureByFile(path + "9.xml");
performAction('>');
checkResultByFile(path + "9_after.xml");
configureByFile(path + "10.xml");
performAction('>');
checkResultByFile(path + "10_after.xml");
configureByFile(path + "11.xml");
performAction('>');
checkResultByFile(path + "11_after.xml");
configureByFile(path + "12.xml");
performAction('>');
checkResultByFile(path + "12_after.xml");
configureByFile(path + "12_2.xml");
performAction('>');
checkResultByFile(path + "12_2_after.xml");
configureByFile(path + "12_3.xml");
performAction('>');
checkResultByFile(path + "12_3_after.xml");
}
}

View File

@@ -0,0 +1,22 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInsight.defaultAction;
import com.intellij.codeInsight.XmlTestUtil;
import org.jetbrains.annotations.NotNull;
public class XmlQuoteTest extends DefaultActionTestCase {
@Override
protected @NotNull String getTestDataPath() {
return XmlTestUtil.getXmlTestDataPath();
}
public void testAttributeStart() { doTest('"'); }
public void testAttributeEnd() { doTest('"'); }
private void doTest(char c) {
String path = "/codeInsight/defaultAction/quote/";
configureByFile(path + getTestName(false) + ".xml");
performAction(c);
checkResultByFile(path + getTestName(false) + "_after.xml");
}
}

View File

@@ -0,0 +1,39 @@
package com.intellij.codeInsight.defaultAction;
import com.intellij.codeInsight.XmlTestUtil;
import org.jetbrains.annotations.NotNull;
public class XmlSlashTest extends DefaultActionTestCase {
@Override
protected @NotNull String getTestDataPath() {
return XmlTestUtil.getXmlTestDataPath();
}
public void testXmlSlash() {
String path = "/codeInsight/defaultAction/slash/";
configureByFile(path + "1.xml");
performAction('/');
checkResultByFile(path + "1_after.xml");
configureByFile(path + "2.xml");
performAction('/');
checkResultByFile(path + "2_after.xml");
configureByFile(path + "3.xml");
performAction('/');
checkResultByFile(path + "3_after.xml");
configureByFile(path + "4.xml");
performAction('/');
checkResultByFile(path + "4_after.xml");
}
public void testHtmlSlash() {
String path = "/codeInsight/defaultAction/slash/";
configureByFile(path + "1.html");
performAction('/');
checkResultByFile(path + "1_after.html");
}
}

View File

@@ -0,0 +1 @@
<a<caret>

View File

@@ -0,0 +1,3 @@
<html>
<head<caret>
</html>

View File

@@ -0,0 +1 @@
<aaa<caret>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0"?>
<root>
<existenttag><tag<caret></existenttag>
</root>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0"?>
<root>
<existenttag><tag><caret></tag></existenttag>
</root>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<sample><inner>text1</inner></sample>
<sample>text3<inner<caret>tail</sample>
</root>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<sample><inner>text1</inner></sample>
<sample>text3<inner><caret></inner>tail</sample>
</root>

View File

@@ -0,0 +1,3 @@
<div><div>
<div<caret>
</div></div>

View File

@@ -0,0 +1,3 @@
<div><div>
<div<caret></div>
</div></div>

View File

@@ -0,0 +1,3 @@
<div><div>
<div><caret></div>
</div></div>

View File

@@ -0,0 +1,3 @@
<body><div><div>
<div<caret>
</div></div></body>

View File

@@ -0,0 +1,3 @@
<body><div><div>
<div><caret></div>
</div></div></body>

View File

@@ -0,0 +1,3 @@
<div><div>
<div><caret></div>
</div></div>

View File

@@ -0,0 +1 @@
<a><caret></a>

View File

@@ -0,0 +1,3 @@
<html>
<head><caret></head>
</html>

View File

@@ -0,0 +1 @@
<aaa><caret></aaa>

View File

@@ -0,0 +1,3 @@
<html>
<a href=""<caret>
</html>

View File

@@ -0,0 +1,3 @@
<root>
<aaa<caret> aaaa
</root>

View File

@@ -0,0 +1,3 @@
<html>
<a href=""><caret></a>
</html>

View File

@@ -0,0 +1,3 @@
<root>
<aaa><caret></aaa> aaaa
</root>

View File

@@ -0,0 +1,9 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head></head>
<body>
<hr>
<a<caret>
</body>
</html>

View File

@@ -0,0 +1,3 @@
<html>
<head<caret>
</html>

View File

@@ -0,0 +1,9 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head></head>
<body>
<hr>
<a><caret></a>
</body>
</html>

View File

@@ -0,0 +1,3 @@
<html>
<head><caret></head>
</html>

View File

@@ -0,0 +1,6 @@
<html>
<head>
<link<caret>
</head>
</html>

View File

@@ -0,0 +1,3 @@
<html>
<head/<caret>
</html>

View File

@@ -0,0 +1,6 @@
<html>
<head>
<link><caret>
</head>
</html>

View File

@@ -0,0 +1,3 @@
<html>
<head/><caret>
</html>

View File

@@ -0,0 +1,11 @@
<html>
<body>
<table>
<tr>
<td>
<table<caret>
</td>
</tr>
</table>
</body>
</html>

View File

@@ -0,0 +1,5 @@
<html>
<head>
<link<caret>
</head>
</html>

View File

@@ -0,0 +1,11 @@
<html>
<body>
<table>
<tr>
<td>
<table><caret></table>
</td>
</tr>
</table>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More