Skip to content

Commit

Permalink
androidTest: fix all androidTests
Browse files Browse the repository at this point in the history
  • Loading branch information
Binnette committed Nov 25, 2024
1 parent aca3524 commit 803f57c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.osmtracker.activity.ButtonsPresets;
import net.osmtracker.activity.Preferences;
import net.osmtracker.util.CustomLayoutsUtils;
import net.osmtracker.util.TestUtils;

import org.junit.Rule;
import org.junit.Test;
Expand All @@ -20,6 +21,7 @@
import static androidx.test.espresso.action.ViewActions.longClick;
import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static net.osmtracker.util.LogcatHelper.checkLogForMessage;
import static net.osmtracker.util.TestUtils.checkToastIsShownWith;
import static net.osmtracker.util.TestUtils.getLayoutsDirectory;
import static net.osmtracker.util.TestUtils.getStringResource;
Expand Down Expand Up @@ -73,6 +75,8 @@ public void layoutDeletionTest(){

deleteLayout(layoutName);

checkLogForMessage("TOAST", TestUtils.getStringResource(R.string.buttons_presets_successful_delete));

// Check the informative Toast is shown
checkToastIsShownWith(getStringResource(R.string.buttons_presets_successful_delete));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.osmtracker.OSMTracker;
import net.osmtracker.R;
import net.osmtracker.activity.AvailableLayouts;
import net.osmtracker.util.TestUtils;

import org.hamcrest.Matcher;
import org.junit.Rule;
Expand All @@ -23,6 +24,7 @@
import static androidx.test.espresso.matcher.ViewMatchers.isEnabled;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static net.osmtracker.util.LogcatHelper.checkLogForMessage;
import static net.osmtracker.util.TestUtils.checkToastIsShownWith;
import static net.osmtracker.util.TestUtils.getStringResource;
import static org.hamcrest.core.IsNot.not;
Expand Down Expand Up @@ -80,6 +82,8 @@ public void checkRepositoryValidity(String user, String repo, String branch, boo
String expectedMessage = (isValid) ? getStringResource(R.string.github_repository_settings_valid_server) :
getStringResource(R.string.github_repository_settings_invalid_server);

checkLogForMessage("TOAST", expectedMessage);

checkToastIsShownWith(expectedMessage);

ViewAssertion expectedDialogState = (isValid) ? doesNotExist() : matches(isDisplayed());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ public void onClick(DialogInterface dialog, int which) {
protected void onPostExecute(Boolean result){
//validating the github repository
if(result){
Toast.makeText(AvailableLayouts.this, getResources().getString(R.string.github_repository_settings_valid_server), Toast.LENGTH_SHORT).show();
String message = getResources().getString(R.string.github_repository_settings_valid_server);
Log.i("TOAST", message);
Toast.makeText(AvailableLayouts.this, message, Toast.LENGTH_SHORT).show();
//save the entered options into the shared preferences file
editor.putString(OSMTracker.Preferences.KEY_GITHUB_USERNAME, repositoryCustomOptions[0]);
editor.putString(OSMTracker.Preferences.KEY_REPOSITORY_NAME, repositoryCustomOptions[1]);
Expand All @@ -257,7 +259,9 @@ protected void onPostExecute(Boolean result){
tmpSharedPref.edit().putBoolean("isCallBack", false).commit();
retrieveAvailableLayouts();
}else{
Toast.makeText(AvailableLayouts.this, getResources().getString(R.string.github_repository_settings_invalid_server), Toast.LENGTH_SHORT).show();
String message = getResources().getString(R.string.github_repository_settings_invalid_server);
Log.e("TOAST", message);
Toast.makeText(AvailableLayouts.this, message, Toast.LENGTH_SHORT).show();
tmpSharedPref.edit().putString(OSMTracker.Preferences.KEY_GITHUB_USERNAME, repositoryCustomOptions[0]).commit();
tmpSharedPref.edit().putString(OSMTracker.Preferences.KEY_REPOSITORY_NAME, repositoryCustomOptions[1]).commit();
tmpSharedPref.edit().putString(OSMTracker.Preferences.KEY_BRANCH_NAME, repositoryCustomOptions[2]).commit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,11 @@ public void onClick(DialogInterface dialog, int which) {

int messageToShowId = (successfulDeletion) ? R.string.buttons_presets_successful_delete :
R.string.buttons_presets_unsuccessful_delete;
String message = getResources().getString(messageToShowId);

Toast.makeText(getApplicationContext(), getResources().getString(messageToShowId), Toast.LENGTH_SHORT).show();
Log.println(successfulDeletion ? Log.INFO : Log.ERROR, "TOAST", message);

Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();

//reload the activity
refreshActivity();
Expand Down

0 comments on commit 803f57c

Please sign in to comment.