This repository has been archived by the owner on Feb 1, 2025. It is now read-only.
-
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.
Merge pull request #124 from MediaTo-SDP/profile_header_displays_foll…
…owers Profile header displays followers and following count
- Loading branch information
Showing
25 changed files
with
539 additions
and
150 deletions.
There are no files selected for viewing
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 was deleted.
Oops, something went wrong.
102 changes: 102 additions & 0 deletions
102
app/src/androidTest/java/com/github/sdp/mediato/MyFollowersFragmentTest.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,102 @@ | ||
package com.github.sdp.mediato; | ||
|
||
import static com.adevinta.android.barista.assertion.BaristaRecyclerViewAssertions.assertRecyclerViewItemCount; | ||
import static com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertDisplayed; | ||
import static com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertNotDisplayed; | ||
import static com.adevinta.android.barista.interaction.BaristaListInteractions.clickListItemChild; | ||
import static com.adevinta.android.barista.interaction.BaristaSleepInteractions.sleep; | ||
|
||
import android.os.Bundle; | ||
import androidx.fragment.app.FragmentManager; | ||
import androidx.test.core.app.ActivityScenario; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
import com.github.sdp.mediato.data.UserDatabase; | ||
import com.github.sdp.mediato.model.Location; | ||
import com.github.sdp.mediato.model.User; | ||
import com.github.sdp.mediato.ui.MyFollowersFragment; | ||
import com.github.sdp.mediato.ui.MyFollowingFragment; | ||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.TimeoutException; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class MyFollowersFragmentTest { | ||
private final static int STANDARD_USER_TIMEOUT = 10; | ||
User user1; | ||
User user2; | ||
User user3; | ||
|
||
@Before | ||
public void setUp() throws ExecutionException, InterruptedException, TimeoutException | ||
{ | ||
try { | ||
UserDatabase.database.useEmulator("10.0.2.2", 9000); | ||
} catch (Exception ignored) { | ||
} | ||
//Create new sample users | ||
user1 = new User.UserBuilder("uniqueId1") | ||
.setUsername("user_test_1") | ||
.setEmail("email_test_1") | ||
.setRegisterDate("09/03/2023") | ||
.setLocation(new Location(3.14, 3.14)) | ||
.build(); | ||
user2 = new User.UserBuilder("uniqueId2") | ||
.setUsername("user_test_2") | ||
.setEmail("email_test_2") | ||
.setRegisterDate("19/03/2023") | ||
.setLocation(new Location(3.14, 3.14)) | ||
.build(); | ||
user3 = new User.UserBuilder("uniqueId3") | ||
.setUsername("user_test_3") | ||
.setEmail("email_test_3") | ||
.setRegisterDate("19/03/2023") | ||
.setLocation(new Location(3.14, 3.14)) | ||
.build(); | ||
|
||
UserDatabase.addUser(user1).get(STANDARD_USER_TIMEOUT, TimeUnit.SECONDS); | ||
UserDatabase.addUser(user2).get(STANDARD_USER_TIMEOUT, TimeUnit.SECONDS); | ||
UserDatabase.addUser(user3).get(STANDARD_USER_TIMEOUT, TimeUnit.SECONDS); | ||
|
||
// Launch the TestingActivity | ||
ActivityScenario<TestingActivity> scenario = ActivityScenario.launch(TestingActivity.class); | ||
|
||
// Set up the TestingActivity to display the SearchFragment | ||
scenario.onActivity(activity -> { | ||
FragmentManager fragmentManager = activity.getSupportFragmentManager(); | ||
MyFollowersFragment myFollowersFragment = new MyFollowersFragment(); | ||
|
||
// Pass the username to the fragment like at profile creation | ||
Bundle bundle = new Bundle(); | ||
bundle.putString("username", "user_test_1"); | ||
myFollowersFragment.setArguments(bundle); | ||
fragmentManager.beginTransaction().replace(R.id.fragment_container, myFollowersFragment) | ||
.commitAllowingStateLoss(); | ||
}); | ||
} | ||
|
||
@Test | ||
public void testRecyclerViewWithNoneFollowing() { | ||
assertRecyclerViewItemCount(R.id.myFollowing_recyclerView, 0); | ||
} | ||
|
||
@Test | ||
public void testRecyclerViewWithTwoFollowings() { | ||
UserDatabase.followUser(user2.getUsername(), user1.getUsername()); | ||
UserDatabase.followUser(user3.getUsername(), user1.getUsername()); | ||
|
||
sleep(500); | ||
|
||
assertRecyclerViewItemCount(R.id.myFollowing_recyclerView, 2); | ||
assertDisplayed(user2.getUsername()); | ||
assertDisplayed(user3.getUsername()); | ||
|
||
assertNotDisplayed(R.id.searchUserAdapter_unfollowButton); | ||
assertNotDisplayed(R.id.searchUserAdapter_followButton); | ||
} | ||
|
||
} | ||
|
||
|
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
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
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
Oops, something went wrong.