-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathHitchhikerTest.java
127 lines (103 loc) · 4.49 KB
/
HitchhikerTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/***************************************************************************
* Copyright 2006-2019 by Christian Ihle *
* contact@kouchat.net *
* *
* This file is part of KouChat. *
* *
* KouChat is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version. *
* *
* KouChat is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with KouChat. *
* If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
package net.usikkert.kouchat.functional;
import java.util.Calendar;
import net.usikkert.kouchat.misc.CommandException;
import net.usikkert.kouchat.misc.User;
import net.usikkert.kouchat.testclient.TestClient;
import net.usikkert.kouchat.util.Tools;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
/**
* Test that simulates a chat between characters in The Hitchhiker's Guide to the Galaxy.
*
* Does not really assert anything. Mostly used for making new screenshots.
*
* @author Christian Ihle
*/
@Ignore
@SuppressWarnings("HardCodedStringLiteral")
public class HitchhikerTest {
private static TestClient arthur;
private static TestClient ford;
private static TestClient trillian;
@Before
public void setUp() {
// Making sure the test clients only logs on once during all the tests
if (arthur == null) {
arthur = new TestClient("Arthur", 0, -6750208);
arthur.logon();
ford = new TestClient("Ford", 0, -13534789);
ford.setInitialTopic("DON'T PANIC", getDateInPast());
ford.logon();
trillian = new TestClient("Trillian", 0);
trillian.logon();
}
}
/**
* In the main chat:
*
* Topic: DON'T PANIC
*
* <Christian>: hey :)
* <Arthur>: What are you doing?
* <Ford>: Preparing for hyperspace. It's rather unpleasantly like being drunk.
* <Arthur>: What's so wrong about being drunk?
* <Ford>: Ask a glass of water.
* *** Trillian went away: It won't affect me, I'm already a woman.
* <Christian>: interesting!
*/
@Test
public void test02DoMainChat() throws CommandException {
// If Console, start KouChat first, to avoid warnings about port numbers in use.
sleep(7000);
// (Re)Start KouChat, write: hey :)
final User christian = arthur.getUser("Christian");
sleep(10000);
arthur.sendChatMessage("What are you doing?");
sleep(16000);
ford.sendChatMessage("Preparing for hyperspace. It's rather unpleasantly like being drunk.");
sleep(9000);
arthur.sendChatMessage("What's so wrong about being drunk?");
sleep(7000);
ford.sendChatMessage("Ask a glass of water.");
sleep(8000);
trillian.goAway("It won't affect me, I'm already a woman.");
sleep(6000);
// Write: interesting!
sleep(1000);
arthur.sendPrivateChatMessage("OK. Leave this to me. I'm British. I know how to queue.", christian);
// Take screenshot of the main chat
sleep(20000);
}
private long getDateInPast() {
final Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.HOUR_OF_DAY, -2);
calendar.add(Calendar.MINUTE, -15);
calendar.add(Calendar.DATE, -12);
return calendar.getTimeInMillis();
}
private void sleep(final int ms) {
Tools.sleep(ms); // Screenshot mode
// Tools.sleep(1500); // Test mode
}
}