mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 04:55:44 +00:00
perf(session): check the known game process first in the game exit watcher (#3306)
Check the known game process first when watching for the game to exit
This commit is contained in:
1 parent
25923966eb
commit
6877a5e8e6
3 files changed
+28
-7
No files matched your search
@@ -1,6 +1,8 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@@ -89,6 +91,20 @@ class SteamGameProcessTest {
|
||||
assertTrue(SteamGameProcess.running("351710", proc))
|
||||
}
|
||||
|
||||
@Test fun aKnownGameProcessIsCheckedBeforeEveryOtherProcess() {
|
||||
val proc = tmp.newFolder("proc")
|
||||
fun process(pid: String, vararg args: String) = File(proc, pid).apply { mkdirs() }.resolve("cmdline").writeBytes(cmdline(*args))
|
||||
process("100", "reaper", "SteamLaunch", "AppId=1")
|
||||
process("200", "reaper", "SteamLaunch", "AppId=1")
|
||||
assertEquals("200", SteamGameProcess.runningPid("1", "200", proc))
|
||||
File(proc, "200/cmdline").writeBytes(cmdline("bash"))
|
||||
assertEquals("100", SteamGameProcess.runningPid("1", "200", proc))
|
||||
assertEquals("100", SteamGameProcess.runningPid("1", "999", proc))
|
||||
File(proc, "100").deleteRecursively()
|
||||
assertNull(SteamGameProcess.runningPid("1", "100", proc))
|
||||
assertNull(SteamGameProcess.runningPid("2", null, proc))
|
||||
}
|
||||
|
||||
@Test fun onlyTheRunningCurrentGameCountsAsAlreadyRunning() {
|
||||
val proc = tmp.newFolder("proc-relaunch")
|
||||
File(proc, "200").apply { mkdirs() }.resolve("cmdline")
|
||||
|
||||
Reference in new issue
Block a user