@@ -30,6 +30,7 @@ public class CoreTest {
3030 private File m_testFile ;
3131 private File m_passwordTestFile ;
3232 private File m_spreadsheetTestFile ;
33+ private File m_docxTestFile ;
3334
3435 @ BeforeClass
3536 public static void startServer () throws InterruptedException {
@@ -89,6 +90,10 @@ public void extractTestFile() throws IOException {
8990 try (InputStream inputStream = assetManager .open ("spreadsheet-test.ods" )) {
9091 copy (inputStream , m_spreadsheetTestFile );
9192 }
93+ m_docxTestFile = new File (appCtx .getCacheDir (), "style-various-1.docx" );
94+ try (InputStream inputStream = assetManager .open ("style-various-1.docx" )) {
95+ copy (inputStream , m_docxTestFile );
96+ }
9297 }
9398
9499 @ After
@@ -102,6 +107,9 @@ public void cleanupTestFile() {
102107 if (null != m_spreadsheetTestFile ) {
103108 m_spreadsheetTestFile .delete ();
104109 }
110+ if (null != m_docxTestFile ) {
111+ m_docxTestFile .delete ();
112+ }
105113 }
106114
107115 private static void copy (InputStream src , File dst ) throws IOException {
@@ -138,6 +146,30 @@ public void test() {
138146 Assert .assertEquals (0 , result .errorCode );
139147 }
140148
149+ @ Test
150+ public void testDocxEdit () {
151+ File cacheDir = InstrumentationRegistry .getInstrumentation ().getTargetContext ().getCacheDir ();
152+ File outputPath = new File (cacheDir , "core_output_docx" );
153+ File cachePath = new File (cacheDir , "core_cache" );
154+
155+ CoreWrapper .CoreOptions coreOptions = new CoreWrapper .CoreOptions ();
156+ coreOptions .inputPath = m_docxTestFile .getAbsolutePath ();
157+ coreOptions .outputPath = outputPath .getPath ();
158+ coreOptions .editable = true ;
159+ coreOptions .cachePath = cachePath .getPath ();
160+
161+ CoreWrapper .CoreResult coreResult = CoreWrapper .hostFile ("docx-edit" , coreOptions );
162+ Assert .assertEquals (0 , coreResult .errorCode );
163+
164+ File resultFile = new File (cacheDir , "result_docx" );
165+ coreOptions .outputPath = resultFile .getPath ();
166+
167+ String htmlDiff = "{\" modifiedText\" :{\" /child:16/child:0/child:0\" :\" Outasdfsdafdline\" ,\" /child:24/child:0/child:0\" :\" Colorasdfasdfasdfed Line\" ,\" /child:6/child:0/child:0\" :\" Text hello world!\" }}" ;
168+
169+ CoreWrapper .CoreResult result = CoreWrapper .backtranslate (coreOptions , htmlDiff );
170+ Assert .assertEquals (0 , result .errorCode );
171+ }
172+
141173 @ Test
142174 public void testPasswordProtectedDocumentWithoutPassword () {
143175 File cacheDir = InstrumentationRegistry .getInstrumentation ().getTargetContext ().getCacheDir ();
0 commit comments