Skip to content

Commit

Permalink
1) created a new build flavor for espresso tests
Browse files Browse the repository at this point in the history
2) create a new source set full of espresso tests
3) updated proguard-testing.pro
4) added test device numbers to .gitignore

// FREEBIE
  • Loading branch information
rhodey authored and moxie0 committed Jun 3, 2015
1 parent 6a1bbed commit 7cc2941
Show file tree
Hide file tree
Showing 33 changed files with 2,280 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ signing.properties
library/lib/
library/obj/
ffpr
test/androidTestEspresso/res/values/arrays.xml
18 changes: 17 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ dependencies {
androidTestCompile ('com.squareup.assertj:assertj-android:1.0.0') {
exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
androidTestCompile 'com.android.support.test:runner:0.2'
androidTestCompile ('com.android.support.test.espresso:espresso-core:2.1') {
exclude group: 'javax.inject'
}
}

dependencyVerification {
Expand Down Expand Up @@ -144,6 +146,13 @@ android {
buildConfigField "String", "PUSH_URL", "\"https://textsecure-service.whispersystems.org\""
}

productFlavors {
base { }
espresso {
testInstrumentationRunner "org.thoughtcrime.securesms.TextSecureWakingTestRunner"
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
Expand Down Expand Up @@ -201,9 +210,16 @@ android {
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
espresso {
manifest.srcFile 'test/espresso/AndroidManifest.xml'
}
androidTest {
java.srcDirs = ['test/androidTest/java']
}
androidTestEspresso {
java.srcDirs = ['test/androidTestEspresso/java']
res.srcDirs = ['test/androidTestEspresso/res']
}
}

lintOptions {
Expand Down
1 change: 1 addition & 0 deletions proguard-testing.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
-dontwarn android.test.**
-dontwarn com.android.support.test.**
-dontwarn sun.reflect.**
-dontwarn sun.misc.**
-dontwarn org.assertj.**
-dontwarn org.hamcrest.**
-dontwarn org.mockito.**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Copyright (C) 2015 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.thoughtcrime.securesms;

import org.hamcrest.Matchers;

import static android.support.test.espresso.Espresso.onData;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.matcher.PreferenceMatchers.withKey;

public class ApplicationPreferencesActivityActions {

public static void clickSmsAndMmsSetting() throws Exception {
onData(Matchers.<Object>allOf(withKey("preference_category_sms_mms"))).perform(click());
}

public static void clickNotificationsSetting() throws Exception {
onData(Matchers.<Object>allOf(withKey("preference_category_notifications"))).perform(click());
}

public static void clickAppProtectionSetting() throws Exception {
onData(Matchers.<Object>allOf(withKey("preference_category_app_protection"))).perform(click());
}

public static void clickAppearanceSetting() throws Exception {
onData(Matchers.<Object>allOf(withKey("preference_category_appearance"))).perform(click());
}

public static void clickDeleteOldMessagesSetting() throws Exception {
onData(Matchers.<Object>allOf(withKey("preference_category_storage"))).perform(click());
}

public static void clickAdvancedSetting() throws Exception {
onData(Matchers.<Object>allOf(withKey("preference_category_advanced"))).perform(click());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Copyright (C) 2015 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.thoughtcrime.securesms;

import android.test.suitebuilder.annotation.LargeTest;

import org.hamcrest.Matchers;

import static android.support.test.espresso.Espresso.onData;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.PreferenceMatchers.withKey;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static org.thoughtcrime.securesms.EspressoUtil.waitOn;

@LargeTest
public class ApplicationPreferencesActivityTest extends TextSecureEspressoTestCase<ConversationListActivity> {

public ApplicationPreferencesActivityTest() {
super(ConversationListActivity.class);
}

private void checkAllPreferencesDisplayed() throws Exception {
onData(Matchers.<Object>allOf(withKey("preference_category_sms_mms")))
.check(matches(isDisplayed()));
onData(Matchers.<Object>allOf(withKey("preference_category_notifications")))
.check(matches(isDisplayed()));
onData(Matchers.<Object>allOf(withKey("preference_category_app_protection")))
.check(matches(isDisplayed()));
onData(Matchers.<Object>allOf(withKey("preference_category_appearance")))
.check(matches(isDisplayed()));
onData(Matchers.<Object>allOf(withKey("preference_category_storage")))
.check(matches(isDisplayed()));
onData(Matchers.<Object>allOf(withKey("preference_category_advanced")))
.check(matches(isDisplayed()));
}

public void testClickSettings() throws Exception {
loadActivity(ConversationListActivity.class, STATE_REGISTRATION_SKIPPED);
ConversationListActivityActions.clickSettings(getContext());
waitOn(ApplicationPreferencesActivity.class);
checkAllPreferencesDisplayed();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Copyright (C) 2015 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.thoughtcrime.securesms;

import android.content.Context;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.thoughtcrime.securesms.EspressoUtil.typeTextAndCloseKeyboard;

public class ConversationActivityActions {

public static void clickAddAttachment(Context context) throws Exception {
openActionBarOverflowOrOptionsMenu(context);
onView(withText(R.string.conversation__menu_add_attachment)).perform(click());
}

public static void clickAllImages(Context context) throws Exception {
openActionBarOverflowOrOptionsMenu(context);
onView(withText(R.string.conversation__menu_view_media)).perform(click());
}

public static void clickDeleteThread(Context context) throws Exception {
openActionBarOverflowOrOptionsMenu(context);
onView(withText(R.string.conversation__menu_delete_thread)).perform(click());
}

public static void toggleEmojiKeyboard() throws Exception {
onView(withId(R.id.emoji_toggle)).perform(click());
}

public static void typeMessage(String message) throws Exception {
typeTextAndCloseKeyboard(onView(withId(R.id.embedded_text_editor)), message);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/**
* Copyright (C) 2015 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.thoughtcrime.securesms;

import android.content.Context;

import org.thoughtcrime.securesms.R;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

public class ConversationListActivityActions {

public static void dismissReminder() throws Exception {
onView(withId(R.id.cancel)).perform(click());
}

public static void clickNewConversation() throws Exception {
onView(withId(R.id.fab)).perform(click());
}

public static void clickNewGroup(Context context) throws Exception {
openActionBarOverflowOrOptionsMenu(context);
onView(withText(R.string.text_secure_normal__menu_new_group)).perform(click());
}

public static void clickLock(Context context) throws Exception {
openActionBarOverflowOrOptionsMenu(context);
onView(withText(R.string.text_secure_normal__menu_clear_passphrase)).perform(click());
}

public static void clickMarkAllRead(Context context) throws Exception {
openActionBarOverflowOrOptionsMenu(context);
onView(withText(R.string.text_secure_normal__mark_all_as_read)).perform(click());
}

public static void clickImportExport(Context context) throws Exception {
openActionBarOverflowOrOptionsMenu(context);
onView(withText(R.string.arrays__import_export)).perform(click());
}

public static void clickMyIdentity(Context context) throws Exception {
openActionBarOverflowOrOptionsMenu(context);
onView(withText(R.string.arrays__my_identity_key)).perform(click());
}

public static void clickSettings(Context context) throws Exception {
openActionBarOverflowOrOptionsMenu(context);
onView(withText(R.string.text_secure_normal__menu_settings)).perform(click());
}

public static void deleteSelected() throws Exception {
onView(withId(R.id.menu_delete_selected)).perform(click());
onView(withText(R.string.delete)).perform(click());
}

public static void cancelDeleteSelected() throws Exception {
onView(withId(R.id.menu_delete_selected)).perform(click());
onView(withText(android.R.string.cancel)).perform(click());
}

}
Loading

0 comments on commit 7cc2941

Please sign in to comment.