Fixed test setup

* Reverted gradle plugin upgrade to prevent forcing users to
  upgrade to Android Studio 4 preview version.
* Refactored TVShowsActivityTests into using the AndroidX libs.
* Updated test setup to handle saving tab state in abstract list fragment.
This commit is contained in:
Martijn Brekhof 2020-04-23 19:26:50 +02:00
parent 5299e8e607
commit c44a5f0612
4 changed files with 17 additions and 16 deletions

View File

@ -32,6 +32,7 @@ import org.xbmc.kore.R;
import org.xbmc.kore.host.HostInfo; import org.xbmc.kore.host.HostInfo;
import org.xbmc.kore.host.HostManager; import org.xbmc.kore.host.HostManager;
import org.xbmc.kore.provider.MediaProvider; import org.xbmc.kore.provider.MediaProvider;
import org.xbmc.kore.ui.AbstractTabsFragment;
import org.xbmc.kore.ui.sections.hosts.HostFragmentManualConfiguration; import org.xbmc.kore.ui.sections.hosts.HostFragmentManualConfiguration;
import org.xbmc.kore.utils.LogUtils; import org.xbmc.kore.utils.LogUtils;
@ -81,10 +82,10 @@ public class Utils {
} }
public static void clearSharedPreferences(Context context) { public static void clearSharedPreferences(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); PreferenceManager.getDefaultSharedPreferences(context)
SharedPreferences.Editor editor = prefs.edit(); .edit().clear().commit();
editor.clear(); context.getSharedPreferences(AbstractTabsFragment.PREFERENCES_NAME, Context.MODE_PRIVATE)
editor.commit(); .edit().clear().commit();
} }
public static void setLearnedAboutDrawerPreference(Context context, boolean learned) { public static void setLearnedAboutDrawerPreference(Context context, boolean learned) {

View File

@ -17,25 +17,25 @@
package org.xbmc.kore.tests.ui.tvshows; package org.xbmc.kore.tests.ui.tvshows;
import android.content.Context; import android.content.Context;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.widget.TextView; import android.widget.TextView;
import androidx.test.espresso.Espresso;
import androidx.test.rule.ActivityTestRule;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.xbmc.kore.R; import org.xbmc.kore.R;
import org.xbmc.kore.host.HostInfo;
import org.xbmc.kore.testhelpers.EspressoTestUtils; import org.xbmc.kore.testhelpers.EspressoTestUtils;
import org.xbmc.kore.tests.ui.AbstractTestClass; import org.xbmc.kore.tests.ui.AbstractTestClass;
import org.xbmc.kore.ui.sections.video.TVShowsActivity; import org.xbmc.kore.ui.sections.video.TVShowsActivity;
import static android.support.test.espresso.Espresso.onView; import static androidx.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click; import static androidx.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withParent; import static androidx.test.espresso.matcher.ViewMatchers.withParent;
import static android.support.test.espresso.matcher.ViewMatchers.withText; import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.Matchers.allOf; import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;

View File

@ -39,7 +39,7 @@ import butterknife.Unbinder;
abstract public class AbstractTabsFragment extends AbstractFragment abstract public class AbstractTabsFragment extends AbstractFragment
implements SharedElementTransition.SharedElement { implements SharedElementTransition.SharedElement {
private static final String TAG = LogUtils.makeLogTag(AbstractTabsFragment.class); private static final String TAG = LogUtils.makeLogTag(AbstractTabsFragment.class);
private static final String PREFERENCES_NAME = "AbstractTabsFragmentPreferences"; public static final String PREFERENCES_NAME = "AbstractTabsFragmentPreferences";
private static final String PREFERENCE_PREFIX_LAST_TAB = "lastTab_"; private static final String PREFERENCE_PREFIX_LAST_TAB = "lastTab_";
@BindView(R.id.pager) ViewPager viewPager; @BindView(R.id.pager) ViewPager viewPager;

View File

@ -6,7 +6,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.0.0-beta04' classpath 'com.android.tools.build:gradle:3.4.1'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files