Skip to content

Commit

Permalink
Fix #3075 and #2290: Use default keyboards for interactions with curr…
Browse files Browse the repository at this point in the history
…ent nonstandard keyboards (#3116)

* Add support for loading proto versions of lessons.

* Upgrade Espresso versions to work around build issues.

Note that I can't actually verify Espresso tests are working with these
versions since the Bazel project doesn't yet have Espresso tests set up.

* Lint fix post-copying from #2927.

* Fix Glide in Bazel.

* Fix concept card name escaping.

Also, refactor HtmlParser to better support/handling different tag types
& prepare for LaTeX SVG image support.

* Copy over test fix from #2927.

* Add support for rendering LaTeX via SVGs.

Much of this is copied from #2927 so see that PR's commit history & the
PR corresponding to this commit for specific details.

* Ensure all thumbnails are opaque.

* Fix interactions to support new localization.

This fixes answer classification, submission, and viewing for drag &
drop, item selection, multiple choice, and text input interactions per
changes in the states structure to support lesson localization.

* Fix blurring for SVGs.

SVGs did not previous support blurring, & this change introduces a way
to leverage the existing bitmap blurrer to introduce blurring
functionality in a way that's consistent with bitmap thumbnails.

* Lint fixes post copying from #2927.

* Remove image loading annotation.

This will be added in a later branch in the chain.

* Add caching module to needed test suites.

* Re-add image load annotation for this PR.

* Add support for hiding the questions player.

* Add missing dep from #2927 to fix build.

* Add support for importing text protos as assets.

This actually provides Bazel-only support for converting text protos to
binary and including those as assets so that we can avoid checking in
binary protos to the codebase.

* Add gitignore for Android Studio Bazel plugin output.

* Import textproto versions of existing dev assets.

This imports local conversions of all existing dev assets as text proto
leveraging the Bazel-only conversion system to convert these to binary
protos and include them as assets.

This is a necessary step to both eventually replace JSON assets with
text proto, and to test that the new proto loading pipeline is working
as designed.

* Undo Espresso version change since it breaks Bazel tests.

* Fix tests.

Various attempts to fix existing tests + move some of the domain tests
over to actually using proto when running with Bazel.

App module tests are hanging currently for unknown reasons (only in
Bazel).

* Use correct Espresso core.

3.1.0 causes tests to hang indefinitely when run with Bazel.

* Add support for concept cards in revision cards.

* Move coroutine dispatchers.

This moves the coroutine dispatchers to a new threading subpackage. It
also simplifies the TestCoroutineDispatcher interface & implementations
(which required moving runUntilIdle to CoroutineExecutorServiceTest).

The test coroutine annotations were also moved to their own files.

* Refactor testing utilities build graph.

This introduces new Bazel libraries for:
- Test dispatchers
- Fake system/Oppia clocks
- Robolectric dependencies

* Introduce dedicated test for TestCoroutineDispatcher.

This also fixes some threading issues in the dispatcher, and clarifies
some of its API that was previously unclear (and can lead to subtle race
conditions).

* Add tests for TestCoroutineDispatcher.

This required a bunch of refactoring, adding the first examples of
dedicated Bazel test build files, and introducing a new test pattern for
sharing code between different implementations. Further, it refined the
API for TesCoroutineDispatcher & fixed some issues in the
implementations (especially Robolectric).

Tests verified as non-flaky in Robolectric across 1000 runs, and 0.2%
flaky across 1000 runs for Espresso (though that may be fixed; waiting
on a follow-up run to confirm stability).

* Workaround ktlint semicolon issue.

* Lint fixes.

* Fix test post-merge.

* Move CoroutineDispatcher to be part of threading.

* Lint fixes.

* Undo version upgrade.

* Fix broken tests.

* Lint fixes.

* Add a bit more proto loading test coverage.

* Comment fix.

* Lint fixes.

* Address earlier TODO.

* Post-merge restructure.

* Post-merge fixes.

This removes unneeded dependencies from PersistentCacheStore, including
Glide.

* Add tests for new tag handlers.

Also, add tests for HtmlParser, and clean up some existing tests.

* Fix broken test build.

* Post-merge lint fixes.

* Lint fixes.

* Address reviewer comment.

* Post-merge fix.

* Address pre-merge TODO.

* Disable local image loading.

Also, add specific LaTeX line in the first fractions interaction so that
the new SVG support can be tested.

* Fix typo.

* Docs + tests.

This adds more documentation & context for code added before without it.
It also adds a bunch of new testing coverage for changes. The tests are
particularly around the html part of the LaTeX loading pipeline, but not
the image parts.

More of both will be needed specifically for the image loading pipeline
changes.

* Docs + tests + refactor.

This adds documentation for all remaining components introduced in #2981,
adds some testing for UrlImageParser, and cleans up the image loading
pipeline to be a bit simpler & cleaner (though this will probably break
down-stream PRs relying on image transformations).

* Lint fixes.

* Fix lint failure & re-enable assets.

* Clean up + tests.

Add tests where reasonable given current testing limitations and
developing time availability, and remove some dead code. Add new testing
utility (GenericViewMatchers) + corresponding Bazel package.

* Consolidate testing module view matchers.

This moves two other view matchers that are part of the testing module
into the new Espresso package.

* Lint fixes.

* Post-merge fixes + docs.

Add TODOs for tests that can't easily be added. Fill in missing
documentation. Fix post-merge issues to ensure SVGs can actually be
blurred (will be verified after this commit).

* Add tests for structural changes.

Revamps StateFragmentTest to include a bunch of new interaction tests to
verify that the new structural changes are correct. These discovered
issues with the old asset converter that needed to be fixed, and new
textproto changes needed to be pulled in.

Removed a few now-unused (or should be unused) asset files.
ExplorationProgressControllerTest is now broken and has to be almost
entirely rewritten to support different explorations. The previous ones
couldn't reasonably be migrated without lots of manual work, so we
abandoned them.

* Rename test (& fix it).

Relevant fixes will be coming in a later commit. This is just committing
the file move.

* Fix/update json assets.

This includes fixes for existing content in textproto files, too, where
the previous conversion script had issues.

Assets that will no longer be included are removed (due to being too
hard to migrate).

The codebase will be broken at this point--thorough test changes are
needed, first.

* Fix a LOT of tests that break due to changes.

Fundamentally, this:
1. Migrates existing structural changes in tests for item selection,
text input, and drag and drop.
2. Introduces proto loading (when run on Bazel) for a few more tests,
including some UI tests.
3. Updates test suites to no longer depend on explorations that weren't
carried over in this change.
4. Cleans up a bunch of existing tests/line wrapping issues and other
things.

* Import structurally updates questions.

This includes proto questions even though they can't yet be imported.
Some tests needed adjustments due to fixes in the questions themselves.

* Fix post-merge test build failures.

* Add test for when practice tab is disabled.

* Fix new module location per reviewer comment.

* Add concept card tests for revision cards.

This required some small updates to one of the revision card test assets
(for both JSON & textproto variants).

* Enable proto loading for revision card testing.

* Use standard keyboard for fractions & ratios.

* Post-merge lint fixes.

* Address reviewer comments.

Fix case sensitive checks for text input, and some minor cleanups in
drag & drop interaction view model.

* Fix broken Gradle test.

Another structural change: 'translation' is now the correct reference
for written translations rather than 'html'.

* Lint fixes.

* Lint fixes.

* Address reviewer comment.

Adds test with config change.

* Address reviewer comment.

Move CONCEPT_CARD_DIALOG_FRAGMENT_TEST to ConceptCardFragment's
Companion object.

* Fix broken test.

* Lint fixes.

* Add tests for fraction + ratio input types.

Also, fix comment in FractionInputInteractionView.
  • Loading branch information
BenHenning authored Apr 24, 2021
1 parent 69e1b7e commit 0dbe671
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.oppia.android.app.utility.KeyboardHelper.Companion.showSoftKeyboard
// TODO(#249): These are the attributes which should be defined in XML, that are required for this interaction view to work correctly
// digits="0123456789/-"
// hint="Write fraction here."
// inputType="date"
// inputType="text"
// background="@drawable/edit_text_background"
// maxLength="200".

Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout-land/fraction_interaction_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/edit_text_background"
android:digits="0123456789/- "
android:fontFamily="sans-serif"
android:hint="@{viewModel.hintText}"
android:imeOptions="actionDone"
android:inputType="date"
android:inputType="text"
android:longClickable="false"
android:maxLength="200"
android:minHeight="48dp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/edit_text_background"
android:digits="0123456789/- "
android:fontFamily="sans-serif"
android:hint="@{viewModel.hintText}"
android:imeOptions="actionDone"
android:inputType="date"
android:inputType="text"
android:longClickable="false"
android:maxLength="200"
android:minHeight="48dp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/edit_text_background"
android:digits="0123456789/- "
android:fontFamily="sans-serif"
android:hint="@{viewModel.hintText}"
android:imeOptions="actionDone"
android:inputType="date"
android:inputType="text"
android:longClickable="false"
android:maxLength="200"
android:minHeight="48dp"
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/fraction_interaction_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/edit_text_background"
android:digits="0123456789/- "
android:fontFamily="sans-serif"
android:hint="@{viewModel.hintText}"
android:imeOptions="actionDone"
android:inputType="date"
android:inputType="text"
android:longClickable="false"
android:maxLength="200"
android:minHeight="48dp"
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/ratio_input_interaction_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/edit_text_background"
android:digits="0123456789: "
android:fontFamily="sans-serif"
android:hint="@{viewModel.hintText}"
android:imeOptions="actionDone"
android:inputType="time"
android:inputType="text"
android:longClickable="false"
android:maxLength="200"
android:minHeight="48dp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.oppia.android.app.player.state

import android.app.Application
import android.content.Context
import android.text.InputType
import android.text.Spannable
import android.text.style.ClickableSpan
import android.view.View
Expand Down Expand Up @@ -38,6 +39,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import com.bumptech.glide.Glide
import com.bumptech.glide.GlideBuilder
import com.bumptech.glide.load.engine.executor.MockGlideExecutor
import com.google.common.truth.Truth.assertThat
import dagger.BindsInstance
import dagger.Component
import dagger.Module
Expand Down Expand Up @@ -1197,6 +1199,43 @@ class StateFragmentTest {
}
}

@Test
fun testStateFragment_fractionInput_textViewwHasTextInputType() {
launchForExploration(TEST_EXPLORATION_ID_2).use { scenario ->
startPlayingExploration()

// Play to state 2 to access the fraction input interaction.
playThroughPrototypeState1()

// Verify that fraction input uses the standard text software keyboard.
scenario.onActivity { activity ->
val textView: TextView = activity.findViewById(R.id.fraction_input_interaction_view)
assertThat(textView.inputType).isEqualTo(InputType.TYPE_CLASS_TEXT)
}
}
}

@Test
fun testStateFragment_ratioInput_textViewHasTextInputType() {
launchForExploration(TEST_EXPLORATION_ID_2).use { scenario ->
startPlayingExploration()
playThroughPrototypeState1()
playThroughPrototypeState2()
playThroughPrototypeState3()
playThroughPrototypeState4()
playThroughPrototypeState5()

// Play to state 7 to access the ratio input interaction.
playThroughPrototypeState6()

// Verify that ratio input uses the standard text software keyboard.
scenario.onActivity { activity ->
val textView: TextView = activity.findViewById(R.id.ratio_input_interaction_view)
assertThat(textView.inputType).isEqualTo(InputType.TYPE_CLASS_TEXT)
}
}
}

private fun addShadowMediaPlayerException(dataSource: Any, exception: Exception) {
val classLoader = StateFragmentTest::class.java.classLoader!!
val shadowMediaPlayerClass = classLoader.loadClass("org.robolectric.shadows.ShadowMediaPlayer")
Expand Down

0 comments on commit 0dbe671

Please sign in to comment.