background image

  

public void setUp() throws Exception {

  

solo = new Solo(getInstrumentation(), getActivity());

  

}

  

@Smoke

  

public void testAddNote() throws Exception {

  

solo.clickOnMenuItem("Add note");

  

//Assert that NoteEditor activity is opened

  

solo.assertCurrentActivity("Expected NoteEditor activity", "NoteEditor");

  

//In text field 0, add Note 1

  

solo.enterText(0, "Note 1");

  

solo.goBack();

  

//Clicks on menu item

  

solo.clickOnMenuItem("Add note");

  

//In text field 0, add Note 2

  

solo.enterText(0, "Note 2");

  

//Go back to first activity named "NotesList"

  

solo.goBackToActivity("NotesList");

  

// solo.

  

boolean expected = true;

  

boolean actual = solo.searchText("Note 1") && solo.searchText("Note 2");

  

//Assert that Note 1 & Note 2 are found

  

assertEquals("Note 1 and/or Note 2 are not found", expected, actual);

  

}

  

@Smoke

  

public void testEditNote() throws Exception {

  

// Click on the second list line

  

solo.clickInList(2);

  

// Change orientation of activity

  

solo.setActivityOrientation(Solo.LANDSCAPE);

  

// Change title

  

solo.clickOnMenuItem("Edit title");

  

//In first text field (0), add test

  

solo.enterText(0, " test");

  

solo.goBackToActivity("NotesList");

  

boolean expected = true;

  

// (Regexp) case insensitive

  

boolean actual = solo.searchText("(?i).*?note 1 test");

  

//Assert that Note 1 test is found

  

assertEquals("Note 1 test is not found", expected, actual);

  

}

  

@Smoke

  

public void testRemoveNote() throws Exception {

  

//(Regexp) case insensitive/text that contains "test"

  

solo.clickOnText("(?i).*?test.*");