summaryrefslogtreecommitdiff
path: root/libraries/app-helpers/interfaces/handheld/src/android/platform/helpers/IGmailHelper.java
blob: 4c01fa8c808e9da50322320a82c7299a4e0be0f5 (plain)
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.platform.helpers;

import android.support.test.uiautomator.Direction;

import java.util.List;

public interface IGmailHelper extends IAppHelper {

    /**
     * Setup expectations: Gmail is open and the navigation bar is visible.
     *
     * This method will navigate to the Inbox or Primary, depending on the name.
     */
    public void goToInbox();

    /**
     * Alias method for AbstractGmailHelper#goToInbox
     */
    public void goToPrimary();

    /**
     * Setup expectations: Gmail is open on the Inbox or Primary page.
     *
     * This method will open a new e-mail to compose and block until complete.
     */
    public void goToComposeEmail();

    /**
     * Checks if the current view is the compose email view.
     *
     * @return true if the current view is the compose email view, false otherwise.
     */
    public boolean isInComposeEmail();

    /**
     * Checks if the app is open on the Inbox or Primary page.
     *
     * @return true if the current view is the Inbox or Primary page, false otherwise.
     */
    public boolean isInPrimaryOrInbox();

    /**
     * Setup expectations: Gmail is open and on the Inbox or Primary page.
     *
     * This method will open the (index)'th visible e-mail in the list and block until the e-mail is
     * visible in the foreground. The top-most visible e-mail will always be labeled 0. To get the
     * number of visible e-mails, consult the getVisibleEmailCount() function.
     */
    public void openEmailByIndex(int index);

    /**
     * Setup expectations: Gmail is open and on the Inbox or Primary page.
     *
     * This method will return the number of visible e-mails for use with the #openEmailByIndex
     * method.
     */
    public int getVisibleEmailCount();

    /**
     * Setup expectations: Gmail is open and an e-mail is open in the foreground.
     *
     * This method will press reply, send a reply e-mail with the given parameters, and block until
     * the original message is in the foreground again.
     */
    public void sendReplyEmail(String address, String body);

    /**
     * Setup expectations: Gmail is open and composing an e-mail.
     *
     * This method will set the e-mail's To address and block until complete.
     */
    public void setEmailToAddress(String address);

    /**
     * Setup expectations: Gmail is open and composing an e-mail.
     *
     * This method will set the e-mail's subject and block until complete.
     */
    public void setEmailSubject(String subject);

    /**
     * Setup expectations: Gmail is open and composing an e-mail.
     *
     * This method will set the e-mail's Body (doesn't use keyboard) and block until complete. Focus
     * will remain on the e-mail body after completion.
     *
     * * @param body The messages to input in the e-mail body.
     */
    public void setEmailBody(String body);

    /**
     * Setup expectations: Gmail is open and composing an e-mail.
     *
     * This method inputs the e-mail body.
     *
     * @param body The messages to input in the e-mail body.
     * @param useKeyboard Types out the e-mail body by keyboard or not.
     */
    default public void setEmailBody(String body, boolean useKeyboard) {
        throw new UnsupportedOperationException("Not yet implemented.");
    }

    /**
     * Setup expectations: Gmail is open and composing an e-mail.
     *
     * This method will press send and block until the device is idle on the original e-mail.
     */
    public void clickSendButton();

    /**
     * Setup expectations: Gmail is open and composing an e-mail.
     *
     * This method will get the e-mail's composition's body and block until complete.
     *
     * @return {String} the text contained in the email composition's body.
     */
    public String getComposeEmailBody();

    /**
     * Setup expectations: Gmail is open and the navigation drawer is visible.
     *
     * This method will open the navigation drawer and block until complete.
     */
    public void openNavigationDrawer();

    /**
     * Setup expectations: Gmail is open and the navigation drawer is open.
     *
     * This method will close the navigation drawer and returns true otherwise false
     */
    public boolean closeNavigationDrawer();

    /**
     * Setup expectations: Gmail is open and the navigation drawer is open.
     *
     * This method will scroll the navigation drawer and block until idle. Only accepts UP and DOWN.
     */
    public void scrollNavigationDrawer(Direction dir);

    /**
     * Setup expectations: Gmail is open and a mailbox is open.
     *
     * This method will scroll the mailbox view.
     *
     * @param direction     The direction to scroll, only accepts UP and DOWN.
     * @param amount        The amount to scroll
     * @param scrollToEnd   Whether or not to scroll to the end
     */
    public void scrollMailbox(Direction direction, float amount, boolean scrollToEnd);

    /**
     * Setup expectations: Gmail is open and an email is open.
     *
     * This method will scroll the current email.
     *
     * @param direction     The direction to scroll, only accepts UP and DOWN.
     * @param amount        The amount to scroll
     * @param scrollToEnd   Whether or not to scroll to the end
     */
    public void scrollEmail(Direction direction, float amount, boolean scrollToEnd);

    /**
     * Setup expectations: Gmail is open and the navigation drawer is open.
     *
     * This method will open the mailbox with the given name and block until emails in
     * that mailbox have loaded.
     *
     * @param mailboxName The case insensitive name of the mailbox to open
     */
    public void openMailbox(String mailboxName);

    /**
     * Setup expectations: Gmail is open and an email is open.
     *
     * This method will return to the mailbox the current email was opened from.
     */
    public void returnToMailbox();

    /**
     * Setup expectations: Gmail is open and an email is open.
     *
     * This method starts downloading the attachment at the specified index in the current email.
     * The download happens in the background. This method returns immediately after starting
     * the download and does not wait for the download to complete.
     *
     * @param index The index of the attachment to download
     */
    public void downloadAttachment(int index);

    /**
     * Setup expectations: Gmail is open and an email is open.
     *
     * This method gets every link target in an open email by traversing the UI tree of the body
     * of the open message.
     *
     * @return an iterator over the links in the message
     */
    public List<String> getEmailLinks();

    /**
     * Setup expectations: Gmail is open and an email is open.
     *
     * This method clicks the link in the open email with the given target.
     *
     * @param target the target of the link to click
     */
    public void openEmailLink(String target);

    /**
     * Setup expectations: Gmail is open and an email is open.
     *
     * This method swipes the current email.
     *
     * @param direction The direction to swipe, only accepts LEFT and RIGHT.
     */
    default public void swipeEmail(Direction direction) {
        throw new UnsupportedOperationException("Not yet implemented.");
    }
}