11package org .wordpress .aztec .demo ;
22
3- import android .support .test .espresso .ViewInteraction ;
43import android .support .test .rule .ActivityTestRule ;
54import android .support .test .runner .AndroidJUnit4 ;
65import android .test .suitebuilder .annotation .LargeTest ;
6+
77import org .junit .Rule ;
88import org .junit .Test ;
99import org .junit .runner .RunWith ;
1010
11- import static android .support .test .espresso .Espresso .onView ;
11+ import static android .support .test .espresso .action .ViewActions .click ;
12+ import static android .support .test .espresso .action .ViewActions .scrollTo ;
13+ import static android .support .test .espresso .action .ViewActions .typeText ;
14+ import static android .support .test .espresso .action .ViewActions .typeTextIntoFocusedView ;
1215import static android .support .test .espresso .assertion .ViewAssertions .matches ;
13- import static android .support .test .espresso .matcher .ViewMatchers .isChecked ;
14- import static android .support .test .espresso .matcher .ViewMatchers .isNotChecked ;
15- import static android .support .test .espresso .matcher .ViewMatchers .withId ;
16- import static org .wordpress .aztec .demo .TestUtils .enterHTML ;
16+ import static android .support .test .espresso .matcher .ViewMatchers .withText ;
17+ import static org .wordpress .aztec .demo .TestUtils .aztecText ;
18+ import static org .wordpress .aztec .demo .TestUtils .boldButton ;
19+ import static org .wordpress .aztec .demo .TestUtils .formattedText ;
20+ import static org .wordpress .aztec .demo .TestUtils .headingButton ;
21+ import static org .wordpress .aztec .demo .TestUtils .headingFiveSelector ;
22+ import static org .wordpress .aztec .demo .TestUtils .headingFourSelector ;
23+ import static org .wordpress .aztec .demo .TestUtils .headingOneSelector ;
24+ import static org .wordpress .aztec .demo .TestUtils .headingSixSelector ;
25+ import static org .wordpress .aztec .demo .TestUtils .headingThreeSelector ;
26+ import static org .wordpress .aztec .demo .TestUtils .headingTwoSelector ;
27+ import static org .wordpress .aztec .demo .TestUtils .italicButton ;
28+ import static org .wordpress .aztec .demo .TestUtils .linkButton ;
29+ import static org .wordpress .aztec .demo .TestUtils .linkOKButton ;
30+ import static org .wordpress .aztec .demo .TestUtils .linkTextField ;
31+ import static org .wordpress .aztec .demo .TestUtils .linkURLField ;
32+ import static org .wordpress .aztec .demo .TestUtils .linkURLText ;
33+ import static org .wordpress .aztec .demo .TestUtils .moreButton ;
34+ import static org .wordpress .aztec .demo .TestUtils .orderedListButton ;
35+ import static org .wordpress .aztec .demo .TestUtils .pageButton ;
36+ import static org .wordpress .aztec .demo .TestUtils .preSelector ;
37+ import static org .wordpress .aztec .demo .TestUtils .quoteButton ;
38+ import static org .wordpress .aztec .demo .TestUtils .sourceText ;
39+ import static org .wordpress .aztec .demo .TestUtils .strikethroughButton ;
40+ import static org .wordpress .aztec .demo .TestUtils .toggleHTMLView ;
41+ import static org .wordpress .aztec .demo .TestUtils .underlineButton ;
42+ import static org .wordpress .aztec .demo .TestUtils .unformattedText ;
43+ import static org .wordpress .aztec .demo .TestUtils .unorderedListButton ;
1744
1845@ LargeTest
1946@ RunWith (AndroidJUnit4 .class )
@@ -24,11 +51,214 @@ public class SimpleTextFormattingTests {
2451
2552 @ Test
2653 public void testSimpleBoldFormatting () {
27- ViewInteraction boldButton = onView (withId (R .id .format_bar_button_bold ));
28- boldButton .check (matches (isNotChecked ()));
54+ // Enter text in visual editor with formatting
55+ aztecText .perform (typeText (unformattedText ));
56+ boldButton .perform (click ());
57+ aztecText .perform (typeText (formattedText ));
58+
59+ // Check that HTML formatting tags were correctly added
60+ toggleHTMLView ();
61+ sourceText .check (matches (withText (unformattedText + "<b>" + formattedText + "</b>" )));
62+ }
63+
64+ @ Test
65+ public void testSimpleItalicFormatting () {
66+ // Enter text in visual editor with formatting
67+ aztecText .perform (typeText (unformattedText ));
68+ italicButton .perform (click ());
69+ aztecText .perform (typeText (formattedText ));
70+
71+ // Check that HTML formatting tags were correctly added
72+ toggleHTMLView ();
73+ sourceText .check (matches (withText (unformattedText + "<i>" + formattedText + "</i>" )));
74+ }
75+
76+ @ Test
77+ public void testSimpleStrikethroughFormatting () {
78+ // Enter text in visual editor with formatting
79+ aztecText .perform (typeText (unformattedText ));
80+ strikethroughButton .perform (click ());
81+ aztecText .perform (typeText (formattedText ));
82+
83+ // Check that HTML formatting tags were correctly added
84+ toggleHTMLView ();
85+ sourceText .check (matches (withText (unformattedText + "<del>" + formattedText + "</del>" )));
86+ }
87+
88+ @ Test
89+ public void testSimpleUnderlineFormatting () {
90+ // Enter text in visual editor with formatting
91+ aztecText .perform (typeText (unformattedText ));
92+ underlineButton .perform (click ());
93+ aztecText .perform (typeText (formattedText ));
94+
95+ // Check that HTML formatting tags were correctly added
96+ toggleHTMLView ();
97+ sourceText .check (matches (withText (unformattedText + "<u>" + formattedText + "</u>" )));
98+ }
99+
100+ @ Test
101+ public void testSimpleQuoteFormatting () {
102+ // Enter text in visual editor with formatting
103+ aztecText .perform (typeText (unformattedText + "\n " ));
104+ quoteButton .perform (click ());
105+ aztecText .perform (typeText (formattedText ));
106+
107+ // Check that HTML formatting tags were correctly added
108+ toggleHTMLView ();
109+ sourceText .check (matches (withText (unformattedText + "\n <blockquote>" + formattedText + "</blockquote>" )));
110+ }
111+
112+ @ Test
113+ public void testSimpleUnorderedListFormatting () {
114+ // Enter text in visual editor with formatting
115+ aztecText .perform (typeText (unformattedText + "\n " ));
116+ unorderedListButton .perform (scrollTo (), click ());
117+ aztecText .perform (typeText (formattedText ));
118+
119+ // Check that HTML formatting tags were correctly added
120+ toggleHTMLView ();
121+ sourceText .check (matches (withText (unformattedText + "\n <ul>\n \t <li>" + formattedText + "</li>\n </ul>" )));
122+ }
123+
124+ @ Test
125+ public void testSimpleOrderedListFormatting () {
126+ // Enter text in visual editor with formatting
127+ aztecText .perform (typeText (unformattedText + "\n " ));
128+ orderedListButton .perform (scrollTo (), click ());
129+ aztecText .perform (typeText (formattedText ));
130+
131+ // Check that HTML formatting tags were correctly added
132+ toggleHTMLView ();
133+ sourceText .check (matches (withText (unformattedText + "\n <ol>\n \t <li>" + formattedText + "</li>\n </ol>" )));
134+ }
135+
136+ @ Test
137+ public void testSimpleLinkFormatting () {
138+ // Enter text in visual editor with formatting
139+ aztecText .perform (typeText (unformattedText ));
140+ linkButton .perform (scrollTo (), click ());
141+ linkURLField .perform (typeTextIntoFocusedView (linkURLText ));
142+ linkTextField .perform (typeText (formattedText ));
143+ linkOKButton .perform (click ());
144+
145+ // Check that HTML formatting tags were correctly added
146+ toggleHTMLView ();
147+ sourceText .check (matches (withText (unformattedText + "<a href='" + linkURLText + "'>" + formattedText + "</a>" )));
148+ }
149+
150+ @ Test
151+ public void testSimpleMoreTagFormatting () {
152+ // Enter text in visual editor more tag in between
153+ aztecText .perform (typeText (unformattedText ));
154+ moreButton .perform (scrollTo (), click ());
155+ aztecText .perform (typeTextIntoFocusedView (unformattedText ));
156+
157+ // Check that more tag was correctly added
158+ toggleHTMLView ();
159+ sourceText .check (matches (withText (unformattedText + "\n \n <!--more-->\n \n " + unformattedText )));
160+ }
161+
162+ @ Test
163+ public void testSimplePageBreakFormatting () {
164+ // Enter text in visual editor with page break in between
165+ aztecText .perform (typeText (unformattedText ));
166+ pageButton .perform (scrollTo (), click ());
167+ aztecText .perform (typeTextIntoFocusedView (unformattedText ));
168+
169+ // Check that page break was correctly added
170+ toggleHTMLView ();
171+ sourceText .check (matches (withText (unformattedText + "\n \n <!--pagebreak-->\n \n " + unformattedText )));
172+ }
173+
174+ @ Test
175+ public void testSimpleHeadingOneFormatting () {
176+ // Enter text in visual editor with formatting
177+ aztecText .perform (typeText (unformattedText + "\n " ));
178+ headingButton .perform (click ());
179+ headingOneSelector .perform (click ());
180+ aztecText .perform (typeTextIntoFocusedView (formattedText ));
181+
182+ // Check that HTML formatting tags were correctly added
183+ toggleHTMLView ();
184+ sourceText .check (matches (withText (unformattedText + "\n <h1>" + formattedText + "</h1>" )));
185+ }
186+
187+ @ Test
188+ public void testSimpleHeadingTwoFormatting () {
189+ // Enter text in visual editor with formatting
190+ aztecText .perform (typeText (unformattedText + "\n " ));
191+ headingButton .perform (click ());
192+ headingTwoSelector .perform (click ());
193+ aztecText .perform (typeTextIntoFocusedView (formattedText ));
194+
195+ // Check that HTML formatting tags were correctly added
196+ toggleHTMLView ();
197+ sourceText .check (matches (withText (unformattedText + "\n <h2>" + formattedText + "</h2>" )));
198+ }
199+
200+ @ Test
201+ public void testSimpleHeadingThreeFormatting () {
202+ // Enter text in visual editor with formatting
203+ aztecText .perform (typeText (unformattedText + "\n " ));
204+ headingButton .perform (click ());
205+ headingThreeSelector .perform (click ());
206+ aztecText .perform (typeTextIntoFocusedView (formattedText ));
207+
208+ // Check that HTML formatting tags were correctly added
209+ toggleHTMLView ();
210+ sourceText .check (matches (withText (unformattedText + "\n <h3>" + formattedText + "</h3>" )));
211+ }
212+
213+ @ Test
214+ public void testSimpleHeadingFourFormatting () {
215+ // Enter text in visual editor with formatting
216+ aztecText .perform (typeText (unformattedText + "\n " ));
217+ headingButton .perform (click ());
218+ headingFourSelector .perform (click ());
219+ aztecText .perform (typeTextIntoFocusedView (formattedText ));
220+
221+ // Check that HTML formatting tags were correctly added
222+ toggleHTMLView ();
223+ sourceText .check (matches (withText (unformattedText + "\n <h4>" + formattedText + "</h4>" )));
224+ }
225+
226+ @ Test
227+ public void testSimpleHeadingFiveFormatting () {
228+ // Enter text in visual editor with formatting
229+ aztecText .perform (typeText (unformattedText + "\n " ));
230+ headingButton .perform (click ());
231+ headingFiveSelector .perform (click ());
232+ aztecText .perform (typeTextIntoFocusedView (formattedText ));
233+
234+ // Check that HTML formatting tags were correctly added
235+ toggleHTMLView ();
236+ sourceText .check (matches (withText (unformattedText + "\n <h5>" + formattedText + "</h5>" )));
237+ }
238+
239+ @ Test
240+ public void testSimpleHeadingSixFormatting () {
241+ // Enter text in visual editor with formatting
242+ aztecText .perform (typeText (unformattedText + "\n " ));
243+ headingButton .perform (click ());
244+ headingSixSelector .perform (click ());
245+ aztecText .perform (typeTextIntoFocusedView (formattedText ));
246+
247+ // Check that HTML formatting tags were correctly added
248+ toggleHTMLView ();
249+ sourceText .check (matches (withText (unformattedText + "\n <h6>" + formattedText + "</h6>" )));
250+ }
29251
30- enterHTML ("<b>hello world</b>" );
252+ @ Test
253+ public void testSimplePreformattedTextFormatting () {
254+ // Enter text in visual editor with formatting
255+ aztecText .perform (typeText (unformattedText + "\n " ));
256+ headingButton .perform (click ());
257+ preSelector .perform (click ());
258+ aztecText .perform (typeTextIntoFocusedView (formattedText ));
31259
32- boldButton .check (matches (isChecked ()));
260+ // Check that HTML formatting tags were correctly added
261+ toggleHTMLView ();
262+ sourceText .check (matches (withText (unformattedText + "\n <pre>" + formattedText + "</pre>" )));
33263 }
34- }
264+ }
0 commit comments