Skip to content

Commit

Permalink
Merge pull request #297 from bounswe/development
Browse files Browse the repository at this point in the history
Milestone 1 main merge
  • Loading branch information
YigitSekerci authored Oct 31, 2023
2 parents d222503 + fa42202 commit bc645b4
Show file tree
Hide file tree
Showing 233 changed files with 41,007 additions and 0 deletions.
19 changes: 19 additions & 0 deletions practice-app/database/database.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const mysql = require('mysql2');

const pool = mysql.createPool({
host: 'localhost',
user: 'root',
password: '',
database: 'adventureworks',
connectionLimit: 10, // Adjust this as per your needs
});

pool.query('SELECT * FROM address', (err, results, fields) => {
if (err) {
console.error('Error executing the query: ' + err);
return;
}

// Process the results
return console.log('Query results: ', results);
});
3 changes: 3 additions & 0 deletions prediction-polls/.idea/.gitignore

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

6 changes: 6 additions & 0 deletions prediction-polls/.idea/vcs.xml

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

17 changes: 17 additions & 0 deletions prediction-polls/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/kotlinc.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
/.idea
local.properties
3 changes: 3 additions & 0 deletions prediction-polls/android/.idea/.gitignore

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

1 change: 1 addition & 0 deletions prediction-polls/android/.idea/.name

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

6 changes: 6 additions & 0 deletions prediction-polls/android/.idea/compiler.xml

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

9 changes: 9 additions & 0 deletions prediction-polls/android/.idea/misc.xml

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

6 changes: 6 additions & 0 deletions prediction-polls/android/.idea/vcs.xml

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

1 change: 1 addition & 0 deletions prediction-polls/android/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
127 changes: 127 additions & 0 deletions prediction-polls/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties

plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("com.google.devtools.ksp")
id("com.google.dagger.hilt.android")
}

android {
namespace = "com.bounswe.predictionpolls"
compileSdk = 34

defaultConfig {
applicationId = "com.bounswe.predictionpolls"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}

buildTypes {
debug {
applicationIdSuffix = ".debug"
isMinifyEnabled = false
buildConfigField("String", "BASE_URL", gradleLocalProperties(rootDir).getProperty("base_url"))
}
create("staging") {
applicationIdSuffix = ".staging"
isMinifyEnabled = true
signingConfig = signingConfigs.getByName("debug")
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
buildConfigField("String", "BASE_URL", gradleLocalProperties(rootDir).getProperty("base_url"))
}
release {
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
buildConfigField("String", "BASE_URL", gradleLocalProperties(rootDir).getProperty("base_url"))
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
compose = true
buildConfig = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.3"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

dependencies {
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
implementation("androidx.activity:activity-compose:1.8.0")
implementation(platform("androidx.compose:compose-bom:2023.10.00"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")

// Navigation
val navVersion = "2.7.4"
implementation("androidx.navigation:navigation-compose:$navVersion")
implementation("androidx.hilt:hilt-navigation-compose:1.0.0")

// Testing
testImplementation("org.mockito:mockito-core:5.3.1")
testImplementation("org.mockito:mockito-inline:5.2.0")
testImplementation("org.mockito.kotlin:mockito-kotlin:5.1.0")
testImplementation("junit:junit:4.13.2")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4")
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation(platform("androidx.compose:compose-bom:2023.10.00"))

debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")

// Dagger Hilt
implementation("com.google.dagger:hilt-android:2.48.1")
ksp("com.google.dagger:hilt-compiler:2.48.1")

// For instrumentation tests Dagger hilt
androidTestImplementation("com.google.dagger:hilt-android-testing:2.48.1")
androidTestAnnotationProcessor("com.google.dagger:hilt-compiler:2.48.1")

// For local unit tests Dagger hilt
testImplementation("com.google.dagger:hilt-android-testing:2.48.1")
testAnnotationProcessor("com.google.dagger:hilt-compiler:2.48.1")

// OkHttp
implementation("com.squareup.okhttp3:okhttp:4.9.0")

// Gson
implementation("com.google.code.gson:gson:2.8.9")

// Chucker
debugImplementation("com.github.chuckerteam.chucker:library:3.5.2")
releaseImplementation("com.github.chuckerteam.chucker:library-no-op:3.5.2")

// Retrofit
implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")
}
21 changes: 21 additions & 0 deletions prediction-polls/android/app/proguard-rules.pro
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.bounswe.predictionpolls.ui.common

import androidx.compose.ui.res.stringResource
import androidx.compose.ui.test.*
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class CustomInputFieldTest {

@get:Rule
val composeTestRule = createComposeRule()

@Test
fun customInputField_isDisplayed() {
composeTestRule.setContent {
CustomInputField(
text = "Test Input"
)
}

composeTestRule.onNodeWithText("Test Input").assertIsDisplayed()
}

@Test
fun customInputField_textInputOutput() {
var inputText = ""
composeTestRule.setContent {
CustomInputField(
text = inputText,
onTextChanged = { inputText = it }
)
}

composeTestRule.onNode(hasSetTextAction()).performTextInput("New Text")

assert(inputText == "New Text")
}

@Test
fun customInputField_iconButtonClicked() {
var iconClicked = false
var description = ""

composeTestRule.setContent {
description = stringResource(com.bounswe.predictionpolls.R.string.ok)
CustomInputField(
trailingIconId = com.bounswe.predictionpolls.R.drawable.ic_google,
trailingIconContentDescription = com.bounswe.predictionpolls.R.string.ok,
onTrailingIconClicked = { iconClicked = true }
)
}

composeTestRule.onNodeWithContentDescription(description).performClick()
assert(iconClicked)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.bounswe.predictionpolls.ui.common

import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.test.*
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class ErrorDialogTest {

@get:Rule
val composeTestRule = createComposeRule()

@Test
fun errorDialog_Displayed_WhenError() {
val errorMessage = "An unexpected error occurred. Please try again later."
var errorTitle = ""
var confirmButtonText = ""

composeTestRule.setContent {
errorTitle = stringResource(id = com.bounswe.predictionpolls.R.string.error_dialog_title)
confirmButtonText = stringResource(id = com.bounswe.predictionpolls.R.string.ok)
ErrorDialog(error = errorMessage)
}

composeTestRule.onNodeWithText(errorTitle).assertIsDisplayed()
composeTestRule.onNodeWithText(confirmButtonText).assertIsDisplayed()
composeTestRule.onNodeWithText(errorMessage).assertIsDisplayed()
}

@Test
fun errorDialog_NotDisplayed_WhenNoError() {
var errorTitle = ""
var confirmButtonText = ""

composeTestRule.setContent {
errorTitle = stringResource(id = com.bounswe.predictionpolls.R.string.error_dialog_title)
confirmButtonText = stringResource(id = com.bounswe.predictionpolls.R.string.ok)
ErrorDialog(error = null)
}

composeTestRule.onNodeWithText(errorTitle).assertDoesNotExist()
composeTestRule.onNodeWithText(confirmButtonText).assertDoesNotExist()
}

@Test
fun errorDialog_Dismissed_OnConfirmClick() {
var errorTitle = ""
var confirmButtonText = ""
var errorMessage: String? by mutableStateOf("An unexpected error occurred. Please try again later.")
val dismissDialog: () -> Unit = { errorMessage = null }

composeTestRule.setContent {
errorTitle = stringResource(id = com.bounswe.predictionpolls.R.string.error_dialog_title)
confirmButtonText = stringResource(id = com.bounswe.predictionpolls.R.string.ok)
ErrorDialog(
error = errorMessage,
onDismiss = dismissDialog
)
}

composeTestRule.onNodeWithText(confirmButtonText).apply {
assertIsDisplayed()
performClick()
}
composeTestRule.waitForIdle()
composeTestRule.onNodeWithText(errorTitle).assertDoesNotExist()
composeTestRule.onNodeWithText(confirmButtonText).assertDoesNotExist()
assert(errorMessage == null)
}
}
Loading

0 comments on commit bc645b4

Please sign in to comment.