add toast on empty name
- show toast if the board name is empty - add test for NewBoardActivity
This commit is contained in:
parent
4253074679
commit
419b8c1faa
@ -0,0 +1,37 @@
|
|||||||
|
package it.unisannio.ding.ids.wedroid.app.view
|
||||||
|
|
||||||
|
import androidx.test.espresso.Espresso.onView
|
||||||
|
import androidx.test.espresso.action.ViewActions.click
|
||||||
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||||
|
import androidx.test.espresso.matcher.RootMatchers.withDecorView
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import androidx.test.filters.LargeTest
|
||||||
|
import androidx.test.rule.ActivityTestRule
|
||||||
|
import it.unisannio.ding.ids.wedroid.app.R
|
||||||
|
import org.hamcrest.core.IsNot.not
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
@LargeTest
|
||||||
|
class NewBoardActivityTest {
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
val activityRule = ActivityTestRule(NewBoardActivity::class.java)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun showToastOnEmptyName() {
|
||||||
|
onView(withId(R.id.newBoardDone))
|
||||||
|
.perform(click())
|
||||||
|
|
||||||
|
onView(withText(R.string.on_add_new_board_empty_name))
|
||||||
|
.inRoot(withDecorView(not(activityRule.activity.window.decorView)))
|
||||||
|
.check(matches(isDisplayed()))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -9,6 +9,7 @@ import androidx.appcompat.widget.Toolbar;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import it.unisannio.ding.ids.wedroid.app.R;
|
import it.unisannio.ding.ids.wedroid.app.R;
|
||||||
|
|
||||||
@ -28,6 +29,12 @@ public class NewBoardActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onDone(View v) {
|
public void onDone(View v) {
|
||||||
|
if (boardName.getText().toString().equals("")) {
|
||||||
|
Toast.makeText(this, R.string.on_add_new_board_empty_name, Toast.LENGTH_LONG)
|
||||||
|
.show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Intent data = new Intent();
|
Intent data = new Intent();
|
||||||
data.putExtra(BOARD_NAME, boardName.getText().toString());
|
data.putExtra(BOARD_NAME, boardName.getText().toString());
|
||||||
data.putExtra(BOARD_PRIVATE, isPrivate.isChecked());
|
data.putExtra(BOARD_PRIVATE, isPrivate.isChecked());
|
||||||
|
@ -8,4 +8,5 @@
|
|||||||
<string name="new_board_done_button">Done</string>
|
<string name="new_board_done_button">Done</string>
|
||||||
<string name="on_null_new_board_name">There was a problem with the name of the new board</string>
|
<string name="on_null_new_board_name">There was a problem with the name of the new board</string>
|
||||||
<string name="on_add_new_board_error">It was not possible to add a new board</string>
|
<string name="on_add_new_board_error">It was not possible to add a new board</string>
|
||||||
|
<string name="on_add_new_board_empty_name">Name cannot be empty</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user