Move the Linux runtime to Ubuntu 26.04 LTS with a separate Kubuntu desktop (#1733)

This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-10-29 09:05:20 -04:00
1 parent 5de690ef39
commit 29c83976d0
305 files changed
+9383 -462

No files matched your search

@@ -1,6 +1,7 @@
package com.droiddeck.launcher.input
import android.os.Looper
import android.view.InputDevice
import android.view.MotionEvent
import java.time.Duration
import org.junit.Assert.*
@@ -13,68 +14,171 @@ import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [28], manifest = Config.NONE)
class DirectTouchHoldTest {
private val events = mutableListOf<String>()
private val touches = mutableListOf<String>()
private val buttons = mutableListOf<String>()
private val hold = DirectTouchHold(8f, object : PointerGestures.Listener {
override fun onMove(x: Float, y: Float) {}
override fun onButton(button: Int, pressed: Boolean, x: Float, y: Float) {
assertEquals(PointerGestures.BTN_RIGHT, button)
events += "$pressed at $x,$y"
buttons += "$pressed at $x,$y"
}
override fun onWheel(steps: Int) {}
override fun onLongPress() {}
}) { events += "cancel touch" }.also { it.configure(TouchGestureConfig(longPressEnabled = true, longPressDelay = 500)) }
}, object : DirectTouchHold.Touch {
override fun down(pointerId: Int, x: Float, y: Float) { touches += "down $pointerId at $x,$y" }
override fun move(pointerId: Int, x: Float, y: Float) { touches += "move $pointerId at $x,$y" }
override fun up(pointerId: Int, x: Float, y: Float) { touches += "up $pointerId at $x,$y" }
override fun cancel() { touches += "cancel" }
}).also { it.configure(TouchGestureConfig(longPressEnabled = true, longPressDelay = 500)) }
@Test fun holdReleasesRawTouchBeforeClickAndConsumesTheLift() {
assertFalse(touch(MotionEvent.ACTION_DOWN))
advance(500)
assertEquals(listOf("cancel touch", "true at 40.0,30.0"), events)
assertTrue(touch(MotionEvent.ACTION_UP))
@Test fun holdClicksRightWithoutTouchingTheGame() {
touch(MotionEvent.ACTION_DOWN)
advance(400)
assertTrue(buttons.isEmpty())
advance(100)
assertEquals(listOf("true at 40.0,30.0"), buttons)
advance(50)
assertEquals("false at 40.0,30.0", events.last())
assertFalse(touch(MotionEvent.ACTION_DOWN))
hold.cancel()
assertEquals(listOf("true at 40.0,30.0", "false at 40.0,30.0"), buttons)
touch(MotionEvent.ACTION_MOVE, 44f)
touch(MotionEvent.ACTION_UP)
assertTrue(touches.isEmpty())
}
@Test fun stillHoldKeepsTheTouchWhenLongPressIsOff() {
@Test fun tapForwardsTheTouchWhenItLifts() {
touch(MotionEvent.ACTION_DOWN)
advance(100)
touch(MotionEvent.ACTION_UP, 50f)
assertEquals(listOf("down 0 at 40.0,30.0"), touches)
advance(50)
assertEquals(listOf("down 0 at 40.0,30.0", "up 0 at 50.0,30.0"), touches)
assertTrue(buttons.isEmpty())
}
@Test fun noneBehaviorForwardsTheTouchAtOnce() {
hold.configure(TouchGestureConfig(directHoldBehavior = TouchGestureConfig.MOUSE_BEHAVIOR_NONE))
touch(MotionEvent.ACTION_DOWN)
assertEquals(listOf("down 0 at 40.0,30.0"), touches)
advance(600)
assertTrue(buttons.isEmpty())
touch(MotionEvent.ACTION_MOVE, 60f)
assertEquals("move 0 at 60.0,30.0", touches.last())
touch(MotionEvent.ACTION_UP, 60f)
advance(50)
assertEquals("up 0 at 60.0,30.0", touches.last())
}
@Test fun dragForwardsTheTouchOnceItMoves() {
touch(MotionEvent.ACTION_DOWN)
touch(MotionEvent.ACTION_MOVE, 60f)
assertEquals(listOf("down 0 at 40.0,30.0", "move 0 at 60.0,30.0"), touches)
advance(600)
assertTrue(buttons.isEmpty())
touch(MotionEvent.ACTION_UP, 60f)
advance(50)
assertEquals("up 0 at 60.0,30.0", touches.last())
}
@Test fun dragKeepsForwardingWithinTheSlop() {
touch(MotionEvent.ACTION_DOWN)
touch(MotionEvent.ACTION_MOVE, 44f)
assertTrue(touches.isEmpty())
touch(MotionEvent.ACTION_UP, 44f)
advance(50)
assertEquals(listOf("down 0 at 40.0,30.0", "up 0 at 44.0,30.0"), touches)
}
@Test fun stillHoldClicksRightWithTheDefaultConfig() {
hold.configure(TouchGestureConfig())
assertFalse(touch(MotionEvent.ACTION_DOWN))
touch(MotionEvent.ACTION_DOWN)
advance(2000)
assertFalse(touch(MotionEvent.ACTION_MOVE))
assertFalse(touch(MotionEvent.ACTION_UP))
assertTrue(events.isEmpty())
touch(MotionEvent.ACTION_MOVE)
assertEquals(listOf("true at 40.0,30.0", "false at 40.0,30.0"), buttons)
touch(MotionEvent.ACTION_UP)
assertTrue(touches.isEmpty())
}
@Test fun longPressFollowsTheConfiguredDelay() {
hold.configure(TouchGestureConfig(longPressEnabled = true, longPressDelay = 800))
touch(MotionEvent.ACTION_DOWN)
advance(700)
assertTrue(events.isEmpty())
assertTrue(buttons.isEmpty())
advance(100)
assertEquals(listOf("cancel touch", "true at 40.0,30.0"), events)
assertEquals(listOf("true at 40.0,30.0"), buttons)
hold.cancel()
}
@Test fun tapDragSecondFingerAndCancellationDoNotRightClick() {
for (action in listOf(MotionEvent.ACTION_UP, MotionEvent.ACTION_MOVE,
MotionEvent.ACTION_POINTER_DOWN, MotionEvent.ACTION_CANCEL)) {
touch(MotionEvent.ACTION_DOWN)
assertFalse(touch(action, 60f))
advance(600)
assertTrue(events.isEmpty())
hold.cancel()
}
@Test fun holdBehaviorKeepsTheButtonUntilTheLift() {
hold.configure(TouchGestureConfig(longPressDelay = 500,
directHoldBehavior = TouchGestureConfig.MOUSE_BEHAVIOR_HOLD))
touch(MotionEvent.ACTION_DOWN)
advance(500)
assertEquals(listOf("true at 40.0,30.0"), buttons)
advance(1000)
assertEquals(listOf("true at 40.0,30.0"), buttons)
touch(MotionEvent.ACTION_UP)
assertEquals(listOf("true at 40.0,30.0", "false at 40.0,30.0"), buttons)
assertTrue(touches.isEmpty())
}
@Test fun secondFingerForwardsTheTouchAndDropsTheHold() {
touch(MotionEvent.ACTION_DOWN)
touch(MotionEvent.ACTION_POINTER_DOWN, 60f)
assertEquals(listOf("down 0 at 40.0,30.0", "down 0 at 60.0,30.0"), touches)
advance(600)
assertTrue(buttons.isEmpty())
touch(MotionEvent.ACTION_UP, 60f)
}
@Test fun modeChangeCancelsPendingHoldAndReleasesAnActiveClick() {
touch(MotionEvent.ACTION_DOWN)
hold.cancel()
advance(600)
assertTrue(events.isEmpty())
assertTrue(buttons.isEmpty())
assertTrue(touches.isEmpty())
touch(MotionEvent.ACTION_DOWN)
advance(500)
hold.cancel()
assertEquals(listOf("true at 40.0,30.0", "false at 40.0,30.0"), buttons)
}
@Test fun cancelForwardsACancelWhenTheTouchIsLive() {
touch(MotionEvent.ACTION_DOWN)
touch(MotionEvent.ACTION_MOVE, 60f)
hold.cancel()
assertEquals(listOf("down 0 at 40.0,30.0", "move 0 at 60.0,30.0", "cancel"), touches)
}
@Test fun cancelDropsAPendingLift() {
touch(MotionEvent.ACTION_DOWN)
touch(MotionEvent.ACTION_UP, 60f)
hold.cancel()
advance(100)
assertEquals(listOf("cancel touch", "true at 40.0,30.0", "false at 40.0,30.0"), events)
assertEquals(listOf("down 0 at 40.0,30.0", "cancel"), touches)
}
@Test fun aQuickSecondTapLiftsTheFirstInsteadOfCancellingIt() {
touch(MotionEvent.ACTION_DOWN)
touch(MotionEvent.ACTION_UP, 50f)
advance(20)
touch(MotionEvent.ACTION_DOWN, 60f)
touch(MotionEvent.ACTION_UP, 60f)
advance(50)
assertEquals(
listOf("down 0 at 40.0,30.0", "up 0 at 50.0,30.0", "down 0 at 60.0,30.0", "up 0 at 60.0,30.0"),
touches,
)
}
@Test fun theSecondFingerLiftsWithItsOwnId() {
multi(MotionEvent.ACTION_DOWN, 0, 0 to 40f)
multi(MotionEvent.ACTION_POINTER_DOWN, 1, 0 to 40f, 1 to 60f)
multi(MotionEvent.ACTION_POINTER_UP, 0, 0 to 40f, 1 to 60f)
multi(MotionEvent.ACTION_UP, 0, 1 to 60f)
advance(100)
assertEquals(
listOf("down 0 at 40.0,30.0", "down 1 at 60.0,30.0", "up 0 at 40.0,30.0", "up 1 at 60.0,30.0"),
touches,
)
}
private fun advance(ms: Long) = shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(ms))
@@ -82,4 +186,23 @@ class DirectTouchHoldTest {
val event = MotionEvent.obtain(0, 0, action, x, 30f, 0)
return hold.onTouch(event).also { event.recycle() }
}
private fun multi(action: Int, index: Int, vararg points: Pair<Int, Float>): Boolean {
val properties = Array(points.size) {
MotionEvent.PointerProperties().apply {
id = points[it].first
toolType = MotionEvent.TOOL_TYPE_FINGER
}
}
val coords = Array(points.size) {
MotionEvent.PointerCoords().apply {
x = points[it].second
y = 30f
pressure = 1f
size = 1f
}
}
val event = MotionEvent.obtain(0, 0, action or (index shl MotionEvent.ACTION_POINTER_INDEX_SHIFT),
points.size, properties, coords, 0, 0, 1f, 1f, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0)
return hold.onTouch(event).also { event.recycle() }
}
}
@@ -220,7 +220,12 @@ class SessionGestureRoutingTest {
override fun onButton(button: Int, pressed: Boolean, x: Float, y: Float) { directButtons += button to pressed }
override fun onWheel(steps: Int) {}
override fun onLongPress() {}
}) {}.also { it.configure(config) }
}, object : DirectTouchHold.Touch {
override fun down(pointerId: Int, x: Float, y: Float) {}
override fun move(pointerId: Int, x: Float, y: Float) {}
override fun up(pointerId: Int, x: Float, y: Float) {}
override fun cancel() {}
}).also { it.configure(config) }
setField("directTouchHold", directHold)
launcherScroll = ScrollTouchGestures(8f, 50f, object : ScrollTouchGestures.Listener {
override fun onMove(x: Float, y: Float) { scrollPositions += x to y }
@@ -25,11 +25,14 @@ class TouchpadGesturesTest {
private val listener = object : PointerGestures.Listener {
override fun onMove(x: Float, y: Float) { events += "move" }
override fun onButton(button: Int, pressed: Boolean, x: Float, y: Float) {
val name = if (button == PointerGestures.BTN_RIGHT) "right" else "left"
val name = when (button) { PointerGestures.BTN_RIGHT -> "right"; PointerGestures.BTN_MIDDLE -> "middle"; else -> "left" }
events += "$name ${if (pressed) "down" else "up"}"
}
override fun onWheel(steps: Int) { events += "wheel $steps" }
override fun onLongPress() { events += "long press" }
override fun onScroll(dx: Float, dy: Float) { events += "scroll" }
override fun onScrollEnd() { events += "scroll end" }
override fun onZoom(steps: Int) { events += "zoom $steps" }
}
@Before fun setUp() {
@@ -41,12 +44,58 @@ class TouchpadGesturesTest {
@Test fun tapHoldsTheLeftButtonBeforeReleasingIt() {
tap()
assertEquals(listOf("left down"), events)
advance(40)
advance(TouchTiming.CLICK_MS - 10)
assertEquals(listOf("left down"), events)
advance(100)
assertEquals(listOf("left down", "left up"), events)
}
@Test fun threeFingerTapClicksTheMiddleButton() {
touch(MotionEvent.ACTION_DOWN, 0, 1 to (400f to 300f))
advance(10)
touch(MotionEvent.ACTION_POINTER_DOWN, 1, 1 to (400f to 300f), 2 to (600f to 310f))
advance(10)
touch(MotionEvent.ACTION_POINTER_DOWN, 2, 1 to (400f to 300f), 2 to (600f to 310f), 3 to (800f to 320f))
advance(60)
touch(MotionEvent.ACTION_POINTER_UP, 2, 1 to (400f to 300f), 2 to (600f to 310f), 3 to (800f to 320f))
touch(MotionEvent.ACTION_POINTER_UP, 1, 1 to (400f to 300f), 2 to (600f to 310f))
touch(MotionEvent.ACTION_UP, 0, 1 to (400f to 300f))
advance(100)
assertEquals(listOf("middle down", "middle up"), events)
}
@Test fun desktopTwoFingerSlideScrollsSmoothlyAndStops() {
touchpad.desktop = true
touch(MotionEvent.ACTION_DOWN, 0, 1 to (400f to 300f))
advance(10)
touch(MotionEvent.ACTION_POINTER_DOWN, 1, 1 to (400f to 300f), 2 to (600f to 300f))
for (step in 1..5) {
advance(16)
touch(MotionEvent.ACTION_MOVE, 0, 1 to (400f to 300f + step * 20f), 2 to (600f to 300f + step * 20f))
}
touch(MotionEvent.ACTION_POINTER_UP, 1, 1 to (400f to 400f), 2 to (600f to 400f))
touch(MotionEvent.ACTION_UP, 0, 1 to (400f to 400f))
advance(100)
assertTrue(events.contains("scroll"))
assertEquals("scroll end", events.last())
assertFalse(events.any { it.startsWith("right") || it.startsWith("wheel") })
}
@Test fun desktopPinchZoomsWithoutScrolling() {
touchpad.desktop = true
touch(MotionEvent.ACTION_DOWN, 0, 1 to (500f to 300f))
advance(10)
touch(MotionEvent.ACTION_POINTER_DOWN, 1, 1 to (500f to 300f), 2 to (600f to 300f))
for (step in 1..6) {
advance(16)
touch(MotionEvent.ACTION_MOVE, 0, 1 to (500f - step * 30f to 300f), 2 to (600f + step * 30f to 300f))
}
touch(MotionEvent.ACTION_POINTER_UP, 1, 1 to (320f to 300f), 2 to (780f to 300f))
touch(MotionEvent.ACTION_UP, 0, 1 to (320f to 300f))
advance(100)
assertTrue(events.isNotEmpty() && events.all { it.startsWith("zoom -") })
}
@Test fun twoFingerTapHoldsTheRightButtonBeforeReleasingIt() {
touch(MotionEvent.ACTION_DOWN, 0, 1 to (400f to 300f))
advance(10)
@@ -56,7 +105,7 @@ class TouchpadGesturesTest {
advance(10)
touch(MotionEvent.ACTION_UP, 0, 1 to (400f to 300f))
assertEquals(listOf("right down"), events)
advance(30)
advance(TouchTiming.CLICK_MS - 20)
assertEquals(listOf("right down"), events)
advance(100)
assertEquals(listOf("right down", "right up"), events)
@@ -71,7 +120,7 @@ class TouchpadGesturesTest {
advance(10)
touch(MotionEvent.ACTION_UP, 0, 1 to (400f to 300f))
assertEquals(listOf("right down"), events)
advance(40)
advance(TouchTiming.CLICK_MS - 10)
assertEquals(listOf("right down"), events)
advance(100)
assertEquals(listOf("right down", "right up"), events)
@@ -82,9 +82,9 @@ class TouchscreenGesturesTest {
@Test fun aVeryFastDoubleTapKeepsFullPressesAndAReleaseGap() {
tap(); tap(); advance(250)
assertEquals(4, leftClicks.size)
assertTrue(leftClicks[1].time - leftClicks[0].time >= 50)
assertTrue(leftClicks[2].time - leftClicks[1].time >= 50)
assertTrue(leftClicks[3].time - leftClicks[2].time >= 50)
assertTrue(leftClicks[1].time - leftClicks[0].time >= TouchTiming.CLICK_MS)
assertTrue(leftClicks[2].time - leftClicks[1].time >= TouchTiming.CLICK_MS)
assertTrue(leftClicks[3].time - leftClicks[2].time >= TouchTiming.CLICK_MS)
}
@Test fun doubleTapUsesTheFirstClickLocationDespiteNormalFingerDrift() {
@@ -121,7 +121,7 @@ class TouchscreenGesturesTest {
gestures.configure(TouchGestureConfig(tapEnabled = false))
tap(); tap(); advance(250)
assertEquals(4, leftClicks.size)
assertTrue(leftClicks[2].time - leftClicks[1].time >= 50)
assertTrue(leftClicks[2].time - leftClicks[1].time >= TouchTiming.CLICK_MS)
}
@Test fun aRapidThirdTapDoesNotDiscardThePendingSecondClick() {
@@ -285,11 +285,11 @@ class TouchscreenGesturesTest {
@Test fun twoFingerTapKeepsItsPressAfterTheLastFingerLifts() {
twoFingerTap()
assertEquals(listOf("button 273 true"), buttons())
advance(49)
advance(TouchTiming.CLICK_MS - 1)
assertEquals(1, rightClicks.size)
advance(1)
assertEquals(listOf(true, false), rightClicks.map { it.down })
assertEquals(50L, rightClicks[1].time - rightClicks[0].time)
assertEquals(TouchTiming.CLICK_MS, rightClicks[1].time - rightClicks[0].time)
}
@Test fun threeFingerKeyboardTapHasAnObservablePressAndReleases() {
@@ -298,14 +298,14 @@ class TouchscreenGesturesTest {
assertEquals(listOf("key 18 true"), events.filter { it.startsWith("key") })
advance(50)
assertEquals(listOf("key 18 true", "key 18 false"), events.filter { it.startsWith("key") })
assertEquals(50L, timedKeys.last().first - timedKeys.first().first)
assertEquals(TouchTiming.CLICK_MS, timedKeys.last().first - timedKeys.first().first)
}
@Test fun twoFingerKeyboardTapHasAnObservablePressAndReleases() {
gestures.configure(TouchGestureConfig(twoFingerTapAction = "key_E"))
twoFingerTap(); advance(50)
assertEquals(listOf(true, false), timedKeys.map { it.third })
assertEquals(50L, timedKeys.last().first - timedKeys.first().first)
assertEquals(TouchTiming.CLICK_MS, timedKeys.last().first - timedKeys.first().first)
}
@Test fun threeFingerMouseTapHasAnObservablePressAndReleases() {
@@ -314,7 +314,7 @@ class TouchscreenGesturesTest {
assertEquals(listOf("button 273 true"), buttons())
advance(50)
assertEquals(listOf(true, false), rightClicks.map { it.down })
assertEquals(50L, rightClicks[1].time - rightClicks[0].time)
assertEquals(TouchTiming.CLICK_MS, rightClicks[1].time - rightClicks[0].time)
}
@Test fun cancellingAMultiFingerTapReleasesItsButtonAndStopsCallbacks() {
@@ -338,7 +338,7 @@ class TouchscreenGesturesTest {
gestures.configure(TouchGestureConfig(tapAction = "right_click", doubleTapEnabled = false))
tap(); tap(); advance(250)
assertEquals(listOf(true, false, true, false), rightClicks.map { it.down })
assertTrue(rightClicks[2].time - rightClicks[1].time >= 50)
assertTrue(rightClicks[2].time - rightClicks[1].time >= TouchTiming.CLICK_MS)
}
@Test fun aFastTwoFingerSwipeDuringSettlingDoesNotClick() {
@@ -0,0 +1,121 @@
package com.droiddeck.launcher.input
import android.os.Looper
import android.view.MotionEvent
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.Shadows.shadowOf
import org.robolectric.annotation.Config
import java.time.Duration
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [28], manifest = Config.NONE)
class TwoFingerGesturesTest {
private val calls = mutableListOf<String>()
private val gestures = TwoFingerGestures(8f, object : TwoFingerGestures.Listener {
override fun cancelTouch() { calls += "cancel" }
override fun replay(event: MotionEvent) { calls += "replay ${event.actionMasked}" }
override fun rightClick(x: Float, y: Float) { calls += "right $x,$y" }
override fun scrollStart(x: Float, y: Float) { calls += "start $x,$y" }
override fun scroll(dx: Float, dy: Float) { calls += "scroll $dx,$dy" }
override fun scrollEnd() { calls += "end" }
})
private var time = 1000L
private var downTime = 0L
private val a = 1 to (400f to 300f)
private val b = 2 to (500f to 300f)
@Test fun tapRightClicksWhereTheFirstFingerLanded() {
assertTrue(touch(MotionEvent.ACTION_DOWN, 0, a))
time += 20
assertTrue(touch(MotionEvent.ACTION_POINTER_DOWN, 1, a, b))
time += 80
assertTrue(touch(MotionEvent.ACTION_POINTER_UP, 1, a, b))
assertTrue(touch(MotionEvent.ACTION_UP, 0, a))
assertEquals(listOf("cancel", "right 400.0,300.0"), calls)
}
@Test fun holdRightClicksOnce() {
touch(MotionEvent.ACTION_DOWN, 0, a)
time += 20
touch(MotionEvent.ACTION_POINTER_DOWN, 1, a, b)
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(TwoFingerGestures.HOLD_MS + 10))
time += 600
assertTrue(touch(MotionEvent.ACTION_POINTER_UP, 1, a, b))
assertTrue(touch(MotionEvent.ACTION_UP, 0, a))
assertEquals(listOf("cancel", "right 400.0,300.0"), calls)
}
@Test fun slidingTogetherScrollsLikeAWheel() {
touch(MotionEvent.ACTION_DOWN, 0, a)
time += 20
touch(MotionEvent.ACTION_POINTER_DOWN, 1, a, b)
time += 20
assertTrue(touch(MotionEvent.ACTION_MOVE, 0, 1 to (400f to 260f), 2 to (500f to 260f)))
assertTrue(touch(MotionEvent.ACTION_MOVE, 0, 1 to (400f to 200f), 2 to (500f to 200f)))
assertTrue(touch(MotionEvent.ACTION_POINTER_UP, 1, 1 to (400f to 200f), 2 to (500f to 200f)))
assertTrue(touch(MotionEvent.ACTION_UP, 0, 1 to (400f to 200f)))
assertEquals(listOf("cancel", "start 450.0,260.0", "scroll 0.0,60.0", "end"), calls)
}
@Test fun pinchPassesThroughForZoom() {
touch(MotionEvent.ACTION_DOWN, 0, a)
time += 20
touch(MotionEvent.ACTION_POINTER_DOWN, 1, a, b)
assertTrue(touch(MotionEvent.ACTION_MOVE, 0, 1 to (350f to 300f), 2 to (550f to 300f)))
assertEquals(listOf("replay 0", "replay 5", "replay 2"), calls)
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(TwoFingerGestures.HOLD_MS + 10))
assertFalse(touch(MotionEvent.ACTION_MOVE, 0, 1 to (340f to 300f), 2 to (560f to 300f)))
assertFalse(touch(MotionEvent.ACTION_POINTER_UP, 1, 1 to (340f to 300f), 2 to (560f to 300f)))
assertFalse(touch(MotionEvent.ACTION_UP, 0, 1 to (340f to 300f)))
assertEquals(3, calls.size)
}
@Test fun oneFingerTapIsReplayedOnRelease() {
assertTrue(touch(MotionEvent.ACTION_DOWN, 0, a))
assertTrue(calls.isEmpty())
time += 60
assertTrue(touch(MotionEvent.ACTION_UP, 0, a))
assertEquals(listOf("replay 0", "replay 1"), calls)
}
@Test fun oneFingerStillIsReplayedAfterTheLandingWindow() {
assertTrue(touch(MotionEvent.ACTION_DOWN, 0, a))
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(TwoFingerGestures.LAND_MS + 10))
assertEquals(listOf("replay 0"), calls)
time += 600
assertFalse(touch(MotionEvent.ACTION_POINTER_DOWN, 1, a, b))
assertFalse(touch(MotionEvent.ACTION_POINTER_UP, 1, a, b))
assertFalse(touch(MotionEvent.ACTION_UP, 0, a))
assertEquals(listOf("replay 0"), calls)
}
@Test fun oneFingerDragIsReplayedOnceItMoves() {
touch(MotionEvent.ACTION_DOWN, 0, a)
time += 16
assertTrue(touch(MotionEvent.ACTION_MOVE, 0, 1 to (402f to 300f)))
assertTrue(calls.isEmpty())
time += 16
assertTrue(touch(MotionEvent.ACTION_MOVE, 0, 1 to (440f to 300f)))
assertEquals(listOf("replay 0", "replay 2", "replay 2"), calls)
assertFalse(touch(MotionEvent.ACTION_MOVE, 0, 1 to (480f to 300f)))
assertFalse(touch(MotionEvent.ACTION_UP, 0, 1 to (480f to 300f)))
}
private fun touch(action: Int, index: Int, vararg pointers: Pair<Int, Pair<Float, Float>>): Boolean {
if (action == MotionEvent.ACTION_DOWN) downTime = time
val properties = pointers.map { (id, _) ->
MotionEvent.PointerProperties().apply { this.id = id; toolType = MotionEvent.TOOL_TYPE_FINGER }
}.toTypedArray()
val coords = pointers.map { (_, at) ->
MotionEvent.PointerCoords().apply { x = at.first; y = at.second; pressure = 1f; size = 1f }
}.toTypedArray()
val masked = action or (index shl MotionEvent.ACTION_POINTER_INDEX_SHIFT)
val event = MotionEvent.obtain(downTime, time, masked, pointers.size, properties, coords, 0, 0, 1f, 1f, 0, 0, 0, 0)
return gestures.onTouch(event).also { event.recycle() }
}
}
@@ -0,0 +1,47 @@
package com.droiddeck.launcher.runtime
import org.junit.Assert.assertEquals
import org.junit.Test
class AccountsMergeTest {
private val own = "root:x:10123:10123:root:/root:/bin/bash"
private val zero = "root:x:0:0:root:/root:/bin/bash"
@Test fun systemUsersSurvive() {
val existing = "root:x:0:0:root:/root:/bin/bash\ndaemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin\n_apt:x:42:65534::/nonexistent:/usr/sbin/nologin\nmessagebus:x:100:102::/nonexistent:/usr/sbin/nologin\n"
assertEquals("$own\n$zero\ndaemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin\n_apt:x:42:65534::/nonexistent:/usr/sbin/nologin\nmessagebus:x:100:102::/nonexistent:/usr/sbin/nologin\n",
LinuxRuntime.mergedAccounts(existing, 2, own, zero, 10123))
}
@Test fun anOldSingleLineFileIsReplacedOnce() {
val merged = LinuxRuntime.mergedAccounts("$own\n", 2, own, zero, 10123)
assertEquals("$own\n$zero\n", merged)
assertEquals(merged, LinuxRuntime.mergedAccounts(merged, 2, own, zero, 10123))
}
@Test fun anotherAppUidIsDropped() {
assertEquals("$own\n$zero\n", LinuxRuntime.mergedAccounts("root:x:10099:10099:root:/root:/bin/bash\n", 2, own, zero, 10123))
}
@Test fun noFileYet() {
assertEquals("$own\n$zero\n", LinuxRuntime.mergedAccounts(null, 2, own, zero, 10123))
}
@Test fun groupsKeepMembers() {
val existing = "root:x:0:\nsudo:x:27:\naudio:x:29:pulse\n"
assertEquals("root:x:10123:\nroot:x:0:\nsudo:x:27:\naudio:x:29:pulse\n",
LinuxRuntime.mergedAccounts(existing, 2, "root:x:10123:", "root:x:0:", 10123))
}
@Test fun storageGroupsAreAddedWithRoot() {
assertEquals("root:x:0:\nsudo:x:27:\nsdcard_rw:x:1015:root\nmedia_rw:x:1023:root\neverybody:x:9997:root\n",
LinuxRuntime.withStorageGroups("root:x:0:\nsudo:x:27:\n"))
}
@Test fun existingStorageGroupsGainRootOnce() {
val existing = "root:x:0:\nmedia_rw:x:1023:pulse\nsdcard_rw:x:1015:root\nshared:x:9997:\n"
val updated = LinuxRuntime.withStorageGroups(existing)
assertEquals("root:x:0:\nmedia_rw:x:1023:pulse,root\nsdcard_rw:x:1015:root\nshared:x:9997:root\n", updated)
assertEquals(updated, LinuxRuntime.withStorageGroups(updated))
}
}
@@ -160,4 +160,25 @@ class BwrapSpawnerPlanTest {
assertFalse(plan.binds.any { it.guest.startsWith("/app/bin/") })
assertFalse(File(dir, "zypak-wrapper").exists())
}
@Test fun preloadsStayOutOfSandboxesWithAnOlderGlibc() {
val base = Files.createTempDirectory("glibc").toFile()
try {
val rootfs = File(base, "rootfs")
File(rootfs, "usr/local/lib").mkdirs()
File(rootfs, "etc").mkdirs()
File(rootfs, "etc/ld.so.preload").writeText("/usr/local/lib/libone.so\n/usr/local/lib/libtwo.so\n")
File(rootfs, "usr/local/lib/libone.so").writeText("x GLIBC_2.17 y GLIBC_2.34 z")
File(rootfs, "usr/local/lib/libtwo.so").writeText("GLIBC_2.38 GLIBC_2.25")
val old = File(base, "old-libc").apply { writeText("GNU C Library (Ubuntu GLIBC 2.23-0ubuntu11) stable release version 2.23, by Roland") }
val new = File(base, "new-libc").apply { writeText("GNU C Library (Ubuntu GLIBC 2.43-0ubuntu1) stable release version 2.43.") }
val same = File(base, "same-libc").apply { writeText("stable release version 2.38.") }
assertFalse(BwrapSpawner.preloadFits(rootfs.path, old.path))
assertTrue(BwrapSpawner.preloadFits(rootfs.path, new.path))
assertTrue(BwrapSpawner.preloadFits(rootfs.path, same.path))
assertTrue(BwrapSpawner.preloadFits(rootfs.path, File(base, "missing").path))
} finally {
base.deleteRecursively()
}
}
}
@@ -76,4 +76,22 @@ class DesktopFileRemovalTest {
file("var/lib/pacman/local/base-1/files", "%FILES%\nusr/\nusr/bin/\nusr/bin/gamescope\n\n%BACKUP%\netc/config\n")
assertEquals(setOf("usr/bin/gamescope"), DesktopFileRemoval.runtimeFiles(root))
}
@Test fun desktopPackageRecordsAreNotRuntimeFilesAndAreRemovedWithTheDesktop() {
file("var/lib/pacman/local/base-1/files", "%FILES%\nusr/bin/gamescope\n")
file("var/lib/pacman/local/kate-26.04.3-1/files", "%FILES%\nusr/bin/kate\n")
file("var/lib/pacman/local/kate-26.04.3-1/desc", "%NAME%\nkate\n")
file("var/lib/pacman/local/htop-3.5.3-1/files", "%FILES%\nusr/bin/htop\n")
file("var/lib/pacman/sync/droiddeck.db", "db")
file("var/lib/pacman/droiddeck-desktop", "stamp")
file("usr/share/droiddeck/pacman/desktop-packages.txt", "kate 26.04.3-1\n../../etc 1\n")
val records = DesktopFileRemoval.desktopRecords(root)
assertEquals(setOf("kate-26.04.3-1"), records)
assertEquals(setOf("usr/bin/gamescope", "usr/bin/htop"), DesktopFileRemoval.runtimeFiles(root))
DesktopFileRemoval.removeRecords(root, records)
assertFalse(File(root, "var/lib/pacman/local/kate-26.04.3-1").exists())
assertTrue(File(root, "var/lib/pacman/local/htop-3.5.3-1/files").exists())
assertFalse(File(root, "var/lib/pacman/sync/droiddeck.db").exists())
assertFalse(File(root, "var/lib/pacman/droiddeck-desktop").exists())
}
}
@@ -0,0 +1,145 @@
package com.droiddeck.launcher.runtime
import com.droiddeck.launcher.core.FileUtils
import com.droiddeck.launcher.core.Hashes
import java.io.File
import java.nio.file.Files
import java.util.zip.GZIPOutputStream
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
@RunWith(RobolectricTestRunner::class)
class DesktopPackTest {
private val parent = Files.createTempDirectory("pack").toFile()
private val root = File(parent, "root").apply { mkdirs() }
@After fun tearDown() { FileUtils.delete(parent) }
private fun file(path: String, text: String) = File(root, path).apply { parentFile?.mkdirs(); writeText(text) }
private fun line(kind: Char, path: String): String {
val file = File(root, path)
return when {
Files.isSymbolicLink(file.toPath()) -> "$kind\tL\t0\t${Files.readSymbolicLink(file.toPath())}\t$path"
file.isDirectory -> "$kind\tD\t0\t-\t$path"
else -> "$kind\tF\t${file.length()}\t${Hashes.sha256(file)}\t$path"
}
}
private fun manifest(lines: List<String>) {
val target = File(root, "${DesktopPack.META}/files.tsv.gz").apply { parentFile?.mkdirs() }
GZIPOutputStream(target.outputStream()).bufferedWriter().use { w -> lines.forEach { w.write(it); w.write("\n") } }
}
private fun installed(): List<String> {
File(root, DesktopPack.INFO).apply { parentFile?.mkdirs() }
.writeText("""{"tag":"ubuntu-r1-desktop","url":"https://example.invalid/d.tar.zst","sha256":"00","size":5}""")
file("usr/bin/runtime-tool", "runtime")
file("${DesktopPack.META}/originals/var/lib/dpkg/status", "Package: bash\n")
file("${DesktopPack.META}/originals/etc/gone.conf", "removed by the desktop")
file("${DesktopPack.META}/originals/etc/group", "root:x:0:")
file("${DesktopPack.META}/originals/etc/hosts", "runtime hosts")
file("etc/group", "root:x:0:\nsddm:x:120:")
file("etc/hosts", "desktop hosts")
file("var/lib/dpkg/status", "Package: bash\n\nPackage: kwin\n")
file("usr/bin/kwin_wayland", "kwin")
file("usr/share/kwin/effect.qml", "effect")
file("usr/share/kwin/edited.qml", "original")
Files.createSymbolicLink(File(root, "usr/bin/kwin").toPath(), File("kwin_wayland").toPath())
val lines = listOf(
line('N', "usr/share/kwin"), line('N', "usr/bin/kwin_wayland"), line('N', "usr/share/kwin/effect.qml"),
line('N', "usr/share/kwin/edited.qml"), line('N', "usr/bin/kwin"), line('C', "var/lib/dpkg/status"), line('C', "etc/group"), line('C', "etc/hosts"),
"R\tF\t22\tx\tetc/gone.conf", "N\tF\t1\tx\t../escape",
)
file("usr/share/kwin/edited.qml", "changed by the user")
file("etc/hosts", "edited by the user")
file("var/lib/dpkg/status", "Package: bash\n\nPackage: kwin\n\nPackage: vlc\n")
return lines
}
@Test fun readsThePackTheRuntimeNames() {
installed()
val info = DesktopPack.info(root)!!
assertEquals("ubuntu-r1-desktop", info.tag)
assertEquals(5L, info.size)
}
@Test fun removingPutsTheRuntimeBackAndKeepsWhatTheUserChanged() {
manifest(installed())
val result = DesktopPack.remove(root)
assertEquals("Package: bash\n", File(root, "var/lib/dpkg/status").readText())
assertEquals("removed by the desktop", File(root, "etc/gone.conf").readText())
assertEquals("root:x:0:", File(root, "etc/group").readText())
assertEquals("edited by the user", File(root, "etc/hosts").readText())
assertFalse(File(root, "usr/bin/kwin_wayland").exists())
assertFalse(Files.exists(File(root, "usr/bin/kwin").toPath(), java.nio.file.LinkOption.NOFOLLOW_LINKS))
assertFalse(File(root, "usr/share/kwin/effect.qml").exists())
assertEquals("changed by the user", File(root, "usr/share/kwin/edited.qml").readText())
assertTrue(File(root, "usr/share/kwin").isDirectory)
assertEquals("runtime", File(root, "usr/bin/runtime-tool").readText())
assertFalse(File(root, DesktopPack.META).exists())
assertFalse(DesktopPack.installed(root))
assertEquals(3, result.removed)
assertEquals(3, result.restored)
assertEquals(3, result.kept)
}
@Test fun emptiedDirectoriesGoAway() {
val lines = installed()
File(root, "usr/share/kwin/edited.qml").delete()
manifest(lines)
DesktopPack.remove(root)
assertFalse(File(root, "usr/share/kwin").exists())
assertTrue(File(root, "usr/share").isDirectory)
}
@Test fun finishingAnInstallDeletesWhatTheDesktopRemoved() {
file("etc/gone.conf", "runtime copy")
manifest(listOf("R\tF\t22\tx\tetc/gone.conf", "R\tF\t1\tx\t../outside"))
File(root.parentFile, "outside").writeText("keep")
DesktopPack.finishInstall(root)
assertFalse(File(root, "etc/gone.conf").exists())
assertTrue(File(root.parentFile, "outside").exists())
File(root.parentFile, "outside").delete()
}
@Test fun theDesktopKeepsPackagesTheUserInstalledBeforeIt() {
val bash = "Package: bash\nArchitecture: arm64\nVersion: 5.2"
val vim = "Package: vim\nArchitecture: arm64\nVersion: 9"
val kwin = "Package: kwin\nArchitecture: arm64\nVersion: 6.6"
file("var/lib/dpkg/status", "$bash\n\n$vim\n\n")
DesktopPack.prepareInstall(root)
file("${DesktopPack.META}/originals/var/lib/dpkg/status", "$bash\n\n")
file("var/lib/dpkg/status", "$bash\n\n$kwin\n\n")
manifest(listOf(line('C', "var/lib/dpkg/status")))
DesktopPack.finishInstall(root)
assertEquals("$bash\n\n$kwin\n\n$vim\n\n", File(root, "var/lib/dpkg/status").readText())
assertFalse(File(root, "var/lib/dpkg/status.droiddeck").exists())
val vlc = "Package: vlc\nArchitecture: arm64\nVersion: 3"
file("var/lib/dpkg/status", "$bash\n\n$kwin\n\n$vim\n\n$vlc\n\n")
DesktopPack.remove(root)
assertEquals("$bash\n\n$vim\n\n$vlc\n\n", File(root, "var/lib/dpkg/status").readText())
}
@Test fun mergingKeepsTheTargetWhenBothSidesChangedAPackage() {
val base = "Package: a\nVersion: 1\n\nPackage: b\nVersion: 1\n\nPackage: c\nVersion: 1\n"
val target = "Package: a\nVersion: 2\n\nPackage: b\nVersion: 1\n\nPackage: c\nVersion: 1\n"
val mine = "Package: a\nVersion: 3\n\nPackage: b\nVersion: 3\n"
assertEquals("Package: a\nVersion: 2\n\nPackage: b\nVersion: 3\n\n", DesktopPack.mergeStatus(base, target, mine))
}
@Test fun pathsMayNotLeaveTheRuntime() {
assertNull(DesktopPack.inside(root, "../x"))
assertNull(DesktopPack.inside(root, "/etc/passwd"))
Files.createSymbolicLink(File(root, "link").toPath(), root.parentFile.toPath())
assertNull(DesktopPack.inside(root, "link/x"))
assertEquals(File(root, "usr/x"), DesktopPack.inside(root, "usr/./x"))
}
}
@@ -0,0 +1,102 @@
package com.droiddeck.launcher.runtime
import com.droiddeck.launcher.core.FileUtils
import java.io.File
import java.nio.file.Files
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
class L2sLinkTest {
private val dir = Files.createTempDirectory("l2s").toFile()
@After fun tearDown() { FileUtils.delete(dir) }
@Test fun aHardLinkBecomesProotsLinkLayout() {
val bin = File(dir, "usr/bin").apply { mkdirs() }
val coreutils = File(bin, "coreutils").apply { writeText("multicall") }
val tail = File(bin, "tail")
assertTrue(LinuxRuntimeInstaller.l2sLink(coreutils, tail))
val intermediate = File(bin, ".l2s.coreutils0001")
assertEquals(intermediate.toPath(), Files.readSymbolicLink(coreutils.toPath()))
assertEquals(intermediate.toPath(), Files.readSymbolicLink(tail.toPath()))
assertEquals(File(bin, ".l2s.coreutils0001.0002").toPath(), Files.readSymbolicLink(intermediate.toPath()))
assertEquals("multicall", tail.readText())
assertEquals("multicall", coreutils.readText())
}
@Test fun eachFurtherLinkRaisesTheCount() {
val bin = File(dir, "usr/bin").apply { mkdirs() }
val coreutils = File(bin, "coreutils").apply { writeText("multicall") }
assertTrue(LinuxRuntimeInstaller.l2sLink(coreutils, File(bin, "tail")))
assertTrue(LinuxRuntimeInstaller.l2sLink(coreutils, File(bin, "head")))
assertTrue(LinuxRuntimeInstaller.l2sLink(File(bin, "tail"), File(bin, "cat")))
val final = File(bin, ".l2s.coreutils0001.0004")
assertTrue(final.isFile)
assertFalse(File(bin, ".l2s.coreutils0001.0002").exists())
for (name in listOf("coreutils", "tail", "head", "cat")) assertEquals("multicall", File(bin, name).readText())
}
@Test fun aSecondFileWithTheSameNameGetsItsOwnChain() {
val a = File(dir, "a").apply { mkdirs() }
val existing = File(a, ".l2s.tool0001").apply { writeText("taken") }
val tool = File(a, "tool").apply { writeText("tool") }
assertTrue(LinuxRuntimeInstaller.l2sLink(tool, File(a, "alias")))
assertEquals("taken", existing.readText())
assertEquals(File(a, ".l2s.tool0002").toPath(), Files.readSymbolicLink(tool.toPath()))
assertEquals("tool", File(a, "alias").readText())
}
@Test fun linksMadeInStagingStillResolveAfterTheTreeIsRenamed() {
val staging = File(dir, "linuxfs.new")
val live = File(dir, "linuxfs")
val bin = File(staging, "usr/bin").apply { mkdirs() }
val cargo = File(staging, "usr/lib/cargo/bin/coreutils").apply { mkdirs() }
val coreutils = File(bin, "coreutils").apply { writeText("multicall") }
assertTrue(LinuxRuntimeInstaller.l2sLink(coreutils, File(cargo, "echo"), staging, live))
assertTrue(LinuxRuntimeInstaller.l2sLink(File(cargo, "echo"), File(cargo, "cat"), staging, live))
assertEquals(File(live, "usr/bin/.l2s.coreutils0001").toPath(), Files.readSymbolicLink(File(cargo, "echo").toPath()))
assertTrue(File(staging, "usr/bin/.l2s.coreutils0001.0003").isFile)
assertTrue(staging.renameTo(live))
for (rel in listOf("usr/bin/coreutils", "usr/lib/cargo/bin/coreutils/echo", "usr/lib/cargo/bin/coreutils/cat"))
assertEquals(rel, "multicall", File(live, rel).readText())
assertTrue(LinuxRuntimeInstaller.l2sLink(File(live, "usr/bin/coreutils"), File(live, "usr/bin/tail")))
assertEquals("multicall", File(live, "usr/bin/tail").readText())
assertTrue(File(live, "usr/bin/.l2s.coreutils0001.0004").isFile)
}
@Test fun aHardLinkTargetMayAlreadyBeAnL2sLinkToTheFinalTree() {
val staging = File(dir, "linuxfs.new")
val live = File(dir, "linuxfs")
val bin = File(staging, "usr/bin").apply { mkdirs() }
File(bin, "coreutils").writeText("multicall")
assertTrue(LinuxRuntimeInstaller.l2sLink(File(bin, "coreutils"), File(bin, "["), staging, live))
assertEquals(File(bin, "coreutils"), LinuxRuntimeInstaller.hardLinkTarget(staging, "./usr/bin/coreutils"))
assertTrue(LinuxRuntimeInstaller.l2sLink(LinuxRuntimeInstaller.hardLinkTarget(staging, "./usr/bin/coreutils"), File(bin, "ls"), staging, live))
assertTrue(staging.renameTo(live))
assertEquals("multicall", File(live, "usr/bin/ls").readText())
}
@Test fun aHardLinkTargetCannotLeaveTheTree() {
val tree = File(dir, "tree").apply { mkdirs() }
val outside = File(dir, "outside").apply { mkdirs() }
Files.createSymbolicLink(File(tree, "escape").toPath(), outside.toPath())
assertEquals(null, LinuxRuntimeInstaller.hardLinkTarget(tree, "../outside/x"))
assertEquals(null, LinuxRuntimeInstaller.hardLinkTarget(tree, "escape/x"))
assertEquals(null, LinuxRuntimeInstaller.hardLinkTarget(tree, ".."))
assertEquals(File(tree, "x"), LinuxRuntimeInstaller.hardLinkTarget(tree, "./x"))
}
@Test fun directoriesAndPlainSymlinksAreLeftAlone() {
val d = File(dir, "d").apply { mkdirs() }
assertFalse(LinuxRuntimeInstaller.l2sLink(d, File(dir, "e")))
val target = File(dir, "t").apply { writeText("t") }
val link = File(dir, "link")
Files.createSymbolicLink(link.toPath(), target.toPath())
assertFalse(LinuxRuntimeInstaller.l2sLink(link, File(dir, "other")))
}
}
@@ -52,6 +52,47 @@ class RuntimeUserDataCarryTest {
assertFalse("only DroidDeck's own menu entries are user data", File(staging, "usr/local/share/applications/other.desktop").exists())
}
@Test fun aMenuEntryTheNewRuntimeShipsIsNotCarried() {
val old = tmp.newFolder("old").also {
put(it, "root/save.dat", "mine")
put(it, "usr/share/applications/droiddeck-return-gaming.desktop", "old runtime")
put(it, "usr/share/applications/droiddeck-steam-x64.desktop", "made by the old desktop")
}
val staging = tmp.newFolder("new").also {
put(it, "root/.bashrc", "shipped")
put(it, "usr/share/applications/droiddeck-return-gaming.desktop", "new runtime")
}
val paths = RuntimeFileTree.existingUserPaths(old, staging)
assertTrue("root" in paths)
assertTrue("usr/share/applications/droiddeck-steam-x64.desktop" in paths)
assertFalse("usr/share/applications/droiddeck-return-gaming.desktop" in paths)
RuntimeFileTree.carryUserData(old, staging, false, paths)
assertEquals("new runtime", File(staging, "usr/share/applications/droiddeck-return-gaming.desktop").readText())
}
@Test fun cachesTiedToThePreviousRuntimeAreDropped() {
val root = tmp.newFolder("rt")
val keep = listOf("root/.cache/mozilla/cache2/entry", "root/.cache/droiddeck/session.log",
"root/.local/share/droiddeck/apt/packages.txt", "root/.local/share/Steam/steam.sh", "root/.config/kwinrc")
val drop = listOf("root/.local/share/droiddeck/pacman/packages.txt", "root/.cache/droiddeck/pacman-restore.log",
"root/.cache/mesa_shader_cache_db/index", "root/.cache/mesa_shader_cache/a/b", "root/.cache/appstream/x.xb",
"root/.cache/discover/c", "root/.cache/ksycoca6_en-POSIX_abc", "root/.cache/plasma_theme_Vapor.kcache",
"root/.cache/kwinsession.kcache", "root/.cache/qtshadercache-arm64-little_endian-lp64/s",
"root/.cache/event-sound-cache.tdb.1.aarch64-unknown-linux-gnu", "root/.cache/fontconfig/x.cache-9")
(keep + drop).forEach { put(root, it) }
RuntimeFileTree.dropStaleState(root)
keep.forEach { assertTrue(it, File(root, it).exists()) }
drop.forEach { assertFalse(it, File(root, it).exists()) }
}
@Test fun droppingStateWithoutAHomeDoesNothing() {
RuntimeFileTree.dropStaleState(tmp.newFolder("empty"))
}
@Test fun aFailureHalfwayPutsEverythingBack() {
val old = userTree()
val staging = tmp.newFolder("new")