1
1
package net .seesharpsoft .intellij .plugins .csv .editor ;
2
2
3
3
import com .intellij .openapi .editor .EditorSettings ;
4
- import com .intellij .openapi .fileEditor .FileEditor ;
5
- import com .intellij .openapi .fileEditor .FileEditorPolicy ;
6
- import com .intellij .openapi .fileEditor .FileEditorProvider ;
7
- import com .intellij .openapi .fileEditor .TextEditor ;
4
+ import com .intellij .openapi .fileEditor .*;
8
5
import com .intellij .openapi .fileEditor .ex .FileEditorProviderManager ;
6
+ import com .intellij .openapi .fileEditor .impl .text .TextEditorState ;
9
7
import com .intellij .testFramework .fixtures .LightCodeInsightFixtureTestCase ;
8
+ import org .jdom .Element ;
10
9
11
10
public class CsvFileEditorTest extends LightCodeInsightFixtureTestCase {
12
11
@@ -18,11 +17,11 @@ protected String getTestDataPath() {
18
17
@ Override
19
18
protected void setUp () throws Exception {
20
19
super .setUp ();
21
- }
22
20
23
- public void testCsvFileEditorProviderIsAvailableAndHasCorrectNameAndPolicy () {
24
21
myFixture .configureByFiles ("AnyFile.csv" );
22
+ }
25
23
24
+ public void testCsvFileEditorProviderIsAvailableAndHasCorrectNameAndPolicy () {
26
25
FileEditorProvider [] fileEditorProviders = FileEditorProviderManager .getInstance ().getProviders (myFixture .getProject (), myFixture .getFile ().getVirtualFile ());
27
26
assertEquals (1 , fileEditorProviders .length );
28
27
assertInstanceOf (fileEditorProviders [0 ], CsvFileEditorProvider .class );
@@ -38,8 +37,6 @@ private void disposeTextEditor(FileEditor fileEditor) {
38
37
}
39
38
40
39
public void testCsvEditorIsTextEditorWithInitialCsvEditorSettings () {
41
- myFixture .configureByFiles ("AnyFile.csv" );
42
-
43
40
FileEditorProvider [] fileEditorProviders = FileEditorProviderManager .getInstance ().getProviders (myFixture .getProject (), myFixture .getFile ().getVirtualFile ());
44
41
FileEditor fileEditor = fileEditorProviders [0 ].createEditor (myFixture .getProject (), myFixture .getFile ().getVirtualFile ());
45
42
assertInstanceOf (fileEditor , TextEditor .class );
@@ -60,8 +57,6 @@ private TextEditor getCurrentTextEditor() {
60
57
}
61
58
62
59
public void testCsvEditorSettingsAreApplied () {
63
- myFixture .configureByFiles ("AnyFile.csv" );
64
-
65
60
CsvEditorSettingsExternalizable csvEditorSettingsExternalizable = CsvEditorSettingsExternalizable .getInstance ();
66
61
csvEditorSettingsExternalizable .setCaretRowShown (false );
67
62
csvEditorSettingsExternalizable .setUseSoftWraps (true );
@@ -74,5 +69,20 @@ public void testCsvEditorSettingsAreApplied() {
74
69
75
70
disposeTextEditor (textEditor );
76
71
}
72
+
73
+ public void testCsvEditorStateReadsAndWritesStates () {
74
+ TextEditor textEditor = getCurrentTextEditor ();
77
75
76
+ FileEditorProvider [] fileEditorProviders = FileEditorProviderManager .getInstance ().getProviders (myFixture .getProject (), myFixture .getFile ().getVirtualFile ());
77
+ CsvFileEditorProvider fileEditorProvider = (CsvFileEditorProvider )fileEditorProviders [0 ];
78
+ Element dummy = new Element ("dummy" );
79
+
80
+ FileEditorState state = fileEditorProvider .readState (dummy , this .getProject (), this .getFile ().getVirtualFile ());
81
+ assertInstanceOf (state , TextEditorState .class );
82
+ textEditor .setState (state );
83
+ fileEditorProvider .writeState (state , this .getProject (), dummy );
84
+
85
+ disposeTextEditor (textEditor );
86
+ }
87
+
78
88
}
0 commit comments