Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ internal class DocumentOptionsScreenTest {

companion object {
private val TEST_DOCUMENT = Document(
documentId = "test_document6130544703607720127.pdf",
documentId = "test_document7878418937470003605.pdf",
documentName = "Test Document",
uploadTime = "2025-03-13 17:49:53",
activityGenerationComplete = true
uploadTime = "2025-03-27 00:16:43",
activityGenerationComplete = true,
public = false
)
private val TEST_USER = User(
email = "test_user@gmail.com",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.example.thinkr.data.remote.document.DocumentApi
import com.example.thinkr.data.remote.study.StudyApi
import com.example.thinkr.data.repositories.doc.DocRepository
import com.example.thinkr.data.repositories.user.UserRepository
import com.example.thinkr.test.R
import com.example.thinkr.ui.document_upload.DocumentUploadScreen
import com.example.thinkr.ui.document_upload.DocumentUploadViewModel
import io.ktor.client.HttpClient
Expand Down Expand Up @@ -82,7 +83,8 @@ internal class DocumentUploadScreenTest {
fileName = any(),
userId = any(),
documentName = any(),
documentContext = any()
documentContext = any(),
documentPublic = any()
)
} returns true

Expand Down Expand Up @@ -177,7 +179,8 @@ internal class DocumentUploadScreenTest {
fileName = any(),
userId = any(),
documentName = any(),
documentContext = any()
documentContext = any(),
documentPublic = any()
)
} returns false

Expand Down Expand Up @@ -229,7 +232,8 @@ internal class DocumentUploadScreenTest {
fileName = any(),
userId = any(),
documentName = any(),
documentContext = any()
documentContext = any(),
documentPublic = any()
)
} throws Exception("Network error")

Expand Down Expand Up @@ -350,7 +354,7 @@ internal class DocumentUploadScreenTest {

// Mock the Context to return our mocked ContentResolver
val testContext = InstrumentationRegistry.getInstrumentation().context // Test package context
val resId = com.example.thinkr.test.R.raw.test_document
val resId = R.raw.test_document
val inputStream = testContext.resources.openRawResource(resId)
val context = ApplicationProvider.getApplicationContext<Context>()
val tempFile = File.createTempFile("test_document", ".pdf", context.cacheDir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,39 +36,52 @@ internal class FlashcardsScreenTest {
private val TEST_FLASHCARDS = listOf(
FlashcardItem(
front = "Eisenberg Institute for Quantum Research",
back = "Research institute that made breakthroughs in quantum entanglement in 2094"
back = "Research institute that made a breakthrough in quantum entanglement in 2094"
),
FlashcardItem(
front = "Quantum Entanglement",
back = "Phenomenon where particles become correlated and share state information"
),
FlashcardItem(
front = "Schrödinger's Constant",
back = "Constant value used in quantum mechanics (SC = 6.973 X 10^-34)"
front = "Schrödinger's Constant (SC)",
back = "Constant used to manipulate structured data transmission without energy loss"
),
FlashcardItem(
front = "Synthetic Neurons",
back = "Artificial neurons capable of storing and encoding memories"
back = "Neurons that can encode memories and allow for skill 'uploading'"
),
FlashcardItem(
front = "Twin Prime Conjecture",
back = "Mathematical conjecture concerning prime numbers with a difference of two"
back = "Mathematical conjecture related to prime numbers"
),
FlashcardItem(
front = "Artificial Intelligence (AI)",
back = "Technology that simulates human intelligence in machines"
front = "Fibonacci Sequence",
back = "Sequence of numbers where each number is the sum of the two preceding ones"
),
FlashcardItem(
front = "The Singularity Equation",
back = "Unclassified document containing references to a mathematical entity redefining physics"
back = "Unclassified document hinting at a mathematical entity redefining physics"
),
FlashcardItem(
front = "Artificial Intelligence (AI)",
back = "Intelligent machines capable of performing tasks that typically require human intelligence"
),
FlashcardItem(
front = "Neuronal Patch",
back = "Patch embedded in the brain to facilitate rapid learning or skill acquisition"
),
FlashcardItem(
front = "Quantum Entanglement",
back = "Phenomenon where particles become interconnected and share properties regardless of distance"
),
FlashcardItem(
front = "The Quantum Paradox of 2094",
back = "Series of scientific discoveries and events in 2094 with profound implications"
)
)

private val TEST_DOCUMENT = Document(
documentId = "test_document6130544703607720127.pdf",
documentId = "test_document7878418937470003605.pdf",
documentName = "Test Document",
uploadTime = "2025-03-13 17:49:53",
activityGenerationComplete = true
activityGenerationComplete = true,
public = false
)

private val TEST_USER = User(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,60 +41,61 @@ internal class QuizScreenTest {
QuizItem(
question = "Who theorized that Schrödinger's Constant could be manipulated to transmit structured data without energy loss?",
options = mapOf(
"A" to "Dr. John Smith",
"B" to "Dr. Emily Liu",
"C" to "Dr. Lena Vasquez",
"D" to "Dr. Michael Chang"
"A" to "Dr. Hiroshi Tanaka",
"B" to "Dr. Lena Vasquez",
"C" to "Dr. Maria Rodriguez",
"D" to "Dr. James Thompson"
),
answer = "C"
answer = "B"
),
QuizItem(
question = "What did the independent team of bioengineers from Osaka, Japan discover in 2094?",
question = "Where did the independent team of bioengineers encode memories into synthetic neurons?",
options = mapOf(
"A" to "A new renewable energy source",
"B" to "A way to encode memories into synthetic neurons",
"C" to "A method to time travel",
"D" to "A cure for cancer"
"A" to "New York City, USA",
"B" to "Paris, France",
"C" to "Osaka, Japan",
"D" to "London, England"
),
answer = "B"
answer = "C"
),
QuizItem(
question = "What was demonstrated when subject #117 used a neuronal patch embedded in the left temporal lobe?",
question = "What skill did subject #117 learn in 8.2 minutes using a neuronal patch embedded in the left temporal lobe?",
options = mapOf(
"A" to "Telepathic communication",
"B" to "Enhanced physical strength",
"C" to "Ability to predict the future",
"D" to "Learning fluent Mandarin in 8.2 minutes"
"A" to "Fluent Mandarin",
"B" to "Playing the piano",
"C" to "Programming in Java",
"D" to "Sculpting"
),
answer = "D"
answer = "A"
),
QuizItem(
question = "What was the name of the autonomous AI at Arctic Research Outpost Z-45?",
question = "What was the name of the autonomous AI in the Arctic Research Outpost Z-45?",
options = mapOf(
"A" to "NOVA-7",
"B" to "AURORA-5",
"C" to "SOLARIS-3",
"D" to "ORION-9"
"A" to "Ava",
"B" to "Echo",
"C" to "Siri",
"D" to "NOVA-7"
),
answer = "A"
answer = "D"
),
QuizItem(
question = "Where was the encrypted transmission from Eris Base located?",
question = "What document was revealed in an encrypted transmission from Eris Base?",
options = mapOf(
"A" to "37.8°N, 122.4°W",
"B" to "0°N, 0°E",
"C" to "14.5°N, 152.3°E",
"D" to "90°S, 0°E"
"A" to "The Quantum Paradox",
"B" to "The AI Dilemma",
"C" to "The Singularity Equation",
"D" to "The Fibonacci Connection"
),
answer = "C"
)
)

private val TEST_DOCUMENT = Document(
documentId = "test_document6130544703607720127.pdf",
documentId = "test_document7878418937470003605.pdf",
documentName = "Test Document",
uploadTime = "2025-03-13 17:49:53",
activityGenerationComplete = true
activityGenerationComplete = true,
public = false
)

private val TEST_USER = User(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ fun FilePickerDialog(
val inputStream = context.contentResolver.openInputStream(uri) ?: throw IOException(
"Could not open document"
)
val file = File(context.filesDir, uri.lastPathSegment ?: "unknown")

val fileName = getFileName(context, uri)
val file = File(context.filesDir, fileName)
inputStream.use { input ->
FileOutputStream(file).use { output ->
input.copyTo(output)
}
}
selectedFileUri = Uri.fromFile(file)
selectedFileName = Uri.fromFile(file)?.let { getFileName(context, it) }
selectedFileName = file.name
}
filePickerError = false
} catch (e: FileNotFoundException) {
Expand Down Expand Up @@ -132,15 +132,17 @@ fun FilePickerDialog(
}
}

private fun getFileName(context: Context, uri: Uri): String? {
val cursor = context.contentResolver.query(uri, null, null, null, null)
cursor?.use {
if (it.moveToFirst()) {
val nameIndex = it.getColumnIndex(OpenableColumns.DISPLAY_NAME)
if (nameIndex != -1) {
return it.getString(nameIndex)
}
private fun getFileName(context: Context, uri: Uri): String {
// Get the display name from ContentResolver
var fileName = context.contentResolver.query(uri,
arrayOf(OpenableColumns.DISPLAY_NAME), null, null, null)?.use { cursor ->
if (cursor.moveToFirst()) {
cursor.getString(cursor.getColumnIndexOrThrow(OpenableColumns.DISPLAY_NAME))
} else {
null
}
}
return null
}
} ?: uri.lastPathSegment?.substringAfterLast('/') ?: "unknown"
// Sanitize filename
fileName = fileName.replace("[^a-zA-Z0-9.-]".toRegex(), "_")
return fileName
}