Skip to content

Commit

Permalink
Fix #3401: Introduced SplashScreenWelcomeMsg PlatformParameter (#3441)
Browse files Browse the repository at this point in the history
* Introduced new SplashTestActivity to have an implementation of Compile Time PlatformParameter

* Add PlatformParameterModule to all TestApplicationComponents + removing Target annotation from Qualifiers

* Correcting Lint issues

* KDoc Changes

* KDoc changes + Refactoring functions

* Nit comment related changes

* Further KDoc changes

* Rearrange Activity in Manifest

* Changing function names in Presenter and coverted KDoc to comment

* Reverted the Prod SplashActivityPresenter and made Second Test Case for PlatformParameterIntegrationTest is made to run on Espresso only
  • Loading branch information
Arjupta authored Jul 8, 2021
1 parent 128b386 commit 96e6131
Show file tree
Hide file tree
Showing 104 changed files with 547 additions and 62 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
android:name=".app.topic.revisioncard.RevisionCardActivity"
android:label="@string/revision_card_activity_title"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity android:name=".app.testing.SplashTestActivity" />
<activity
android:name=".app.topic.TopicActivity"
android:label="@string/topic_page"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import org.oppia.android.app.testing.HtmlParserTestActivity
import org.oppia.android.app.testing.ImageRegionSelectionTestActivity
import org.oppia.android.app.testing.NavigationDrawerTestActivity
import org.oppia.android.app.testing.ProfileChooserFragmentTestActivity
import org.oppia.android.app.testing.SplashTestActivity
import org.oppia.android.app.testing.TestFontScaleConfigurationUtilActivity
import org.oppia.android.app.testing.TopicRevisionTestActivity
import org.oppia.android.app.testing.TopicTestActivity
Expand Down Expand Up @@ -112,6 +113,7 @@ interface ActivityComponent {
fun inject(recentlyPlayedActivity: RecentlyPlayedActivity)
fun inject(revisionCardActivity: RevisionCardActivity)
fun inject(splashActivity: SplashActivity)
fun inject(splashTestActivity: SplashTestActivity)
fun inject(stateFragmentTestActivity: StateFragmentTestActivity)
fun inject(storyActivity: StoryActivity)
fun inject(testFontScaleConfigurationUtilActivity: TestFontScaleConfigurationUtilActivity)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.oppia.android.app.testing

import android.os.Bundle
import org.oppia.android.app.activity.InjectableAppCompatActivity
import org.oppia.android.app.splash.SplashActivity
import org.oppia.android.util.platformparameter.PlatformParameterValue
import javax.inject.Inject

/**
* A test activity to verify the injection of [PlatformParameterValue] in the [SplashActivity].
* This test activity is used in integration tests for platform parameters.
*/
class SplashTestActivity : InjectableAppCompatActivity() {

@Inject
lateinit var splashTestActivityPresenter: SplashTestActivityPresenter

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
activityComponent.inject(this)
splashTestActivityPresenter.handleOnCreate()
}

companion object {
val WELCOME_MSG = "Welcome User"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package org.oppia.android.app.testing

import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.lifecycle.Transformations
import org.oppia.android.R
import org.oppia.android.app.activity.ActivityScope
import org.oppia.android.domain.platformparameter.PlatformParameterController
import org.oppia.android.util.data.AsyncResult
import org.oppia.android.util.data.DataProviders.Companion.toLiveData
import org.oppia.android.util.platformparameter.PlatformParameterValue
import org.oppia.android.util.platformparameter.SplashScreenWelcomeMsg
import javax.inject.Inject
import javax.inject.Provider

/** The presenter for [SplashTestActivity]. */
@ActivityScope
class SplashTestActivityPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val platformParameterController: PlatformParameterController,
@SplashScreenWelcomeMsg
private val splashScreenWelcomeMsgParam: Provider<PlatformParameterValue<Boolean>>
) {
fun handleOnCreate() {
activity.setContentView(R.layout.splash_test_activity)
loadPlatformParameters()
}

private fun loadPlatformParameters() {
fetchPlatformParametersFromDatabase().observe(
activity,
Observer {
showToastIfAllowed()
}
)
}

private fun fetchPlatformParametersFromDatabase(): LiveData<Boolean> {
return Transformations.map(
platformParameterController.getParameterDatabase().toLiveData(),
::processPlatformParameters
)
}

private fun processPlatformParameters(loadingStatus: AsyncResult<Unit>): Boolean {
return loadingStatus.isSuccess()
}

private fun showToastIfAllowed() {
if (splashScreenWelcomeMsgParam.get().value) {
Toast.makeText(activity, SplashTestActivity.WELCOME_MSG, Toast.LENGTH_SHORT).show()
}
}
}
7 changes: 7 additions & 0 deletions app/src/main/res/layout/splash_test_activity.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".app.splash.SplashActivity" />
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ import org.oppia.android.domain.onboarding.ExpirationMetaDataRetrieverModule
import org.oppia.android.domain.oppialogger.LogStorageModule
import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorkerModule
import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfigurationModule
import org.oppia.android.domain.platformparameter.PlatformParameterModule
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.AccessibilityTestRule
Expand Down Expand Up @@ -688,6 +689,7 @@ class AdministratorControlsActivityTest {
@Component(
modules = [
RobolectricModule::class,
PlatformParameterModule::class,
TestDispatcherModule::class, ApplicationModule::class,
LoggerModule::class, ContinueModule::class, FractionInputModule::class,
ItemSelectionInputModule::class, MultipleChoiceInputModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import org.oppia.android.domain.onboarding.ExpirationMetaDataRetrieverModule
import org.oppia.android.domain.oppialogger.LogStorageModule
import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorkerModule
import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfigurationModule
import org.oppia.android.domain.platformparameter.PlatformParameterModule
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.AccessibilityTestRule
Expand Down Expand Up @@ -251,6 +252,7 @@ class AppVersionActivityTest {
@Component(
modules = [
RobolectricModule::class,
PlatformParameterModule::class,
TestDispatcherModule::class, ApplicationModule::class,
LoggerModule::class, ContinueModule::class, FractionInputModule::class,
ItemSelectionInputModule::class, MultipleChoiceInputModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import org.oppia.android.domain.onboarding.ExpirationMetaDataRetrieverModule
import org.oppia.android.domain.oppialogger.LogStorageModule
import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorkerModule
import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfigurationModule
import org.oppia.android.domain.platformparameter.PlatformParameterModule
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.FRACTIONS_STORY_ID_0
import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID
Expand Down Expand Up @@ -471,6 +472,7 @@ class CompletedStoryListActivityTest {
@Component(
modules = [
RobolectricModule::class,
PlatformParameterModule::class,
TestDispatcherModule::class, ApplicationModule::class,
LoggerModule::class, ContinueModule::class, FractionInputModule::class,
ItemSelectionInputModule::class, MultipleChoiceInputModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import org.oppia.android.domain.onboarding.ExpirationMetaDataRetrieverModule
import org.oppia.android.domain.oppialogger.LogStorageModule
import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorkerModule
import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfigurationModule
import org.oppia.android.domain.platformparameter.PlatformParameterModule
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.AccessibilityTestRule
Expand Down Expand Up @@ -129,6 +130,7 @@ class LessonThumbnailImageViewTest {
@Component(
modules = [
RobolectricModule::class,
PlatformParameterModule::class,
TestDispatcherModule::class, ApplicationModule::class,
LoggerModule::class, ContinueModule::class, FractionInputModule::class,
ItemSelectionInputModule::class, MultipleChoiceInputModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import org.oppia.android.domain.onboarding.ExpirationMetaDataRetrieverModule
import org.oppia.android.domain.oppialogger.LogStorageModule
import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorkerModule
import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfigurationModule
import org.oppia.android.domain.platformparameter.PlatformParameterModule
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.AccessibilityTestRule
Expand Down Expand Up @@ -408,6 +409,7 @@ class DeveloperOptionsActivityTest {
@Component(
modules = [
RobolectricModule::class,
PlatformParameterModule::class,
TestDispatcherModule::class, ApplicationModule::class,
LoggerModule::class, ContinueModule::class, FractionInputModule::class,
ItemSelectionInputModule::class, MultipleChoiceInputModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import org.oppia.android.domain.onboarding.ExpirationMetaDataRetrieverModule
import org.oppia.android.domain.oppialogger.LogStorageModule
import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorkerModule
import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfigurationModule
import org.oppia.android.domain.platformparameter.PlatformParameterModule
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.AccessibilityTestRule
Expand Down Expand Up @@ -178,6 +179,7 @@ class FAQListFragmentTest {
@Component(
modules = [
RobolectricModule::class,
PlatformParameterModule::class,
TestDispatcherModule::class, ApplicationModule::class,
LoggerModule::class, ContinueModule::class, FractionInputModule::class,
ItemSelectionInputModule::class, MultipleChoiceInputModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import org.oppia.android.domain.onboarding.ExpirationMetaDataRetrieverModule
import org.oppia.android.domain.oppialogger.LogStorageModule
import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorkerModule
import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfigurationModule
import org.oppia.android.domain.platformparameter.PlatformParameterModule
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.AccessibilityTestRule
Expand Down Expand Up @@ -176,6 +177,7 @@ class FAQSingleActivityTest {
@Component(
modules = [
RobolectricModule::class,
PlatformParameterModule::class,
TestDispatcherModule::class, ApplicationModule::class,
LoggerModule::class, ContinueModule::class, FractionInputModule::class,
ItemSelectionInputModule::class, MultipleChoiceInputModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import org.oppia.android.domain.onboarding.ExpirationMetaDataRetrieverModule
import org.oppia.android.domain.oppialogger.LogStorageModule
import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorkerModule
import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfigurationModule
import org.oppia.android.domain.platformparameter.PlatformParameterModule
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.AccessibilityTestRule
Expand Down Expand Up @@ -109,6 +110,7 @@ class FaqListActivityTest {
@Component(
modules = [
RobolectricModule::class,
PlatformParameterModule::class,
TestDispatcherModule::class, ApplicationModule::class,
LoggerModule::class, ContinueModule::class, FractionInputModule::class,
ItemSelectionInputModule::class, MultipleChoiceInputModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import org.oppia.android.domain.onboarding.ExpirationMetaDataRetrieverModule
import org.oppia.android.domain.oppialogger.LogStorageModule
import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorkerModule
import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfigurationModule
import org.oppia.android.domain.platformparameter.PlatformParameterModule
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.AccessibilityTestRule
Expand Down Expand Up @@ -111,6 +112,7 @@ class HelpActivityTest {
@Component(
modules = [
RobolectricModule::class,
PlatformParameterModule::class,
TestDispatcherModule::class, ApplicationModule::class,
LoggerModule::class, ContinueModule::class, FractionInputModule::class,
ItemSelectionInputModule::class, MultipleChoiceInputModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import org.oppia.android.domain.onboarding.ExpirationMetaDataRetrieverModule
import org.oppia.android.domain.oppialogger.LogStorageModule
import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorkerModule
import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfigurationModule
import org.oppia.android.domain.platformparameter.PlatformParameterModule
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.AccessibilityTestRule
Expand Down Expand Up @@ -297,6 +298,7 @@ class HelpFragmentTest {
@Component(
modules = [
RobolectricModule::class,
PlatformParameterModule::class,
TestDispatcherModule::class, ApplicationModule::class,
LoggerModule::class, ContinueModule::class, FractionInputModule::class,
ItemSelectionInputModule::class, MultipleChoiceInputModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import org.oppia.android.domain.onboarding.ExpirationMetaDataRetrieverModule
import org.oppia.android.domain.oppialogger.LogStorageModule
import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorkerModule
import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfigurationModule
import org.oppia.android.domain.platformparameter.PlatformParameterModule
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.FRACTIONS_STORY_ID_0
import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID
Expand Down Expand Up @@ -1445,6 +1446,7 @@ class HomeActivityTest {
@Component(
modules = [
RobolectricModule::class,
PlatformParameterModule::class,
TestDispatcherModule::class, ApplicationModule::class,
LoggerModule::class, ContinueModule::class, FractionInputModule::class,
ItemSelectionInputModule::class, MultipleChoiceInputModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import org.oppia.android.domain.onboarding.ExpirationMetaDataRetrieverModule
import org.oppia.android.domain.oppialogger.LogStorageModule
import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorkerModule
import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfigurationModule
import org.oppia.android.domain.platformparameter.PlatformParameterModule
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.FRACTIONS_EXPLORATION_ID_0
import org.oppia.android.domain.topic.FRACTIONS_STORY_ID_0
Expand Down Expand Up @@ -937,6 +938,7 @@ class RecentlyPlayedFragmentTest {
@Component(
modules = [
RobolectricModule::class,
PlatformParameterModule::class,
TestDispatcherModule::class, ApplicationModule::class,
LoggerModule::class, ContinueModule::class, FractionInputModule::class,
ItemSelectionInputModule::class, MultipleChoiceInputModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import org.oppia.android.domain.onboarding.ExpirationMetaDataRetrieverModule
import org.oppia.android.domain.oppialogger.LogStorageModule
import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorkerModule
import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfigurationModule
import org.oppia.android.domain.platformparameter.PlatformParameterModule
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.AccessibilityTestRule
Expand Down Expand Up @@ -321,9 +322,9 @@ class TopicSummaryViewModelTest {
@Singleton
@Component(
modules = [
TestDispatcherModule::class, ApplicationModule::class, RobolectricModule::class,
LoggerModule::class, ContinueModule::class, FractionInputModule::class,
ItemSelectionInputModule::class, MultipleChoiceInputModule::class,
TestDispatcherModule::class, PlatformParameterModule::class, ApplicationModule::class,
RobolectricModule::class, LoggerModule::class, ContinueModule::class,
FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class,
NumberWithUnitsRuleModule::class, NumericInputRuleModule::class, TextInputRuleModule::class,
DragDropSortInputModule::class, InteractionsModule::class, GcsResourceModule::class,
GlideImageLoaderModule::class, ImageParsingModule::class, HtmlParserEntityTypeModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import org.oppia.android.domain.onboarding.ExpirationMetaDataRetrieverModule
import org.oppia.android.domain.oppialogger.LogStorageModule
import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorkerModule
import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfigurationModule
import org.oppia.android.domain.platformparameter.PlatformParameterModule
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.AccessibilityTestRule
Expand Down Expand Up @@ -316,9 +317,9 @@ class WelcomeViewModelTest {
@Singleton
@Component(
modules = [
TestDispatcherModule::class, ApplicationModule::class, RobolectricModule::class,
LoggerModule::class, ContinueModule::class, FractionInputModule::class,
ItemSelectionInputModule::class, MultipleChoiceInputModule::class,
TestDispatcherModule::class, PlatformParameterModule::class, ApplicationModule::class,
RobolectricModule::class, LoggerModule::class, ContinueModule::class,
FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class,
NumberWithUnitsRuleModule::class, NumericInputRuleModule::class, TextInputRuleModule::class,
DragDropSortInputModule::class, InteractionsModule::class, GcsResourceModule::class,
GlideImageLoaderModule::class, ImageParsingModule::class, HtmlParserEntityTypeModule::class,
Expand Down
Loading

0 comments on commit 96e6131

Please sign in to comment.