Skip to content

Commit ea58ffa

Browse files
authored
Merge branch 'develop' into issue/fixing-missing-href-in-url-with-parameters
2 parents 859a832 + f824e87 commit ea58ffa

File tree

35 files changed

+1628
-64
lines changed

35 files changed

+1628
-64
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,8 @@ annotations/
4646
# Enforce plugins
4747
!/.idea/externalDependencies.xml
4848

49+
# OS generated
50+
/.DS_Store
51+
52+
# Kotlin lint
53+
ktlint

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22

3+
## Unreleased
34
### Fixed
5+
- The text handling following immediately after images
6+
- Undo/redo edit history
7+
- The demo app sample text
48
- URL span not including href attribute when other attributes are present
59

610
## [1.0-beta.11](https://github.com/wordpress-mobile/AztecEditor-Android/releases/tag/v1.0-beta.11) - 2017-11-20

app/src/androidTest/kotlin/org/wordpress/aztec/demo/Actions.kt

Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import android.view.View
1414
import android.widget.EditText
1515
import org.hamcrest.Matcher
1616
import org.hamcrest.Matchers.allOf
17+
import org.wordpress.aztec.AztecText
18+
import org.wordpress.aztec.watchers.EndOfBufferMarkerAdder
1719

1820
object Actions {
1921
fun invokeClick(): ViewAction {
@@ -32,7 +34,6 @@ object Actions {
3234
}
3335
}
3436

35-
@Suppress("DEPRECATION")
3637
fun relativeClick(xPercent: Float = 0.5f, yPercent: Float = 0.5f): ViewAction {
3738
return GeneralClickAction(
3839
Tap.SINGLE,
@@ -45,7 +46,7 @@ object Actions {
4546

4647
floatArrayOf(x, y)
4748
},
48-
Press.FINGER)
49+
Press.FINGER, 0, 0)
4950
}
5051

5152
fun selectAll(): ViewAction {
@@ -65,4 +66,94 @@ object Actions {
6566
}
6667
}
6768
}
69+
70+
fun copyToClipboardAztec(): ViewAction {
71+
return object : ViewAction {
72+
override fun getConstraints(): Matcher<View> {
73+
return allOf(isDisplayed(), isAssignableFrom(EditText::class.java))
74+
}
75+
76+
override fun getDescription(): String {
77+
return "Copy to Aztec clipboard"
78+
}
79+
80+
override fun perform(uiController: UiController?, view: View?) {
81+
if (view is AztecText) {
82+
view.copy(view.text, view.selectionStart, view.selectionEnd)
83+
}
84+
}
85+
}
86+
}
87+
88+
fun copyRangeToClipboardAztec(start: Int, end: Int): ViewAction {
89+
return object : ViewAction {
90+
override fun getConstraints(): Matcher<View> {
91+
return allOf(isDisplayed(), isAssignableFrom(EditText::class.java))
92+
}
93+
94+
override fun getDescription(): String {
95+
return "Copy to Aztec clipboard"
96+
}
97+
98+
override fun perform(uiController: UiController?, view: View?) {
99+
if (view is AztecText) {
100+
view.copy(view.text, start, end)
101+
}
102+
}
103+
}
104+
}
105+
106+
fun pasteFromClipboardAztec(): ViewAction {
107+
return object : ViewAction {
108+
override fun getConstraints(): Matcher<View> {
109+
return allOf(isDisplayed(), isAssignableFrom(EditText::class.java))
110+
}
111+
112+
override fun getDescription(): String {
113+
return "Paste from Aztec clipboard"
114+
}
115+
116+
override fun perform(uiController: UiController?, view: View?) {
117+
if (view is AztecText) {
118+
view.paste(view.text, view.selectionStart, view.selectionEnd)
119+
}
120+
}
121+
}
122+
}
123+
124+
fun pasteRangeFromClipboardAztec(start: Int, end: Int): ViewAction {
125+
return object : ViewAction {
126+
override fun getConstraints(): Matcher<View> {
127+
return allOf(isDisplayed(), isAssignableFrom(EditText::class.java))
128+
}
129+
130+
override fun getDescription(): String {
131+
return "Paste from Aztec clipboard from range [$start] to [$end]"
132+
}
133+
134+
override fun perform(uiController: UiController?, view: View?) {
135+
if (view is AztecText) {
136+
view.paste(view.text, start, end)
137+
}
138+
}
139+
}
140+
}
141+
142+
fun setAztecCursorPositionEnd(): ViewAction {
143+
return object : ViewAction {
144+
override fun getConstraints(): Matcher<View> {
145+
return allOf(isDisplayed(), isAssignableFrom(EditText::class.java))
146+
}
147+
148+
override fun getDescription(): String {
149+
return "Set Aztec cursor at the end of current text buffer"
150+
}
151+
152+
override fun perform(uiController: UiController?, view: View?) {
153+
if (view is AztecText) {
154+
view.setSelection(EndOfBufferMarkerAdder.safeLength(view))
155+
}
156+
}
157+
}
158+
}
68159
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.wordpress.aztec.demo
2+
3+
import android.support.test.rule.ActivityTestRule
4+
import org.junit.Before
5+
import org.junit.Rule
6+
import org.wordpress.aztec.AztecText
7+
8+
/**
9+
* Base class for History testing.
10+
*/
11+
abstract class BaseHistoryTest : BaseTest() {
12+
13+
protected val throttleTime: Long = 1000L
14+
15+
@Rule
16+
@JvmField
17+
var mActivityTestRule = ActivityTestRule(MainActivity::class.java)
18+
19+
/**
20+
* Increases the history time to cover test device variability.
21+
*/
22+
@Before
23+
fun init() {
24+
val aztecText = mActivityTestRule.activity.findViewById<AztecText>(R.id.aztec)
25+
aztecText.history.historyThrottleTime = throttleTime
26+
}
27+
}

app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditorPage.kt

Lines changed: 83 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,18 @@ class EditorPage : BasePage() {
9595
return this
9696
}
9797

98+
/**
99+
* Using selectAllText() + delete() do not work as intended. This method
100+
* will select all the text in the editor and then delete that text.
101+
*/
102+
fun selectAllAndDelete(): EditorPage {
103+
selectAllText()
104+
editor.perform(pressKey(KeyEvent.KEYCODE_FORWARD_DEL))
105+
label("Select all text and delete")
106+
107+
return this
108+
}
109+
98110
fun delete(characters: Int): EditorPage {
99111
for (i in 1..characters) {
100112
editor.perform(pressKey(KeyEvent.KEYCODE_DEL))
@@ -103,6 +115,20 @@ class EditorPage : BasePage() {
103115
return this
104116
}
105117

118+
fun insertNewLine(): EditorPage {
119+
editor.perform(pressKey(KeyEvent.KEYCODE_ENTER))
120+
label("Insert new line")
121+
122+
return this
123+
}
124+
125+
fun clearText(): EditorPage {
126+
editor.perform(ViewActions.clearText())
127+
label("Clear editor text")
128+
129+
return this
130+
}
131+
106132
fun insertText(text: String): EditorPage {
107133
editor.perform(typeText(text), ViewActions.closeSoftKeyboard())
108134
label("Inserted text")
@@ -304,17 +330,71 @@ class EditorPage : BasePage() {
304330
return this
305331
}
306332

333+
fun verify(expected: String): EditorPage {
334+
editor.check(matches(Matchers.withStrippedText(expected)))
335+
label("Verified expected editor contents")
336+
337+
return this
338+
}
339+
307340
fun verifyHTML(expected: String): EditorPage {
308341
htmlEditor.check(matches(Matchers.withStrippedText(expected)))
309-
label("Verified expected editor contents")
342+
label("Verified expected HTML editor contents")
310343

311344
return this
312345
}
313346

314347
fun verifyHTML(expected: Regex): EditorPage {
315348
htmlEditor.check(matches(Matchers.withRegex(expected)))
316-
label("Verified expected editor contents")
349+
label("Verified expected HTML editor contents")
350+
351+
return this
352+
}
353+
354+
fun verifyHTMLNoStripping(expected: String): EditorPage {
355+
htmlEditor.check(matches(withText(expected)))
356+
label("Verified expected HTML editor contents without stripping")
357+
358+
return this
359+
}
360+
361+
fun copyToClipboard(): EditorPage {
362+
editor.perform(Actions.copyToClipboardAztec())
363+
label("Copy to Aztec clipboard")
364+
365+
return this
366+
}
367+
368+
fun copyRangeToClipboard(start: Int, end: Int): EditorPage {
369+
editor.perform(Actions.copyRangeToClipboardAztec(start, end))
370+
label("Copy text from index [$start] to [$end] to clipboard")
371+
372+
return this
373+
}
374+
375+
fun pasteFromClipboard(): EditorPage {
376+
editor.perform(Actions.pasteFromClipboardAztec())
377+
label("Paste from Aztec clipboard")
378+
379+
return this
380+
}
381+
382+
fun pasteRangeFromClipboard(start: Int, end: Int): EditorPage {
383+
editor.perform(Actions.pasteRangeFromClipboardAztec(start, end))
384+
label("Past from Aztec clipboard from range [$start] to [$end]")
385+
386+
return this
387+
}
388+
389+
fun setCursorPositionAtEnd(): EditorPage {
390+
editor.perform(Actions.setAztecCursorPositionEnd())
391+
label("Set Aztec cursor position at the end of text buffer")
392+
393+
return this
394+
}
317395

396+
fun threadSleep(millis: Long): EditorPage {
397+
Thread.sleep(millis)
318398
return this
319399
}
320400

@@ -333,4 +413,4 @@ class EditorPage : BasePage() {
333413
UNORDERED(onData(hasToString("Unordered List"))),
334414
ORDERED(onData(hasToString("Ordered List")))
335415
}
336-
}
416+
}

0 commit comments

Comments
 (0)