forked from AdevintaSpain/Barista
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue AdevintaSpain#283 assertDisplayedAtPosition doesn't assert …
…displayed list view I removed the scrollListToPosition from assertDisplayedAtPosition as it is done in assertCustomAssertionAtPosition. isShowOnScreen checks to see if the view is visible to the user. getShownViewsById retuns a list of all views that match the viewId and are visible to the user.
- Loading branch information
Showing
6 changed files
with
372 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...java/com/schibsted/spain/barista/sample/ListViewWithDifferentDataInsideViewPagerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.schibsted.spain.barista.sample; | ||
|
||
import androidx.test.rule.ActivityTestRule; | ||
import androidx.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static com.schibsted.spain.barista.assertion.BaristaListAssertions.assertDisplayedAtPosition; | ||
import static com.schibsted.spain.barista.interaction.BaristaSleepInteractions.sleep; | ||
import static com.schibsted.spain.barista.interaction.BaristaViewPagerInteractions.swipeViewPagerBack; | ||
import static com.schibsted.spain.barista.interaction.BaristaViewPagerInteractions.swipeViewPagerForward; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class ListViewWithDifferentDataInsideViewPagerTest { | ||
|
||
@Rule | ||
public ActivityTestRule<ListViewsWithDifferentDataInsideViewPagerActivity> activityRule = | ||
new ActivityTestRule<>(ListViewsWithDifferentDataInsideViewPagerActivity.class); | ||
|
||
@Test | ||
public void checkClickRecyclerViewItem() { | ||
swipeViewPagerForward(R.id.pager); | ||
sleep(500); | ||
|
||
assertDisplayedAtPosition(R.id.listview, 1, "Marionberry"); | ||
|
||
swipeViewPagerBack(R.id.pager); | ||
sleep(500); | ||
|
||
assertDisplayedAtPosition(R.id.listview, 0, android.R.id.text1, "Apple"); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
.../com/schibsted/spain/barista/sample/RecyclerViewWithDifferentDataInsideViewPagerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.schibsted.spain.barista.sample; | ||
|
||
import androidx.test.rule.ActivityTestRule; | ||
import androidx.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static com.schibsted.spain.barista.assertion.BaristaListAssertions.assertDisplayedAtPosition; | ||
import static com.schibsted.spain.barista.interaction.BaristaSleepInteractions.sleep; | ||
import static com.schibsted.spain.barista.interaction.BaristaViewPagerInteractions.swipeViewPagerBack; | ||
import static com.schibsted.spain.barista.interaction.BaristaViewPagerInteractions.swipeViewPagerForward; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class RecyclerViewWithDifferentDataInsideViewPagerTest { | ||
|
||
@Rule | ||
public ActivityTestRule<RecyclerViewsWithDifferentDataInsideViewPagerActivity> activityRule = | ||
new ActivityTestRule<>(RecyclerViewsWithDifferentDataInsideViewPagerActivity.class); | ||
|
||
@Test | ||
public void checkClickRecyclerViewItem() { | ||
swipeViewPagerForward(R.id.pager); | ||
sleep(500); | ||
|
||
assertDisplayedAtPosition(R.id.recycler, 1, "Marionberry"); | ||
|
||
swipeViewPagerBack(R.id.pager); | ||
sleep(500); | ||
|
||
assertDisplayedAtPosition(R.id.recycler, 0, R.id.textview, "Apple"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
...com/schibsted/spain/barista/sample/ListViewsWithDifferentDataInsideViewPagerActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package com.schibsted.spain.barista.sample; | ||
|
||
import android.os.Bundle; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.LinearLayout; | ||
import android.widget.ListView; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.fragment.app.Fragment; | ||
import androidx.fragment.app.FragmentManager; | ||
import androidx.fragment.app.FragmentStatePagerAdapter; | ||
import androidx.viewpager.widget.PagerAdapter; | ||
import androidx.viewpager.widget.ViewPager; | ||
|
||
public class ListViewsWithDifferentDataInsideViewPagerActivity extends AppCompatActivity { | ||
|
||
private static final int NUM_PAGES = 2; | ||
|
||
private static final String[] FRUIT_LIST_ONE = { | ||
"Apple", "Apricot", "Avocado", "Banana", "Bilberry", "Blackberry", "Blackcurrant", | ||
"Blueberry", "Boysenberry", "Currant", "Cherry", "Cherimoya", "Cloudberry", "Coconut", | ||
"Cranberry", "Cucumber", "Custardapple", "Damson", "Date", "Dragonfruit", "Durian", | ||
"Elderberry", "Feijoa", "Fig", "Gojiberry", "Gooseberry", "Grape", "Raisin", "Grapefruit", | ||
"Guava", "Honeyberry", "Huckleberry", "Jabuticaba", "Jackfruit", "Jambul", "Jujube", | ||
"Juniperberry", "Kiwifruit", "Kumquat", "Lemon", "Lime", "Loquat", "Longan", "Lychee"}; | ||
|
||
private static final String[] FRUIT_LIST_TWO = {"Mango", "Marionberry", "Melon", "Cantaloupe", "Honeydew", "Watermelon", "Miraclefruit", | ||
"Mulberry", "Nectarine", "Nance", "Olive", "Orange", "Bloodorange", "Clementine", "Mandarine", | ||
"Tangerine", "Papaya", "Passionfruit", "Peach", "Pear", "Persimmon", "Physalis", "Plantain", | ||
"Plum", "Prune(driedplum)", "Pineapple", "Plumcot(orPluot)", "Pomegranate", "Pomelo", | ||
"Purplemangosteen", "Quince", "Raspberry", "Salmonberry", "Rambutan", "Redcurrant", | ||
"Salalberry", "Salak", "Satsuma", "Starfruit", "Solanumquitoense", "Strawberry", "Tamarillo", | ||
"Tamarind", "Uglifruit", "Yuzu"}; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_viewpager); | ||
|
||
ViewPager mPager = findViewById(R.id.pager); | ||
PagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager()); | ||
mPager.setAdapter(mPagerAdapter); | ||
} | ||
|
||
private static class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter { | ||
ScreenSlidePagerAdapter(FragmentManager fm) { | ||
super(fm); | ||
} | ||
|
||
@Override | ||
public Fragment getItem(int position) { | ||
return new ScreenSlidePageFragment(position); | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return NUM_PAGES; | ||
} | ||
} | ||
|
||
public static class ScreenSlidePageFragment extends Fragment { | ||
|
||
private int position; | ||
|
||
public ScreenSlidePageFragment(int position) { | ||
this.position = position; | ||
} | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | ||
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.activity_lists, container, false); | ||
|
||
LinearLayout listsContainer = rootView.findViewById(R.id.multi_list_container); | ||
|
||
ListView listView = new ListView(requireContext()); | ||
if (position == 0) { | ||
listView.setAdapter(new ArrayAdapter<>(requireContext(), android.R.layout.simple_list_item_1, FRUIT_LIST_ONE)); | ||
} else { | ||
listView.setAdapter(new ArrayAdapter<>(requireContext(), android.R.layout.simple_list_item_1, FRUIT_LIST_TWO)); | ||
} | ||
listView.setId(R.id.listview); | ||
listsContainer.addView(listView, | ||
new LinearLayout.LayoutParams( | ||
ViewGroup.LayoutParams.WRAP_CONTENT, | ||
ViewGroup.LayoutParams.MATCH_PARENT, | ||
1 | ||
)); | ||
|
||
return rootView; | ||
} | ||
} | ||
} |
Oops, something went wrong.