|
@@ -1,138 +0,0 @@
|
1
|
|
-/*
|
2
|
|
- * Copyright (c) 2006-2011 DMDirc Developers
|
3
|
|
- *
|
4
|
|
- * Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
|
- * of this software and associated documentation files (the "Software"), to deal
|
6
|
|
- * in the Software without restriction, including without limitation the rights
|
7
|
|
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
|
- * copies of the Software, and to permit persons to whom the Software is
|
9
|
|
- * furnished to do so, subject to the following conditions:
|
10
|
|
- *
|
11
|
|
- * The above copyright notice and this permission notice shall be included in
|
12
|
|
- * all copies or substantial portions of the Software.
|
13
|
|
- *
|
14
|
|
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
|
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
|
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
|
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
|
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
|
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
|
- * SOFTWARE.
|
21
|
|
- */
|
22
|
|
-
|
23
|
|
-package com.dmdirc.addons.ui_swing.components.frames;
|
24
|
|
-
|
25
|
|
-import com.dmdirc.harness.ui.ClassComponentMatcher;
|
26
|
|
-import com.dmdirc.harness.ui.DMDircUITestCase;
|
27
|
|
-import com.dmdirc.addons.ui_swing.components.inputfields.TextAreaInputField;
|
28
|
|
-import org.junit.Test;
|
29
|
|
-import org.uispec4j.Trigger;
|
30
|
|
-import org.uispec4j.Window;
|
31
|
|
-import org.uispec4j.interception.WindowInterceptor;
|
32
|
|
-
|
33
|
|
-public class InputTextFrameTest extends DMDircUITestCase {
|
34
|
|
-
|
35
|
|
- static InputTextFrame tf;
|
36
|
|
- static String text;
|
37
|
|
-
|
38
|
|
- static {
|
39
|
|
- tf = new CustomInputFrame(getMockedControllerAndMainFrame(),
|
40
|
|
- getMockedContainer());
|
41
|
|
- text = "line1\nline2";
|
42
|
|
- }
|
43
|
|
-
|
44
|
|
- @Test
|
45
|
|
- public void testPasteDialogContents() throws InterruptedException {
|
46
|
|
- final Window dialog = getDialog();
|
47
|
|
- dialog.titleEquals("DMDirc: Multi-line paste").check();
|
48
|
|
- dialog.getButton("Edit").click();
|
49
|
|
- assertTrue(dialog.getTextBox(new ClassComponentMatcher(
|
50
|
|
- TextAreaInputField.class)).getText().equals(text));
|
51
|
|
- }
|
52
|
|
-
|
53
|
|
- @Test
|
54
|
|
- public void testPasteDialogWithTextBefore() throws InterruptedException {
|
55
|
|
- tf.getInputField().setText("testing:");
|
56
|
|
- final Window dialog = getDialog();
|
57
|
|
- dialog.titleEquals("DMDirc: Multi-line paste").check();
|
58
|
|
- dialog.getButton("Edit").click();
|
59
|
|
- assertTrue(dialog.getTextBox(new ClassComponentMatcher(
|
60
|
|
- TextAreaInputField.class)).getText().equals("testing:" + text));
|
61
|
|
- }
|
62
|
|
-
|
63
|
|
- @Test
|
64
|
|
- public void testPasteDialogWithTextAfter() throws InterruptedException {
|
65
|
|
- tf.getInputField().setText(":testing");
|
66
|
|
- tf.getInputField().setCaretPosition(0);
|
67
|
|
- final Window dialog = getDialog();
|
68
|
|
- dialog.titleEquals("DMDirc: Multi-line paste").check();
|
69
|
|
- dialog.getButton("Edit").click();
|
70
|
|
- assertTrue(dialog.getTextBox(new ClassComponentMatcher(
|
71
|
|
- TextAreaInputField.class)).getText().equals(text + ":testing"));
|
72
|
|
- }
|
73
|
|
-
|
74
|
|
- @Test
|
75
|
|
- public void testPasteDialogWithTextAround() throws InterruptedException {
|
76
|
|
- tf.getInputField().setText("testing::testing");
|
77
|
|
- tf.getInputField().setCaretPosition(8);
|
78
|
|
- final Window dialog = getDialog();
|
79
|
|
- dialog.titleEquals("DMDirc: Multi-line paste").check();
|
80
|
|
- dialog.getButton("Edit").click();
|
81
|
|
- assertEquals("testing:" + text + ":testing",
|
82
|
|
- dialog.getTextBox(new ClassComponentMatcher(
|
83
|
|
- TextAreaInputField.class)).getText());
|
84
|
|
- }
|
85
|
|
-
|
86
|
|
- @Test
|
87
|
|
- public void testPasteDialogWithSelection() {
|
88
|
|
- tf.getInputField().setText("testing:SELECTED:testing");
|
89
|
|
- tf.getInputField().setSelectionStart(8);
|
90
|
|
- tf.getInputField().setSelectionEnd(16);
|
91
|
|
- final Window dialog = getDialog();
|
92
|
|
- dialog.titleEquals("DMDirc: Multi-line paste").check();
|
93
|
|
- dialog.getButton("Edit").click();
|
94
|
|
- assertEquals("testing:" + text + ":testing",
|
95
|
|
- dialog.getTextBox(new ClassComponentMatcher(
|
96
|
|
- TextAreaInputField.class)).getText());
|
97
|
|
- }
|
98
|
|
-
|
99
|
|
- /**
|
100
|
|
- * Creates a new paste dialog with the specified text for the specified
|
101
|
|
- * frame.
|
102
|
|
- *
|
103
|
|
- * @param frame Parent frame
|
104
|
|
- * @param text Text to "paste"
|
105
|
|
- *
|
106
|
|
- * @return Wrapped Dialog
|
107
|
|
- */
|
108
|
|
- private Window getDialog() {
|
109
|
|
- return WindowInterceptor.run(new PasteDialogTrigger(tf, text));
|
110
|
|
- }
|
111
|
|
-
|
112
|
|
- /**
|
113
|
|
- * Creates a new paste dialog for the specified frame with the specified text.
|
114
|
|
- */
|
115
|
|
- private static class PasteDialogTrigger implements Trigger {
|
116
|
|
-
|
117
|
|
- private InputTextFrame frame;
|
118
|
|
- private String text;
|
119
|
|
-
|
120
|
|
- /**
|
121
|
|
- * Creates a new paste dialog for the specified frame with the specified text.
|
122
|
|
- *
|
123
|
|
- * @param frame Parent frame
|
124
|
|
- * @param text Text to "paste"
|
125
|
|
- */
|
126
|
|
- public PasteDialogTrigger(final InputTextFrame frame, final String text) {
|
127
|
|
- this.frame = frame;
|
128
|
|
- this.text = text;
|
129
|
|
- }
|
130
|
|
-
|
131
|
|
- /** {@inheritDoc} */
|
132
|
|
- @Override
|
133
|
|
- public void run() throws Exception {
|
134
|
|
- frame.doPaste(text);
|
135
|
|
- }
|
136
|
|
- }
|
137
|
|
-
|
138
|
|
-}
|