From 8aeb721ca26acfa5a7bf7d40a71ef2e9df67c6aa Mon Sep 17 00:00:00 2001 From: David Schachter Date: Thu, 12 Nov 2026 23:18:11 -0800 Subject: [PATCH 1/4] ADFA-7141: Tell plugins the file that is shown, not the one left Plugins' FileChangeListener heard the previously active file. The editor's displayed-index observer reported getCurrentFile(), but setCurrentFile() and BaseEditorActivity.onTabSelected set the index before the current file, so the observer read the tab being left. A plugin tab (index -1) reported the last file instead of null, and closing the last file reported nothing. - EditorViewModel.displayedFile() is the file at the displayed index, or null for -1. The observer reports that. - removeFile() resets to -1 when the last file closes, as removeAllFiles() does, so listeners hear that no file is shown. EditorViewModelDisplayedFileTest replays the observer against the ViewModel: opening, switching tabs in onTabSelected's order, a plugin tab, closing the last file and closing all files. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Vh2DAZWMkFWJh7CY7P4kCH --- .../editor/EditorHandlerActivity.kt | 2 +- .../androidide/viewmodel/EditorViewModel.kt | 11 ++- .../EditorViewModelDisplayedFileTest.kt | 90 +++++++++++++++++++ 3 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 app/src/test/java/com/itsaky/androidide/viewmodel/EditorViewModelDisplayedFileTest.kt diff --git a/app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt b/app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt index eb62c37071..9063edc611 100644 --- a/app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt +++ b/app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt @@ -356,7 +356,7 @@ open class EditorHandlerActivity : if (tabPosition >= 0) { this.content.editorContainer.displayedChild = tabPosition } - EditorEvents.notifyFileChanged(editorViewModel.getCurrentFile()) + EditorEvents.notifyFileChanged(editorViewModel.displayedFile()) } pluginEditorProvider = diff --git a/app/src/main/java/com/itsaky/androidide/viewmodel/EditorViewModel.kt b/app/src/main/java/com/itsaky/androidide/viewmodel/EditorViewModel.kt index e8d602b5a4..2679b2878b 100644 --- a/app/src/main/java/com/itsaky/androidide/viewmodel/EditorViewModel.kt +++ b/app/src/main/java/com/itsaky/androidide/viewmodel/EditorViewModel.kt @@ -408,7 +408,9 @@ class EditorViewModel : ViewModel() { files.removeAt(index) if (files.isEmpty()) { - mCurrentFile.value = null + // As removeAllFiles does: no tab is left to select, so nothing else would tell the + // displayed-file observers that no file is shown. + setCurrentFile(-1, null) } } @@ -472,6 +474,13 @@ class EditorViewModel : ViewModel() { fun getCurrentFile(): File? = mCurrentFile.value?.second + /** + * The file at [displayedFileIndex], or null when it is -1 (a plugin tab, or no tab). Observers + * of the displayed index read this, not [getCurrentFile]: [setCurrentFile] and the tab-selected + * callback set the index first, so the current file still names the tab being left. + */ + fun displayedFile(): File? = files.getOrNull(displayedFileIndex) + /** * Get the [OpenedFilesCache] if it is already loaded, otherwise read the cache from the file system * and invoke the given callback. diff --git a/app/src/test/java/com/itsaky/androidide/viewmodel/EditorViewModelDisplayedFileTest.kt b/app/src/test/java/com/itsaky/androidide/viewmodel/EditorViewModelDisplayedFileTest.kt new file mode 100644 index 0000000000..2ecb79134e --- /dev/null +++ b/app/src/test/java/com/itsaky/androidide/viewmodel/EditorViewModelDisplayedFileTest.kt @@ -0,0 +1,90 @@ +package com.itsaky.androidide.viewmodel + +import androidx.arch.core.executor.testing.InstantTaskExecutorRule +import com.google.common.truth.Truth.assertThat +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TestRule +import java.io.File + +/** + * What plugins hear as the active file (ADFA-7141). EditorHandlerActivity reports + * [EditorViewModel.displayedFile] each time the displayed index changes; reading the current file + * there named the tab being left, because the index is set before the current file. + */ +class EditorViewModelDisplayedFileTest { + @get:Rule + val rule: TestRule = InstantTaskExecutorRule() + + private val a = File("/project/A.kt") + private val b = File("/project/B.kt") + private lateinit var viewModel: EditorViewModel + private val heard = mutableListOf() + + @Before + fun setUp() { + viewModel = EditorViewModel() + // The activity's observer, reduced to what it reports. + viewModel._displayedFile.observeForever { heard += viewModel.displayedFile() } + heard.clear() + } + + private fun open(file: File) { + viewModel.addFile(file) + viewModel.setCurrentFile(viewModel.getOpenedFileCount() - 1, file) + } + + @Test + fun openingAFileReportsThatFile() { + open(a) + open(b) + + assertThat(heard).containsExactly(a, b).inOrder() + } + + @Test + fun switchingTabsReportsTheTabSwitchedTo() { + open(a) + open(b) + heard.clear() + + // The order of BaseEditorActivity.onTabSelected: the index first, then setCurrentFile. + viewModel.displayedFileIndex = 0 + viewModel.setCurrentFile(0, a) + + assertThat(heard).containsExactly(a, a) + } + + @Test + fun aPluginTabReportsNoFile() { + open(a) + heard.clear() + + viewModel.displayedFileIndex = -1 + + assertThat(heard).containsExactly(null) + } + + @Test + fun closingTheLastFileReportsNoFile() { + open(a) + heard.clear() + + viewModel.removeFile(0) + + assertThat(heard).containsExactly(null) + assertThat(viewModel.getCurrentFile()).isNull() + } + + @Test + fun closingAllFilesReportsNoFile() { + open(a) + open(b) + heard.clear() + + viewModel.removeAllFiles() + + assertThat(heard).containsExactly(null) + } +} From 274b2a39740582602a0fe7f3ec0a0a3567bcb37b Mon Sep 17 00:00:00 2001 From: David Schachter Date: Fri, 13 Nov 2026 03:21:16 -0800 Subject: [PATCH 2/4] ADFA-7141: Set the current file before the shown index, for listeners Plugins heard the right file after the first fix. But a plugin that asked IdeEditorService for the current file, or its text, inside its callback still got the tab being left: the callback runs as the shown index is set, and setCurrentFile() set the index first. An independent review found it. - setCurrentFile() sets the current file, then the index. - onTabSelected and openFile, which set the index on its own, call setCurrentFile() instead. - displayedFile()'s KDoc says when -1 happens: a plugin tab just added, or no file open. aListenerReadingTheCurrentFileGetsTheShownFile fails with the old order (the listener reads B while A is shown). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Vh2DAZWMkFWJh7CY7P4kCH --- .../activities/editor/BaseEditorActivity.kt | 4 +++- .../editor/EditorHandlerActivity.kt | 2 +- .../androidide/viewmodel/EditorViewModel.kt | 10 ++++---- .../EditorViewModelDisplayedFileTest.kt | 24 ++++++++++++++++--- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt b/app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt index 812c443225..cb8ebf6ae5 100644 --- a/app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt +++ b/app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt @@ -1347,7 +1347,9 @@ abstract class BaseEditorActivity : return } - editorViewModel.displayedFileIndex = fileIndex + // With the current file, not the index alone: plugins hear the switch as the index is set, and + // may ask for the current file. + editorViewModel.setCurrentFile(fileIndex, editorViewModel.getOpenedFiles().getOrNull(fileIndex)) val editorView = if (this is EditorHandlerActivity) { diff --git a/app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt b/app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt index 9063edc611..a79295361a 100644 --- a/app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt +++ b/app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt @@ -1151,7 +1151,7 @@ open class EditorHandlerActivity : if (fileIndex < 0) return@withContext null editorViewModel.startDrawerOpened = false - editorViewModel.displayedFileIndex = fileIndex + editorViewModel.setCurrentFile(fileIndex, file) val tabPosition = getTabPositionForFileIndex(fileIndex) val tab = content.tabs.getTabAt(tabPosition) diff --git a/app/src/main/java/com/itsaky/androidide/viewmodel/EditorViewModel.kt b/app/src/main/java/com/itsaky/androidide/viewmodel/EditorViewModel.kt index 2679b2878b..10f3d0c1ed 100644 --- a/app/src/main/java/com/itsaky/androidide/viewmodel/EditorViewModel.kt +++ b/app/src/main/java/com/itsaky/androidide/viewmodel/EditorViewModel.kt @@ -424,8 +424,10 @@ class EditorViewModel : ViewModel() { index: Int, file: File?, ) { - displayedFileIndex = index + // The current file first: observers of the displayed index run as it is set, and the plugins + // they notify may ask for the current file. mCurrentFile.value = index to file + displayedFileIndex = index } fun updateFile( @@ -475,9 +477,9 @@ class EditorViewModel : ViewModel() { fun getCurrentFile(): File? = mCurrentFile.value?.second /** - * The file at [displayedFileIndex], or null when it is -1 (a plugin tab, or no tab). Observers - * of the displayed index read this, not [getCurrentFile]: [setCurrentFile] and the tab-selected - * callback set the index first, so the current file still names the tab being left. + * The file at [displayedFileIndex], or null when it is -1 (a plugin tab just added, or no file + * open). Observers of the displayed index read this rather than [getCurrentFile], which a new + * plugin tab leaves at the last file. */ fun displayedFile(): File? = files.getOrNull(displayedFileIndex) diff --git a/app/src/test/java/com/itsaky/androidide/viewmodel/EditorViewModelDisplayedFileTest.kt b/app/src/test/java/com/itsaky/androidide/viewmodel/EditorViewModelDisplayedFileTest.kt index 2ecb79134e..9dbb07e716 100644 --- a/app/src/test/java/com/itsaky/androidide/viewmodel/EditorViewModelDisplayedFileTest.kt +++ b/app/src/test/java/com/itsaky/androidide/viewmodel/EditorViewModelDisplayedFileTest.kt @@ -22,12 +22,19 @@ class EditorViewModelDisplayedFileTest { private lateinit var viewModel: EditorViewModel private val heard = mutableListOf() + // What a plugin reads with IdeEditorService.getCurrentFile() inside its callback. + private val currentInCallback = mutableListOf() + @Before fun setUp() { viewModel = EditorViewModel() // The activity's observer, reduced to what it reports. - viewModel._displayedFile.observeForever { heard += viewModel.displayedFile() } + viewModel._displayedFile.observeForever { + heard += viewModel.displayedFile() + currentInCallback += viewModel.getCurrentFile() + } heard.clear() + currentInCallback.clear() } private fun open(file: File) { @@ -49,13 +56,24 @@ class EditorViewModelDisplayedFileTest { open(b) heard.clear() - // The order of BaseEditorActivity.onTabSelected: the index first, then setCurrentFile. - viewModel.displayedFileIndex = 0 + // What BaseEditorActivity.onTabSelected does: the file at the index, then the editor's file. + viewModel.setCurrentFile(0, viewModel.getOpenedFiles().getOrNull(0)) viewModel.setCurrentFile(0, a) assertThat(heard).containsExactly(a, a) } + @Test + fun aListenerReadingTheCurrentFileGetsTheShownFile() { + open(a) + open(b) + currentInCallback.clear() + + viewModel.setCurrentFile(0, a) + + assertThat(currentInCallback).containsExactly(a) + } + @Test fun aPluginTabReportsNoFile() { open(a) From ec9e549b583ca0f9e9c533b2e443dbf1f3582856 Mon Sep 17 00:00:00 2001 From: David Schachter Date: Fri, 13 Nov 2026 05:16:50 -0800 Subject: [PATCH 3/4] ADFA-7141: Keep the opened file current while a new editor loads A new editor learns its file only once its text has loaded, so the second setCurrentFile(fileIndex, editorView.file) in onTabSelected replaced the right file with null after a file was opened. The current file then stayed null until the user switched tabs, which could hide the install action and confuse "Close others". This was already the case on stage; the previous commit made it a one-line fix. - EditorViewModel.selectFile(index, editorFile) shows the opened file at index, falling back to it while the editor's own file is null. onTabSelected calls it twice, so the tests pin the logic the activity uses. - The tab-switching test now also checks the current file a listener reads in its callback, and a new test covers an editor that has not loaded yet. They fail with the fallback removed, and with the index set before the current file. - KDoc fixes: the test class, and displayedFile()'s null cases. Found by an independent review of 274b2a397. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Vh2DAZWMkFWJh7CY7P4kCH --- .../activities/editor/BaseEditorActivity.kt | 4 +-- .../androidide/viewmodel/EditorViewModel.kt | 17 ++++++++++--- .../EditorViewModelDisplayedFileTest.kt | 25 +++++++++++++++---- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt b/app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt index cb8ebf6ae5..59790ffb84 100644 --- a/app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt +++ b/app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt @@ -1349,7 +1349,7 @@ abstract class BaseEditorActivity : // With the current file, not the index alone: plugins hear the switch as the index is set, and // may ask for the current file. - editorViewModel.setCurrentFile(fileIndex, editorViewModel.getOpenedFiles().getOrNull(fileIndex)) + editorViewModel.selectFile(fileIndex) val editorView = if (this is EditorHandlerActivity) { @@ -1364,7 +1364,7 @@ abstract class BaseEditorActivity : } editorView.onEditorSelected() - editorViewModel.setCurrentFile(fileIndex, editorView.file) + editorViewModel.selectFile(fileIndex, editorView.file) refreshSymbolInput(editorView) invalidateOptionsMenu() } diff --git a/app/src/main/java/com/itsaky/androidide/viewmodel/EditorViewModel.kt b/app/src/main/java/com/itsaky/androidide/viewmodel/EditorViewModel.kt index 10f3d0c1ed..664a341061 100644 --- a/app/src/main/java/com/itsaky/androidide/viewmodel/EditorViewModel.kt +++ b/app/src/main/java/com/itsaky/androidide/viewmodel/EditorViewModel.kt @@ -477,12 +477,23 @@ class EditorViewModel : ViewModel() { fun getCurrentFile(): File? = mCurrentFile.value?.second /** - * The file at [displayedFileIndex], or null when it is -1 (a plugin tab just added, or no file - * open). Observers of the displayed index read this rather than [getCurrentFile], which a new - * plugin tab leaves at the last file. + * The file at [displayedFileIndex], or null when there is none there: -1 (a plugin tab just + * added, or no file open), or briefly an index past the end while a tab is added or closed. + * Observers of the displayed index read this rather than [getCurrentFile], which a new plugin + * tab leaves at the last file. */ fun displayedFile(): File? = files.getOrNull(displayedFileIndex) + /** + * Shows the opened file at [index], as a selected tab does. [editorFile] is the tab's editor's + * own file, null until a new editor has loaded its text; the opened file stands in until then, + * so the current file is never null while a file is shown. + */ + fun selectFile( + index: Int, + editorFile: File? = null, + ) = setCurrentFile(index, editorFile ?: files.getOrNull(index)) + /** * Get the [OpenedFilesCache] if it is already loaded, otherwise read the cache from the file system * and invoke the given callback. diff --git a/app/src/test/java/com/itsaky/androidide/viewmodel/EditorViewModelDisplayedFileTest.kt b/app/src/test/java/com/itsaky/androidide/viewmodel/EditorViewModelDisplayedFileTest.kt index 9dbb07e716..447e9c1d17 100644 --- a/app/src/test/java/com/itsaky/androidide/viewmodel/EditorViewModelDisplayedFileTest.kt +++ b/app/src/test/java/com/itsaky/androidide/viewmodel/EditorViewModelDisplayedFileTest.kt @@ -10,8 +10,8 @@ import java.io.File /** * What plugins hear as the active file (ADFA-7141). EditorHandlerActivity reports - * [EditorViewModel.displayedFile] each time the displayed index changes; reading the current file - * there named the tab being left, because the index is set before the current file. + * [EditorViewModel.displayedFile] each time the displayed index changes, and plugins may read the + * current file in that callback; both used to name the tab being left. */ class EditorViewModelDisplayedFileTest { @get:Rule @@ -56,11 +56,26 @@ class EditorViewModelDisplayedFileTest { open(b) heard.clear() - // What BaseEditorActivity.onTabSelected does: the file at the index, then the editor's file. - viewModel.setCurrentFile(0, viewModel.getOpenedFiles().getOrNull(0)) - viewModel.setCurrentFile(0, a) + currentInCallback.clear() + + // What BaseEditorActivity.onTabSelected does: select the index, then again with the editor's file. + viewModel.selectFile(0) + viewModel.selectFile(0, a) assertThat(heard).containsExactly(a, a) + assertThat(currentInCallback).containsExactly(a, a) + } + + @Test + fun aTabWhoseEditorHasNotLoadedKeepsTheOpenedFileCurrent() { + open(a) + open(b) + + // A new editor knows its file only once its text has loaded. + viewModel.selectFile(0) + viewModel.selectFile(0, editorFile = null) + + assertThat(viewModel.getCurrentFile()).isEqualTo(a) } @Test From ca103380222f38b13021a45898003cc26a99efaf Mon Sep 17 00:00:00 2001 From: David Schachter Date: Mon, 16 Nov 2026 22:03:59 -0800 Subject: [PATCH 4/4] ADFA-7141: Close others by the opened file, not the editor's From an independent review of ec9e549b5. Since that commit, the current file is set from the opened file as soon as its tab is shown. But a CodeEditorView's file stays null until its text has loaded, or for good if the read failed. closeOthers compared the current file with each editor's file, so the shown tab didn't match itself and was closed. Example: with [Shown, A, B] and Shown still loading, "Close others" closed Shown and A and kept B. Before ec9e549b5 both sides were null in that case, which matched by accident. closeOthers now compares against the view model's opened file at each index. That also removes its skip of a missing editor, which spun forever because the index never changed. CloseOthersTest drives the real closeOthers and closeFile on a built, uncreated activity, with the tab strip and editor container mocked in step with the opened files: - keeps a shown file whose editor hasn't loaded. Against ec9e549b5 this fails: it keeps B.kt; - keeps a loaded shown file in the middle. 210 editor and view-model tests pass, and spotlessCheck is clean. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Vh2DAZWMkFWJh7CY7P4kCH --- .../editor/EditorHandlerActivity.kt | 13 +-- .../activities/editor/CloseOthersTest.kt | 96 +++++++++++++++++++ 2 files changed, 100 insertions(+), 9 deletions(-) create mode 100644 app/src/test/java/com/itsaky/androidide/activities/editor/CloseOthersTest.kt diff --git a/app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt b/app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt index a79295361a..724af78792 100644 --- a/app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt +++ b/app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt @@ -1795,16 +1795,11 @@ open class EditorHandlerActivity : // keep closing the file at index 0 // if openedFiles[0] == file, then keep closing files at index 1 while (editorViewModel.getOpenedFileCount() != 1) { - val editor = getEditorAtIndex(index) - - if (editor == null) { - log.error("Unable to save file at index {}", index) - continue - } - // Index of files changes as we keep close files - // So we compare the files instead of index - if (file != editor.file) { + // So we compare the files instead of index. The opened file, not the editor's: an + // editor's file is null until its text has loaded, or for good if the read failed, + // while the current file is set from the opened file as soon as its tab is shown. + if (file != editorViewModel.getOpenedFile(index)) { closeFile(index) } else { index = 1 diff --git a/app/src/test/java/com/itsaky/androidide/activities/editor/CloseOthersTest.kt b/app/src/test/java/com/itsaky/androidide/activities/editor/CloseOthersTest.kt new file mode 100644 index 0000000000..ae8eb98a2c --- /dev/null +++ b/app/src/test/java/com/itsaky/androidide/activities/editor/CloseOthersTest.kt @@ -0,0 +1,96 @@ +package com.itsaky.androidide.activities.editor + +import android.content.Intent +import android.widget.ViewFlipper +import com.google.android.material.tabs.TabLayout +import com.google.common.truth.Truth.assertThat +import com.itsaky.androidide.app.BaseApplication +import com.itsaky.androidide.databinding.ActivityEditorBinding +import com.itsaky.androidide.databinding.ContentEditorBinding +import com.itsaky.androidide.ui.CodeEditorView +import io.mockk.every +import io.mockk.mockk +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.Robolectric +import org.robolectric.RobolectricTestRunner +import org.robolectric.annotation.Config +import java.io.File + +/** + * "Close others" keeps the shown file (ADFA-7141). The current file is set from the opened file + * as soon as a tab is shown, while its editor's own file stays null until the text has loaded, or + * for good if the read failed. Comparing against the editor's file closed the shown tab instead. + */ +@RunWith(RobolectricTestRunner::class) +@Config(application = CloseOthersTest.TestApp::class) +class CloseOthersTest { + open class TestApp : BaseApplication() + + private val shown = File("/project/Shown.kt") + private val a = File("/project/A.kt") + private val b = File("/project/B.kt") + + @Test + fun closeOthersKeepsAShownFileWhoseEditorHasNotLoaded() { + val activity = activityWithTabs(listOf(shown to null, a to a, b to b)) + activity.editorViewModel.selectFile(0) + + activity.closeOthers() + + assertThat(activity.editorViewModel.getOpenedFiles()).containsExactly(shown) + } + + @Test + fun closeOthersKeepsALoadedShownFileInTheMiddle() { + val activity = activityWithTabs(listOf(a to a, shown to shown, b to b)) + activity.editorViewModel.selectFile(1, shown) + + activity.closeOthers() + + assertThat(activity.editorViewModel.getOpenedFiles()).containsExactly(shown) + } + + /** + * An editor activity, built but not created as in the other activity tests here, whose tab + * strip and editor container follow its opened files. Each pair is an opened file and the file + * its editor reports: null while the editor loads. + */ + private fun activityWithTabs(tabs: List>): EditorHandlerActivity { + val activity = Robolectric.buildActivity(EditorHandlerActivity::class.java, Intent()).get() + val editors = + tabs + .map { (_, editorFile) -> + mockk(relaxed = true) { + every { file } returns editorFile + every { isModified } returns false + } + }.toMutableList() + val tabStrip = mockk(relaxed = true) { every { tabCount } answers { editors.size } } + val container = + mockk(relaxed = true) { + every { childCount } answers { editors.size } + every { getChildAt(any()) } answers { editors.getOrNull(firstArg()) } + every { removeViewAt(any()) } answers { editors.removeAt(firstArg()) } + } + // The binding's views are public Java fields, which mockk cannot stub. + val content = mockk(relaxed = true) + ContentEditorBinding::class.java + .getDeclaredField("tabs") + .apply { isAccessible = true } + .set(content, tabStrip) + ContentEditorBinding::class.java + .getDeclaredField("editorContainer") + .apply { isAccessible = true } + .set(content, container) + val binding = mockk(relaxed = true) + ActivityEditorBinding::class.java + .getDeclaredField("content") + .apply { isAccessible = true } + .set(binding, content) + activity._binding = binding + + tabs.forEach { (opened, _) -> activity.editorViewModel.addFile(opened) } + return activity + } +}