}
@Test fun `profiles`() {
- loadAndUseProject(tempDirManager, {
- it.path
- }) { project ->
- val projectInspectionProfileManager = ProjectInspectionProfileManager.getInstanceImpl(project)
-
- assertThat(projectInspectionProfileManager.state).isEmpty()
-
- // cause to use app profile
- runInInitMode {
- val currentProfile = projectInspectionProfileManager.currentProfile
- assertThat(currentProfile.isProjectLevel).isTrue()
- currentProfile.disableTool("Convert2Diamond", project)
- }
-
- project.saveStore()
-
- val inspectionDir = Paths.get(project.stateStore.stateStorageManager.expandMacros(PROJECT_CONFIG_DIR), "inspectionProfiles")
- val file = inspectionDir.resolve("profiles_settings.xml")
-
- assertThat(file).doesNotExist()
- val profileFile = inspectionDir.resolve("Project_Default.xml")
- assertThat(profileFile.readText()).isEqualTo("""
+ runInInitMode {
+ loadAndUseProject(tempDirManager, {
+ it.path
+ }) { project ->
+ val projectInspectionProfileManager = ProjectInspectionProfileManager.getInstanceImpl(project)
+ projectInspectionProfileManager.forceLoadSchemes()
+
+ assertThat(projectInspectionProfileManager.state).isEmpty()
+
+ // cause to use app profile
+ runInInitMode {
+ val currentProfile = projectInspectionProfileManager.currentProfile
+ assertThat(currentProfile.isProjectLevel).isTrue()
+ currentProfile.disableTool("Convert2Diamond", project)
+ }
+
+ project.saveStore()
+
+ val inspectionDir = Paths.get(project.stateStore.stateStorageManager.expandMacros(PROJECT_CONFIG_DIR), "inspectionProfiles")
+ val file = inspectionDir.resolve("profiles_settings.xml")
+
+ assertThat(file).doesNotExist()
+ val profileFile = inspectionDir.resolve("Project_Default.xml")
+ assertThat(profileFile.readText()).isEqualTo("""
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
</profile>
</component>""".trimIndent())
- profileFile.write("""
+ profileFile.write("""
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
</profile>
</component>""".trimIndent())
- project.baseDir.refresh(false, true)
- (ProjectManager.getInstance() as StoreAwareProjectManager).flushChangedAlarm()
- runInInitMode {
- assertThat(projectInspectionProfileManager.currentProfile.getToolDefaultState("Convert2Diamond", project).level).isEqualTo(HighlightDisplayLevel.ERROR)
+ project.baseDir.refresh(false, true)
+ (ProjectManager.getInstance() as StoreAwareProjectManager).flushChangedAlarm()
+ runInInitMode {
+ assertThat(projectInspectionProfileManager.currentProfile.getToolDefaultState("Convert2Diamond", project).level).isEqualTo(HighlightDisplayLevel.ERROR)
+ }
}
}
}
import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters
import com.intellij.util.xmlb.XmlSerializer
import org.jdom.Element
+import org.jetbrains.annotations.TestOnly
import java.util.concurrent.CompletableFuture
import java.util.function.Function
})
}
+ @TestOnly
+ fun forceLoadSchemes() {
+ LOG.assertTrue(ApplicationManager.getApplication().isUnitTestMode)
+ schemeManager.loadSchemes()
+ }
+
fun isCurrentProfileInitialized() = currentProfile.wasInitialized()
@Synchronized override fun updateProfile(profile: Profile) {