Skip to content

Commit

Permalink
Feature/issue 98/change package structure (#99)
Browse files Browse the repository at this point in the history
Issue-98 - renamed package structure, ensured unit tests are passing and fixed bug with the onPrepare throwing an UnsupportedException. Excluded LoggingUtils.java from coverage calculations. Removed redundant classes and tests
  • Loading branch information
goldy1992 authored Nov 9, 2019
1 parent 7138c94 commit 8e525cc
Show file tree
Hide file tree
Showing 293 changed files with 1,292 additions and 1,283 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
compileSdkVersion PIE
buildToolsVersion BUILD_TOOLS_VERSION
defaultConfig {
applicationId "com.example.mike.mp3player"
applicationId "com.github.goldy1992.mp3player"
minSdkVersion MARSHMALLOW
targetSdkVersion OREO
versionCode 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.mike.mp3player;
package com.github.goldy1992.mp3player;

import android.view.View;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.mike.mp3player;
package com.github.goldy1992.mp3player;


import android.view.View;
Expand All @@ -13,9 +13,9 @@
import androidx.test.rule.ActivityTestRule;
import androidx.test.rule.GrantPermissionRule;

import com.example.mike.mp3player.client.activities.MainActivity;
import com.example.mike.mp3player.client.activities.MainActivityInjectorAndroidTestImpl;
import com.example.mike.mp3player.commons.MediaItemType;
import com.github.goldy1992.mp3player.client.activities.MainActivity;
import com.github.goldy1992.mp3player.client.activities.MainActivityInjectorAndroidTestImpl;
import com.github.goldy1992.mp3player.commons.MediaItemType;
import com.google.android.material.tabs.TabLayout;

import org.hamcrest.Description;
Expand All @@ -34,8 +34,8 @@
import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static com.example.mike.mp3player.TestUtils.assertTabName;
import static com.example.mike.mp3player.TestUtils.withRecyclerView;
import static com.github.goldy1992.mp3player.TestUtils.assertTabName;
import static com.github.goldy1992.mp3player.TestUtils.withRecyclerView;
import static org.hamcrest.core.AllOf.allOf;
import static org.junit.Assert.assertEquals;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.mike.mp3player;
package com.github.goldy1992.mp3player;


import android.content.res.Resources;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.mike.mp3player;
package com.github.goldy1992.mp3player;

import android.view.View;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.github.goldy1992.mp3player.client.activities;


import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;

import androidx.test.espresso.NoMatchingViewException;
import androidx.test.espresso.ViewAssertion;
import androidx.test.filters.LargeTest;
import androidx.test.rule.ActivityTestRule;
import androidx.test.rule.GrantPermissionRule;
import androidx.test.runner.AndroidJUnit4;

import com.github.goldy1992.mp3player.R;
import com.google.android.material.tabs.TabLayout;

import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static org.junit.Assert.assertTrue;

@LargeTest
@RunWith(AndroidJUnit4.class)
public class SplashScreenEntryActivityAndroidTestImplTest {

@Rule
public ActivityTestRule<SplashScreenEntryActivityAndroidTestImpl> mActivityTestRule = new ActivityTestRule<>(SplashScreenEntryActivityAndroidTestImpl.class);

@Rule
public GrantPermissionRule mGrantPermissionRule =
GrantPermissionRule.grant(
"android.permission.WRITE_EXTERNAL_STORAGE");

@Test
public void splashScreenEntryActivityAndroidTestImplTest() {

onView(withId(R.id.tabs)).check(new ViewAssertion() {
@Override
public void check(View view, NoMatchingViewException noViewFoundException) {
if (view instanceof TabLayout) {
TabLayout tabLayout = (TabLayout) view;
TabLayout.Tab tab = tabLayout.getTabAt(0);
assertTrue(tab.getText().equals("SONGS"));
}
else
{
throw noViewFoundException;
}
}
});


}

private static Matcher<View> childAtPosition(
final Matcher<View> parentMatcher, final int position) {

return new TypeSafeMatcher<View>() {
@Override
public void describeTo(Description description) {
description.appendText("Child at position " + position + " in parent ");
parentMatcher.describeTo(description);
}

@Override
public boolean matchesSafely(View view) {
ViewParent parent = view.getParent();
return parent instanceof ViewGroup && parentMatcher.matches(parent)
&& view.equals(((ViewGroup) parent).getChildAt(position));
}
};
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.mike.mp3player.client.views.fragments;
package com.github.goldy1992.mp3player.client.views.fragments;

import android.os.HandlerThread;
import android.support.v4.media.MediaMetadataCompat;
Expand All @@ -10,7 +10,7 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;

import com.example.mike.mp3player.R;
import com.github.goldy1992.mp3player.R;

import org.junit.Before;
import org.junit.Test;
Expand All @@ -22,7 +22,7 @@
import static androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static com.example.mike.mp3player.CustomMatchers.withSeekbarProgress;
import static com.github.goldy1992.mp3player.CustomMatchers.withSeekbarProgress;
import static org.hamcrest.CoreMatchers.containsString;

@MediumTest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.mike.mp3player.client.views.fragments;
package com.github.goldy1992.mp3player.client.views.fragments;

import android.os.Bundle;
import android.util.Log;
Expand All @@ -9,7 +9,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.example.mike.mp3player.R;
import com.github.goldy1992.mp3player.R;

public class TestSeekBarFragment extends AsyncFragment {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.mike.mp3player.client.views.fragments;
package com.github.goldy1992.mp3player.client.views.fragments;

import android.util.Log;

Expand All @@ -7,7 +7,7 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;

import com.example.mike.mp3player.R;
import com.github.goldy1992.mp3player.R;

import org.junit.Before;
import org.junit.Test;
Expand Down
2 changes: 1 addition & 1 deletion app/src/automation/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mike.mp3player"
package="com.github.goldy1992.mp3player"
android:installLocation="preferExternal">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.mike.mp3player;
package com.github.goldy1992.mp3player;

public final class TestConstants {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.example.mike.mp3player.client.activities;
package com.github.goldy1992.mp3player.client.activities;

import android.os.Bundle;

import androidx.test.espresso.IdlingResource;
import androidx.viewpager2.widget.ViewPager2;

import com.example.mike.mp3player.dagger.components.DaggerAndroidTestMediaActivityCompatComponent;
import com.example.mike.mp3player.dagger.components.MediaActivityCompatComponent;
import com.github.goldy1992.mp3player.dagger.components.DaggerAndroidTestMediaActivityCompatComponent;
import com.github.goldy1992.mp3player.dagger.components.MediaActivityCompatComponent;

public class MainActivityInjectorAndroidTestImpl extends MainActivity implements IdlingResource {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.mike.mp3player.client.activities;
package com.github.goldy1992.mp3player.client.activities;

public class SplashScreenEntryActivityAndroidTestImpl extends SplashScreenEntryActivity {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package com.example.mike.mp3player.dagger.components;
package com.github.goldy1992.mp3player.dagger.components;

import android.content.Context;

import com.example.mike.mp3player.client.MediaBrowserConnectorCallback;
import com.example.mike.mp3player.dagger.modules.AlbumArtPainterModule;
import com.example.mike.mp3player.dagger.modules.AndroidTestComponentNameModule;
import com.example.mike.mp3player.dagger.modules.MainHandlerModule;
import com.example.mike.mp3player.dagger.modules.MediaBrowserAdapterModule;
import com.example.mike.mp3player.dagger.modules.MediaControllerAdapterModule;
import com.example.mike.mp3player.dagger.modules.MediaControllerCallbackModule;
import com.example.mike.mp3player.dagger.modules.MyDrawerListenerModule;
import com.example.mike.mp3player.dagger.modules.service.HandlerThreadModule;
import com.example.mike.mp3player.dagger.scopes.ComponentScope;
import com.github.goldy1992.mp3player.client.MediaBrowserConnectorCallback;
import com.github.goldy1992.mp3player.dagger.modules.AlbumArtPainterModule;
import com.github.goldy1992.mp3player.dagger.modules.AndroidTestComponentNameModule;
import com.github.goldy1992.mp3player.dagger.modules.MainHandlerModule;
import com.github.goldy1992.mp3player.dagger.modules.MediaBrowserAdapterModule;
import com.github.goldy1992.mp3player.dagger.modules.MediaControllerAdapterModule;
import com.github.goldy1992.mp3player.dagger.modules.MediaControllerCallbackModule;
import com.github.goldy1992.mp3player.dagger.modules.MyDrawerListenerModule;
import com.github.goldy1992.mp3player.dagger.modules.service.HandlerThreadModule;
import com.github.goldy1992.mp3player.dagger.scopes.ComponentScope;

import dagger.BindsInstance;
import dagger.Component;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.github.goldy1992.mp3player.dagger.components;

import android.content.Context;

import com.github.goldy1992.mp3player.dagger.modules.AndroidTestContentRetrieverMapModule;
import com.github.goldy1992.mp3player.dagger.modules.PlaybackNotificationManagerModule;
import com.github.goldy1992.mp3player.dagger.modules.service.ContentManagerModule;
import com.github.goldy1992.mp3player.dagger.modules.service.ContentRetrieverModule;
import com.github.goldy1992.mp3player.dagger.modules.service.ContentSearcherModule;
import com.github.goldy1992.mp3player.dagger.modules.service.ExoPlayerModule;
import com.github.goldy1992.mp3player.dagger.modules.service.HandlerThreadModule;
import com.github.goldy1992.mp3player.dagger.modules.service.MediaItemBuilderModule;
import com.github.goldy1992.mp3player.dagger.modules.service.MediaItemTypeIdModule;
import com.github.goldy1992.mp3player.dagger.modules.service.MediaSessionCompatModule;
import com.github.goldy1992.mp3player.dagger.modules.service.MediaSessionConnectorModule;
import com.github.goldy1992.mp3player.dagger.modules.service.PlaybackManagerModule;
import com.github.goldy1992.mp3player.dagger.modules.service.SearchDatabaseModule;
import com.github.goldy1992.mp3player.dagger.modules.service.ServiceModule;
import com.github.goldy1992.mp3player.service.MediaPlaybackService;

import javax.inject.Singleton;

import dagger.BindsInstance;
import dagger.Component;

@Singleton
@Component(modules = {
AndroidTestContentRetrieverMapModule.class,
ContentManagerModule.class,
ContentRetrieverModule.class,
ContentSearcherModule.class,
ExoPlayerModule.class,
HandlerThreadModule.class,
MediaItemBuilderModule.class,
MediaItemTypeIdModule.class,
MediaSessionCompatModule.class,
MediaSessionConnectorModule.class,
PlaybackManagerModule.class,
PlaybackNotificationManagerModule.class,
SearchDatabaseModule.class,
ServiceModule.class
})
public interface AndroidTestServiceComponent extends ServiceComponent {

@Component.Factory
interface Factory extends ServiceComponent.Factory {
AndroidTestServiceComponent create(@BindsInstance Context context,
@BindsInstance MediaPlaybackService mediaPlaybackService,
@BindsInstance String workerId);
}
}

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.example.mike.mp3player.dagger.modules;
package com.github.goldy1992.mp3player.dagger.modules;

import android.content.ComponentName;
import android.content.Context;

import com.example.mike.mp3player.service.MediaPlaybackServiceAndroidTestImpl;
import com.github.goldy1992.mp3player.service.MediaPlaybackServiceAndroidTestImpl;

import dagger.Module;
import dagger.Provides;
Expand Down
Loading

0 comments on commit 8e525cc

Please sign in to comment.