Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shazam and camera send the song to the post #241

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
0c53a7a
storage emulator
RoCKnD79 May 19, 2023
f30b4e6
refactoring
yasmineben510 May 23, 2023
9f6f893
finished connecting shazam, camera and post creation
yasmineben510 May 24, 2023
cca677d
Added tests
yasmineben510 May 25, 2023
ef28ebd
Update BluetoothServiceManagerTest.kt
yasmineben510 May 25, 2023
83c2336
Merge branch 'main' into 207-make-the-shazamactivity-send-the-found-s…
yasmineben510 May 25, 2023
ba8e2ae
Merge branch 'main' into 207-make-the-shazamactivity-send-the-found-s…
yasmineben510 May 25, 2023
e152dd2
set up emulator and written first tests
yasmineben510 May 25, 2023
16c0b18
Update FirebaseStorageAPITest.kt
yasmineben510 May 25, 2023
9fe4ef3
unfixable tho
RoCKnD79 May 26, 2023
06c46a7
profile caching setup
saraanej May 26, 2023
1c77e12
add tests
saraanej May 26, 2023
a24af84
Merge branch 'main' into profile-caching
saraanej May 26, 2023
a786eef
Merge branch 'main' into 207-make-the-shazamactivity-send-the-found-s…
yasmineben510 May 26, 2023
804ffbd
wip
RoCKnD79 May 26, 2023
ffaac16
fixed bugs
yasmineben510 May 26, 2023
d3da954
fix the posting of pictures
yasmineben510 May 26, 2023
82a81a3
video works
yasmineben510 May 26, 2023
5af39da
fix edit profile activity tests
RoCKnD79 May 26, 2023
eafce12
potential fix for createpost test
RoCKnD79 May 27, 2023
a4394d4
oh nah
RoCKnD79 May 27, 2023
12a47be
fixing bugs
yasmineben510 May 27, 2023
796ccbe
fair enough
RoCKnD79 May 27, 2023
5a5516e
Merge branch 'profile_storage' of github.com:OrkestApp/sdp_2023 into …
RoCKnD79 May 27, 2023
67873e8
Merge branch 'main' into 207-make-the-shazamactivity-send-the-found-s…
saraanej May 31, 2023
9a2119a
last version of storage
RoCKnD79 May 31, 2023
e6c05c5
Merge branch 'main' into profile_storage
RoCKnD79 May 31, 2023
c5cd658
merge with main
RoCKnD79 May 31, 2023
b21cd9f
aosdaomds
RoCKnD79 May 31, 2023
7191eb8
Merge branch 'profile-caching' into 207-make-the-shazamactivity-send-…
saraanej May 31, 2023
91d85fe
Merge remote-tracking branch 'origin/profile_storage' into 207-make-t…
saraanej May 31, 2023
3cb2f7f
test
saraanej May 31, 2023
99d34ac
working version edit profile
saraanej May 31, 2023
99f596b
add differrent pics for the song
Zermelo-101 May 31, 2023
cc1d310
Merge branch '207-make-the-shazamactivity-send-the-found-song-the-pos…
Zermelo-101 May 31, 2023
ad12ea8
add differrent pics for the song
Zermelo-101 May 31, 2023
4347a08
correctVideo
saraanej May 31, 2023
2b4c24f
Merge branch '207-make-the-shazamactivity-send-the-found-song-the-pos…
saraanej May 31, 2023
2744d98
images for the profile
evguersl May 31, 2023
9659984
Merge remote-tracking branch 'origin/207-make-the-shazamactivity-send…
evguersl May 31, 2023
4026ebb
Fetch profile pictures
saraanej May 31, 2023
01ba670
Merge branch '207-make-the-shazamactivity-send-the-found-song-the-pos…
saraanej May 31, 2023
cff17ca
Update FollowListActivity.kt
yasmineben510 May 31, 2023
1a90212
Merge branch '207-make-the-shazamactivity-send-the-found-song-the-pos…
yasmineben510 May 31, 2023
34d4ee6
title
saraanej May 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ dependencies {
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'

// Room components
var room_version = "2.5.1"

Expand Down Expand Up @@ -312,6 +312,18 @@ dependencies {





// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:31.5.0')

// Add the dependency for the Cloud Storage library
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-storage-ktx'

// FirebaseUI Storage only
implementation 'com.firebaseui:firebase-ui-storage:7.2.0'

//refreshing
implementation 'com.google.accompanist:accompanist-swiperefresh:0.25.1'
}
Expand Down Expand Up @@ -353,4 +365,3 @@ connectedCheck {
configurations.all {
resolutionStrategy.force 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10'
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.github.orkest
import com.google.firebase.firestore.ktx.firestore
import com.google.firebase.firestore.ktx.firestoreSettings
import com.google.firebase.ktx.Firebase
import com.google.firebase.storage.FirebaseStorage
import org.junit.BeforeClass
import org.junit.FixMethodOrder
import org.junit.Test
Expand All @@ -21,11 +22,16 @@ class AAARunBeforeTests {
fun setupEmulator() {

val db = Firebase.firestore
db.useEmulator("10.0.2.2", 8080)
db.useEmulator("10.0.2.2", 8181)
db.firestoreSettings = firestoreSettings {
isPersistenceEnabled = false
}

val storage = FirebaseStorage.getInstance()
storage.useEmulator("10.0.2.2", 9199)



}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class CreatePostTest {
// Define your intent data
val intent = Intent(ApplicationProvider.getApplicationContext(), CreatePost::class.java).apply {
putExtra("isVideo", true)
putExtra("iTest", true)
putExtra("URI", "your_uri")
putExtra(Constants.SONG_NAME, "song_name")
putExtra(Constants.SONG_ARTIST, "song_artist")
Expand Down
21 changes: 18 additions & 3 deletions app/src/androidTest/java/com/github/orkest/EditProfileTest.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package com.github.orkest

import android.content.Intent
import android.graphics.Bitmap
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.test.*
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.core.graphics.drawable.toBitmap
import com.github.orkest.ui.EditProfileActivity
import com.github.orkest.ui.EditProfileScreen
import com.github.orkest.ui.authentication.AuthViewModel
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import java.io.ByteArrayOutputStream


class EditProfileTest {

Expand All @@ -16,8 +20,19 @@ class EditProfileTest {

@Before
fun setup(){

composeTestRule.setContent {
EditProfileScreen(EditProfileActivity())
val context = LocalContext.current
val intent = Intent(context, EditProfileActivity::class.java)

val d = context.getDrawable(R.drawable.blank_profile_pic)
val stream = ByteArrayOutputStream()
d?.toBitmap()?.compress(Bitmap.CompressFormat.JPEG, 100, stream)
val bitmapdata: ByteArray = stream.toByteArray()

intent.putExtra("bio", "tqt")
intent.putExtra("profilePic", bitmapdata)
context.startActivity(intent)
}
}

Expand Down
20 changes: 0 additions & 20 deletions app/src/androidTest/java/com/github/orkest/OnCreateProfileTest.kt

This file was deleted.

25 changes: 25 additions & 0 deletions app/src/androidTest/java/com/github/orkest/PersistenceTesting.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.github.orkest

import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.room.Room
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.github.orkest.data.OrkestDate
import com.github.orkest.data.Profile
import com.github.orkest.data.Song
import com.github.orkest.domain.persistence.AppDao
import com.github.orkest.domain.persistence.AppDatabase
Expand All @@ -29,6 +31,7 @@ class PersistenceTesting {
private lateinit var userDao: MockUserDao
private lateinit var songDao: MockSongDao
private lateinit var postDao: MockPostDao
private lateinit var profileDao: MockProfileDao

@Before
fun setup() {
Expand All @@ -40,6 +43,7 @@ class PersistenceTesting {
userDao = MockUserDao()
songDao = MockSongDao()
postDao = MockPostDao()
profileDao = MockProfileDao()
}

@After
Expand Down Expand Up @@ -96,6 +100,15 @@ class PersistenceTesting {
val allPosts = postDao.getAllPosts()
assertEquals(posts, allPosts)
}

@Test
fun testProfileDao() = runBlocking{
val profile = AppEntities.Companion.ProfileEntity(1,"Yas", -1, "Bio", 23, 1, ArrayList(), ArrayList())

profileDao.insertProfile(profile)
val currentProfile = profileDao.getProfile()
assertEquals(profile, currentProfile)
}
}

/**
Expand Down Expand Up @@ -142,4 +155,16 @@ class MockPostDao: AppDao.Companion.PostDao{
override fun insertPosts(posts: List<AppEntities.Companion.PostEntity>) {
postList.addAll(posts)
}
}

class MockProfileDao: AppDao.Companion.ProfileDao{
private val profile = MutableLiveData<AppEntities.Companion.ProfileEntity>()

override fun getProfile(): AppEntities.Companion.ProfileEntity? {
return profile.value
}

override fun insertProfile(currentProfile: AppEntities.Companion.ProfileEntity) {
profile.value = currentProfile
}
}
24 changes: 24 additions & 0 deletions app/src/androidTest/java/com/github/orkest/View/CameraViewTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ package com.github.orkest.View

import androidx.compose.ui.test.*
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.matcher.IntentMatchers.*
import com.github.orkest.data.Constants
import com.github.orkest.shazam.domain.ShazamConstants
import com.github.orkest.ui.Camera.CameraView
import com.github.orkest.ui.feed.CreatePost
import org.junit.Before
import org.junit.Rule
import org.junit.Test
Expand Down Expand Up @@ -67,4 +72,23 @@ class CameraViewTest {
}
}

@Test
fun takePictureSendsIntentToPostCreationWithShazamSong() {
Intents.init()
//Set the song to be found
ShazamConstants.SONG_FOUND = Constants.DUMMY_RUDE_BOY_SONG
//click on take picture button
composeTestRule.onNodeWithTag("Take Picture Button").performClick()
Thread.sleep(3000) //Wait for the UI to update
//Click on save button
composeTestRule.onNodeWithTag("Save Button").performClick()
//Check if the intent was sent to the post creation activity
Intents.intended(hasComponent(CreatePost::class.java.name))
//Check if the intent was sent to the post creation activity with correct extras
Intents.intended(hasExtra(Constants.SONG_NAME, Constants.DUMMY_RUDE_BOY_SONG.Title))
Intents.intended(hasExtra(Constants.SONG_ARTIST, Constants.DUMMY_RUDE_BOY_SONG.Artist))
Intents.release()
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.Intents.intended
import androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.github.orkest.data.Constants
import com.github.orkest.data.User
import com.github.orkest.ui.FollowList
import com.github.orkest.ui.profile.ProfileActivity
Expand Down Expand Up @@ -52,7 +53,7 @@ class FollowListActivityTest{
@Test
fun backButton_navigatesBack() {
composeTestRule.setContent {
OrkestTheme { FollowList(ProfileActivity(), viewModel = viewModel) }
OrkestTheme { FollowList(ProfileActivity(Constants.APPLICATION_CONTEXT), viewModel = viewModel) }
}
val activityScenario = launchActivity<FollowListActivity>(intent)
activityScenario.moveToState(Lifecycle.State.RESUMED)
Expand All @@ -67,7 +68,7 @@ class FollowListActivityTest{
@Test
fun profileRowNavigatesToUserProfile(){
composeTestRule.setContent {
OrkestTheme { FollowList(ProfileActivity(), viewModel = viewModel) }
OrkestTheme { FollowList(ProfileActivity(Constants.APPLICATION_CONTEXT), viewModel = viewModel) }
}
Intents.init()
composeTestRule.onNodeWithTag("Profile Row", useUnmergedTree = true).performClick()
Expand All @@ -79,23 +80,23 @@ class FollowListActivityTest{
@Test
fun profilePictureIsDisplayed(){
composeTestRule.setContent {
OrkestTheme { FollowList(ProfileActivity(), viewModel = viewModel) }
OrkestTheme { FollowList(ProfileActivity(Constants.APPLICATION_CONTEXT), viewModel = viewModel) }
}
composeTestRule.onNodeWithContentDescription("Contact profile picture").assertIsDisplayed()
}

@Test
fun usernameIsDisplayed(){
composeTestRule.setContent {
OrkestTheme { FollowList(ProfileActivity(), viewModel = viewModel) }
OrkestTheme { FollowList(ProfileActivity(Constants.APPLICATION_CONTEXT), viewModel = viewModel) }
}
composeTestRule.onNodeWithTag("Username", useUnmergedTree = true).assertIsDisplayed()
}

@Test
fun displayFollowersList() {
composeTestRule.setContent {
OrkestTheme { FollowList(ProfileActivity(), viewModel = viewModel) }
OrkestTheme { FollowList(ProfileActivity(Constants.APPLICATION_CONTEXT), viewModel = viewModel) }
}
// Launch the activity with the followers parameter
intent.putExtra("isFollowers", true)
Expand All @@ -109,7 +110,7 @@ class FollowListActivityTest{
@Test
fun displayFollowingsList() {
composeTestRule.setContent {
OrkestTheme { FollowList(ProfileActivity(), viewModel = viewModel) }
OrkestTheme { FollowList(ProfileActivity(Constants.APPLICATION_CONTEXT), viewModel = viewModel) }
}
// Launch the activity with the followings parameter
intent.putExtra("isFollowers", false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.github.orkest.bluetooth.data.TestDeviceUI
import com.github.orkest.bluetooth.domain.BluetoothConstants
import com.github.orkest.bluetooth.domain.Device
import com.github.orkest.bluetooth.ui.BluetoothActivity
import com.github.orkest.data.Constants
import com.github.orkest.ui.profile.ProfileViewModel
import org.junit.Rule
import org.junit.Test
Expand All @@ -40,7 +41,7 @@ class bluetoothUITest {
BluetoothConstants.MESSAGE_READ -> {
// construct a string from the valid bytes in the buffer
val msgReceived = String(msg.obj as ByteArray, 0, msg.arg1)
val follow = ProfileViewModel(msgReceived)
val follow = ProfileViewModel(Constants.APPLICATION_CONTEXT, msgReceived)
follow.updateCurrentUserFollowings(true)
follow.updateUserFollowers(true)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.github.orkest.View.feed
import androidx.compose.ui.test.*
import androidx.compose.ui.test.junit4.createComposeRule
import com.github.orkest.ViewModel.feed.MockPostViewModel
import com.github.orkest.data.Song
import com.github.orkest.ui.feed.CreatePost
import com.github.orkest.ui.feed.EditPostScreen
import org.junit.Assert.*
Expand All @@ -15,11 +16,13 @@ class CreatePostTest{

@get:Rule
val composeTestRule = createComposeRule()
lateinit var viewModel: MockPostViewModel

@Before
fun setup(){
// Start the app
val viewModel = MockPostViewModel()
viewModel = MockPostViewModel()
viewModel.updateSong(Song("TestTitle","TestArtist"))
composeTestRule.setContent {
EditPostScreen(viewModel = viewModel, activity = CreatePost())
}
Expand Down Expand Up @@ -47,6 +50,13 @@ class CreatePostTest{
composeTestRule.onNodeWithText("Post Description").assertIsDisplayed()
}

@Test
fun songPostUpdatesBasedOnSong() {
assertEquals(viewModel.getSong(), Song("TestTitle","TestArtist"))
composeTestRule.onNodeWithText("TestTitle").assertIsDisplayed()
composeTestRule.onNodeWithText("TestArtist").assertIsDisplayed()
}

//Not necessary to test the other, since this is just a demo activity


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ProfileUITest {
fun profileScreen_displaysRightValues() {
composeTestRule.setContent {
ProfileActivitySetting {
ProfileActivityScreen(ProfileActivity(), viewModel = viewModel)
ProfileActivityScreen(ProfileActivity(Constants.APPLICATION_CONTEXT), viewModel = viewModel)
}
}
composeTestRule.onNodeWithText(John.username).assertIsDisplayed()
Expand Down Expand Up @@ -87,7 +87,7 @@ class ProfileUITest {
fun addFavoriteSongsAndArtistsButtonsAreDisplayedAndClickable() {
composeTestRule.setContent {
ProfileActivitySetting {
ProfileActivityScreen(ProfileActivity(), viewModel = viewModel)
ProfileActivityScreen(ProfileActivity(Constants.APPLICATION_CONTEXT), viewModel = viewModel)
}
}

Expand Down
Loading