Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catroid-1595 changes Tests from Toasts to Snackbar Hints #5018

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions catroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ dependencies {
androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"

androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
androidTestImplementation 'org.robolectric:shadows-framework:4.7.3'

// Room Test helpers
testImplementation("androidx.room:room-testing:$room_version")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Catroid: An on-device visual programming system for Android devices
* Copyright (C) 2010-2022 The Catrobat Team
* Copyright (C) 2010-2024 The Catrobat Team
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -39,6 +39,7 @@
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;

import androidx.test.espresso.NoMatchingViewException;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import static org.catrobat.catroid.uiespresso.content.brick.utils.BrickDataInteractionWrapper.onBrickAtPosition;
Expand All @@ -48,7 +49,6 @@
import static org.catrobat.catroid.uiespresso.formulaeditor.utils.FormulaEditorWrapper.FORMULA_EDITOR_TEXT_FIELD_MATCHER;
import static org.catrobat.catroid.uiespresso.formulaeditor.utils.FormulaEditorWrapper.onFormulaEditor;
import static org.catrobat.catroid.uiespresso.util.UiTestUtils.getResourcesString;
import static org.catrobat.catroid.uiespresso.util.UiTestUtils.onToast;

import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.Espresso.pressBack;
Expand Down Expand Up @@ -131,7 +131,7 @@ public void testFormulaIsNotValidToast1() {
onFormulaEditor()
.performClickOn(BACKSPACE);
pressBack();
onToast(withText(R.string.formula_editor_parse_fail))
onView(withText(R.string.formula_editor_parse_fail))
.check(matches(isDisplayed()));
onView(isRoot()).perform(CustomActions.wait(3000));
}
Expand All @@ -144,7 +144,7 @@ public void testFormulaIsNotValidToast2() {
onFormulaEditor()
.performEnterFormula("1+1+");
pressBack();
onToast(withText(R.string.formula_editor_parse_fail))
onView(withText(R.string.formula_editor_parse_fail))
.check(matches(isDisplayed()));
onView(isRoot()).perform(CustomActions.wait(3000));
}
Expand All @@ -157,7 +157,43 @@ public void testFormulaIsNotValidToast3() {
onFormulaEditor()
.performEnterFormula("+");
pressBack();
onToast(withText(R.string.formula_editor_parse_fail))
onView(withText(R.string.formula_editor_parse_fail))
.check(matches(isDisplayed()));
onView(isRoot()).perform(CustomActions.wait(3000));
}
@Category({Cat.CatrobatLanguage.class, Level.Smoke.class})
@Test(expected = NoMatchingViewException.class)
public void testFormulaIsNotValidToastFail1() {
onFormulaEditor()
.performClickOn(BACKSPACE);
pressBack();
onView(withText(R.string.formula_editor_parse_fail_formula_too_long))
.check(matches(isDisplayed()));
onView(isRoot()).perform(CustomActions.wait(3000));
}

@Category({Cat.CatrobatLanguage.class, Level.Smoke.class})
@Test(expected = NoMatchingViewException.class)
public void testFormulaIsNotValidToastFail2() {
onFormulaEditor()
.performClickOn(BACKSPACE);
onFormulaEditor()
.performEnterFormula("1+1+");
pressBack();
onView(withText(R.string.formula_editor_parse_fail_formula_too_long))
.check(matches(isDisplayed()));
onView(isRoot()).perform(CustomActions.wait(3000));
}

@Category({Cat.CatrobatLanguage.class, Level.Smoke.class})
@Test(expected = NoMatchingViewException.class)
public void testFormulaIsNotValidToastFail3() {
onFormulaEditor()
.performClickOn(BACKSPACE);
onFormulaEditor()
.performEnterFormula("+");
pressBack();
onView(withText(R.string.formula_editor_parse_fail_formula_too_long))
.check(matches(isDisplayed()));
onView(isRoot()).perform(CustomActions.wait(3000));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public void saveExternal() throws IOException {
.perform(click());

onToast(withText(pendingToastText))
.check(matches(isDisplayed()));
.check(matches((isDisplayed())));
onView(isRoot()).perform(CustomActions
.wait(DURATION_WAIT_FOR_ZIP_FILE_IN_MILLISECONDS));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Catroid: An on-device visual programming system for Android devices
* Copyright (C) 2010-2022 The Catrobat Team
* Copyright (C) 2010-2024 The Catrobat Team
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Catroid: An on-device visual programming system for Android devices
* Copyright (C) 2010-2022 The Catrobat Team
* Copyright (C) 2010-2024 The Catrobat Team
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -51,4 +51,4 @@ public void describeTo(Description description) {
}
};
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Catroid: An on-device visual programming system for Android devices
* Copyright (C) 2010-2023 The Catrobat Team
* Copyright (C) 2010-2024 The Catrobat Team
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -92,14 +92,14 @@
import org.catrobat.catroid.utils.ProjectManagerExtensionsKt;
import org.catrobat.catroid.utils.ShowTextUtils.AndroidStringProvider;
import org.catrobat.catroid.utils.SnackbarUtil;
import org.catrobat.catroid.utils.ToastUtil;
import org.catrobat.paintroid.colorpicker.ColorPickerDialog;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
Expand Down Expand Up @@ -708,7 +708,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_GPS && resultCode == AppCompatActivity.RESULT_CANCELED && SensorHandler.gpsAvailable()) {
showComputeDialog();
} else {
ToastUtil.showError(getActivity(), R.string.error_gps_not_available);
SnackbarUtil.hintSnackbar(requireActivity(), R.string.error_gps_not_available);
}
}

Expand Down Expand Up @@ -874,15 +874,15 @@ private boolean checkReturnWithoutSaving(int errorType) {
confirmSwitchEditTextTimeStamp[0] = 0;
confirmSwitchEditTextTimeStamp[1] = 0;
confirmSwitchEditTextCounter = 0;
ToastUtil.showSuccess(getActivity(), R.string.formula_editor_changes_discarded);
SnackbarUtil.wasHintAlreadyShown(getActivity(), String.valueOf(R.string.formula_editor_changes_discarded));
return true;
} else {
switch (errorType) {
case InternFormulaParser.PARSER_INPUT_SYNTAX_ERROR:
ToastUtil.showError(getActivity(), R.string.formula_editor_parse_fail);
SnackbarUtil.hintSnackbar(requireActivity(), R.string.formula_editor_parse_fail);
break;
case InternFormulaParser.PARSER_STACK_OVERFLOW:
ToastUtil.showError(getActivity(), R.string.formula_editor_parse_fail_formula_too_long);
SnackbarUtil.hintSnackbar(requireActivity(),R.string.formula_editor_parse_fail_formula_too_long);
break;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Catroid: An on-device visual programming system for Android devices
* Copyright (C) 2010-2022 The Catrobat Team
* Copyright (C) 2010-2024 The Catrobat Team
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -170,4 +170,9 @@ public static void dismissAllHints() {
hint.dismiss();
}
}

// public static void showError(Context context, String message) {
// Snackbar.make(context, message, Toast.LENGTH_SHORT, DEFAULT_COLOR);
// }

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Catroid: An on-device visual programming system for Android devices
* Copyright (C) 2010-2022 The Catrobat Team
* Copyright (C) 2010-2024 The Catrobat Team
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down