diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java index 7cbf3209e..f66b3ba26 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java @@ -29,6 +29,27 @@ import org.junit.Test; */ public class IndentationCheckTest extends BaseCheckTestSupport { + @Test + public void testAndroidStyle() throws Exception + { + final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); + checkConfig.addAttribute("basicOffset", "4"); + checkConfig.addAttribute("lineWrappingIndentation", "8"); + checkConfig.addAttribute("throwsIndent", "8"); + final String[] expected = { + "28: 'extends' have incorrect indentation level 3, expected level should be 8.", + "30: 'member def type' have incorrect indentation level 3, expected level should be 4.", + "33: 'foo' have incorrect indentation level 8, expected level should be 12.", + "36: 'int' have incorrect indentation level 8, expected level should be 12.", + "39: 'true' have incorrect indentation level 13, expected level should be 16.", + "42: '+' have incorrect indentation level 16, expected level should be 20.", + "43: 'if' have incorrect indentation level 8, expected level should be 12.", + "46: 'if rcurly' have incorrect indentation level 11, expected level should be 12.", + "48: 'method def' child have incorrect indentation level 7, expected level should be 8.", + }; + verify(checkConfig, getPath("indentation/InputAndroidStyle.java"), expected); + } + @Test public void testAnonClassesFromGuava() throws Exception { diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/indentation/InputAndroidStyle.java b/src/test/resources/com/puppycrawl/tools/checkstyle/indentation/InputAndroidStyle.java new file mode 100644 index 000000000..61fca729f --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/indentation/InputAndroidStyle.java @@ -0,0 +1,52 @@ +package com.puppycrawl.tools.checkstyle.indentation; + +class InputAndroidStyleCorrect + extends FooForExtend { //correct + + String string = foo("fooooooooooooooo", 0, false); + + String string1 = + foo("fooooooooooooooo", 0, false); //correct + + String foo (String aStr, + int aNnum, boolean aFlag) { //correct + + if (true && true && + true && true) { //correct + String string2 = foo("fooooooo" + + "oooooooo", 0, false); //correct + if (false && + false && false) { //correct + + } + } + return "string"; + } +} + +class InputAndroidStyleIncorrect + extends FooForExtend { //incorrect + + String string = foo("fooooooooooooooo", 0, false); //incorrect + + String string1 = + foo("fooooooooooooooo", 0, false); //incorrect + + String foo (String aStr, + int aNnum, boolean aFlag) { //incorrect + + if (true && true && + true && true) { //incorrect + + String string2 = foo("fooooooo" + + "oooooooo", 0, false); //incorrect + if (false && + false && false) { //incorrect + + } //incorrect + } + return "string"; //incorrect + } +} + +class FooForExtend {} \ No newline at end of file