Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.logseq.logseq

import android.accessibilityservice.AccessibilityService
import android.view.View
import android.view.ViewGroup
import android.view.inspector.WindowInspector
import android.webkit.WebView
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialExpressiveTheme
Expand Down Expand Up @@ -373,6 +377,58 @@ class AndroidOutlinerSpacingTest {
assertEquals("A disclosure must not change document row spacing", after.value, before.value, 0.5f)
}

@Test fun deeplyNestedEmbedsKeepTheDisclosureInTheTrailingGutter() {
fun embedSnapshot(type: String, collapsed: Boolean = false): String {
val response = JSONObject(snapshot())
val rows = response.getJSONObject("result").getJSONArray("outlinerRows")
val embed = rows.getJSONObject(0).put("depth", 24).put("isCollapsed", collapsed)
embed.getJSONObject("block").put("markup", JSONArray().put(JSONObject()
.put("type", type).put("embedURL", "https://127.0.0.1:1")))
if (collapsed) rows.remove(1) else rows.getJSONObject(1).put("depth", 25)
return response.toString()
}
fun findWebView(view: View): WebView? = when (view) {
is WebView -> view
is ViewGroup -> (0 until view.childCount).firstNotNullOfOrNull { findWebView(view.getChildAt(it)) }
else -> null
}
render()
val disclosure = ui.onNodeWithTag("button.outliner.collapse.parent")
val rowEnd = disclosure.getUnclippedBoundsInRoot().right
for (type in listOf("iframe", "video")) {
ui.runOnIdle {
filter.applyJson(requireNotNull(bridge).applySnapshot(embedSnapshot(type)))
}
val media = ui.onNodeWithTag("media.webview.loaded", useUnmergedTree = true)
media.assertIsDisplayed()
disclosure.assertIsDisplayed()
val buttonBounds = disclosure.getUnclippedBoundsInRoot()
assertTrue("The $type disclosure ends at the row edge",
buttonBounds.right in (rowEnd - 1.dp)..(rowEnd + 1.dp))
val webView = ui.runOnIdle {
requireNotNull(WindowInspector.getGlobalWindowViews().firstNotNullOfOrNull(::findWebView))
.also { it.loadDataWithBaseURL(null, """
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Wide $type fixture</title>
<body style="margin:0;background:teal">
<video controls width="1600" height="180"></video>
</body>
""".trimIndent(), "text/html", "UTF-8", null) }
}
ui.waitUntil(5_000) { ui.runOnIdle { webView.title == "Wide $type fixture" } }
assertTrue("The $type leaves room for the disclosure",
media.getUnclippedBoundsInRoot().right <= buttonBounds.left + 1.dp)
disclosure.performTouchInput { click(center) }
ui.runOnIdle {
assertTrue(events.filterIsInstance<LuiEvent.Extension>().any { it.name == "collapse" })
events.clear()
filter.applyJson(requireNotNull(bridge).applySnapshot(embedSnapshot(type, collapsed = true)))
}
ui.onNodeWithText("Child note").assertDoesNotExist()
disclosure.assertIsDisplayed()
}
}

@Test fun taskDatePropertiesAlignWithBlockText() {
render()
for (variant in 0..3) {
Expand All @@ -398,8 +454,19 @@ class AndroidOutlinerSpacingTest {
render()
val zoom = ui.onNodeWithTag("button.outliner.zoom.parent.Parent note")
zoom.assertIsDisplayed().assertTouchWidthIsEqualTo(48.dp).assertTouchHeightIsEqualTo(48.dp)
val bullet = zoom.getUnclippedBoundsInRoot()
val journal = ui.onNodeWithTag("list.outliner")
val viewport = journal.getUnclippedBoundsInRoot()
ui.runOnIdle { events.clear() }
zoom.performTouchInput { click(center) }
ui.runOnIdle { assertEquals(1, events.filterIsInstance<LuiEvent.Press>().size) }
journal.performTouchInput {
click(Offset(
(bullet.left - viewport.left - 4.dp).toPx(),
((bullet.top + bullet.bottom) / 2 - viewport.top).toPx(),
))
}
ui.runOnIdle {
assertEquals(listOf("parent"), events.filterIsInstance<LuiEvent.Extension>()
.filter { it.name == "open-node" }.map { it.values["uuid"] })
}
}
}
Loading
Loading