Skip to content

Commit 7cc2941

Browse files
rhodeymoxie0
authored andcommitted
1) created a new build flavor for espresso tests
2) create a new source set full of espresso tests 3) updated proguard-testing.pro 4) added test device numbers to .gitignore // FREEBIE
1 parent 6a1bbed commit 7cc2941

33 files changed

+2280
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ signing.properties
2020
library/lib/
2121
library/obj/
2222
ffpr
23+
test/androidTestEspresso/res/values/arrays.xml

build.gradle

+17-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ dependencies {
7878
androidTestCompile ('com.squareup.assertj:assertj-android:1.0.0') {
7979
exclude group: 'org.hamcrest', module: 'hamcrest-core'
8080
}
81-
androidTestCompile 'com.android.support.test:runner:0.2'
81+
androidTestCompile ('com.android.support.test.espresso:espresso-core:2.1') {
82+
exclude group: 'javax.inject'
83+
}
8284
}
8385

8486
dependencyVerification {
@@ -144,6 +146,13 @@ android {
144146
buildConfigField "String", "PUSH_URL", "\"https://textsecure-service.whispersystems.org\""
145147
}
146148

149+
productFlavors {
150+
base { }
151+
espresso {
152+
testInstrumentationRunner "org.thoughtcrime.securesms.TextSecureWakingTestRunner"
153+
}
154+
}
155+
147156
compileOptions {
148157
sourceCompatibility JavaVersion.VERSION_1_7
149158
targetCompatibility JavaVersion.VERSION_1_7
@@ -201,9 +210,16 @@ android {
201210
res.srcDirs = ['res']
202211
assets.srcDirs = ['assets']
203212
}
213+
espresso {
214+
manifest.srcFile 'test/espresso/AndroidManifest.xml'
215+
}
204216
androidTest {
205217
java.srcDirs = ['test/androidTest/java']
206218
}
219+
androidTestEspresso {
220+
java.srcDirs = ['test/androidTestEspresso/java']
221+
res.srcDirs = ['test/androidTestEspresso/res']
222+
}
207223
}
208224

209225
lintOptions {

proguard-testing.pro

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
-dontwarn android.test.**
55
-dontwarn com.android.support.test.**
66
-dontwarn sun.reflect.**
7+
-dontwarn sun.misc.**
78
-dontwarn org.assertj.**
89
-dontwarn org.hamcrest.**
910
-dontwarn org.mockito.**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* Copyright (C) 2015 Open Whisper Systems
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
package org.thoughtcrime.securesms;
18+
19+
import org.hamcrest.Matchers;
20+
21+
import static android.support.test.espresso.Espresso.onData;
22+
import static android.support.test.espresso.action.ViewActions.click;
23+
import static android.support.test.espresso.matcher.PreferenceMatchers.withKey;
24+
25+
public class ApplicationPreferencesActivityActions {
26+
27+
public static void clickSmsAndMmsSetting() throws Exception {
28+
onData(Matchers.<Object>allOf(withKey("preference_category_sms_mms"))).perform(click());
29+
}
30+
31+
public static void clickNotificationsSetting() throws Exception {
32+
onData(Matchers.<Object>allOf(withKey("preference_category_notifications"))).perform(click());
33+
}
34+
35+
public static void clickAppProtectionSetting() throws Exception {
36+
onData(Matchers.<Object>allOf(withKey("preference_category_app_protection"))).perform(click());
37+
}
38+
39+
public static void clickAppearanceSetting() throws Exception {
40+
onData(Matchers.<Object>allOf(withKey("preference_category_appearance"))).perform(click());
41+
}
42+
43+
public static void clickDeleteOldMessagesSetting() throws Exception {
44+
onData(Matchers.<Object>allOf(withKey("preference_category_storage"))).perform(click());
45+
}
46+
47+
public static void clickAdvancedSetting() throws Exception {
48+
onData(Matchers.<Object>allOf(withKey("preference_category_advanced"))).perform(click());
49+
}
50+
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* Copyright (C) 2015 Open Whisper Systems
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
package org.thoughtcrime.securesms;
18+
19+
import android.test.suitebuilder.annotation.LargeTest;
20+
21+
import org.hamcrest.Matchers;
22+
23+
import static android.support.test.espresso.Espresso.onData;
24+
import static android.support.test.espresso.assertion.ViewAssertions.matches;
25+
import static android.support.test.espresso.matcher.PreferenceMatchers.withKey;
26+
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
27+
import static org.thoughtcrime.securesms.EspressoUtil.waitOn;
28+
29+
@LargeTest
30+
public class ApplicationPreferencesActivityTest extends TextSecureEspressoTestCase<ConversationListActivity> {
31+
32+
public ApplicationPreferencesActivityTest() {
33+
super(ConversationListActivity.class);
34+
}
35+
36+
private void checkAllPreferencesDisplayed() throws Exception {
37+
onData(Matchers.<Object>allOf(withKey("preference_category_sms_mms")))
38+
.check(matches(isDisplayed()));
39+
onData(Matchers.<Object>allOf(withKey("preference_category_notifications")))
40+
.check(matches(isDisplayed()));
41+
onData(Matchers.<Object>allOf(withKey("preference_category_app_protection")))
42+
.check(matches(isDisplayed()));
43+
onData(Matchers.<Object>allOf(withKey("preference_category_appearance")))
44+
.check(matches(isDisplayed()));
45+
onData(Matchers.<Object>allOf(withKey("preference_category_storage")))
46+
.check(matches(isDisplayed()));
47+
onData(Matchers.<Object>allOf(withKey("preference_category_advanced")))
48+
.check(matches(isDisplayed()));
49+
}
50+
51+
public void testClickSettings() throws Exception {
52+
loadActivity(ConversationListActivity.class, STATE_REGISTRATION_SKIPPED);
53+
ConversationListActivityActions.clickSettings(getContext());
54+
waitOn(ApplicationPreferencesActivity.class);
55+
checkAllPreferencesDisplayed();
56+
}
57+
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* Copyright (C) 2015 Open Whisper Systems
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
package org.thoughtcrime.securesms;
18+
19+
import android.content.Context;
20+
21+
import static android.support.test.espresso.Espresso.onView;
22+
import static android.support.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
23+
import static android.support.test.espresso.action.ViewActions.click;
24+
import static android.support.test.espresso.matcher.ViewMatchers.withId;
25+
import static android.support.test.espresso.matcher.ViewMatchers.withText;
26+
import static org.thoughtcrime.securesms.EspressoUtil.typeTextAndCloseKeyboard;
27+
28+
public class ConversationActivityActions {
29+
30+
public static void clickAddAttachment(Context context) throws Exception {
31+
openActionBarOverflowOrOptionsMenu(context);
32+
onView(withText(R.string.conversation__menu_add_attachment)).perform(click());
33+
}
34+
35+
public static void clickAllImages(Context context) throws Exception {
36+
openActionBarOverflowOrOptionsMenu(context);
37+
onView(withText(R.string.conversation__menu_view_media)).perform(click());
38+
}
39+
40+
public static void clickDeleteThread(Context context) throws Exception {
41+
openActionBarOverflowOrOptionsMenu(context);
42+
onView(withText(R.string.conversation__menu_delete_thread)).perform(click());
43+
}
44+
45+
public static void toggleEmojiKeyboard() throws Exception {
46+
onView(withId(R.id.emoji_toggle)).perform(click());
47+
}
48+
49+
public static void typeMessage(String message) throws Exception {
50+
typeTextAndCloseKeyboard(onView(withId(R.id.embedded_text_editor)), message);
51+
}
52+
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/**
2+
* Copyright (C) 2015 Open Whisper Systems
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
package org.thoughtcrime.securesms;
18+
19+
import android.content.Context;
20+
21+
import org.thoughtcrime.securesms.R;
22+
23+
import static android.support.test.espresso.Espresso.onView;
24+
import static android.support.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
25+
import static android.support.test.espresso.action.ViewActions.click;
26+
import static android.support.test.espresso.matcher.ViewMatchers.withId;
27+
import static android.support.test.espresso.matcher.ViewMatchers.withText;
28+
29+
public class ConversationListActivityActions {
30+
31+
public static void dismissReminder() throws Exception {
32+
onView(withId(R.id.cancel)).perform(click());
33+
}
34+
35+
public static void clickNewConversation() throws Exception {
36+
onView(withId(R.id.fab)).perform(click());
37+
}
38+
39+
public static void clickNewGroup(Context context) throws Exception {
40+
openActionBarOverflowOrOptionsMenu(context);
41+
onView(withText(R.string.text_secure_normal__menu_new_group)).perform(click());
42+
}
43+
44+
public static void clickLock(Context context) throws Exception {
45+
openActionBarOverflowOrOptionsMenu(context);
46+
onView(withText(R.string.text_secure_normal__menu_clear_passphrase)).perform(click());
47+
}
48+
49+
public static void clickMarkAllRead(Context context) throws Exception {
50+
openActionBarOverflowOrOptionsMenu(context);
51+
onView(withText(R.string.text_secure_normal__mark_all_as_read)).perform(click());
52+
}
53+
54+
public static void clickImportExport(Context context) throws Exception {
55+
openActionBarOverflowOrOptionsMenu(context);
56+
onView(withText(R.string.arrays__import_export)).perform(click());
57+
}
58+
59+
public static void clickMyIdentity(Context context) throws Exception {
60+
openActionBarOverflowOrOptionsMenu(context);
61+
onView(withText(R.string.arrays__my_identity_key)).perform(click());
62+
}
63+
64+
public static void clickSettings(Context context) throws Exception {
65+
openActionBarOverflowOrOptionsMenu(context);
66+
onView(withText(R.string.text_secure_normal__menu_settings)).perform(click());
67+
}
68+
69+
public static void deleteSelected() throws Exception {
70+
onView(withId(R.id.menu_delete_selected)).perform(click());
71+
onView(withText(R.string.delete)).perform(click());
72+
}
73+
74+
public static void cancelDeleteSelected() throws Exception {
75+
onView(withId(R.id.menu_delete_selected)).perform(click());
76+
onView(withText(android.R.string.cancel)).perform(click());
77+
}
78+
79+
}

0 commit comments

Comments
 (0)