-
Notifications
You must be signed in to change notification settings - Fork 530
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 #4135 : Added FractionInputInteractionViewTestActivityTest #4268
Changes from 7 commits
c04bb5b
08e29e8
1d0d4fa
c3e5021
e64ac58
452fb01
eeab088
3343e24
fb7f52c
f53f983
cb903e5
8e7822b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ import org.oppia.android.util.math.FractionParser | |
import javax.inject.Inject | ||
|
||
/** [StateItemViewModel] for the fraction input interaction. */ | ||
class FractionInteractionViewModel private constructor( | ||
class FractionInteractionViewModel public constructor( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need to modify this?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean that we need to remove the access modifier since all constructors are public by default? |
||
interaction: Interaction, | ||
val hasConversationView: Boolean, | ||
val isSplitView: Boolean, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package org.oppia.android.app.testing | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.databinding.DataBindingUtil | ||
import org.oppia.android.R | ||
import org.oppia.android.app.activity.ActivityComponentImpl | ||
import org.oppia.android.app.activity.InjectableAppCompatActivity | ||
import org.oppia.android.app.customview.interaction.FractionInputInteractionView | ||
import org.oppia.android.app.model.Interaction | ||
import org.oppia.android.app.model.WrittenTranslationContext | ||
import org.oppia.android.app.player.state.answerhandling.AnswerErrorCategory | ||
import org.oppia.android.app.player.state.answerhandling.InteractionAnswerErrorOrAvailabilityCheckReceiver | ||
import org.oppia.android.app.player.state.itemviewmodel.FractionInteractionViewModel | ||
import org.oppia.android.app.player.state.listener.StateKeyboardButtonListener | ||
import org.oppia.android.app.translation.AppLanguageResourceHandler | ||
import org.oppia.android.databinding.ActivityFractionInputInteractionViewTestBinding | ||
import org.oppia.android.domain.translation.TranslationController | ||
import javax.inject.Inject | ||
|
||
/** | ||
* This is a dummy activity to test input interaction views. | ||
* It contains [FractionInputInteractionView] | ||
*/ | ||
class FractionInputInteractionViewTestActivity : | ||
InjectableAppCompatActivity(), | ||
StateKeyboardButtonListener, | ||
InteractionAnswerErrorOrAvailabilityCheckReceiver { | ||
private lateinit var binding: ActivityFractionInputInteractionViewTestBinding | ||
lateinit var fractionInteractionViewModel: FractionInteractionViewModel | ||
|
||
@Inject | ||
lateinit var resourceHandler: AppLanguageResourceHandler | ||
|
||
@Inject | ||
lateinit var translationController: TranslationController | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
(activityComponent as ActivityComponentImpl).inject(this) | ||
binding = DataBindingUtil.setContentView<ActivityFractionInputInteractionViewTestBinding>( | ||
this, R.layout.activity_fraction_input_interaction_view_test | ||
) | ||
fractionInteractionViewModel = FractionInteractionViewModel( | ||
interaction = Interaction.getDefaultInstance(), | ||
hasConversationView = false, | ||
isSplitView = false, | ||
errorOrAvailabilityCheckReceiver = this, | ||
writtenTranslationContext = WrittenTranslationContext.getDefaultInstance(), | ||
resourceHandler = resourceHandler, | ||
translationController = translationController | ||
) | ||
binding.fractionInteractionViewModel = fractionInteractionViewModel | ||
} | ||
|
||
fun getPendingAnswerErrorOnSubmitClick(v: View) { | ||
fractionInteractionViewModel.checkPendingAnswerError(AnswerErrorCategory.SUBMIT_TIME) | ||
} | ||
|
||
override fun onEditorAction(actionCode: Int) { | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,6 @@ import androidx.databinding.DataBindingUtil | |
import org.oppia.android.R | ||
import org.oppia.android.app.activity.ActivityComponentImpl | ||
import org.oppia.android.app.activity.InjectableAppCompatActivity | ||
import org.oppia.android.app.customview.interaction.FractionInputInteractionView | ||
import org.oppia.android.app.customview.interaction.NumericInputInteractionView | ||
import org.oppia.android.app.customview.interaction.TextInputInteractionView | ||
import org.oppia.android.app.model.InputInteractionViewTestActivityParams | ||
|
@@ -40,7 +39,7 @@ import org.oppia.android.app.player.state.itemviewmodel.MathExpressionInteractio | |
|
||
/** | ||
* This is a dummy activity to test input interaction views. | ||
* It contains [FractionInputInteractionView], [NumericInputInteractionView],and [TextInputInteractionView]. | ||
* It contains [NumericInputInteractionView],and [TextInputInteractionView]. | ||
*/ | ||
class InputInteractionViewTestActivity : | ||
InjectableAppCompatActivity(), | ||
|
@@ -124,16 +123,13 @@ class InputInteractionViewTestActivity : | |
.create(interaction = params.interaction) | ||
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why we need to remove this line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, we don't need line 58 and 59, please check if we need them here. |
||
binding.numericInputViewModel = numericInputViewModel | ||
binding.textInputViewModel = textInputViewModel | ||
binding.fractionInteractionViewModel = fractionInteractionViewModel | ||
binding.ratioInteractionInputViewModel = ratioExpressionInputInteractionViewModel | ||
binding.mathExpressionInteractionsViewModel = mathExpressionViewModel | ||
} | ||
|
||
fun getPendingAnswerErrorOnSubmitClick(v: View) { | ||
fractionInteractionViewModel.checkPendingAnswerError(AnswerErrorCategory.SUBMIT_TIME) | ||
numericInputViewModel.checkPendingAnswerError(AnswerErrorCategory.SUBMIT_TIME) | ||
ratioExpressionInputInteractionViewModel | ||
.checkPendingAnswerError(AnswerErrorCategory.SUBMIT_TIME) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<data> | ||
|
||
<import type="android.view.View"></import> | ||
|
||
<variable | ||
name="fractionInteractionViewModel" | ||
type="org.oppia.android.app.player.state.itemviewmodel.FractionInteractionViewModel" /> | ||
</data> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:descendantFocusability="beforeDescendants" | ||
android:focusableInTouchMode="true" | ||
android:gravity="center" | ||
android:orientation="vertical" | ||
tools:context=".testing.FractionInputInteractionViewTestActivity"> | ||
|
||
<org.oppia.android.app.customview.interaction.FractionInputInteractionView | ||
android:id="@+id/test_fraction_input_interaction_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="8dp" | ||
android:background="@drawable/edit_text_background" | ||
android:fontFamily="sans-serif" | ||
android:hint="@{fractionInteractionViewModel.hintText}" | ||
android:imeOptions="actionDone" | ||
android:longClickable="false" | ||
android:maxLength="200" | ||
android:minHeight="48dp" | ||
android:paddingStart="16dp" | ||
android:paddingEnd="16dp" | ||
android:paddingBottom="8dp" | ||
android:singleLine="true" | ||
android:text="@={fractionInteractionViewModel.answerText}" | ||
android:textColor="@color/oppia_primary_text" | ||
android:textColorHint="@color/edit_text_hint" | ||
android:textSize="14sp" | ||
android:textStyle="italic" | ||
app:textChangedListener="@{fractionInteractionViewModel.answerTextWatcher}" /> | ||
|
||
<TextView | ||
android:id="@+id/fraction_input_error" | ||
style="@style/TextViewStart" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginEnd="8dp" | ||
android:fontFamily="sans-serif" | ||
android:minHeight="32dp" | ||
android:text="@{fractionInteractionViewModel.errorMessage}" | ||
android:textColor="@color/edit_text_error" | ||
android:textSize="12sp" | ||
android:visibility="@{fractionInteractionViewModel.errorMessage.length() > 0 ? View.VISIBLE : View.INVISIBLE}" /> | ||
|
||
<Button | ||
android:id="@+id/submit_button" | ||
style="@style/StateButtonActive" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="8dp" | ||
android:onClick="getPendingAnswerErrorOnSubmitClick" | ||
android:text="Submit" | ||
android:textColor="@color/color_def_white" /> | ||
</LinearLayout> | ||
</layout> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to update this?