mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
[workspace] project view actions availability test
GitOrigin-RevId: ac9a0acff4353c62f2e495b6831043d582ac84cc
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c1b420f208
commit
5e00825577
@@ -1,13 +1,21 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.ide.workspace
|
||||
|
||||
import com.intellij.ide.DataManager
|
||||
import com.intellij.ide.impl.HeadlessDataManager
|
||||
import com.intellij.ide.projectView.impl.ProjectViewImpl
|
||||
import com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode
|
||||
import com.intellij.ide.util.treeView.AbstractTreeNode
|
||||
import com.intellij.openapi.actionSystem.*
|
||||
import com.intellij.projectView.BaseProjectViewTestCase
|
||||
import com.intellij.testFramework.PlatformTestUtil
|
||||
import com.intellij.util.ui.tree.TreeUtil
|
||||
import java.nio.file.Path
|
||||
|
||||
class WorkspaceProjectTreeStructureTest: BaseProjectViewTestCase() {
|
||||
|
||||
override fun getTestDirectoryName() = "workspace"
|
||||
|
||||
override fun getProjectDirOrFile(isDirectoryBasedProject: Boolean): Path {
|
||||
return Path.of(testDataPath, testPath, testDirectoryName, "workspace")
|
||||
}
|
||||
@@ -15,7 +23,12 @@ class WorkspaceProjectTreeStructureTest: BaseProjectViewTestCase() {
|
||||
override fun setUpModule() {
|
||||
}
|
||||
|
||||
fun testWorkspace() {
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
HeadlessDataManager.fallbackToProductionDataManager(testRootDisposable)
|
||||
}
|
||||
|
||||
fun testStructure() {
|
||||
val rootElement = myStructure.rootElement as AbstractTreeNode<*>
|
||||
val workspace = myStructure.getChildElements(rootElement).filterIsInstance<PsiDirectoryNode>().first()
|
||||
assertStructureEqual("Workspace: workspace\n" +
|
||||
@@ -24,4 +37,26 @@ class WorkspaceProjectTreeStructureTest: BaseProjectViewTestCase() {
|
||||
" Subproject: untitled1\n" +
|
||||
" HtmlFile:bar.html", workspace)
|
||||
}
|
||||
|
||||
fun testActions() {
|
||||
val projectView = ProjectViewImpl.getInstance(project) as ProjectViewImpl
|
||||
val tree = projectView.currentProjectViewPane.tree
|
||||
PlatformTestUtil.waitForPromise(TreeUtil.promiseExpandAll(tree))
|
||||
|
||||
tree.setSelectionRow(0)
|
||||
val context = DataManager.getInstance().getDataContext(projectView.component)
|
||||
assertTrue(isActionEnabled(context))
|
||||
|
||||
tree.setSelectionRow(1)
|
||||
val context1 = DataManager.getInstance().getDataContext(projectView.component)
|
||||
assertFalse(isActionEnabled(context1))
|
||||
}
|
||||
|
||||
private fun isActionEnabled(context: DataContext): Boolean {
|
||||
val action = ActionManager.getInstance().getAction("AddToWorkspace")
|
||||
val presentation = Presentation()
|
||||
val actionEvent = AnActionEvent.createFromDataContext(ActionPlaces.PROJECT_VIEW_POPUP, presentation, context)
|
||||
action.update(actionEvent)
|
||||
return presentation.isEnabled
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user