summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorWesley Wolfe <weswolf@aol.com>2012-10-17 04:33:02 -0500
committerWesley Wolfe <weswolf@aol.com>2012-10-17 04:56:11 -0500
commit6c2c2c19a24d98c1216cba9b9ded7a04fcb31654 (patch)
treeafbeba71af056fcbbefdfa7f49135e6898f92941 /src/test
parent9fd9767a4a55c90bf488e2077123be8a55aaa982 (diff)
downloadbukkit-6c2c2c19a24d98c1216cba9b9ded7a04fcb31654.tar
bukkit-6c2c2c19a24d98c1216cba9b9ded7a04fcb31654.tar.gz
bukkit-6c2c2c19a24d98c1216cba9b9ded7a04fcb31654.tar.lz
bukkit-6c2c2c19a24d98c1216cba9b9ded7a04fcb31654.tar.xz
bukkit-6c2c2c19a24d98c1216cba9b9ded7a04fcb31654.zip
Add a tab completion API for chat messages. Adds BUKKIT-2607
This implementation provides access to a (mutable) list and the base message. Also provided is a convenience method for getting the last 'token' in the provided string.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/bukkit/event/PlayerChatTabCompleteEventTest.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/test/java/org/bukkit/event/PlayerChatTabCompleteEventTest.java b/src/test/java/org/bukkit/event/PlayerChatTabCompleteEventTest.java
new file mode 100644
index 00000000..619bf30b
--- /dev/null
+++ b/src/test/java/org/bukkit/event/PlayerChatTabCompleteEventTest.java
@@ -0,0 +1,28 @@
+package org.bukkit.event;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.bukkit.event.player.PlayerChatTabCompleteEvent;
+import org.bukkit.plugin.messaging.TestPlayer;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableList;
+
+public class PlayerChatTabCompleteEventTest {
+
+ @Test
+ public void testGetLastToken() {
+ assertThat(getToken("Hello everyone!"), is("everyone!"));
+ assertThat(getToken(" welcome to the show..."), is("show..."));
+ assertThat(getToken("The whitespace is here "), is(""));
+ assertThat(getToken("Too much whitespace is here "), is(""));
+ assertThat(getToken("The_whitespace_is_missing"), is("The_whitespace_is_missing"));
+ assertThat(getToken(""), is(""));
+ assertThat(getToken(" "), is(""));
+ }
+
+ private String getToken(String message) {
+ return new PlayerChatTabCompleteEvent(TestPlayer.getInstance(), message, ImmutableList.<String>of()).getLastToken();
+ }
+}