-
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.
- Loading branch information
bakjoul
committed
Dec 16, 2021
0 parents
commit 0c8a0ab
Showing
69 changed files
with
1,753 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,3 @@ | ||
# OpenClassrooms | ||
|
||
Ce dépôt contient une mini-application pour le P3 du parcours **Grande École du Numérique**. |
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 @@ | ||
/build |
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,51 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 28 | ||
defaultConfig { | ||
applicationId "com.openclassrooms.entrevoisins" | ||
minSdkVersion 21 | ||
targetSdkVersion 28 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation 'com.android.support:appcompat-v7:28.0.0' | ||
implementation 'com.android.support:design:28.0.0' | ||
implementation 'com.android.support.constraint:constraint-layout:1.1.3' | ||
implementation 'com.android.support:support-v4:28.0.0' | ||
implementation 'com.android.support:recyclerview-v7:28.0.0' | ||
|
||
implementation 'com.jakewharton:butterknife:9.0.0' | ||
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0' | ||
|
||
implementation 'com.github.bumptech.glide:glide:4.9.0' | ||
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0' | ||
|
||
// EVENT BUS | ||
implementation 'org.greenrobot:eventbus:3.1.1' | ||
|
||
// UNIT TEST | ||
testImplementation 'junit:junit:4.12' | ||
testImplementation 'org.hamcrest:java-hamcrest:2.0.0.0' | ||
// INSTRUMENTATION TEST | ||
androidTestImplementation 'com.android.support.test:rules:1.0.2' | ||
androidTestImplementation 'com.android.support.test:runner:1.0.2' | ||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' | ||
androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.2' | ||
} |
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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
71 changes: 71 additions & 0 deletions
71
...c/androidTest/java/com/openclassrooms/entrevoisins/neighbour_list/NeighboursListTest.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,71 @@ | ||
|
||
package com.openclassrooms.entrevoisins.neighbour_list; | ||
|
||
import android.support.test.espresso.contrib.RecyclerViewActions; | ||
import android.support.test.espresso.matcher.ViewMatchers; | ||
import android.support.test.rule.ActivityTestRule; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import com.openclassrooms.entrevoisins.R; | ||
import com.openclassrooms.entrevoisins.ui.neighbour_list.ListNeighbourActivity; | ||
import com.openclassrooms.entrevoisins.utils.DeleteViewAction; | ||
|
||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static android.support.test.espresso.Espresso.onView; | ||
import static android.support.test.espresso.assertion.ViewAssertions.matches; | ||
import static android.support.test.espresso.matcher.ViewMatchers.assertThat; | ||
import static android.support.test.espresso.matcher.ViewMatchers.hasMinimumChildCount; | ||
import static com.openclassrooms.entrevoisins.utils.RecyclerViewItemCountAssertion.withItemCount; | ||
import static org.hamcrest.core.IsNull.notNullValue; | ||
|
||
|
||
|
||
/** | ||
* Test class for list of neighbours | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class NeighboursListTest { | ||
|
||
// This is fixed | ||
private static int ITEMS_COUNT = 12; | ||
|
||
private ListNeighbourActivity mActivity; | ||
|
||
@Rule | ||
public ActivityTestRule<ListNeighbourActivity> mActivityRule = | ||
new ActivityTestRule(ListNeighbourActivity.class); | ||
|
||
@Before | ||
public void setUp() { | ||
mActivity = mActivityRule.getActivity(); | ||
assertThat(mActivity, notNullValue()); | ||
} | ||
|
||
/** | ||
* We ensure that our recyclerview is displaying at least on item | ||
*/ | ||
@Test | ||
public void myNeighboursList_shouldNotBeEmpty() { | ||
// First scroll to the position that needs to be matched and click on it. | ||
onView(ViewMatchers.withId(R.id.list_neighbours)) | ||
.check(matches(hasMinimumChildCount(1))); | ||
} | ||
|
||
/** | ||
* When we delete an item, the item is no more shown | ||
*/ | ||
@Test | ||
public void myNeighboursList_deleteAction_shouldRemoveItem() { | ||
// Given : We remove the element at position 2 | ||
onView(ViewMatchers.withId(R.id.list_neighbours)).check(withItemCount(ITEMS_COUNT)); | ||
// When perform a click on a delete icon | ||
onView(ViewMatchers.withId(R.id.list_neighbours)) | ||
.perform(RecyclerViewActions.actionOnItemAtPosition(1, new DeleteViewAction())); | ||
// Then : the number of element is 11 | ||
onView(ViewMatchers.withId(R.id.list_neighbours)).check(withItemCount(ITEMS_COUNT-1)); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
app/src/androidTest/java/com/openclassrooms/entrevoisins/utils/DeleteViewAction.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,26 @@ | ||
package com.openclassrooms.entrevoisins.utils; | ||
|
||
import android.support.test.espresso.UiController; | ||
import android.support.test.espresso.ViewAction; | ||
import android.view.View; | ||
import com.openclassrooms.entrevoisins.R; | ||
import org.hamcrest.Matcher; | ||
|
||
public class DeleteViewAction implements ViewAction { | ||
@Override | ||
public Matcher<View> getConstraints() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Click on specific button"; | ||
} | ||
|
||
@Override | ||
public void perform(UiController uiController, View view) { | ||
View button = view.findViewById(R.id.item_list_delete_button); | ||
// Maybe check for null | ||
button.performClick(); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...ndroidTest/java/com/openclassrooms/entrevoisins/utils/RecyclerViewItemCountAssertion.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,37 @@ | ||
package com.openclassrooms.entrevoisins.utils; | ||
|
||
import android.support.test.espresso.NoMatchingViewException; | ||
import android.support.test.espresso.ViewAssertion; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.View; | ||
|
||
import org.hamcrest.Matcher; | ||
import org.hamcrest.Matchers; | ||
import org.junit.Assert; | ||
|
||
public class RecyclerViewItemCountAssertion implements ViewAssertion { | ||
private final Matcher<Integer> matcher; | ||
|
||
public static RecyclerViewItemCountAssertion withItemCount(int expectedCount) { | ||
return withItemCount(Matchers.is(expectedCount)); | ||
} | ||
|
||
public static RecyclerViewItemCountAssertion withItemCount(Matcher<Integer> matcher) { | ||
return new RecyclerViewItemCountAssertion(matcher); | ||
} | ||
|
||
private RecyclerViewItemCountAssertion(Matcher<Integer> matcher) { | ||
this.matcher = matcher; | ||
} | ||
|
||
@Override | ||
public void check(View view, NoMatchingViewException noViewFoundException) { | ||
if (noViewFoundException != null) { | ||
throw noViewFoundException; | ||
} | ||
|
||
RecyclerView recyclerView = (RecyclerView) view; | ||
RecyclerView.Adapter adapter = recyclerView.getAdapter(); | ||
Assert.assertThat(adapter.getItemCount(), matcher); | ||
} | ||
} |
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,30 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.openclassrooms.entrevoisins"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:networkSecurityConfig="@xml/network_security_config" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:name=".ui.neighbour_list.AddNeighbourActivity" | ||
android:label="@string/activity_new_neighbour" /> | ||
<activity | ||
android:name=".ui.neighbour_list.ListNeighbourActivity" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme.NoActionBar"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions
28
app/src/main/java/com/openclassrooms/entrevoisins/di/DI.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,28 @@ | ||
package com.openclassrooms.entrevoisins.di; | ||
|
||
import com.openclassrooms.entrevoisins.service.DummyNeighbourApiService; | ||
import com.openclassrooms.entrevoisins.service.NeighbourApiService; | ||
|
||
/** | ||
* Dependency injector to get instance of services | ||
*/ | ||
public class DI { | ||
|
||
private static NeighbourApiService service = new DummyNeighbourApiService(); | ||
|
||
/** | ||
* Get an instance on @{@link NeighbourApiService} | ||
* @return | ||
*/ | ||
public static NeighbourApiService getNeighbourApiService() { | ||
return service; | ||
} | ||
|
||
/** | ||
* Get always a new instance on @{@link NeighbourApiService}. Useful for tests, so we ensure the context is clean. | ||
* @return | ||
*/ | ||
public static NeighbourApiService getNewInstanceApiService() { | ||
return new DummyNeighbourApiService(); | ||
} | ||
} |
Oops, something went wrong.