From fb70b2ac7d0c82dde4233e1944d56ee7a4ea3f79 Mon Sep 17 00:00:00 2001 From: David Luhmer Date: Sat, 6 Apr 2019 13:46:48 -0300 Subject: [PATCH] optimize imports --- .../tests/NewsReaderListActivityUiTests.java | 2 ++ .../de/luhmer/owncloudnewsreader/tests/NightModeTest.java | 8 +++++++- .../tests => helper}/CustomMatchers.java | 8 +++++--- .../tests => helper}/OrientationChangeAction.java | 2 +- .../tests => helper}/RecyclerViewAssertions.java | 2 +- .../src/androidTest/java/screengrab/ScreenshotTest.java | 2 ++ 6 files changed, 18 insertions(+), 6 deletions(-) rename News-Android-App/src/androidTest/java/{de/luhmer/owncloudnewsreader/tests => helper}/CustomMatchers.java (95%) rename News-Android-App/src/androidTest/java/{de/luhmer/owncloudnewsreader/tests => helper}/OrientationChangeAction.java (98%) rename News-Android-App/src/androidTest/java/{de/luhmer/owncloudnewsreader/tests => helper}/RecyclerViewAssertions.java (95%) diff --git a/News-Android-App/src/androidTest/java/de/luhmer/owncloudnewsreader/tests/NewsReaderListActivityUiTests.java b/News-Android-App/src/androidTest/java/de/luhmer/owncloudnewsreader/tests/NewsReaderListActivityUiTests.java index cec84357..bfb84a3b 100644 --- a/News-Android-App/src/androidTest/java/de/luhmer/owncloudnewsreader/tests/NewsReaderListActivityUiTests.java +++ b/News-Android-App/src/androidTest/java/de/luhmer/owncloudnewsreader/tests/NewsReaderListActivityUiTests.java @@ -27,6 +27,8 @@ import de.luhmer.owncloudnewsreader.NewsReaderListActivity; import de.luhmer.owncloudnewsreader.R; import de.luhmer.owncloudnewsreader.adapter.NewsListRecyclerAdapter; import de.luhmer.owncloudnewsreader.adapter.ViewHolder; +import helper.OrientationChangeAction; +import helper.RecyclerViewAssertions; import static androidx.test.InstrumentationRegistry.getInstrumentation; import static androidx.test.InstrumentationRegistry.registerInstance; diff --git a/News-Android-App/src/androidTest/java/de/luhmer/owncloudnewsreader/tests/NightModeTest.java b/News-Android-App/src/androidTest/java/de/luhmer/owncloudnewsreader/tests/NightModeTest.java index b2effbee..c6235e0f 100644 --- a/News-Android-App/src/androidTest/java/de/luhmer/owncloudnewsreader/tests/NightModeTest.java +++ b/News-Android-App/src/androidTest/java/de/luhmer/owncloudnewsreader/tests/NightModeTest.java @@ -20,12 +20,14 @@ import java.time.Instant; import java.time.ZoneOffset; import androidx.test.InstrumentationRegistry; +import androidx.test.espresso.assertion.ViewAssertions; import androidx.test.filters.LargeTest; import androidx.test.rule.ActivityTestRule; import androidx.test.runner.AndroidJUnit4; import de.luhmer.owncloudnewsreader.NewsReaderListActivity; import de.luhmer.owncloudnewsreader.R; import de.luhmer.owncloudnewsreader.helper.ThemeChooser; +import helper.CustomMatchers; import static android.preference.PreferenceManager.KEY_HAS_SET_DEFAULT_VALUES; import static androidx.test.InstrumentationRegistry.getInstrumentation; @@ -39,9 +41,11 @@ import static androidx.test.espresso.matcher.PreferenceMatchers.withSummary; import static androidx.test.espresso.matcher.PreferenceMatchers.withTitle; import static androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription; +import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static de.luhmer.owncloudnewsreader.SettingsActivity.CB_OLED_MODE; import static de.luhmer.owncloudnewsreader.SettingsActivity.SP_APP_THEME; +import static helper.CustomMatchers.withBackgroundColor; import static junit.framework.TestCase.assertTrue; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.instanceOf; @@ -88,12 +92,14 @@ public class NightModeTest { defaultValueSp.edit().putBoolean(KEY_HAS_SET_DEFAULT_VALUES, false).commit(); + /* // Set Fixed time Instant.now( Clock.fixed( Instant.parse( "2019-04-05T18:00:00Z"), ZoneOffset.UTC ) ); + */ } @@ -102,7 +108,7 @@ public class NightModeTest { launchActivity(); assertFalse(isDarkTheme()); - //onView(withId(R.id.sliding_layout)).check(ViewAssertions.matches(CustomMatchers.withBackgroundColor(android.R.color.white, getActivity()))); + onView(withId(R.id.sliding_layout)).check(matches(withBackgroundColor(android.R.color.white, getActivity()))); } @Test diff --git a/News-Android-App/src/androidTest/java/de/luhmer/owncloudnewsreader/tests/CustomMatchers.java b/News-Android-App/src/androidTest/java/helper/CustomMatchers.java similarity index 95% rename from News-Android-App/src/androidTest/java/de/luhmer/owncloudnewsreader/tests/CustomMatchers.java rename to News-Android-App/src/androidTest/java/helper/CustomMatchers.java index c54202f3..f7e019e5 100644 --- a/News-Android-App/src/androidTest/java/de/luhmer/owncloudnewsreader/tests/CustomMatchers.java +++ b/News-Android-App/src/androidTest/java/helper/CustomMatchers.java @@ -1,4 +1,4 @@ -package de.luhmer.owncloudnewsreader.tests; +package helper; import android.app.Activity; import android.content.Context; @@ -38,7 +38,7 @@ public class CustomMatchers { Drawable drawable = view.getBackground(); Drawable otherDrawable = ContextCompat.getDrawable(view.getContext(), resourceColorId); - if (drawable instanceof ColorDrawable && otherDrawable instanceof ColorDrawable) { + if (drawable instanceof ColorDrawable) { int colorId = ((ColorDrawable) drawable).getColor(); if(colorId == resourceColorId) { @@ -47,7 +47,9 @@ public class CustomMatchers { error = "FAILED Got: " + colorId; } } else { - error = "Not color drawables!!"; + Log.e(TAG, drawable.toString()); + Log.e(TAG, otherDrawable.toString()); + error = "Not ColorDrawable's!!"; } return false; diff --git a/News-Android-App/src/androidTest/java/de/luhmer/owncloudnewsreader/tests/OrientationChangeAction.java b/News-Android-App/src/androidTest/java/helper/OrientationChangeAction.java similarity index 98% rename from News-Android-App/src/androidTest/java/de/luhmer/owncloudnewsreader/tests/OrientationChangeAction.java rename to News-Android-App/src/androidTest/java/helper/OrientationChangeAction.java index dbc4aaa4..d4dbab4c 100644 --- a/News-Android-App/src/androidTest/java/de/luhmer/owncloudnewsreader/tests/OrientationChangeAction.java +++ b/News-Android-App/src/androidTest/java/helper/OrientationChangeAction.java @@ -23,7 +23,7 @@ * */ -package de.luhmer.owncloudnewsreader.tests; +package helper; import android.app.Activity; import android.content.pm.ActivityInfo; diff --git a/News-Android-App/src/androidTest/java/de/luhmer/owncloudnewsreader/tests/RecyclerViewAssertions.java b/News-Android-App/src/androidTest/java/helper/RecyclerViewAssertions.java similarity index 95% rename from News-Android-App/src/androidTest/java/de/luhmer/owncloudnewsreader/tests/RecyclerViewAssertions.java rename to News-Android-App/src/androidTest/java/helper/RecyclerViewAssertions.java index fd7488c8..aa3bf316 100644 --- a/News-Android-App/src/androidTest/java/de/luhmer/owncloudnewsreader/tests/RecyclerViewAssertions.java +++ b/News-Android-App/src/androidTest/java/helper/RecyclerViewAssertions.java @@ -1,4 +1,4 @@ -package de.luhmer.owncloudnewsreader.tests; +package helper; import androidx.test.espresso.NoMatchingViewException; import androidx.test.espresso.ViewAssertion; diff --git a/News-Android-App/src/androidTest/java/screengrab/ScreenshotTest.java b/News-Android-App/src/androidTest/java/screengrab/ScreenshotTest.java index df174330..6c7b217a 100644 --- a/News-Android-App/src/androidTest/java/screengrab/ScreenshotTest.java +++ b/News-Android-App/src/androidTest/java/screengrab/ScreenshotTest.java @@ -31,8 +31,10 @@ import tools.fastlane.screengrab.locale.LocaleTestRule; */ @RunWith(AndroidJUnit4.class) public class ScreenshotTest { + @ClassRule public static final LocaleTestRule localTestRule = new LocaleTestRule(); + @Rule public ActivityTestRule mActivityRule = new ActivityTestRule<>(NewsReaderListActivity.class);