forked from oppia/oppia-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix oppia#2942: Add support for LaTeX math tags via SVG rendering [Bl…
…ocked: oppia#2980] (oppia#2981) * 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 oppia#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 oppia#2927. * Add support for rendering LaTeX via SVGs. Much of this is copied from oppia#2927 so see that PR's commit history & the PR corresponding to this commit for specific details. * 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 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. * 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 oppia#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.
- Loading branch information
1 parent
b283acc
commit 0cf6d11
Showing
35 changed files
with
1,363 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
app/src/main/java/org/oppia/android/app/testing/HtmlParserTestActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,14 @@ | ||
package org.oppia.android.app.testing | ||
|
||
import android.os.Bundle | ||
import android.text.Spannable | ||
import android.widget.TextView | ||
import org.oppia.android.R | ||
import org.oppia.android.app.activity.InjectableAppCompatActivity | ||
import org.oppia.android.util.gcsresource.DefaultResourceBucketName | ||
import org.oppia.android.util.parser.HtmlParser | ||
import javax.inject.Inject | ||
|
||
/** This is a dummy activity to test Html parsing. */ | ||
class HtmlParserTestActivity : InjectableAppCompatActivity() { | ||
@Inject | ||
lateinit var htmlParserFactory: HtmlParser.Factory | ||
|
||
@Inject | ||
@field:DefaultResourceBucketName | ||
lateinit var resourceBucketName: String | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
activityComponent.inject(this) | ||
setContentView(R.layout.test_html_parser_activity) | ||
|
||
val testHtmlContentTextView: TextView = findViewById(R.id.test_html_content_text_view) | ||
val rawDummyString = | ||
"\u003cp\u003e\"Let's try one last question,\" said Mr. Baker. \"Here's a pineapple cake cut into pieces.\"\u003c/p\u003e\u003coppia-noninteractive-image alt-with-value=\"\u0026amp;quot;Pineapple cake with 7/9 having cherries.\u0026amp;quot;\" caption-with-value=\"\u0026amp;quot;\u0026amp;quot;\" filepath-with-value=\"\u0026amp;quot;pineapple_cake_height_479_width_480.png\u0026amp;quot;\"\u003e\u003c/oppia-noninteractive-image\u003e\u003cp\u003e\u00a0\u003c/p\u003e\u003cp\u003e\u003cstrong\u003eQuestion 6\u003c/strong\u003e: What fraction of the cake has big red cherries in the pineapple slices?\u003c/p\u003e" // ktlint-disable max-line-length | ||
val htmlResult: Spannable = | ||
htmlParserFactory.create( | ||
resourceBucketName, | ||
/* entityType= */ "exploration", | ||
/* entityId= */ "oppia", | ||
/* imageCenterAlign= */ false | ||
).parseOppiaHtml( | ||
rawDummyString, | ||
testHtmlContentTextView | ||
) | ||
testHtmlContentTextView.text = htmlResult | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ allprojects { | |
repositories { | ||
google() | ||
jcenter() | ||
maven { url 'https://jitpack.io' } | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.