From 625aeab39834aa255ed40978919566f259ea858a Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Mon, 30 Nov 2015 00:39:24 +0100 Subject: [PATCH] Reformat code --- .idea/codeStyleSettings.xml | 231 ++++++++++++++++++ .../com/termux/app/TermuxActivityTest.java | 22 +- .../com/termux/terminal/ByteQueueTest.java | 12 +- .../java/com/termux/terminal/DecSetTest.java | 6 +- .../com/termux/terminal/KeyHandlerTest.java | 1 + .../terminal/OperatingSystemControlTest.java | 4 +- .../com/termux/terminal/ScrollRegionTest.java | 2 +- .../com/termux/terminal/TerminalRowTest.java | 8 +- .../com/termux/terminal/TerminalTestCase.java | 13 +- .../com/termux/terminal/TextStyleTest.java | 4 +- .../com/termux/terminal/UnicodeInputTest.java | 10 +- 11 files changed, 271 insertions(+), 42 deletions(-) create mode 100644 .idea/codeStyleSettings.xml diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml new file mode 100644 index 00000000..4789cb6d --- /dev/null +++ b/.idea/codeStyleSettings.xml @@ -0,0 +1,231 @@ + + + + + + \ No newline at end of file diff --git a/app/src/test/java/com/termux/app/TermuxActivityTest.java b/app/src/test/java/com/termux/app/TermuxActivityTest.java index 1763bfd4..b9358aa3 100644 --- a/app/src/test/java/com/termux/app/TermuxActivityTest.java +++ b/app/src/test/java/com/termux/app/TermuxActivityTest.java @@ -7,19 +7,19 @@ import java.util.LinkedHashSet; public class TermuxActivityTest extends TestCase { - private void assertUrlsAre(String text, String... urls) { - LinkedHashSet expected = new LinkedHashSet<>(); - Collections.addAll(expected, urls); - assertEquals(expected, TermuxActivity.extractUrls(text)); - } + private void assertUrlsAre(String text, String... urls) { + LinkedHashSet expected = new LinkedHashSet<>(); + Collections.addAll(expected, urls); + assertEquals(expected, TermuxActivity.extractUrls(text)); + } - public void testExtractUrls() { - assertUrlsAre("hello http://example.com world", "http://example.com"); + public void testExtractUrls() { + assertUrlsAre("hello http://example.com world", "http://example.com"); - assertUrlsAre("http://example.com\nhttp://another.com", "http://example.com", "http://another.com"); + assertUrlsAre("http://example.com\nhttp://another.com", "http://example.com", "http://another.com"); - assertUrlsAre("hello http://example.com world and http://more.example.com with secure https://more.example.com", - "http://example.com", "http://more.example.com", "https://more.example.com"); - } + assertUrlsAre("hello http://example.com world and http://more.example.com with secure https://more.example.com", + "http://example.com", "http://more.example.com", "https://more.example.com"); + } } diff --git a/app/src/test/java/com/termux/terminal/ByteQueueTest.java b/app/src/test/java/com/termux/terminal/ByteQueueTest.java index aa761d3f..51439e3c 100644 --- a/app/src/test/java/com/termux/terminal/ByteQueueTest.java +++ b/app/src/test/java/com/termux/terminal/ByteQueueTest.java @@ -17,21 +17,21 @@ public class ByteQueueTest extends TestCase { public void testCompleteWrites() throws Exception { ByteQueue q = new ByteQueue(10); - assertEquals(true, q.write(new byte[] { 1, 2, 3 }, 0, 3)); + assertEquals(true, q.write(new byte[]{1, 2, 3}, 0, 3)); byte[] arr = new byte[10]; assertEquals(3, q.read(arr, true)); - assertArrayEquals(new byte[] { 1, 2, 3 }, new byte[] { arr[0], arr[1], arr[2] }); + assertArrayEquals(new byte[]{1, 2, 3}, new byte[]{arr[0], arr[1], arr[2]}); - assertEquals(true, q.write(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, 0, 10)); + assertEquals(true, q.write(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 0, 10)); assertEquals(10, q.read(arr, true)); - assertArrayEquals(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, arr); + assertArrayEquals(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, arr); } public void testQueueWraparound() throws Exception { ByteQueue q = new ByteQueue(10); - byte[] origArray = new byte[] { 1, 2, 3, 4, 5, 6 }; + byte[] origArray = new byte[]{1, 2, 3, 4, 5, 6}; byte[] readArray = new byte[origArray.length]; for (int i = 0; i < 20; i++) { q.write(origArray, 0, origArray.length); @@ -43,7 +43,7 @@ public class ByteQueueTest extends TestCase { public void testWriteNotesClosing() throws Exception { ByteQueue q = new ByteQueue(10); q.close(); - assertEquals(false, q.write(new byte[] { 1, 2, 3 }, 0, 3)); + assertEquals(false, q.write(new byte[]{1, 2, 3}, 0, 3)); } public void testReadNonBlocking() throws Exception { diff --git a/app/src/test/java/com/termux/terminal/DecSetTest.java b/app/src/test/java/com/termux/terminal/DecSetTest.java index 71d95aba..5baf0808 100644 --- a/app/src/test/java/com/termux/terminal/DecSetTest.java +++ b/app/src/test/java/com/termux/terminal/DecSetTest.java @@ -4,13 +4,13 @@ package com.termux.terminal; *
  * "CSI ? Pm h", DEC Private Mode Set (DECSET)
  * 
- * + *

* and - * + *

*

  * "CSI ? Pm l", DEC Private Mode Reset (DECRST)
  * 
- * + *

* controls various aspects of the terminal */ public class DecSetTest extends TerminalTestCase { diff --git a/app/src/test/java/com/termux/terminal/KeyHandlerTest.java b/app/src/test/java/com/termux/terminal/KeyHandlerTest.java index 6bb15a80..1e48d5f7 100644 --- a/app/src/test/java/com/termux/terminal/KeyHandlerTest.java +++ b/app/src/test/java/com/termux/terminal/KeyHandlerTest.java @@ -1,6 +1,7 @@ package com.termux.terminal; import android.view.KeyEvent; + import junit.framework.TestCase; public class KeyHandlerTest extends TestCase { diff --git a/app/src/test/java/com/termux/terminal/OperatingSystemControlTest.java b/app/src/test/java/com/termux/terminal/OperatingSystemControlTest.java index 0019ed69..c174524c 100644 --- a/app/src/test/java/com/termux/terminal/OperatingSystemControlTest.java +++ b/app/src/test/java/com/termux/terminal/OperatingSystemControlTest.java @@ -1,11 +1,11 @@ package com.termux.terminal; +import android.util.Base64; + import java.util.ArrayList; import java.util.List; import java.util.Random; -import android.util.Base64; - /** "ESC ]" is the Operating System Command. */ public class OperatingSystemControlTest extends TerminalTestCase { diff --git a/app/src/test/java/com/termux/terminal/ScrollRegionTest.java b/app/src/test/java/com/termux/terminal/ScrollRegionTest.java index ba92d9a6..ff431455 100644 --- a/app/src/test/java/com/termux/terminal/ScrollRegionTest.java +++ b/app/src/test/java/com/termux/terminal/ScrollRegionTest.java @@ -2,7 +2,7 @@ package com.termux.terminal; /** * ${CSI}${top};${bottom}r" - set Scrolling Region [top;bottom] (default = full size of window) (DECSTBM). - * + *

* "DECSTBM moves the cursor to column 1, line 1 of the page" (http://www.vt100.net/docs/vt510-rm/DECSTBM). */ public class ScrollRegionTest extends TerminalTestCase { diff --git a/app/src/test/java/com/termux/terminal/TerminalRowTest.java b/app/src/test/java/com/termux/terminal/TerminalRowTest.java index 4138aa19..ba81034a 100644 --- a/app/src/test/java/com/termux/terminal/TerminalRowTest.java +++ b/app/src/test/java/com/termux/terminal/TerminalRowTest.java @@ -1,10 +1,10 @@ package com.termux.terminal; +import junit.framework.TestCase; + import java.util.Arrays; import java.util.Random; -import junit.framework.TestCase; - public class TerminalRowTest extends TestCase { /** The properties of these code points are validated in {@link #testStaticConstants()}. */ @@ -96,7 +96,7 @@ public class TerminalRowTest extends TestCase { assertEquals(80, row.getSpaceUsed()); assertColumnCharIndicesStartsWith(0, 1, 2, 3); - char[] someChars = new char[] { 'a', 'c', 'e', '4', '5', '6', '7', '8' }; + char[] someChars = new char[]{'a', 'c', 'e', '4', '5', '6', '7', '8'}; char[] rawLine = new char[80]; Arrays.fill(rawLine, ' '); @@ -373,7 +373,7 @@ public class TerminalRowTest extends TestCase { assertEquals(0, WcWidth.width(0x009F)); assertEquals(1, Character.charCount(0x009F)); - int[] points = new int[] { 0xC2541, 'a', '8', 0x73EE, 0x009F, 0x881F, 0x8324, 0xD4C9, 0xFFFD, 'B', 0x009B, 0x61C9, 'Z' }; + int[] points = new int[]{0xC2541, 'a', '8', 0x73EE, 0x009F, 0x881F, 0x8324, 0xD4C9, 0xFFFD, 'B', 0x009B, 0x61C9, 'Z'}; // int[] expected = new int[] { TerminalEmulator.UNICODE_REPLACEMENT_CHAR, 'a', '8', 0x73EE, 0x009F, 0x881F, 0x8324, 0xD4C9, 0xFFFD, // 'B', 0x009B, 0x61C9, 'Z' }; int currentColumn = 0; diff --git a/app/src/test/java/com/termux/terminal/TerminalTestCase.java b/app/src/test/java/com/termux/terminal/TerminalTestCase.java index a04f62a3..46323a01 100644 --- a/app/src/test/java/com/termux/terminal/TerminalTestCase.java +++ b/app/src/test/java/com/termux/terminal/TerminalTestCase.java @@ -1,5 +1,8 @@ package com.termux.terminal; +import junit.framework.AssertionFailedError; +import junit.framework.TestCase; + import java.io.ByteArrayOutputStream; import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; @@ -9,12 +12,6 @@ import java.util.List; import java.util.Objects; import java.util.Set; -import junit.framework.AssertionFailedError; -import junit.framework.TestCase; - -import com.termux.terminal.TerminalEmulator; -import com.termux.terminal.TerminalOutput; - public abstract class TerminalTestCase extends TestCase { public static class MockTerminalOutput extends TerminalOutput { @@ -130,8 +127,8 @@ public abstract class TerminalTestCase extends TestCase { @Override public boolean equals(Object o) { - return o instanceof LineWrapper && ((LineWrapper) o).mLine == mLine; - } + return o instanceof LineWrapper && ((LineWrapper) o).mLine == mLine; + } } protected TerminalTestCase assertInvariants() { diff --git a/app/src/test/java/com/termux/terminal/TextStyleTest.java b/app/src/test/java/com/termux/terminal/TextStyleTest.java index 2a4a89ac..ed6d97eb 100644 --- a/app/src/test/java/com/termux/terminal/TextStyleTest.java +++ b/app/src/test/java/com/termux/terminal/TextStyleTest.java @@ -4,10 +4,10 @@ import junit.framework.TestCase; public class TextStyleTest extends TestCase { - private static final int[] ALL_EFFECTS = new int[] { 0, TextStyle.CHARACTER_ATTRIBUTE_BOLD, TextStyle.CHARACTER_ATTRIBUTE_ITALIC, + private static final int[] ALL_EFFECTS = new int[]{0, TextStyle.CHARACTER_ATTRIBUTE_BOLD, TextStyle.CHARACTER_ATTRIBUTE_ITALIC, TextStyle.CHARACTER_ATTRIBUTE_UNDERLINE, TextStyle.CHARACTER_ATTRIBUTE_BLINK, TextStyle.CHARACTER_ATTRIBUTE_INVERSE, TextStyle.CHARACTER_ATTRIBUTE_INVISIBLE, TextStyle.CHARACTER_ATTRIBUTE_STRIKETHROUGH, TextStyle.CHARACTER_ATTRIBUTE_PROTECTED, - TextStyle.CHARACTER_ATTRIBUTE_DIM }; + TextStyle.CHARACTER_ATTRIBUTE_DIM}; public void testEncodingSingle() { for (int fx : ALL_EFFECTS) { diff --git a/app/src/test/java/com/termux/terminal/UnicodeInputTest.java b/app/src/test/java/com/termux/terminal/UnicodeInputTest.java index ba0bbf07..9120f360 100644 --- a/app/src/test/java/com/termux/terminal/UnicodeInputTest.java +++ b/app/src/test/java/com/termux/terminal/UnicodeInputTest.java @@ -10,14 +10,14 @@ public class UnicodeInputTest extends TerminalTestCase { // continue with valid successor bytes (see Table 3-7), it must not consume the successor bytes as part of the ill-formed // subsequence whenever those successor bytes themselves constitute part of a well-formed UTF-8 code unit subsequence." withTerminalSized(5, 5); - mTerminal.append(new byte[] { (byte) 0b11101111, (byte) 'a' }, 2); + mTerminal.append(new byte[]{(byte) 0b11101111, (byte) 'a'}, 2); assertLineIs(0, ((char) TerminalEmulator.UNICODE_REPLACEMENT_CHAR) + "a "); } public void testUnassignedCodePoint() throws UnsupportedEncodingException { withTerminalSized(3, 3); // UTF-8 for U+C2541, an unassigned code point: - byte[] b = new byte[] { (byte) 0xf3, (byte) 0x82, (byte) 0x95, (byte) 0x81 }; + byte[] b = new byte[]{(byte) 0xf3, (byte) 0x82, (byte) 0x95, (byte) 0x81}; mTerminal.append(b, b.length); enterString("Y"); assertEquals(1, Character.charCount(TerminalEmulator.UNICODE_REPLACEMENT_CHAR)); @@ -26,10 +26,10 @@ public class UnicodeInputTest extends TerminalTestCase { public void testStuff() { withTerminalSized(80, 24); - byte[] b = new byte[] { (byte) 0xf3, (byte) 0x82, (byte) 0x95, (byte) 0x81, (byte) 0x61, (byte) 0x38, (byte) 0xe7, (byte) 0x8f, + byte[] b = new byte[]{(byte) 0xf3, (byte) 0x82, (byte) 0x95, (byte) 0x81, (byte) 0x61, (byte) 0x38, (byte) 0xe7, (byte) 0x8f, (byte) 0xae, (byte) 0xc2, (byte) 0x9f, (byte) 0xe8, (byte) 0xa0, (byte) 0x9f, (byte) 0xe8, (byte) 0x8c, (byte) 0xa4, (byte) 0xed, (byte) 0x93, (byte) 0x89, (byte) 0xef, (byte) 0xbf, (byte) 0xbd, (byte) 0x42, (byte) 0xc2, (byte) 0x9b, - (byte) 0xe6, (byte) 0x87, (byte) 0x89, (byte) 0x5a }; + (byte) 0xe6, (byte) 0x87, (byte) 0x89, (byte) 0x5a}; mTerminal.append(b, b.length); } @@ -80,7 +80,7 @@ public class UnicodeInputTest extends TerminalTestCase { public void testOverlongUtf8Encoding() throws Exception { // U+0020 should be encoded as 0x20, 0xc0 0xa0 is an overlong encoding // so should be replaced with the replacement char U+FFFD. - withTerminalSized(5, 5).mTerminal.append(new byte[] { (byte) 0xc0, (byte) 0xa0, 'Y' }, 3); + withTerminalSized(5, 5).mTerminal.append(new byte[]{(byte) 0xc0, (byte) 0xa0, 'Y'}, 3); assertLineIs(0, "\uFFFDY "); }