Skip to content

Instantly share code, notes, and snippets.

fun bind(htmlContent: String?) {
var result: Spanned
result = HtmlParser.buildSpannedText(binding.root.tvContents,context,htmlContent,
HtmlParser.TagHandler()
{ b: Boolean, s: String, editable: Editable?, attributes: Attributes? ->
if (b && s.equals("oppia-noninteractive-image")) {
var value: String? = HtmlParser.getValue(attributes, "filepath-with-value");
// unescapeEntities method to remove html quotes
var strictMode: Boolean = true;
)]}'
{"exploration": {"param_changes": [], "states": {"Q6 on N and D": {"param_changes": [], "interaction": {"solution": null, "answer_groups": [{"tagged_skill_misconception_id": null, "outcome": {"param_changes": [], "feedback": {"content_id": "feedback_1", "html": "\u003cp\u003eThat's great! You've really learned this well!\u003c/p\u003e"}, "dest": "Final Card", "refresher_exploration_id": null, "missing_prerequisite_skill_id": null, "labelled_as_correct": false}, "training_data": [], "rule_specs": [{"rule_type": "Equals", "inputs": {"x": "7/9"}}]}, {"tagged_skill_misconception_id": null, "outcome": {"param_changes": [], "feedback": {"content_id": "feedback_2", "html": "\u003cp\u003eOops, read the question carefully and try again!\u003c/p\u003e"}, "dest": "Q6 on N and D", "refresher_exploration_id": null, "missing_prerequisite_skill_id": null, "labelled_as_correct": false}, "training_data": [], "rule_specs": [{"rule_type": "Equals", "inputs": {"x": "2/9"}}]}, {"tagged_skill_misconception_id": null, "outcome
private fun subscribeToCurrentState() {
ephemeralStateLiveData.observe(fragment, Observer<EphemeralState> { result ->
logger.d("StateFragment", "getCurrentState: ${result.state.name}")
val customizationArgsMap: Map<String, InteractionObject> = result.state.interaction.customizationArgsMap
val allKeys: Set<String> = customizationArgsMap.keys
for (key in allKeys) {
logger.d("StateFragment", key)
}
private fun subscribeToCurrentState() {
ephemeralStateLiveData.observe(fragment, Observer<EphemeralState> { result ->
logger.d(STATE_LOG, "getCurrentState: ${result}")
entityType = "exploration"
val customizationArgsMap: Map<String, InteractionObject> = result.state.interaction.customizationArgsMap
val allKeys: Set<String> = customizationArgsMap.keys
for (key in allKeys) {
logger.d(TAG_STATE_FRAGMENT, key)
}
class GlideImageLoader @Inject constructor() : ImageLoader {
override fun load(context: Context, path: String, target: SimpleTarget<Bitmap>) {
Glide.with(context)
.asBitmap()
.load(path)
.into(target)
}
}
junit.framework.AssertionFailedError
at junit.framework.Assert.fail(Assert.java:48)
at junit.framework.Assert.assertTrue(Assert.java:20)
at junit.framework.Assert.assertNotNull(Assert.java:218)
at junit.framework.Assert.assertNotNull(Assert.java:211)
at org.oppia.app.parser.UrlImageParserTest.testImageLoader_returnSuccess(UrlImageParserTest.kt:56)
at java.lang.reflect.Method.invoke(Native Method)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
@Test
fun testImageLoader_returnSuccess() {
val imageView = activityTestRule.activity.findViewById(R.id.test_url_parser_image_view) as ImageView
var drawable: Drawable? = null
val testBitmap: Bitmap? = null
val target = object : CustomTarget<Bitmap>() {
override fun onLoadCleared(placeholder: Drawable?) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
@RunWith(AndroidJUnit4::class)
class UrlImageParserTest {
@Inject
lateinit var mockImageLoader: ImageLoader // Inject the mock ImageLoader provided below.
private lateinit var launchedActivity: Activity
@get:Rule
var activityTestRule: ActivityTestRule<UrlImageParserTestActivity> = ActivityTestRule(
UrlImageParserTestActivity::class.java, /* initialTouchMode= */ true, /* launchActivity= */ false
@RunWith(AndroidJUnit4::class)
class HtmlParserTest {
private lateinit var launchedActivity: Activity
@Inject
lateinit var htmlParserFactory: HtmlParser.Factory
@Inject
lateinit var urlImageParserFactory : UrlImageParser.Factory
@get:Rule
@veena14cs
veena14cs / Welcome profile name testcase
Created January 3, 2020 09:15
Profile id is returning -1.
@Test
fun testHomeActivity_firstOpen_hasProfileName() {
profileManagementController.loginToProfile(ProfileId.newBuilder().setInternalId(0).build())
launch(HomeActivity::class.java).use {
onView(
atPositionOnView(
R.id.home_recycler_view,
0,
R.id.profile_name_textview
)