mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 00:37:47 +00:00
remove unmaintained espresso tests
we hardly knew ye closes #4559 // FREEBIE
This commit is contained in:
parent
487f8cbb38
commit
43ebf829ca
@ -1,51 +0,0 @@
|
||||
/**
|
||||
* 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());
|
||||
}
|
||||
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/**
|
||||
* 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.Espresso.openContextualActionModeOverflowMenu;
|
||||
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 clickForwardMessage() throws Exception {
|
||||
openContextualActionModeOverflowMenu();
|
||||
onView(withText(R.string.conversation_context__menu_forward_message)).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);
|
||||
}
|
||||
|
||||
public static void clickSend() throws Exception {
|
||||
onView(withId(R.id.send_button)).perform(click());
|
||||
}
|
||||
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.action.ViewActions.click;
|
||||
import static android.support.test.espresso.action.ViewActions.longClick;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static org.thoughtcrime.securesms.EspressoUtil.addContact;
|
||||
import static org.thoughtcrime.securesms.EspressoUtil.waitOn;
|
||||
|
||||
/**
|
||||
* rhodey
|
||||
*/
|
||||
@LargeTest
|
||||
public class ConversationActivityTest extends TextSecureEspressoTestCase<ConversationListActivity> {
|
||||
|
||||
public ConversationActivityTest() {
|
||||
super(ConversationListActivity.class);
|
||||
}
|
||||
|
||||
public void testForwardMessage() throws Exception {
|
||||
final String[] CONTACT_NAMES = new String[] {"Clement Duval", "Masha Kolenkia"};
|
||||
final String[] CONTACT_NUMBERS = new String[] {"55555555555", "33333333333"};
|
||||
final String MESSAGE = "I struck him in the name of liberty";
|
||||
|
||||
addContact(getContext(), CONTACT_NAMES[0], CONTACT_NUMBERS[0]);
|
||||
addContact(getContext(), CONTACT_NAMES[1], CONTACT_NUMBERS[1]);
|
||||
loadActivity(ConversationListActivity.class, STATE_REGISTERED);
|
||||
|
||||
ConversationListActivityActions.clickNewConversation();
|
||||
waitOn(NewConversationActivity.class);
|
||||
NewConversationActivityActions.clickContactWithName(CONTACT_NAMES[0]);
|
||||
waitOn(ConversationActivity.class);
|
||||
ConversationActivityActions.typeMessage(MESSAGE);
|
||||
ConversationActivityActions.clickSend();
|
||||
|
||||
onView(withText(MESSAGE)).perform(longClick());
|
||||
ConversationActivityActions.clickForwardMessage();
|
||||
|
||||
waitOn(ShareActivity.class);
|
||||
onView(withId(R.id.menu_new_message)).perform(click());
|
||||
waitOn(NewConversationActivity.class);
|
||||
NewConversationActivityActions.filterNameOrNumber(CONTACT_NAMES[1]);
|
||||
NewConversationActivityActions.clickContactWithName(CONTACT_NAMES[1]);
|
||||
|
||||
waitOn(ConversationActivity.class);
|
||||
onView(withText(MESSAGE)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
/**
|
||||
* 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__your_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());
|
||||
}
|
||||
|
||||
}
|
@ -1,279 +0,0 @@
|
||||
/**
|
||||
* 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 android.util.Log;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
import org.thoughtcrime.securesms.components.reminder.DefaultSmsReminder;
|
||||
import org.thoughtcrime.securesms.components.reminder.ExpiredBuildReminder;
|
||||
import org.thoughtcrime.securesms.components.reminder.PushRegistrationReminder;
|
||||
import org.thoughtcrime.securesms.components.reminder.SystemSmsImportReminder;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
|
||||
import static android.support.test.espresso.Espresso.pressBack;
|
||||
import static android.support.test.espresso.action.ViewActions.longClick;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withContentDescription;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
import static org.thoughtcrime.securesms.EspressoUtil.addContact;
|
||||
import static org.thoughtcrime.securesms.EspressoUtil.waitOn;
|
||||
import static org.thoughtcrime.securesms.ViewMatchers.withRecyclerItem;
|
||||
import static org.thoughtcrime.securesms.ViewMatchers.withRecyclerItemCount;
|
||||
|
||||
@LargeTest
|
||||
public class ConversationListActivityTest extends TextSecureEspressoTestCase<ConversationListActivity> {
|
||||
private final static String TAG = ConversationListActivityTest.class.getSimpleName();
|
||||
|
||||
public ConversationListActivityTest() {
|
||||
super(ConversationListActivity.class);
|
||||
}
|
||||
|
||||
private void checkOptionsMenuItemsDisplayed() throws Exception {
|
||||
onView(withContentDescription(getContext().getString(R.string.conversation_list__menu_search)))
|
||||
.check(matches(isDisplayed()));
|
||||
|
||||
openActionBarOverflowOrOptionsMenu(getContext());
|
||||
onView(withText(R.string.text_secure_normal__menu_new_group)).check(matches(isDisplayed()));
|
||||
onView(withText(R.string.text_secure_normal__mark_all_as_read)).check(matches(isDisplayed()));
|
||||
onView(withText(R.string.arrays__import_export)).check(matches(isDisplayed()));
|
||||
onView(withText(R.string.arrays__your_identity_key)).check(matches(isDisplayed()));
|
||||
onView(withText(R.string.text_secure_normal__menu_settings)).check(matches(isDisplayed()));
|
||||
|
||||
if (!TextSecurePreferences.isPasswordDisabled(getContext())) {
|
||||
onView(withText(R.string.text_secure_normal__menu_clear_passphrase))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
pressBack();
|
||||
}
|
||||
|
||||
private boolean checkReminderIsDisplayed() throws Exception {
|
||||
boolean reminderVisible = true;
|
||||
Integer reminderTitleResId = null;
|
||||
Integer reminderTextResId = null;
|
||||
|
||||
if (ExpiredBuildReminder.isEligible(getContext())) {
|
||||
reminderTitleResId = R.string.reminder_header_expired_build;
|
||||
reminderTextResId = R.string.reminder_header_expired_build_details;
|
||||
} else if (DefaultSmsReminder.isEligible(getContext())) {
|
||||
reminderTitleResId = R.string.reminder_header_sms_default_title;
|
||||
reminderTextResId = R.string.reminder_header_sms_default_text;
|
||||
} else if (SystemSmsImportReminder.isEligible(getContext())) {
|
||||
reminderTitleResId = R.string.reminder_header_sms_import_title;
|
||||
reminderTextResId = R.string.reminder_header_sms_import_text;
|
||||
} else if (PushRegistrationReminder.isEligible(getContext())) {
|
||||
reminderTitleResId = R.string.reminder_header_push_title;
|
||||
reminderTextResId = R.string.reminder_header_push_text;
|
||||
} else {
|
||||
reminderVisible = false;
|
||||
}
|
||||
|
||||
if (reminderVisible) {
|
||||
onView(withId(R.id.reminder_title)).check(matches(isDisplayed()));
|
||||
onView(withId(R.id.reminder_title)).check(matches(withText(reminderTitleResId)));
|
||||
onView(withId(R.id.reminder_text)).check(matches(isDisplayed()));
|
||||
onView(withId(R.id.reminder_text)).check(matches(withText(reminderTextResId)));
|
||||
}
|
||||
|
||||
return reminderVisible;
|
||||
}
|
||||
|
||||
private void loadAndCheckState() throws Exception {
|
||||
loadActivity(ConversationListActivity.class, STATE_REGISTRATION_SKIPPED);
|
||||
checkOptionsMenuItemsDisplayed();
|
||||
checkReminderIsDisplayed();
|
||||
}
|
||||
|
||||
public void testDismissAllReminders() throws Exception {
|
||||
loadAndCheckState();
|
||||
|
||||
int expectedReminders = 0;
|
||||
if (ExpiredBuildReminder.isEligible(getContext())) expectedReminders++;
|
||||
if (DefaultSmsReminder.isEligible(getContext())) expectedReminders++;
|
||||
if (SystemSmsImportReminder.isEligible(getContext())) expectedReminders++;
|
||||
|
||||
Log.d(TAG, "expecting to see " + expectedReminders + " reminders");
|
||||
while (expectedReminders > 0) {
|
||||
if (!checkReminderIsDisplayed()) {
|
||||
throw new IllegalStateException("expected to see " + expectedReminders + " more reminders");
|
||||
}
|
||||
|
||||
Log.d(TAG, "found reminder, dismissing now");
|
||||
ConversationListActivityActions.dismissReminder();
|
||||
expectedReminders--;
|
||||
|
||||
ConversationListActivityActions.clickSettings(getContext());
|
||||
waitOn(ApplicationPreferencesActivity.class);
|
||||
pressBack();
|
||||
waitOn(ConversationListActivity.class);
|
||||
}
|
||||
|
||||
if (checkReminderIsDisplayed() && !PushRegistrationReminder.isEligible(getContext())) {
|
||||
throw new IllegalStateException("only expected to see " + expectedReminders + " reminders");
|
||||
}
|
||||
}
|
||||
|
||||
public void testClickNewConversation() throws Exception {
|
||||
loadAndCheckState();
|
||||
ConversationListActivityActions.clickNewConversation();
|
||||
waitOn(NewConversationActivity.class);
|
||||
}
|
||||
|
||||
public void testClickNewGroup() throws Exception {
|
||||
loadAndCheckState();
|
||||
ConversationListActivityActions.clickNewGroup(getContext());
|
||||
waitOn(GroupCreateActivity.class);
|
||||
}
|
||||
|
||||
public void testClickImportExport() throws Exception {
|
||||
loadAndCheckState();
|
||||
ConversationListActivityActions.clickImportExport(getContext());
|
||||
waitOn(ImportExportActivity.class);
|
||||
}
|
||||
|
||||
public void testClickMyIdentity() throws Exception {
|
||||
loadAndCheckState();
|
||||
ConversationListActivityActions.clickMyIdentity(getContext());
|
||||
waitOn(ViewLocalIdentityActivity.class);
|
||||
}
|
||||
|
||||
public void testClickSettings() throws Exception {
|
||||
loadAndCheckState();
|
||||
ConversationListActivityActions.clickSettings(getContext());
|
||||
waitOn(ApplicationPreferencesActivity.class);
|
||||
}
|
||||
|
||||
public static Matcher<Object> isThreadFrom(final String contactName) {
|
||||
return new TypeSafeMatcher<Object>() {
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("is thread from: " + contactName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(Object object) {
|
||||
if (!(object instanceof ConversationListItem)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ConversationListItem itemView = (ConversationListItem) object;
|
||||
TextView fromView = (TextView) itemView.findViewById(R.id.from);
|
||||
return fromView.getText().toString().equals(contactName);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Matcher<Object> withThreadSnippet(final String snippet) {
|
||||
return new TypeSafeMatcher<Object>() {
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("is thread with snippet: " + snippet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(Object object) {
|
||||
if (!(object instanceof ConversationListItem)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ConversationListItem itemView = (ConversationListItem) object;
|
||||
TextView snippetView = (TextView) itemView.findViewById(R.id.subject);
|
||||
return snippetView.getText().toString().equals(snippet);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testSaveTextDraft() throws Exception {
|
||||
final String CONTACT_NAME = "Clement Duval";
|
||||
final String CONTACT_NUMBER = "55555555555";
|
||||
final String DRAFT_MESSAGE = "I struck him in the name of liberty";
|
||||
final String DRAFT_SNIPPET = getContext().getString(R.string.ThreadRecord_draft) + " " + DRAFT_MESSAGE;
|
||||
|
||||
addContact(getContext(), CONTACT_NAME, CONTACT_NUMBER);
|
||||
loadAndCheckState();
|
||||
|
||||
ConversationListActivityActions.clickNewConversation();
|
||||
waitOn(NewConversationActivity.class);
|
||||
NewConversationActivityActions.clickContactWithName(CONTACT_NAME);
|
||||
waitOn(ConversationActivity.class);
|
||||
ConversationActivityActions.typeMessage(DRAFT_MESSAGE);
|
||||
pressBack();
|
||||
waitOn(ConversationListActivity.class);
|
||||
|
||||
onView(withId(R.id.list)).check(matches(
|
||||
withRecyclerItemCount(1L)
|
||||
));
|
||||
onView(withId(R.id.list)).check(matches(
|
||||
withRecyclerItem(allOf(
|
||||
isDisplayed(),
|
||||
isThreadFrom(CONTACT_NAME),
|
||||
withThreadSnippet(DRAFT_SNIPPET)))
|
||||
));
|
||||
}
|
||||
|
||||
/*
|
||||
this is known to fail on some older devices due to some espresso
|
||||
related app-compat bug
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testSaveDeleteTextDraft() throws Exception {
|
||||
final String CONTACT_NAME = "Clement Duval";
|
||||
final String CONTACT_NUMBER = "55555555555";
|
||||
final String DRAFT_MESSAGE = "I struck him in the name of liberty";
|
||||
final String DRAFT_SNIPPET = getContext().getString(R.string.ThreadRecord_draft) + " " + DRAFT_MESSAGE;
|
||||
|
||||
addContact(getContext(), CONTACT_NAME, CONTACT_NUMBER);
|
||||
loadAndCheckState();
|
||||
|
||||
ConversationListActivityActions.clickNewConversation();
|
||||
waitOn(NewConversationActivity.class);
|
||||
NewConversationActivityActions.clickContactWithName(CONTACT_NAME);
|
||||
waitOn(ConversationActivity.class);
|
||||
ConversationActivityActions.typeMessage(DRAFT_MESSAGE);
|
||||
pressBack();
|
||||
waitOn(ConversationListActivity.class);
|
||||
|
||||
onView(withId(R.id.list)).check(matches(
|
||||
withRecyclerItemCount(1L)
|
||||
));
|
||||
onView(withId(R.id.list)).check(matches(
|
||||
withRecyclerItem(allOf(
|
||||
isDisplayed(),
|
||||
isThreadFrom(CONTACT_NAME),
|
||||
withThreadSnippet(DRAFT_SNIPPET)))
|
||||
));
|
||||
|
||||
onView(withText(CONTACT_NAME)).perform(longClick());
|
||||
ConversationListActivityActions.deleteSelected();
|
||||
|
||||
onView(withId(R.id.list)).check(matches(
|
||||
withRecyclerItemCount(0L)
|
||||
));
|
||||
}
|
||||
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
/**
|
||||
* 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.app.Activity;
|
||||
import android.app.Instrumentation.ActivityMonitor;
|
||||
import android.content.ContentProviderOperation;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.provider.ContactsContract;
|
||||
import android.support.test.espresso.NoActivityResumedException;
|
||||
import android.support.test.espresso.ViewInteraction;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static android.support.test.espresso.action.ViewActions.replaceText;
|
||||
import static android.support.test.espresso.action.ViewActions.typeText;
|
||||
import static android.support.test.espresso.Espresso.closeSoftKeyboard;
|
||||
import static android.support.test.espresso.Espresso.pressBack;
|
||||
|
||||
public class EspressoUtil {
|
||||
private final static String TAG = EspressoUtil.class.getSimpleName();
|
||||
|
||||
public static void waitOn(Class<? extends Activity> clazz) {
|
||||
Log.w(TAG, "waiting for " + clazz.getName());
|
||||
new ActivityMonitor(clazz.getName(), null, true).waitForActivityWithTimeout(10000);
|
||||
}
|
||||
|
||||
public static void actuallyCloseSoftKeyboard() throws Exception {
|
||||
closeSoftKeyboard();
|
||||
Thread.sleep(800);
|
||||
}
|
||||
|
||||
public static void typeTextAndCloseKeyboard(ViewInteraction view, String text) throws Exception {
|
||||
view.perform(typeText(text));
|
||||
actuallyCloseSoftKeyboard();
|
||||
}
|
||||
|
||||
public static void replaceTextAndCloseKeyboard(ViewInteraction view, String text) throws Exception {
|
||||
view.perform(replaceText(text));
|
||||
actuallyCloseSoftKeyboard();
|
||||
}
|
||||
|
||||
public static void closeAllActivities() throws Exception {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
try {
|
||||
|
||||
pressBack();
|
||||
|
||||
} catch (NoActivityResumedException e) {
|
||||
Log.d(TAG, "you made me do this, android");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalStateException("what are you doing with 10 open activities?!");
|
||||
}
|
||||
|
||||
public static long addContact(Context context, String name, String number) throws Exception {
|
||||
ArrayList<ContentProviderOperation> operations = new ArrayList<>();
|
||||
|
||||
operations.add(ContentProviderOperation
|
||||
.newInsert(ContactsContract.RawContacts.CONTENT_URI)
|
||||
.withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, null)
|
||||
.withValue(ContactsContract.RawContacts.ACCOUNT_NAME, null)
|
||||
.build());
|
||||
|
||||
operations.add(ContentProviderOperation
|
||||
.newInsert(ContactsContract.Data.CONTENT_URI)
|
||||
.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
|
||||
.withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE)
|
||||
.withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, name)
|
||||
.build());
|
||||
|
||||
operations.add(ContentProviderOperation.
|
||||
newInsert(ContactsContract.Data.CONTENT_URI)
|
||||
.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
|
||||
.withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE)
|
||||
.withValue(ContactsContract.CommonDataKinds.Phone.NUMBER, number)
|
||||
.withValue(ContactsContract.CommonDataKinds.Phone.TYPE, ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE)
|
||||
.build());
|
||||
|
||||
return context.getContentResolver().applyBatch(ContactsContract.AUTHORITY, operations).length;
|
||||
}
|
||||
|
||||
public static void removeAllContacts(Context context) throws Exception {
|
||||
ContentResolver contentResolver = context.getContentResolver();
|
||||
Cursor cursor = contentResolver.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
|
||||
|
||||
try {
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
String contactKey = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
|
||||
Uri contactUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, contactKey);
|
||||
contentResolver.delete(contactUri, null, null);
|
||||
}
|
||||
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
/**
|
||||
* 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.support.test.espresso.matcher.ViewMatchers;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
||||
@LargeTest
|
||||
public class GroupCreateActivityTest extends TextSecureEspressoTestCase<ConversationListActivity> {
|
||||
|
||||
public GroupCreateActivityTest() {
|
||||
super(ConversationListActivity.class);
|
||||
}
|
||||
|
||||
private void clickNewGroup() throws Exception {
|
||||
ConversationListActivityActions.clickNewGroup(getContext());
|
||||
EspressoUtil.waitOn(GroupCreateActivity.class);
|
||||
}
|
||||
|
||||
public void testLayoutWithPush() throws Exception {
|
||||
loadActivity(ConversationListActivity.class, STATE_REGISTERED);
|
||||
clickNewGroup();
|
||||
|
||||
onView(ViewMatchers.withId(R.id.push_disabled)).check(matches(not(isDisplayed())));
|
||||
onView(withId(R.id.push_disabled_reason)).check(matches(not(isDisplayed())));
|
||||
}
|
||||
|
||||
public void testLayoutWithoutPush() throws Exception {
|
||||
loadActivity(ConversationListActivity.class, STATE_REGISTRATION_SKIPPED);
|
||||
clickNewGroup();
|
||||
|
||||
onView(ViewMatchers.withId(R.id.push_disabled)).check(matches(isDisplayed()));
|
||||
onView(withId(R.id.push_disabled_reason)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/**
|
||||
* 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.support.test.espresso.matcher.ViewMatchers;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.action.ViewActions.swipeLeft;
|
||||
import static android.support.test.espresso.action.ViewActions.swipeRight;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
|
||||
@LargeTest
|
||||
public class ImportExportActivityTest extends TextSecureEspressoTestCase<ConversationListActivity> {
|
||||
|
||||
public ImportExportActivityTest() {
|
||||
super(ConversationListActivity.class);
|
||||
}
|
||||
|
||||
private void checkImportLayout() throws Exception {
|
||||
onView(ViewMatchers.withId(R.id.import_sms)).check(matches(isDisplayed()));
|
||||
onView(withId(R.id.import_encrypted_backup)).check(matches(isDisplayed()));
|
||||
onView(withId(R.id.import_plaintext_backup)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
private void checkExportLayout() throws Exception {
|
||||
onView(withId(R.id.export_plaintext_backup)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
private void clickImportExport() throws Exception {
|
||||
loadActivity(ConversationListActivity.class, STATE_REGISTRATION_SKIPPED);
|
||||
ConversationListActivityActions.clickImportExport(getContext());
|
||||
EspressoUtil.waitOn(ImportExportActivity.class);
|
||||
}
|
||||
|
||||
public void testLayout() throws Exception {
|
||||
clickImportExport();
|
||||
checkImportLayout();
|
||||
onView(withId(R.id.import_sms)).perform(swipeLeft());
|
||||
checkExportLayout();
|
||||
onView(withId(R.id.export_plaintext_backup)).perform(swipeRight());
|
||||
checkImportLayout();
|
||||
}
|
||||
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
/**
|
||||
* 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 static android.support.test.espresso.Espresso.onView;
|
||||
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.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
||||
public class NewConversationActivityActions {
|
||||
|
||||
public static void filterNameOrNumber(String nameOrNumber) throws Exception {
|
||||
EspressoUtil.replaceTextAndCloseKeyboard(onView(withId(R.id.filter)), nameOrNumber);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void clickContactWithName(String name) throws Exception {
|
||||
onView(allOf(withId(R.id.name), withText(name))).perform(click());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void clickContactWithNumber(String number) throws Exception {
|
||||
onView(allOf(withId(R.id.number), withText(containsString(number)))).perform(click());
|
||||
}
|
||||
|
||||
}
|
@ -1,125 +0,0 @@
|
||||
/**
|
||||
* 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 static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
|
||||
@LargeTest
|
||||
public class NewConversationActivityTest extends TextSecureEspressoTestCase<ConversationListActivity> {
|
||||
|
||||
final String[][] TEST_CONTACTS = {
|
||||
{"Nadezhda Tolokonnikova", "11111111111", "Nad", "ezh", "ova"},
|
||||
{"Jules Bonnot", "22222222222", "Jul", "nno", "not"},
|
||||
{"Masha Kolenkia", "33333333333", "Mas", "len", "kia"},
|
||||
{"Chairman Meow", "44444444444", "Cha", "rma", "eow"},
|
||||
{"Clement Duval", "55555555555", "Cle", "eme", "val"},
|
||||
{"Nestor Makhno", "66666666666", "Nes", "sto", "hno"},
|
||||
{"Wilhelm Reich", "77777777777", "Wil", "hel", "ich"}
|
||||
};
|
||||
|
||||
public NewConversationActivityTest() {
|
||||
super(ConversationListActivity.class);
|
||||
}
|
||||
|
||||
private void populateContacts() throws Exception {
|
||||
for(String[] TEST_CONTACT : TEST_CONTACTS) {
|
||||
EspressoUtil.addContact(getContext(), TEST_CONTACT[0], TEST_CONTACT[1]);
|
||||
}
|
||||
}
|
||||
|
||||
private void clickNewConversation() throws Exception{
|
||||
ConversationListActivityActions.clickNewConversation();
|
||||
EspressoUtil.waitOn(NewConversationActivity.class);
|
||||
EspressoUtil.actuallyCloseSoftKeyboard();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testContactFilterPrefix() throws Exception {
|
||||
populateContacts();
|
||||
loadActivity(ConversationListActivity.class, STATE_REGISTERED);
|
||||
clickNewConversation();
|
||||
|
||||
for (String[] TEST_CONTACT : TEST_CONTACTS) {
|
||||
NewConversationActivityActions.filterNameOrNumber(TEST_CONTACT[2]);
|
||||
onView(allOf(withId(R.id.name), withText(TEST_CONTACT[0]))).check(matches(isDisplayed()));
|
||||
}
|
||||
}
|
||||
|
||||
// this is known to fail on some devices, see #2378
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testContactFilterMiddle() throws Exception {
|
||||
populateContacts();
|
||||
loadActivity(ConversationListActivity.class, STATE_REGISTERED);
|
||||
clickNewConversation();
|
||||
|
||||
for (String[] TEST_CONTACT : TEST_CONTACTS) {
|
||||
NewConversationActivityActions.filterNameOrNumber(TEST_CONTACT[3]);
|
||||
onView(allOf(withId(R.id.name), withText(TEST_CONTACT[0]))).check(matches(isDisplayed()));
|
||||
}
|
||||
}
|
||||
|
||||
// this is known to fail on some devices, see #2378
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testContactFilterPostfix() throws Exception {
|
||||
populateContacts();
|
||||
loadActivity(ConversationListActivity.class, STATE_REGISTERED);
|
||||
clickNewConversation();
|
||||
|
||||
for (String[] TEST_CONTACT : TEST_CONTACTS) {
|
||||
NewConversationActivityActions.filterNameOrNumber(TEST_CONTACT[4]);
|
||||
onView(allOf(withId(R.id.name), withText(TEST_CONTACT[0]))).check(matches(isDisplayed()));
|
||||
}
|
||||
}
|
||||
|
||||
public void testNewConversationWithNonPushContact() throws Exception {
|
||||
populateContacts();
|
||||
loadActivity(ConversationListActivity.class, STATE_REGISTERED);
|
||||
clickNewConversation();
|
||||
|
||||
NewConversationActivityActions.clickContactWithName("Chairman Meow");
|
||||
EspressoUtil.waitOn(ConversationActivity.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testNewConversationWithUnknownWhenRegistered() throws Exception {
|
||||
loadActivity(ConversationListActivity.class, STATE_REGISTERED);
|
||||
clickNewConversation();
|
||||
|
||||
NewConversationActivityActions.filterNameOrNumber("8888888888");
|
||||
NewConversationActivityActions.clickContactWithNumber("8888888888");
|
||||
EspressoUtil.waitOn(ConversationActivity.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testNewConversationWithUnknownWhenUnregistered() throws Exception {
|
||||
loadActivity(ConversationListActivity.class, STATE_REGISTRATION_SKIPPED);
|
||||
clickNewConversation();
|
||||
|
||||
NewConversationActivityActions.filterNameOrNumber("8888888888");
|
||||
NewConversationActivityActions.clickContactWithNumber("8888888888");
|
||||
EspressoUtil.waitOn(ConversationActivity.class);
|
||||
}
|
||||
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
/**
|
||||
* 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 static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.action.ViewActions.click;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
|
||||
public class PassphraseChangeActivityActions {
|
||||
|
||||
public static void clickOk() throws Exception {
|
||||
onView(withId(R.id.ok_button)).perform(click());
|
||||
}
|
||||
|
||||
public static void clickCancel() throws Exception {
|
||||
onView(withId(R.id.cancel_button)).perform(click());
|
||||
}
|
||||
|
||||
public static void typeNewPassphrase(String passphrase, String repeat) throws Exception {
|
||||
EspressoUtil.typeTextAndCloseKeyboard(onView(withId(R.id.new_passphrase)), passphrase);
|
||||
EspressoUtil.typeTextAndCloseKeyboard(onView(withId(R.id.repeat_passphrase)), repeat);
|
||||
}
|
||||
|
||||
public static void typeNewPassphrase(String passphrase) throws Exception {
|
||||
typeNewPassphrase(passphrase, passphrase);
|
||||
}
|
||||
|
||||
public static void typeChangePassphrase(String oldPassphrase, String newPassphrase) throws Exception {
|
||||
EspressoUtil.typeTextAndCloseKeyboard(onView(withId(R.id.old_passphrase)), oldPassphrase);
|
||||
EspressoUtil.typeTextAndCloseKeyboard(onView(withId(R.id.new_passphrase)), newPassphrase);
|
||||
EspressoUtil.typeTextAndCloseKeyboard(onView(withId(R.id.repeat_passphrase)), newPassphrase);
|
||||
}
|
||||
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
/**
|
||||
* 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.thoughtcrime.securesms.preferences.AppProtectionPreferenceFragmentActions;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
||||
@LargeTest
|
||||
public class PassphraseChangeActivityTest extends TextSecureEspressoTestCase<ConversationListActivity> {
|
||||
|
||||
private static final String ORIGINAL_PASSPHRASE = "badpass";
|
||||
private static final String CHANGE_PASSPHRASE = "worse";
|
||||
|
||||
public PassphraseChangeActivityTest() {
|
||||
super(ConversationListActivity.class);
|
||||
}
|
||||
|
||||
private void checkState() throws Exception {
|
||||
EspressoUtil.actuallyCloseSoftKeyboard();
|
||||
|
||||
if (TextSecurePreferences.isPasswordDisabled(getContext())) {
|
||||
onView(withId(R.id.old_passphrase)).check(matches(not(isDisplayed())));
|
||||
onView(withId(R.id.old_passphrase_label)).check(matches(not(isDisplayed())));
|
||||
} else {
|
||||
onView(withId(R.id.old_passphrase)).check(matches(isDisplayed()));
|
||||
onView(withId(R.id.old_passphrase_label)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
onView(withId(R.id.new_passphrase)).check(matches(isDisplayed()));
|
||||
onView(withId(R.id.repeat_passphrase)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
private void clickEnablePassphraseAndCheckState() throws Exception {
|
||||
loadActivity(ConversationListActivity.class, STATE_REGISTRATION_SKIPPED);
|
||||
ConversationListActivityActions.clickSettings(getContext());
|
||||
EspressoUtil.waitOn(ApplicationPreferencesActivity.class);
|
||||
ApplicationPreferencesActivityActions.clickAppProtectionSetting();
|
||||
AppProtectionPreferenceFragmentActions.clickEnablePassphrase();
|
||||
EspressoUtil.waitOn(PassphraseChangeActivity.class);
|
||||
checkState();
|
||||
}
|
||||
|
||||
public void testEnablePassphrase() throws Exception {
|
||||
clickEnablePassphraseAndCheckState();
|
||||
PassphraseChangeActivityActions.typeNewPassphrase(ORIGINAL_PASSPHRASE);
|
||||
PassphraseChangeActivityActions.clickOk();
|
||||
|
||||
EspressoUtil.waitOn(ApplicationPreferencesActivity.class);
|
||||
assertTrue(!TextSecurePreferences.isPasswordDisabled(getContext()));
|
||||
}
|
||||
|
||||
public void testEnablePassphraseCancel() throws Exception {
|
||||
clickEnablePassphraseAndCheckState();
|
||||
EspressoUtil.actuallyCloseSoftKeyboard();
|
||||
PassphraseChangeActivityActions.clickCancel();
|
||||
|
||||
EspressoUtil.waitOn(ApplicationPreferencesActivity.class);
|
||||
assertTrue(TextSecurePreferences.isPasswordDisabled(getContext()));
|
||||
}
|
||||
|
||||
public void testEnablePassphraseDoesNotMatch() throws Exception {
|
||||
clickEnablePassphraseAndCheckState();
|
||||
PassphraseChangeActivityActions.typeNewPassphrase(ORIGINAL_PASSPHRASE, "nope");
|
||||
PassphraseChangeActivityActions.clickOk();
|
||||
PassphraseChangeActivityActions.clickCancel();
|
||||
|
||||
EspressoUtil.waitOn(ApplicationPreferencesActivity.class);
|
||||
assertTrue(TextSecurePreferences.isPasswordDisabled(getContext()));
|
||||
}
|
||||
|
||||
private void clickChangePassphraseAndCheckState() throws Exception {
|
||||
testEnablePassphrase();
|
||||
AppProtectionPreferenceFragmentActions.clickChangePassphrase();
|
||||
EspressoUtil.waitOn(PassphraseChangeActivity.class);
|
||||
checkState();
|
||||
}
|
||||
|
||||
public void testChangePassphrase() throws Exception {
|
||||
clickChangePassphraseAndCheckState();
|
||||
PassphraseChangeActivityActions.typeChangePassphrase(ORIGINAL_PASSPHRASE, CHANGE_PASSPHRASE);
|
||||
PassphraseChangeActivityActions.clickOk();
|
||||
|
||||
EspressoUtil.waitOn(ApplicationPreferencesActivity.class);
|
||||
assertTrue(!TextSecurePreferences.isPasswordDisabled(getContext()));
|
||||
}
|
||||
|
||||
public void testChangePassphraseCancel() throws Exception {
|
||||
clickChangePassphraseAndCheckState();
|
||||
|
||||
EspressoUtil.actuallyCloseSoftKeyboard();
|
||||
PassphraseChangeActivityActions.clickCancel();
|
||||
|
||||
EspressoUtil.waitOn(ApplicationPreferencesActivity.class);
|
||||
assertTrue(!TextSecurePreferences.isPasswordDisabled(getContext()));
|
||||
}
|
||||
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
/**
|
||||
* 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 static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.action.ViewActions.click;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
|
||||
public class RegistrationActivityActions {
|
||||
|
||||
public static void typeCountryCode(String countryCode) throws Exception {
|
||||
EspressoUtil.replaceTextAndCloseKeyboard(onView(withId(R.id.country_code)), countryCode);
|
||||
}
|
||||
|
||||
public static void typeLocalNumber(String localNumber) throws Exception {
|
||||
EspressoUtil.replaceTextAndCloseKeyboard(onView(withId(R.id.number)), localNumber);
|
||||
}
|
||||
|
||||
public static void clickRegister() throws Exception {
|
||||
onView(withId(R.id.registerButton)).perform(click());
|
||||
}
|
||||
|
||||
public static void clickCancel() throws Exception {
|
||||
onView(withId(R.id.skipButton)).perform(click());
|
||||
}
|
||||
|
||||
public static void clickContinue() throws Exception {
|
||||
onView(withText(R.string.RegistrationActivity_continue)).perform(click());
|
||||
}
|
||||
|
||||
public static void clickEdit() throws Exception {
|
||||
onView(withText(R.string.RegistrationActivity_edit)).perform(click());
|
||||
}
|
||||
|
||||
public static void enterPstnNumber(String pstnCountry, String pstnNumber) throws Exception {
|
||||
typeCountryCode(pstnCountry);
|
||||
typeLocalNumber(pstnNumber);
|
||||
}
|
||||
|
||||
public static void sleepTillRegistrationConnected() {
|
||||
long timeout = 0L;
|
||||
while (timeout < 10000L) {
|
||||
try {
|
||||
|
||||
Thread.sleep(1000);
|
||||
timeout += 1000;
|
||||
onView(withId(R.id.verification_progress)).check(matches(isDisplayed()));
|
||||
return;
|
||||
|
||||
} catch (InterruptedException e) { }
|
||||
catch (AssertionError e) { }
|
||||
}
|
||||
throw new AssertionError("failed to connect to registration servers within 10 seconds");
|
||||
}
|
||||
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
/**
|
||||
* 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.support.test.espresso.matcher.ViewMatchers;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
||||
@LargeTest
|
||||
public class RegistrationActivityTest extends TextSecureEspressoTestCase<ConversationListActivity> {
|
||||
|
||||
public RegistrationActivityTest() {
|
||||
super(ConversationListActivity.class);
|
||||
}
|
||||
|
||||
private void loadStateAndCheck() throws Exception {
|
||||
loadActivity(RegistrationActivity.class, STATE_BASE);
|
||||
onView(ViewMatchers.withId(R.id.skipButton)).check(matches(not(isDisplayed())));
|
||||
onView(withId(R.id.registerButton)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
public void testRegister() throws Exception {
|
||||
loadStateAndCheck();
|
||||
RegistrationActivityActions.enterPstnNumber(pstnCountry, pstnNumber);
|
||||
sleepThroughRegistrationLimit();
|
||||
RegistrationActivityActions.clickRegister();
|
||||
RegistrationActivityActions.clickContinue();
|
||||
EspressoUtil.waitOn(RegistrationProgressActivity.class);
|
||||
RegistrationActivityActions.sleepTillRegistrationConnected();
|
||||
RegistrationBypassUtil.receiveVerificationSms(getContext(), pstnCountry, pstnNumber, verificationCode);
|
||||
EspressoUtil.waitOn(ConversationListActivity.class);
|
||||
}
|
||||
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
/**
|
||||
* 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 android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Build.VERSION;
|
||||
import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.service.SmsListener;
|
||||
import org.thoughtcrime.securesms.util.SmsUtil;
|
||||
import org.thoughtcrime.securesms.test.R;
|
||||
|
||||
public class RegistrationBypassUtil {
|
||||
|
||||
private static final String TAG = RegistrationBypassUtil.class.getSimpleName();
|
||||
|
||||
private static String getKeyForDevice() {
|
||||
Log.d(TAG, "release: " + VERSION.RELEASE + ", model: " + Build.MODEL);
|
||||
return VERSION.RELEASE + " - " + Build.MODEL;
|
||||
}
|
||||
|
||||
public static String getPstnStringForDevice(Context context) {
|
||||
final String DEVICE_KEY = getKeyForDevice();
|
||||
final String[] TEST_DEVICES = context.getResources().getStringArray(R.array.test_devices);
|
||||
final String[] PSTN_STRINGS = context.getResources().getStringArray(R.array.test_pstn_numbers);
|
||||
int deviceIndex = -1;
|
||||
|
||||
if (TEST_DEVICES.length == 0 || PSTN_STRINGS.length != TEST_DEVICES.length) {
|
||||
throw new AssertionError("one test device per pstn number required");
|
||||
}
|
||||
|
||||
for (int i = 0; i < TEST_DEVICES.length; i++) {
|
||||
if (TEST_DEVICES[i].equals(DEVICE_KEY)) {
|
||||
deviceIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (deviceIndex < 0) return PSTN_STRINGS[PSTN_STRINGS.length - 1];
|
||||
else return PSTN_STRINGS[deviceIndex];
|
||||
}
|
||||
|
||||
public static String getVerificationCodeForPstnString(Context context, String pstnString) {
|
||||
final String[] PSTN_STRINGS = context.getResources().getStringArray(R.array.test_pstn_numbers);
|
||||
final String[] VERIFY_CODES = context.getResources().getStringArray(R.array.test_verification_codes);
|
||||
int pstnIndex = -1;
|
||||
|
||||
if (PSTN_STRINGS.length == 0 || PSTN_STRINGS.length != VERIFY_CODES.length) {
|
||||
throw new AssertionError("one verification code per pstn number required");
|
||||
}
|
||||
|
||||
for (int i = 0; i < PSTN_STRINGS.length; i++) {
|
||||
if (PSTN_STRINGS[i].equals(pstnString)) {
|
||||
pstnIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pstnIndex < 0) throw new AssertionError("no verification code for " + pstnString);
|
||||
else return VERIFY_CODES[pstnIndex];
|
||||
}
|
||||
|
||||
public static void receiveVerificationSms(Context context,
|
||||
String pstnCountry,
|
||||
String pstnNumber,
|
||||
String verificationCode)
|
||||
throws Exception
|
||||
{
|
||||
final String smsVerifyMessage = "Your TextSecure verification code: " + verificationCode;
|
||||
final Intent smsVerifyIntent = SmsUtil.buildSmsReceivedIntent(pstnCountry + pstnNumber, smsVerifyMessage);
|
||||
|
||||
try {
|
||||
new SmsListener().onReceive(context, smsVerifyIntent);
|
||||
} catch (IllegalStateException e) {
|
||||
Log.w(TAG, "some api levels are picky with abortBroadcast()", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,132 +0,0 @@
|
||||
/**
|
||||
* 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.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
public class TextSecureEspressoTestCase<T extends Activity> extends ActivityInstrumentationTestCase2<T> {
|
||||
|
||||
private static final String TAG = TextSecureEspressoTestCase.class.getSimpleName();
|
||||
|
||||
public static final int STATE_BASE = 0x00000000;
|
||||
public static final int STATE_REGISTRATION_SKIPPED = 0x00000001;
|
||||
public static final int STATE_REGISTERED = 0x00000002;
|
||||
|
||||
private static final long REGISTRATION_RATE_LIMIT_MS = 60000 + 10000;
|
||||
private static long TIME_LAST_REGISTERED = 0L;
|
||||
|
||||
protected String pstnCountry;
|
||||
protected String pstnNumber;
|
||||
protected String verificationCode;
|
||||
|
||||
public TextSecureEspressoTestCase(Class<T> clazz) {
|
||||
super(clazz);
|
||||
}
|
||||
|
||||
protected static void sleepThroughRegistrationLimit() {
|
||||
long msPassedSinceReg = System.currentTimeMillis() - TIME_LAST_REGISTERED;
|
||||
long msSleepRemaining = REGISTRATION_RATE_LIMIT_MS - msPassedSinceReg;
|
||||
|
||||
Log.d(TAG, "sleeping for " + msSleepRemaining + "ms to avoid registration rate limit");
|
||||
while (msSleepRemaining > 0) {
|
||||
try {
|
||||
|
||||
Thread.sleep(1000);
|
||||
msSleepRemaining -= 1000;
|
||||
|
||||
} catch (InterruptedException e) { }
|
||||
}
|
||||
TIME_LAST_REGISTERED = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
protected Context getContext() {
|
||||
return getInstrumentation().getTargetContext();
|
||||
}
|
||||
|
||||
private void initBaseState() throws Exception {
|
||||
EspressoUtil.removeAllContacts(getContext());
|
||||
DatabaseFactory.getDraftDatabase(getContext()).clearAllDrafts();
|
||||
DatabaseFactory.getThreadDatabase(getContext()).deleteAllConversations();
|
||||
PreferenceManager.getDefaultSharedPreferences(getContext()).edit().clear().commit();
|
||||
getContext().getSharedPreferences(MasterSecretUtil.PREFERENCES_NAME, 0).edit().clear().commit();
|
||||
getContext().getSharedPreferences("SecureSMS", 0).edit().clear().commit();
|
||||
}
|
||||
|
||||
protected void loadActivity(Class<? extends Activity> clazz, int state) throws Exception {
|
||||
switch (state) {
|
||||
case STATE_REGISTRATION_SKIPPED:
|
||||
TextSecurePreferences.setPromptedPushRegistration(getContext(), true);
|
||||
getActivity();
|
||||
break;
|
||||
|
||||
case STATE_REGISTERED:
|
||||
getActivity();
|
||||
EspressoUtil.waitOn(RegistrationActivity.class);
|
||||
RegistrationActivityActions.enterPstnNumber(pstnCountry, pstnNumber);
|
||||
sleepThroughRegistrationLimit();
|
||||
RegistrationActivityActions.clickRegister();
|
||||
RegistrationActivityActions.clickContinue();
|
||||
EspressoUtil.waitOn(RegistrationProgressActivity.class);
|
||||
RegistrationActivityActions.sleepTillRegistrationConnected();
|
||||
RegistrationBypassUtil.receiveVerificationSms(getContext(), pstnCountry, pstnNumber, verificationCode);
|
||||
break;
|
||||
|
||||
default:
|
||||
getActivity();
|
||||
}
|
||||
|
||||
EspressoUtil.waitOn(clazz);
|
||||
}
|
||||
|
||||
private void initMockPstnState() throws Exception {
|
||||
final Context context = getInstrumentation().getContext();
|
||||
final String pstnString = RegistrationBypassUtil.getPstnStringForDevice(context);
|
||||
|
||||
pstnCountry = pstnString.split(":")[0].replace("+", "");
|
||||
pstnNumber = pstnString.split(":")[1];
|
||||
verificationCode = RegistrationBypassUtil.getVerificationCodeForPstnString(context, pstnString);
|
||||
|
||||
Log.d(TAG, "using pstn string of " + pstnString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
System.setProperty("dexmaker.dexcache", getContext().getCacheDir().getPath());
|
||||
super.setUp();
|
||||
|
||||
if (pstnCountry == null || pstnNumber == null || verificationCode == null) {
|
||||
initMockPstnState();
|
||||
}
|
||||
initBaseState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
EspressoUtil.actuallyCloseSoftKeyboard();
|
||||
EspressoUtil.closeAllActivities();
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
/**
|
||||
* 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.app.Application;
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.Context;
|
||||
import android.os.PowerManager;
|
||||
import android.support.test.runner.AndroidJUnitRunner;
|
||||
import android.util.Log;
|
||||
|
||||
public class TextSecureWakingTestRunner extends AndroidJUnitRunner {
|
||||
|
||||
@Override public void onStart() {
|
||||
runOnMainSync(new Runnable() {
|
||||
@Override public void run() {
|
||||
Application app = (Application) getTargetContext().getApplicationContext();
|
||||
String simpleName = TextSecureWakingTestRunner.class.getSimpleName();
|
||||
|
||||
((KeyguardManager) app.getSystemService(Context.KEYGUARD_SERVICE))
|
||||
.newKeyguardLock(simpleName)
|
||||
.disableKeyguard();
|
||||
|
||||
((PowerManager) app.getSystemService(Context.POWER_SERVICE))
|
||||
.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, simpleName)
|
||||
.acquire();
|
||||
}
|
||||
});
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
/**
|
||||
* 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.support.test.espresso.matcher.ViewMatchers;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
||||
import org.whispersystems.libaxolotl.IdentityKey;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
|
||||
@LargeTest
|
||||
public class ViewLocalIdentityActivityTest extends TextSecureEspressoTestCase<ConversationListActivity> {
|
||||
|
||||
public ViewLocalIdentityActivityTest() {
|
||||
super(ConversationListActivity.class);
|
||||
}
|
||||
|
||||
private void clickMyIdentity() throws Exception {
|
||||
loadActivity(ConversationListActivity.class, STATE_REGISTRATION_SKIPPED);
|
||||
ConversationListActivityActions.clickMyIdentity(getContext());
|
||||
EspressoUtil.waitOn(ViewLocalIdentityActivity.class);
|
||||
}
|
||||
|
||||
public void testLayout() throws Exception {
|
||||
clickMyIdentity();
|
||||
final IdentityKey idKey = IdentityKeyUtil.getIdentityKey(getContext());
|
||||
onView(ViewMatchers.withId(R.id.identity_fingerprint)).check(matches(withText(idKey.getFingerprint())));
|
||||
}
|
||||
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
/**
|
||||
* 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.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
|
||||
public class ViewMatchers {
|
||||
|
||||
public static Matcher<View> withRecyclerItem(final Matcher<Object> itemMatcher) {
|
||||
return new TypeSafeMatcher<View>() {
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("with recycler item: ");
|
||||
itemMatcher.describeTo(description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(View view) {
|
||||
if (!(view instanceof RecyclerView)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RecyclerView recyclerView = ((RecyclerView) view);
|
||||
for (int i = 0; i < recyclerView.getChildCount(); i++) {
|
||||
if (itemMatcher.matches(recyclerView.getChildAt(i))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Matcher<View> withRecyclerItemCount(final long itemCount) {
|
||||
return new TypeSafeMatcher<View>() {
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("with recycler item count: " + itemCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(View view) {
|
||||
if (!(view instanceof RecyclerView)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RecyclerView recyclerView = ((RecyclerView) view);
|
||||
return recyclerView.getChildCount() == itemCount;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/**
|
||||
* 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.preferences;
|
||||
|
||||
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 AdvancedPreferenceFragmentActions {
|
||||
|
||||
public static void clickTextSecureMessages() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_toggle_push_messaging"))).perform(click());
|
||||
}
|
||||
|
||||
public static void clickEnterKeySends() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_enter_sends"))).perform(click());
|
||||
}
|
||||
|
||||
public static void clickChooseIdentity() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_choose_identity"))).perform(click());
|
||||
}
|
||||
|
||||
public static void clickSubmitDebugLog() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_submit_debug_logs"))).perform(click());
|
||||
}
|
||||
|
||||
}
|
@ -1,112 +0,0 @@
|
||||
/**
|
||||
* 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.preferences;
|
||||
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
||||
import org.thoughtcrime.securesms.ConversationListActivity;
|
||||
import org.thoughtcrime.securesms.LogSubmitActivity;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.RegistrationActivity;
|
||||
import org.thoughtcrime.securesms.contacts.ContactIdentityManager;
|
||||
import org.thoughtcrime.securesms.ApplicationPreferencesActivityActions;
|
||||
import org.thoughtcrime.securesms.ConversationListActivityActions;
|
||||
import org.thoughtcrime.securesms.TextSecureEspressoTestCase;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onData;
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.action.ViewActions.click;
|
||||
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.isChecked;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isNotChecked;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static org.thoughtcrime.securesms.EspressoUtil.waitOn;
|
||||
|
||||
@LargeTest
|
||||
public class AdvancedPreferenceFragmentTest extends TextSecureEspressoTestCase<ConversationListActivity> {
|
||||
|
||||
public AdvancedPreferenceFragmentTest() {
|
||||
super(ConversationListActivity.class);
|
||||
}
|
||||
|
||||
private void checkAllPreferencesDisplayed() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_toggle_push_messaging")))
|
||||
.check(matches(isDisplayed()));
|
||||
onData(Matchers.<Object>allOf(withKey("pref_enter_sends")))
|
||||
.check(matches(isDisplayed()));
|
||||
onData(Matchers.<Object>allOf(withKey("pref_submit_debug_logs")))
|
||||
.check(matches(isDisplayed()));
|
||||
|
||||
ContactIdentityManager identity = ContactIdentityManager.getInstance(getContext());
|
||||
if (!identity.isSelfIdentityAutoDetected()) {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_choose_identity")))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
}
|
||||
|
||||
private void checkViewsMatchPreferences() throws Exception {
|
||||
if (TextSecurePreferences.isPushRegistered(getContext())) {
|
||||
isChecked().matches(onData(Matchers.<Object>allOf(withKey("pref_toggle_push_messaging"))));
|
||||
} else {
|
||||
isNotChecked().matches(onData(Matchers.<Object>allOf(withKey("pref_toggle_push_messaging"))));
|
||||
}
|
||||
|
||||
if (TextSecurePreferences.isEnterSendsEnabled(getContext())) {
|
||||
isChecked().matches(onData(Matchers.<Object>allOf(withKey("pref_enter_sends"))));
|
||||
} else {
|
||||
isNotChecked().matches(onData(Matchers.<Object>allOf(withKey("pref_enter_sends"))));
|
||||
}
|
||||
}
|
||||
|
||||
private void clickAdvancedSettingAndCheckState() throws Exception {
|
||||
ConversationListActivityActions.clickSettings(getContext());
|
||||
waitOn(ApplicationPreferencesActivity.class);
|
||||
ApplicationPreferencesActivityActions.clickAdvancedSetting();
|
||||
|
||||
checkAllPreferencesDisplayed();
|
||||
checkViewsMatchPreferences();
|
||||
}
|
||||
|
||||
public void testEnableTextSecureMessages() throws Exception {
|
||||
loadActivity(ConversationListActivity.class, STATE_REGISTRATION_SKIPPED);
|
||||
clickAdvancedSettingAndCheckState();
|
||||
AdvancedPreferenceFragmentActions.clickTextSecureMessages();
|
||||
waitOn(RegistrationActivity.class);
|
||||
}
|
||||
|
||||
public void testDisableTextSecureMessages() throws Exception {
|
||||
loadActivity(ConversationListActivity.class, STATE_REGISTERED);
|
||||
clickAdvancedSettingAndCheckState();
|
||||
AdvancedPreferenceFragmentActions.clickTextSecureMessages();
|
||||
onView(withText(R.string.ApplicationPreferencesActivity_disable_signal_messages_and_calls))
|
||||
.check(matches(isDisplayed()));
|
||||
onView(withText(android.R.string.cancel)).perform(click());
|
||||
}
|
||||
|
||||
public void testSubmitDebugLog() throws Exception {
|
||||
loadActivity(ConversationListActivity.class, STATE_REGISTRATION_SKIPPED);
|
||||
clickAdvancedSettingAndCheckState();
|
||||
AdvancedPreferenceFragmentActions.clickSubmitDebugLog();
|
||||
waitOn(LogSubmitActivity.class);
|
||||
}
|
||||
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
/**
|
||||
* 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.preferences;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onData;
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.action.ViewActions.click;
|
||||
import static android.support.test.espresso.matcher.PreferenceMatchers.withKey;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
|
||||
public class AppProtectionPreferenceFragmentActions {
|
||||
|
||||
public static void clickEnablePassphrase() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_enable_passphrase_temporary"))).perform(click());
|
||||
}
|
||||
|
||||
public static void disablePassphrase() throws Exception {
|
||||
clickEnablePassphrase();
|
||||
onView(withText(R.string.ApplicationPreferencesActivity_disable)).perform(click());
|
||||
}
|
||||
|
||||
public static void clickChangePassphrase() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_change_passphrase"))).perform(click());
|
||||
}
|
||||
|
||||
public static void clickTimeoutPassphrase() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_timeout_passphrase"))).perform(click());
|
||||
}
|
||||
|
||||
public static void clickScreenSecurity() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_screen_security"))).perform(click());
|
||||
}
|
||||
|
||||
}
|
@ -1,136 +0,0 @@
|
||||
/**
|
||||
* 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.preferences;
|
||||
|
||||
import android.os.Build;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
||||
import org.thoughtcrime.securesms.ConversationListActivity;
|
||||
import org.thoughtcrime.securesms.PassphraseChangeActivity;
|
||||
import org.thoughtcrime.securesms.ApplicationPreferencesActivityActions;
|
||||
import org.thoughtcrime.securesms.ConversationListActivityActions;
|
||||
import org.thoughtcrime.securesms.PassphraseChangeActivityActions;
|
||||
import org.thoughtcrime.securesms.TextSecureEspressoTestCase;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
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.isChecked;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isNotChecked;
|
||||
import static org.thoughtcrime.securesms.EspressoUtil.waitOn;
|
||||
|
||||
@LargeTest
|
||||
public class AppProtectionPreferenceFragmentTest extends TextSecureEspressoTestCase<ConversationListActivity> {
|
||||
|
||||
private static final String ORIGINAL_PASSPHRASE = "badpass";
|
||||
|
||||
public AppProtectionPreferenceFragmentTest() {
|
||||
super(ConversationListActivity.class);
|
||||
}
|
||||
|
||||
private void checkAllPreferencesDisplayed() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_enable_passphrase_temporary"))).check(matches(isDisplayed()));
|
||||
onData(Matchers.<Object>allOf(withKey("pref_change_passphrase"))).check(matches(isDisplayed()));
|
||||
onData(Matchers.<Object>allOf(withKey("pref_timeout_passphrase"))).check(matches(isDisplayed()));
|
||||
onData(Matchers.<Object>allOf(withKey("pref_timeout_interval"))).check(matches(isDisplayed()));
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_screen_security")))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
}
|
||||
|
||||
private void checkViewsMatchPreferences() throws Exception {
|
||||
if (!TextSecurePreferences.isPasswordDisabled(getContext())) {
|
||||
isChecked().matches(onData(Matchers.<Object>allOf(withKey("pref_enable_passphrase_temporary"))));
|
||||
} else {
|
||||
isNotChecked().matches(onData(Matchers.<Object>allOf(withKey("pref_enable_passphrase_temporary"))));
|
||||
}
|
||||
|
||||
if (TextSecurePreferences.isPassphraseTimeoutEnabled(getContext())) {
|
||||
isChecked().matches(onData(Matchers.<Object>allOf(withKey("pref_timeout_passphrase"))));
|
||||
} else {
|
||||
isNotChecked().matches(onData(Matchers.<Object>allOf(withKey("pref_timeout_passphrase"))));
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
if (TextSecurePreferences.isScreenSecurityEnabled(getContext())) {
|
||||
isChecked().matches(onData(Matchers.<Object>allOf(withKey("pref_screen_security"))));
|
||||
} else {
|
||||
isNotChecked().matches(onData(Matchers.<Object>allOf(withKey("pref_screen_security"))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkState() throws Exception {
|
||||
checkAllPreferencesDisplayed();
|
||||
checkViewsMatchPreferences();
|
||||
}
|
||||
|
||||
private void clickAppProtectionSettingAndCheckState() throws Exception {
|
||||
loadActivity(ConversationListActivity.class, STATE_REGISTRATION_SKIPPED);
|
||||
ConversationListActivityActions.clickSettings(getContext());
|
||||
waitOn(ApplicationPreferencesActivity.class);
|
||||
ApplicationPreferencesActivityActions.clickAppProtectionSetting();
|
||||
checkState();
|
||||
}
|
||||
|
||||
public void testEnablePassphrase() throws Exception {
|
||||
clickAppProtectionSettingAndCheckState();
|
||||
|
||||
AppProtectionPreferenceFragmentActions.clickEnablePassphrase();
|
||||
waitOn(PassphraseChangeActivity.class);
|
||||
PassphraseChangeActivityActions.typeNewPassphrase(ORIGINAL_PASSPHRASE);
|
||||
PassphraseChangeActivityActions.clickOk();
|
||||
waitOn(ApplicationPreferencesActivity.class);
|
||||
|
||||
isChecked().matches(onData(Matchers.<Object>allOf(withKey("pref_enable_passphrase_temporary"))));
|
||||
checkState();
|
||||
}
|
||||
|
||||
public void testDisablePassphrase() throws Exception {
|
||||
testEnablePassphrase();
|
||||
AppProtectionPreferenceFragmentActions.disablePassphrase();
|
||||
|
||||
isNotChecked().matches(onData(Matchers.<Object>allOf(withKey("pref_enable_passphrase_temporary"))));
|
||||
checkState();
|
||||
}
|
||||
|
||||
public void testEnablePassphraseTimeout() throws Exception {
|
||||
testEnablePassphrase();
|
||||
AppProtectionPreferenceFragmentActions.clickTimeoutPassphrase();
|
||||
|
||||
isChecked().matches(onData(Matchers.<Object>allOf(withKey("pref_timeout_passphrase"))));
|
||||
checkState();
|
||||
}
|
||||
|
||||
public void testDisableScreenSecurity() throws Exception {
|
||||
clickAppProtectionSettingAndCheckState();
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
return;
|
||||
}
|
||||
|
||||
AppProtectionPreferenceFragmentActions.clickScreenSecurity();
|
||||
isNotChecked().matches(onData(Matchers.<Object>allOf(withKey("pref_screen_security"))));
|
||||
checkState();
|
||||
}
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
/**
|
||||
* 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.preferences;
|
||||
|
||||
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 AppearancePreferenceFragmentActions {
|
||||
|
||||
public static void clickTheme() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_theme"))).perform(click());
|
||||
}
|
||||
|
||||
public static void clickLanguage() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_language"))).perform(click());
|
||||
}
|
||||
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
/**
|
||||
* 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.preferences;
|
||||
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.thoughtcrime.securesms.ConversationListActivity;
|
||||
import org.thoughtcrime.securesms.TextSecureEspressoTestCase;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
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.PreferenceMatchers.withSummaryText;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
|
||||
@LargeTest
|
||||
public class AppearancePreferenceFragmentTest extends TextSecureEspressoTestCase<ConversationListActivity> {
|
||||
|
||||
public AppearancePreferenceFragmentTest() {
|
||||
super(ConversationListActivity.class);
|
||||
}
|
||||
|
||||
private void checkAllPreferencesDisplayed() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_theme")))
|
||||
.check(matches(isDisplayed()));
|
||||
onData(Matchers.<Object>allOf(withKey("pref_language")))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
private void checkViewsMatchPreferences() throws Exception {
|
||||
// todo :|
|
||||
final String theme = TextSecurePreferences.getTheme(getContext());
|
||||
onData(Matchers.<Object>allOf(withKey("pref_theme"), withSummaryText(theme)))
|
||||
.check(matches(isDisplayed()));
|
||||
|
||||
final String language = TextSecurePreferences.getTheme(getContext());
|
||||
onData(Matchers.<Object>allOf(withKey("pref_language"), withSummaryText(language)))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
/**
|
||||
* 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.preferences;
|
||||
|
||||
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 NotificationsPreferenceFragmentActions {
|
||||
|
||||
public static void clickEnableNotifications() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_key_enable_notifications"))).perform(click());
|
||||
}
|
||||
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
/**
|
||||
* 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.preferences;
|
||||
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
||||
import org.thoughtcrime.securesms.ConversationListActivity;
|
||||
import org.thoughtcrime.securesms.ApplicationPreferencesActivityActions;
|
||||
import org.thoughtcrime.securesms.ConversationListActivityActions;
|
||||
import org.thoughtcrime.securesms.TextSecureEspressoTestCase;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
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.isChecked;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isNotChecked;
|
||||
import static org.thoughtcrime.securesms.EspressoUtil.waitOn;
|
||||
|
||||
@LargeTest
|
||||
public class NotificationsPreferenceFragmentTest extends TextSecureEspressoTestCase<ConversationListActivity> {
|
||||
|
||||
public NotificationsPreferenceFragmentTest() {
|
||||
super(ConversationListActivity.class);
|
||||
}
|
||||
|
||||
private void checkAllPreferencesDisplayed() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_key_enable_notifications")))
|
||||
.check(matches(isDisplayed()));
|
||||
onData(Matchers.<Object>allOf(withKey("pref_key_ringtone")))
|
||||
.check(matches(isDisplayed()));
|
||||
onData(Matchers.<Object>allOf(withKey("pref_key_vibrate")))
|
||||
.check(matches(isDisplayed()));
|
||||
onData(Matchers.<Object>allOf(withKey("pref_led_color")))
|
||||
.check(matches(isDisplayed()));
|
||||
onData(Matchers.<Object>allOf(withKey("pref_led_blink")))
|
||||
.check(matches(isDisplayed()));
|
||||
onData(Matchers.<Object>allOf(withKey("pref_key_inthread_notifications")))
|
||||
.check(matches(isDisplayed()));
|
||||
onData(Matchers.<Object>allOf(withKey("pref_repeat_alerts")))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
private void checkViewsMatchPreferences() throws Exception {
|
||||
if (TextSecurePreferences.isNotificationsEnabled(getContext())) {
|
||||
isChecked().matches(onData(Matchers.<Object>allOf(withKey("pref_key_enable_notifications"))));
|
||||
} else {
|
||||
isNotChecked().matches(onData(Matchers.<Object>allOf(withKey("pref_key_enable_notifications"))));
|
||||
}
|
||||
|
||||
if (TextSecurePreferences.isNotificationVibrateEnabled(getContext())) {
|
||||
isChecked().matches(onData(Matchers.<Object>allOf(withKey("pref_key_vibrate"))));
|
||||
} else {
|
||||
isNotChecked().matches(onData(Matchers.<Object>allOf(withKey("pref_key_vibrate"))));
|
||||
}
|
||||
|
||||
if (TextSecurePreferences.isInThreadNotifications(getContext())) {
|
||||
isChecked().matches(onData(Matchers.<Object>allOf(withKey("pref_key_inthread_notifications"))));
|
||||
} else {
|
||||
isNotChecked().matches(onData(Matchers.<Object>allOf(withKey("pref_key_inthread_notifications"))));
|
||||
}
|
||||
}
|
||||
|
||||
private void clickNotificationsSettingAndCheckState() throws Exception {
|
||||
loadActivity(ConversationListActivity.class, STATE_REGISTRATION_SKIPPED);
|
||||
ConversationListActivityActions.clickSettings(getContext());
|
||||
waitOn(ApplicationPreferencesActivity.class);
|
||||
ApplicationPreferencesActivityActions.clickNotificationsSetting();
|
||||
|
||||
checkAllPreferencesDisplayed();
|
||||
checkViewsMatchPreferences();
|
||||
}
|
||||
|
||||
public void testEnableNotifications() throws Exception {
|
||||
clickNotificationsSettingAndCheckState();
|
||||
NotificationsPreferenceFragmentActions.clickEnableNotifications();
|
||||
isChecked().matches(onData(Matchers.<Object>allOf(withKey("pref_key_enable_notifications"))));
|
||||
}
|
||||
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/**
|
||||
* 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.preferences;
|
||||
|
||||
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 SmsMmsPreferenceFragmentActions {
|
||||
|
||||
public static void clickReceiveAllSms() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_all_sms"))).perform(click());
|
||||
}
|
||||
|
||||
public static void clickReceiveAllMms() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_all_mms"))).perform(click());
|
||||
}
|
||||
|
||||
public static void clickSmsDeliveryReports() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_delivery_report_sms"))).perform(click());
|
||||
}
|
||||
|
||||
public static void clickWifiCallingCompat() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_wifi_sms"))).perform(click());
|
||||
}
|
||||
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
/**
|
||||
* 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.preferences;
|
||||
|
||||
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 StoragePreferenceFragmentActions {
|
||||
|
||||
public static void clickDeleteOldMessages() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_trim_threads"))).perform(click());
|
||||
}
|
||||
|
||||
public static void clickConversationLengthLimit() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_trim_length"))).perform(click());
|
||||
}
|
||||
|
||||
public static void clickTrimAllNow() throws Exception {
|
||||
onData(Matchers.<Object>allOf(withKey("pref_trim_now"))).perform(click());
|
||||
}
|
||||
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.thoughtcrime.securesms">
|
||||
|
||||
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||
|
||||
</manifest>
|
Loading…
x
Reference in New Issue
Block a user