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

Fixes #4294: After deleting a profile deleted successfully message should be displayed #4887

Closed
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
c8b91a4
added snackbar
Akshatkamboj14 Mar 2, 2023
8257029
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
Akshatkamboj14 Mar 2, 2023
7e57949
merged into develop
Akshatkamboj14 Mar 2, 2023
38f0f6e
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
Akshatkamboj14 Mar 10, 2023
748d8a1
changed the timing to short
Akshatkamboj14 Mar 11, 2023
f631b95
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
Akshatkamboj14 Mar 11, 2023
6ea61fb
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
Akshatkamboj14 Apr 4, 2023
a5a9a56
added comments
Akshatkamboj14 Apr 4, 2023
44e9e3b
added comments
Akshatkamboj14 Apr 4, 2023
80fbab2
added comments
Akshatkamboj14 Apr 4, 2023
84ca7c6
added comments
Akshatkamboj14 Apr 4, 2023
9c687fa
Merge branch 'develop' into After-deleting-a-profile-Deleted-successf…
adhiamboperes Apr 19, 2023
824fc2d
added snackbar
Akshatkamboj14 Apr 25, 2023
0eabafe
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
Akshatkamboj14 Apr 25, 2023
85f8dbc
added snackbar
Akshatkamboj14 Apr 25, 2023
257e961
added snackbar
Akshatkamboj14 Apr 25, 2023
8960942
added snackbar
Akshatkamboj14 Apr 25, 2023
958b911
Merge branch 'After-deleting-a-profile-Deleted-successfully-message-s…
Akshatkamboj14 Apr 26, 2023
31faaef
added snackbar-request-provider-id
Akshatkamboj14 May 3, 2023
a3a3c19
rearranged-imports
Akshatkamboj14 May 3, 2023
46b1418
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
Akshatkamboj14 May 3, 2023
e5f39e9
rearranged-imports
Akshatkamboj14 May 3, 2023
39740b8
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
Akshatkamboj14 May 14, 2023
84da79d
added test for the snackbar controller
Akshatkamboj14 May 29, 2023
2db6631
corrected import statements
Akshatkamboj14 May 29, 2023
aa06e79
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
Akshatkamboj14 Jul 4, 2023
dbe3cc4
merged-into-develop
Akshatkamboj14 Jul 10, 2023
455edf4
added two tests
Akshatkamboj14 Jul 11, 2023
b7f1542
added the main functionality tests and some few changes
Akshatkamboj14 Jul 12, 2023
2f1c932
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
Akshatkamboj14 Jul 12, 2023
4d8d714
removed unused import
Akshatkamboj14 Jul 12, 2023
c92ddfd
added Kdoc for the sealed class
Akshatkamboj14 Jul 13, 2023
f2f51be
corrected tests and kdocs
Akshatkamboj14 Jul 14, 2023
e02a1e1
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
Akshatkamboj14 Jul 18, 2023
a40b2f8
corrected issues
Akshatkamboj14 Jul 18, 2023
1501043
added last
Akshatkamboj14 Jul 30, 2023
47baaae
added snackbarManagerTest
Akshatkamboj14 Aug 3, 2023
6f89a7d
added new line at the end
Akshatkamboj14 Aug 3, 2023
9aaff1e
merged into develop
Akshatkamboj14 Aug 3, 2023
f26d0e4
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
Akshatkamboj14 Aug 3, 2023
319dd8a
test-commit
Akshatkamboj14 Aug 3, 2023
4176ab7
corrected k-doc
Akshatkamboj14 Aug 3, 2023
821c760
removed coroutine disp
Akshatkamboj14 Aug 3, 2023
a226cc1
restored
Akshatkamboj14 Aug 3, 2023
7abb519
corrected tests
Akshatkamboj14 Aug 8, 2023
5e2d339
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
Akshatkamboj14 Aug 8, 2023
8252511
started changes
Akshatkamboj14 Oct 31, 2023
3cc76fb
merged-with-develop
Akshatkamboj14 Oct 31, 2023
34f45b1
few changes
Akshatkamboj14 Nov 10, 2023
64f48ba
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
Akshatkamboj14 Nov 28, 2023
8430f81
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
Akshatkamboj14 Nov 29, 2023
fc47617
done some changes acc to gist-1
Akshatkamboj14 Nov 29, 2023
3e7d3ce
done some changes acc to gist-1
Akshatkamboj14 Nov 29, 2023
599af85
done some changes acc to gist-1
Akshatkamboj14 Nov 29, 2023
f2f1f69
done some changes acc to gist-1
Akshatkamboj14 Nov 29, 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
Prev Previous commit
Next Next commit
added last
  • Loading branch information
Akshatkamboj14 committed Jul 30, 2023
commit 1501043b20f51d733b4d3077dd65bdb405855d6d
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
package org.oppia.android.app.settings.profile

import android.app.Application
import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import androidx.test.core.app.ApplicationProvider
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.intent.Intents
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.runners.AndroidJUnit4
import dagger.Component
import javax.inject.Inject
import javax.inject.Singleton
import org.hamcrest.Matchers.allOf
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.android.R
import org.oppia.android.app.activity.ActivityComponent
import org.oppia.android.app.activity.ActivityComponentFactory
import org.oppia.android.app.activity.route.ActivityRouterModule
import org.oppia.android.app.application.ApplicationComponent
import org.oppia.android.app.application.ApplicationInjector
import org.oppia.android.app.application.ApplicationInjectorProvider
import org.oppia.android.app.application.ApplicationModule
import org.oppia.android.app.application.ApplicationStartupListenerModule
import org.oppia.android.app.application.testing.TestingBuildFlavorModule
import org.oppia.android.app.devoptions.DeveloperOptionsModule
import org.oppia.android.app.devoptions.DeveloperOptionsStarterModule
import org.oppia.android.app.player.state.itemviewmodel.SplitScreenInteractionModule
import org.oppia.android.app.shim.ViewBindingShimModule
import org.oppia.android.app.translation.testing.ActivityRecreatorTestModule
import org.oppia.android.data.backends.gae.NetworkConfigProdModule
import org.oppia.android.data.backends.gae.NetworkModule
import org.oppia.android.domain.classify.InteractionsModule
import org.oppia.android.domain.classify.rules.algebraicexpressioninput.AlgebraicExpressionInputModule
import org.oppia.android.domain.classify.rules.continueinteraction.ContinueModule
import org.oppia.android.domain.classify.rules.dragAndDropSortInput.DragDropSortInputModule
import org.oppia.android.domain.classify.rules.fractioninput.FractionInputModule
import org.oppia.android.domain.classify.rules.imageClickInput.ImageClickInputModule
import org.oppia.android.domain.classify.rules.itemselectioninput.ItemSelectionInputModule
import org.oppia.android.domain.classify.rules.mathequationinput.MathEquationInputModule
import org.oppia.android.domain.classify.rules.multiplechoiceinput.MultipleChoiceInputModule
import org.oppia.android.domain.classify.rules.numberwithunits.NumberWithUnitsRuleModule
import org.oppia.android.domain.classify.rules.numericexpressioninput.NumericExpressionInputModule
import org.oppia.android.domain.classify.rules.numericinput.NumericInputRuleModule
import org.oppia.android.domain.classify.rules.ratioinput.RatioInputModule
import org.oppia.android.domain.classify.rules.textinput.TextInputRuleModule
import org.oppia.android.domain.exploration.ExplorationProgressModule
import org.oppia.android.domain.exploration.ExplorationStorageModule
import org.oppia.android.domain.hintsandsolution.HintsAndSolutionConfigModule
import org.oppia.android.domain.hintsandsolution.HintsAndSolutionProdModule
import org.oppia.android.domain.onboarding.ExpirationMetaDataRetrieverModule
import org.oppia.android.domain.oppialogger.LogStorageModule
import org.oppia.android.domain.oppialogger.LoggingIdentifierModule
import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule
import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule
import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule
import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule
import org.oppia.android.domain.platformparameter.PlatformParameterModule
import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule
import androidx.test.espresso.assertion.ViewAssertions.matches
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.snackbar.SnackbarController
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule
import org.oppia.android.testing.OppiaTestRule
import org.oppia.android.testing.TestLogReportingModule
import org.oppia.android.testing.junit.InitializeDefaultLocaleRule
import org.oppia.android.testing.robolectric.RobolectricModule
import org.oppia.android.testing.threading.TestCoroutineDispatchers
import org.oppia.android.testing.threading.TestDispatcherModule
import org.oppia.android.testing.time.FakeOppiaClockModule
import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.AssetModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.locale.LocaleProdModule
import org.oppia.android.util.logging.EventLoggingConfigurationModule
import org.oppia.android.util.logging.LoggerModule
import org.oppia.android.util.logging.SyncStatusModule
import org.oppia.android.util.logging.firebase.FirebaseLogUploaderModule
import org.oppia.android.util.networking.NetworkConnectionDebugUtilModule
import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule
import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule
import org.oppia.android.util.parser.image.GlideImageLoaderModule
import org.oppia.android.util.parser.image.ImageParsingModule
import org.robolectric.annotation.LooperMode

/** Tests for [SnackbarManager]*/
@RunWith(AndroidJUnit4::class)
@LooperMode(LooperMode.Mode.PAUSED)
class SnackbarManagerTest {

@get:Rule
val initializeDefaultLocaleRule = InitializeDefaultLocaleRule()

@get:Rule
val oppiaTestRule = OppiaTestRule()

@Inject
lateinit var context: Context

@Inject
lateinit var snackbarManager: SnackbarManager

@Inject
lateinit var testCoroutineDispatchers: TestCoroutineDispatchers

@Before
fun setUp() {
Intents.init()
setUpTestApplicationComponent()
testCoroutineDispatchers.registerIdlingResource()
}

@After
fun tearDown() {
testCoroutineDispatchers.unregisterIdlingResource()
Intents.release()
}


@Test
fun firstTest(){
snackbarManager.showSnackbar(R.string.profile_edit_delete_success, SnackbarController.SnackbarDuration.SHORT)
onView(allOf(withText(R.string.profile_edit_delete_success)))
.check(matches(isDisplayed()))
}


private fun setUpTestApplicationComponent() {
ApplicationProvider.getApplicationContext<TestApplication>().inject(this)
}

@Singleton
@Component(
modules = [
RobolectricModule::class,
PlatformParameterModule::class, PlatformParameterSingletonModule::class,
TestDispatcherModule::class, ApplicationModule::class,
LoggerModule::class, ContinueModule::class, FractionInputModule::class,
ItemSelectionInputModule::class, MultipleChoiceInputModule::class,
NumberWithUnitsRuleModule::class, NumericInputRuleModule::class, TextInputRuleModule::class,
DragDropSortInputModule::class, ImageClickInputModule::class, InteractionsModule::class,
GcsResourceModule::class, GlideImageLoaderModule::class, ImageParsingModule::class,
HtmlParserEntityTypeModule::class, QuestionModule::class, TestLogReportingModule::class,
AccessibilityTestModule::class, LogStorageModule::class, CachingTestModule::class,
PrimeTopicAssetsControllerModule::class, ExpirationMetaDataRetrieverModule::class,
ViewBindingShimModule::class, RatioInputModule::class, WorkManagerConfigurationModule::class,
ApplicationStartupListenerModule::class, LogReportWorkerModule::class,
HintsAndSolutionConfigModule::class, HintsAndSolutionProdModule::class,
FirebaseLogUploaderModule::class, FakeOppiaClockModule::class,
DeveloperOptionsStarterModule::class, DeveloperOptionsModule::class,
ExplorationStorageModule::class, NetworkModule::class, NetworkConfigProdModule::class,
NetworkConnectionUtilDebugModule::class, NetworkConnectionDebugUtilModule::class,
AssetModule::class, LocaleProdModule::class, ActivityRecreatorTestModule::class,
NumericExpressionInputModule::class, AlgebraicExpressionInputModule::class,
MathEquationInputModule::class, SplitScreenInteractionModule::class,
LoggingIdentifierModule::class, ApplicationLifecycleModule::class,
SyncStatusModule::class, MetricLogSchedulerModule::class, TestingBuildFlavorModule::class,
EventLoggingConfigurationModule::class, ActivityRouterModule::class,
CpuPerformanceSnapshotterModule::class, ExplorationProgressModule::class
]
)

interface TestApplicationComponent : ApplicationComponent {
@Component.Builder
interface Builder : ApplicationComponent.Builder

fun inject(snackbarManagerTest: SnackbarManagerTest)
}

class TestApplication : Application(), ActivityComponentFactory, ApplicationInjectorProvider {
private val component: TestApplicationComponent by lazy {
DaggerSnackbarManagerTest_TestApplicationComponent.builder()
.setApplication(this)
.build() as TestApplicationComponent
}

fun inject(snackbarManagerTest: SnackbarManagerTest) {
component.inject(snackbarManagerTest)
}

override fun createActivityComponent(activity: AppCompatActivity): ActivityComponent {
return component.getActivityComponentBuilderProvider().get().setActivity(activity).build()
}

override fun getApplicationInjector(): ApplicationInjector = component
}
}