Skip to content

Commit c9b96b9

Browse files
authored
Merge pull request #395 from wordpress-mobile/feature/run-ui-tests-with-travis
Fixing tests
2 parents a80ad55 + 07c5961 commit c9b96b9

File tree

2 files changed

+83
-80
lines changed

2 files changed

+83
-80
lines changed

app/src/androidTest/java/org/wordpress/aztec/demo/SimpleTextFormattingTests.java

Lines changed: 50 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import android.support.test.rule.ActivityTestRule;
44
import android.support.test.runner.AndroidJUnit4;
5-
import android.test.suitebuilder.annotation.LargeTest;
65

76
import org.junit.Rule;
87
import org.junit.Test;
@@ -28,23 +27,20 @@
2827
import static org.wordpress.aztec.demo.TestUtils.headingTwoSelector;
2928
import static org.wordpress.aztec.demo.TestUtils.italicButton;
3029
import static org.wordpress.aztec.demo.TestUtils.linkButton;
31-
import static org.wordpress.aztec.demo.TestUtils.linkOKButton;
3230
import static org.wordpress.aztec.demo.TestUtils.linkTextField;
3331
import static org.wordpress.aztec.demo.TestUtils.linkURLField;
3432
import static org.wordpress.aztec.demo.TestUtils.linkURLText;
33+
import static org.wordpress.aztec.demo.TestUtils.listButton;
34+
import static org.wordpress.aztec.demo.TestUtils.listOrderedSelector;
35+
import static org.wordpress.aztec.demo.TestUtils.listUnorderedSelector;
3536
import static org.wordpress.aztec.demo.TestUtils.moreButton;
36-
import static org.wordpress.aztec.demo.TestUtils.orderedListButton;
37-
import static org.wordpress.aztec.demo.TestUtils.pageButton;
38-
import static org.wordpress.aztec.demo.TestUtils.preSelector;
3937
import static org.wordpress.aztec.demo.TestUtils.quoteButton;
4038
import static org.wordpress.aztec.demo.TestUtils.sourceText;
4139
import static org.wordpress.aztec.demo.TestUtils.strikethroughButton;
4240
import static org.wordpress.aztec.demo.TestUtils.toggleHTMLView;
4341
import static org.wordpress.aztec.demo.TestUtils.underlineButton;
4442
import static org.wordpress.aztec.demo.TestUtils.unformattedText;
45-
import static org.wordpress.aztec.demo.TestUtils.unorderedListButton;
4643

47-
@LargeTest
4844
@RunWith(AndroidJUnit4.class)
4945
public class SimpleTextFormattingTests {
5046

@@ -55,7 +51,7 @@ public class SimpleTextFormattingTests {
5551
public void testSimpleBoldFormatting() {
5652
// Enter text in visual editor with formatting
5753
aztecText.perform(typeText(unformattedText));
58-
boldButton.perform(click());
54+
boldButton.perform(betterScrollTo(), betterClick());
5955
aztecText.perform(typeText(formattedText));
6056

6157
// Check that HTML formatting tags were correctly added
@@ -67,7 +63,7 @@ public void testSimpleBoldFormatting() {
6763
public void testSimpleItalicFormatting() {
6864
// Enter text in visual editor with formatting
6965
aztecText.perform(typeText(unformattedText));
70-
italicButton.perform(click());
66+
italicButton.perform(betterScrollTo(),betterClick());
7167
aztecText.perform(typeText(formattedText));
7268

7369
// Check that HTML formatting tags were correctly added
@@ -79,7 +75,7 @@ public void testSimpleItalicFormatting() {
7975
public void testSimpleStrikethroughFormatting() {
8076
// Enter text in visual editor with formatting
8177
aztecText.perform(typeText(unformattedText));
82-
strikethroughButton.perform(click());
78+
strikethroughButton.perform(betterScrollTo(),betterClick());
8379
aztecText.perform(typeText(formattedText));
8480

8581
// Check that HTML formatting tags were correctly added
@@ -91,7 +87,7 @@ public void testSimpleStrikethroughFormatting() {
9187
public void testSimpleUnderlineFormatting() {
9288
// Enter text in visual editor with formatting
9389
aztecText.perform(typeText(unformattedText));
94-
underlineButton.perform(click());
90+
underlineButton.perform(betterScrollTo(),betterClick());
9591
aztecText.perform(typeText(formattedText));
9692

9793
// Check that HTML formatting tags were correctly added
@@ -103,7 +99,7 @@ public void testSimpleUnderlineFormatting() {
10399
public void testSimpleQuoteFormatting() {
104100
// Enter text in visual editor with formatting
105101
aztecText.perform(typeText(unformattedText + "\n"));
106-
quoteButton.perform(click());
102+
quoteButton.perform(betterScrollTo(),betterClick());
107103
aztecText.perform(typeText(formattedText));
108104

109105
// Check that HTML formatting tags were correctly added
@@ -115,7 +111,8 @@ public void testSimpleQuoteFormatting() {
115111
public void testSimpleUnorderedListFormatting() {
116112
// Enter text in visual editor with formatting
117113
aztecText.perform(typeText(unformattedText + "\n"));
118-
unorderedListButton.perform(scrollTo(), click());
114+
listButton.perform(scrollTo(), click());
115+
listUnorderedSelector.perform(betterClick());
119116
aztecText.perform(typeText(formattedText));
120117

121118
// Check that HTML formatting tags were correctly added
@@ -127,7 +124,8 @@ public void testSimpleUnorderedListFormatting() {
127124
public void testSimpleOrderedListFormatting() {
128125
// Enter text in visual editor with formatting
129126
aztecText.perform(typeText(unformattedText + "\n"));
130-
orderedListButton.perform(scrollTo(), click());
127+
listButton.perform(scrollTo(), click());
128+
listOrderedSelector.perform(betterClick());
131129
aztecText.perform(typeText(formattedText));
132130

133131
// Check that HTML formatting tags were correctly added
@@ -148,7 +146,7 @@ public void testSimpleLinkFormatting() {
148146

149147
// Check that link dialog contains the correct values
150148
toggleHTMLView();
151-
linkButton.perform(scrollTo(), click());
149+
linkButton.perform(scrollTo(), betterClick());
152150
linkURLField.check(matches(withText(linkURLText)));
153151
linkTextField.check(matches(withText(formattedText)));
154152
}
@@ -165,24 +163,25 @@ public void testSimpleMoreTagFormatting() {
165163
sourceText.check(matches(withText(unformattedText + "\n\n<!--more-->\n\n" + unformattedText)));
166164
}
167165

168-
@Test
169-
public void testSimplePageBreakFormatting() {
170-
// Enter text in visual editor with page break in between
171-
aztecText.perform(typeText(unformattedText));
172-
pageButton.perform(betterScrollTo(), betterClick());
173-
aztecText.perform(typeTextIntoFocusedView(unformattedText));
174-
175-
// Check that page break was correctly added
176-
toggleHTMLView();
177-
sourceText.check(matches(withText(unformattedText + "\n\n<!--nextpage-->\n\n" + unformattedText)));
178-
}
166+
//TODO: uncomment when Page Break is to be added back as a feature
167+
// @Test
168+
// public void testSimplePageBreakFormatting() {
169+
// // Enter text in visual editor with page break in between
170+
// aztecText.perform(typeText(unformattedText));
171+
// pageButton.perform(betterScrollTo(), betterClick());
172+
// aztecText.perform(typeTextIntoFocusedView(unformattedText));
173+
//
174+
// // Check that page break was correctly added
175+
// toggleHTMLView();
176+
// sourceText.check(matches(withText(unformattedText + "\n\n<!--nextpage-->\n\n" + unformattedText)));
177+
// }
179178

180179
@Test
181180
public void testSimpleHeadingOneFormatting() {
182181
// Enter text in visual editor with formatting
183182
aztecText.perform(typeText(unformattedText + "\n"));
184-
headingButton.perform(click());
185-
headingOneSelector.perform(click());
183+
headingButton.perform(betterScrollTo(),betterClick());
184+
headingOneSelector.perform(betterClick());
186185
aztecText.perform(typeTextIntoFocusedView(formattedText));
187186

188187
// Check that HTML formatting tags were correctly added
@@ -194,8 +193,8 @@ public void testSimpleHeadingOneFormatting() {
194193
public void testSimpleHeadingTwoFormatting() {
195194
// Enter text in visual editor with formatting
196195
aztecText.perform(typeText(unformattedText + "\n"));
197-
headingButton.perform(click());
198-
headingTwoSelector.perform(click());
196+
headingButton.perform(betterScrollTo(),betterClick());
197+
headingTwoSelector.perform(betterClick());
199198
aztecText.perform(typeTextIntoFocusedView(formattedText));
200199

201200
// Check that HTML formatting tags were correctly added
@@ -207,8 +206,8 @@ public void testSimpleHeadingTwoFormatting() {
207206
public void testSimpleHeadingThreeFormatting() {
208207
// Enter text in visual editor with formatting
209208
aztecText.perform(typeText(unformattedText + "\n"));
210-
headingButton.perform(click());
211-
headingThreeSelector.perform(click());
209+
headingButton.perform(betterScrollTo(),betterClick());
210+
headingThreeSelector.perform(betterClick());
212211
aztecText.perform(typeTextIntoFocusedView(formattedText));
213212

214213
// Check that HTML formatting tags were correctly added
@@ -220,8 +219,8 @@ public void testSimpleHeadingThreeFormatting() {
220219
public void testSimpleHeadingFourFormatting() {
221220
// Enter text in visual editor with formatting
222221
aztecText.perform(typeText(unformattedText + "\n"));
223-
headingButton.perform(click());
224-
headingFourSelector.perform(click());
222+
headingButton.perform(betterScrollTo(),betterClick());
223+
headingFourSelector.perform(betterClick());
225224
aztecText.perform(typeTextIntoFocusedView(formattedText));
226225

227226
// Check that HTML formatting tags were correctly added
@@ -233,8 +232,8 @@ public void testSimpleHeadingFourFormatting() {
233232
public void testSimpleHeadingFiveFormatting() {
234233
// Enter text in visual editor with formatting
235234
aztecText.perform(typeText(unformattedText + "\n"));
236-
headingButton.perform(click());
237-
headingFiveSelector.perform(click());
235+
headingButton.perform(betterScrollTo(),betterClick());
236+
headingFiveSelector.perform(betterClick());
238237
aztecText.perform(typeTextIntoFocusedView(formattedText));
239238

240239
// Check that HTML formatting tags were correctly added
@@ -246,25 +245,27 @@ public void testSimpleHeadingFiveFormatting() {
246245
public void testSimpleHeadingSixFormatting() {
247246
// Enter text in visual editor with formatting
248247
aztecText.perform(typeText(unformattedText + "\n"));
249-
headingButton.perform(click());
250-
headingSixSelector.perform(click());
248+
headingButton.perform(betterScrollTo(),betterClick());
249+
headingSixSelector.perform(betterClick());
251250
aztecText.perform(typeTextIntoFocusedView(formattedText));
252251

253252
// Check that HTML formatting tags were correctly added
254253
toggleHTMLView();
255254
sourceText.check(matches(withText(unformattedText + "\n<h6>" + formattedText + "</h6>")));
256255
}
257256

258-
@Test
259-
public void testSimplePreformattedTextFormatting() {
260-
// Enter text in visual editor with formatting
261-
aztecText.perform(typeText(unformattedText + "\n"));
262-
headingButton.perform(click());
263-
preSelector.perform(click());
264-
aztecText.perform(typeTextIntoFocusedView(formattedText));
257+
//TODO: uncomment when Preformatted will be added back as a feature
258+
// @Test
259+
// public void testSimplePreformattedTextFormatting() {
260+
// // Enter text in visual editor with formatting
261+
// aztecText.perform(typeText(unformattedText + "\n"));
262+
// headingButton.perform(betterScrollTo(),betterClick());
263+
// preSelector.perform(betterScrollTo(),betterClick());
264+
// aztecText.perform(typeTextIntoFocusedView(formattedText));
265+
//
266+
// // Check that HTML formatting tags were correctly added
267+
// toggleHTMLView();
268+
// sourceText.check(matches(withText(unformattedText + "\n<pre>" + formattedText + "</pre>")));
269+
// }
265270

266-
// Check that HTML formatting tags were correctly added
267-
toggleHTMLView();
268-
sourceText.check(matches(withText(unformattedText + "\n<pre>" + formattedText + "</pre>")));
269-
}
270271
}

app/src/androidTest/java/org/wordpress/aztec/demo/TestUtils.java

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import static android.support.test.espresso.Espresso.onData;
1212
import static android.support.test.espresso.Espresso.onView;
13-
import static android.support.test.espresso.action.ViewActions.click;
1413
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
1514
import static android.support.test.espresso.matcher.ViewMatchers.withId;
1615
import static org.hamcrest.Matchers.allOf;
@@ -22,54 +21,57 @@
2221
public class TestUtils {
2322

2423
// Strings
25-
public static String unformattedText = "hello";
26-
public static String formattedText = "world";
27-
public static String linkURLText = "https://github.com/wordpress-mobile/AztecEditor-Android";
24+
static String unformattedText = "hello";
25+
static String formattedText = "world";
26+
static String linkURLText = "https://github.com/wordpress-mobile/AztecEditor-Android";
2827

2928
// Editor Views
30-
public static ViewInteraction aztecText = onView(withId(R.id.aztec));
31-
public static ViewInteraction sourceText = onView(allOf(withId(R.id.source), isDisplayed()));
29+
static ViewInteraction aztecText = onView(withId(R.id.aztec));
30+
static ViewInteraction sourceText = onView(allOf(withId(R.id.source), isDisplayed()));
3231

3332
// Format Toolbar Buttons
34-
public static ViewInteraction boldButton = onView(withId(R.id.format_bar_button_bold));
35-
public static ViewInteraction headingButton = onView(withId(R.id.format_bar_button_heading));
36-
public static ViewInteraction italicButton = onView(withId(R.id.format_bar_button_italic));
37-
public static ViewInteraction linkButton = onView(withId(R.id.format_bar_button_link));
38-
public static ViewInteraction moreButton = onView(withId(R.id.format_bar_button_more));
39-
public static ViewInteraction orderedListButton = onView(withId(R.id.format_bar_button_ol));
40-
public static ViewInteraction pageButton = onView(withId(R.id.format_bar_button_page));
41-
public static ViewInteraction quoteButton = onView(withId(R.id.format_bar_button_quote));
42-
public static ViewInteraction strikethroughButton = onView(withId(R.id.format_bar_button_strikethrough));
43-
public static ViewInteraction underlineButton = onView(withId(R.id.format_bar_button_underline));
44-
public static ViewInteraction unorderedListButton = onView(withId(R.id.format_bar_button_ul));
33+
static ViewInteraction boldButton = onView(withId(R.id.format_bar_button_bold));
34+
static ViewInteraction headingButton = onView(withId(R.id.format_bar_button_heading));
35+
static ViewInteraction italicButton = onView(withId(R.id.format_bar_button_italic));
36+
static ViewInteraction linkButton = onView(withId(R.id.format_bar_button_link));
37+
static ViewInteraction moreButton = onView(withId(R.id.format_bar_button_more));
38+
static ViewInteraction pageButton = onView(withId(R.id.format_bar_button_page));
39+
static ViewInteraction quoteButton = onView(withId(R.id.format_bar_button_quote));
40+
static ViewInteraction strikethroughButton = onView(withId(R.id.format_bar_button_strikethrough));
41+
static ViewInteraction underlineButton = onView(withId(R.id.format_bar_button_underline));
42+
static ViewInteraction listButton = onView(withId(R.id.format_bar_button_list));
43+
44+
// List Selectors
45+
static DataInteraction listUnorderedSelector = onData(hasToString("Unordered List"));
46+
static DataInteraction listOrderedSelector = onData(hasToString("Ordered List"));
4547

4648
// Heading/Paragraph Format Selectors
47-
public static DataInteraction headingOneSelector = onData(hasToString("Heading 1"));
48-
public static DataInteraction headingTwoSelector = onData(hasToString("Heading 2"));
49-
public static DataInteraction headingThreeSelector = onData(hasToString("Heading 3"));
50-
public static DataInteraction headingFourSelector = onData(hasToString("Heading 4"));
51-
public static DataInteraction headingFiveSelector = onData(hasToString("Heading 5"));
52-
public static DataInteraction headingSixSelector = onData(hasToString("Heading 6"));
53-
public static DataInteraction preSelector = onData(hasToString("Preformat"));
49+
static DataInteraction headingOneSelector = onData(hasToString("Heading 1"));
50+
static DataInteraction headingTwoSelector = onData(hasToString("Heading 2"));
51+
static DataInteraction headingThreeSelector = onData(hasToString("Heading 3"));
52+
static DataInteraction headingFourSelector = onData(hasToString("Heading 4"));
53+
static DataInteraction headingFiveSelector = onData(hasToString("Heading 5"));
54+
static DataInteraction headingSixSelector = onData(hasToString("Heading 6"));
55+
static DataInteraction preSelector = onData(hasToString("Preformat"));
5456

5557
// Link Modal
56-
public static ViewInteraction linkOKButton = onView(withId(android.R.id.button1));
57-
public static ViewInteraction linkTextField = onView(withId(R.id.linkText));
58-
public static ViewInteraction linkURLField = onView(withId(R.id.linkURL));
58+
static ViewInteraction linkOKButton = onView(withId(android.R.id.button1));
59+
static ViewInteraction linkTextField = onView(withId(R.id.linkText));
60+
static ViewInteraction linkURLField = onView(withId(R.id.linkURL));
5961

6062
// Switch to HTML view
61-
public static void toggleHTMLView() {
63+
static void toggleHTMLView() {
6264
ViewInteraction htmlButton = onView(withId(R.id.format_bar_button_html));
63-
htmlButton.perform(click());
65+
htmlButton.perform(betterScrollTo(), betterClick());
6466
}
6567

6668
// Better scrolling action for last toolbar item (<90% of item displayed)
67-
public static ViewAction betterScrollTo() {
69+
static ViewAction betterScrollTo() {
6870
return ViewActions.actionWithAssertions(new BetterScrollToAction());
6971
}
7072

7173
// Better click action for last toolbar item (<90% of item displayed)
72-
public static ViewAction betterClick() {
74+
static ViewAction betterClick() {
7375
return new BetterClickAction(Tap.SINGLE, GeneralLocation.CENTER, Press.FINGER);
7476
}
7577
}

0 commit comments

Comments
 (0)