@@ -73,10 +73,13 @@ bool TestXMLBeans::testXML2XSD()
73
73
if (!testXML2XSDParameters ()) {
74
74
return false ;
75
75
}
76
- if (!testXML2XSDLoadXSD ()) {
76
+ if (!testXML2XSDConfig ()) {
77
77
return false ;
78
78
}
79
- if (!testXML2XSDConfig ()) {
79
+ if (!testXML2XSDConfigCheck ()) {
80
+ return false ;
81
+ }
82
+ if (!testXML2XSDLoadXSD ()) {
80
83
return false ;
81
84
}
82
85
return true ;
@@ -88,10 +91,13 @@ bool TestXMLBeans::testXSD2XML()
88
91
if (!testXSD2XMLParameters ()) {
89
92
return false ;
90
93
}
91
- if (!testXSD2XMLRun ()) {
94
+ if (!testXSD2XMLConfig ()) {
92
95
return false ;
93
96
}
94
- if (!testXSD2XMLConfig ()) {
97
+ if (!testXSD2XMLConfigCheck ()) {
98
+ return false ;
99
+ }
100
+ if (!testXSD2XMLRun ()) {
95
101
return false ;
96
102
}
97
103
return true ;
@@ -172,6 +178,11 @@ bool TestXMLBeans::testXML2XSDRunInner(const QString &code,
172
178
app.mainWindow ()->loadFile (fileInput);
173
179
_factoryFileToRead = expectedDataFile ;
174
180
_factoryErrorInExecution = errorInExecution ;
181
+ QTemporaryFile file;
182
+ file.open ();
183
+ file.write (" a" );
184
+ file.close ();
185
+ app.data ()->setInst2XSDPath (file.fileName ());
175
186
app.mainWindow ()->controller ()->setXMLVsXSDFactory (this );
176
187
MainWindow *resultWindow = app.mainWindow ()->controller ()->generateXSDFromData ();
177
188
const bool result = NULL != resultWindow ;
@@ -254,6 +265,11 @@ bool TestXMLBeans::testXSD2XMLRunInner(const QString &code,
254
265
_factoryChooseElement = elementChosen ;
255
266
_factoryFileToRead = expectedDataFile ;
256
267
_factoryErrorInExecution = errorInExecution ;
268
+ QTemporaryFile file;
269
+ file.open ();
270
+ file.write (" a" );
271
+ file.close ();
272
+ app.data ()->setXsd2InstPath (file.fileName ());
257
273
app.mainWindow ()->controller ()->setXMLVsXSDFactory (this );
258
274
MainWindow *resultWindow = app.mainWindow ()->controller ()->generateDataFromXSD ();
259
275
const bool result = NULL != resultWindow ;
@@ -289,15 +305,58 @@ bool TestXMLBeans::testXML2XSDConfig()
289
305
if (!app.init ()) {
290
306
return error (" init" );
291
307
}
308
+ const QString ExpectedValue =" xyz2" ;
309
+ const QString ExpectedValue2 =" xyz3" ;
310
+ app.data ()->setInst2XSDPath (ExpectedValue);
311
+ if (!compare ( " Config 1" , ExpectedValue, Config::getString (Config::KEY_TOOLS_XMLBEANS_INST2XSD, " " ) ) ) {
312
+ return false ;
313
+ }
314
+ if (!compare ( " Config 2" , ExpectedValue, app.data ()->inst2XSDPath ()) ) {
315
+ return false ;
316
+ }
317
+ app.data ()->setInst2XSDPath (" " );
292
318
ConfigValidation configValidation;
293
- Config::saveString (Config::KEY_TOOLS_XMLBEANS_INST2XSD, " xyz" );
294
319
configValidation.init (app.data ());
295
- Config::saveString (Config::KEY_TOOLS_XMLBEANS_INST2XSD, " aaa" );
320
+ if (!setTextWidget (&configValidation, " pathInst2Xsd" , ExpectedValue2)) {
321
+ return error (" No widget" );
322
+ }
296
323
configValidation.save ();
297
324
//
298
- QString savedData = app.data ()->inst2XSDPath ();
299
- if (savedData != " xyz" ) {
300
- return error (QString (" Expected %1 found '%2'" ).arg (" xyz" ).arg (savedData));
325
+ if (!compare ( " Config 3" , ExpectedValue2, app.data ()->inst2XSDPath ()) ) {
326
+ return false ;
327
+ }
328
+ XMLToXSD testObject (app.data ());
329
+ if (!compare ( " Config 4" , ExpectedValue2, testObject.getInst2XSD ()) ) {
330
+ return false ;
331
+ }
332
+ return true ;
333
+ }
334
+
335
+ bool TestXMLBeans::testXML2XSDConfigCheck ()
336
+ {
337
+ _subTestName = " TestXMLBeans/testXML2XSDConfigCheck" ;
338
+ App app;
339
+ if (!app.init ()) {
340
+ return error (" init" );
341
+ }
342
+ app.data ()->setInst2XSDPath (" " );
343
+ if (XMLToXSD::checkForConfiguration (app.data (), NULL )) {
344
+ return error (" Empty" );
345
+ }
346
+ QString fileName ;
347
+ {
348
+ QTemporaryFile file;
349
+ file.open ();
350
+ file.write (" a" );
351
+ file.close ();
352
+ fileName = file.fileName ();
353
+ app.data ()->setInst2XSDPath (fileName);
354
+ if (!XMLToXSD::checkForConfiguration (app.data (), NULL )) {
355
+ return error (" Existent:" +fileName);
356
+ }
357
+ }
358
+ if (XMLToXSD::checkForConfiguration (app.data (), NULL )) {
359
+ return error (" Non Existent:" +fileName);
301
360
}
302
361
return true ;
303
362
}
@@ -309,15 +368,58 @@ bool TestXMLBeans::testXSD2XMLConfig()
309
368
if (!app.init ()) {
310
369
return error (" init" );
311
370
}
371
+ const QString ExpectedValue =" xyz2" ;
372
+ const QString ExpectedValue2 =" xyz3" ;
373
+ app.data ()->setXsd2InstPath (ExpectedValue);
374
+ if (!compare ( " Config 1" , ExpectedValue, Config::getString (Config::KEY_TOOLS_XMLBEANS_XSD2INST, " " ) ) ) {
375
+ return false ;
376
+ }
377
+ if (!compare ( " Config 2" , ExpectedValue, app.data ()->xsd2InstPath ()) ) {
378
+ return false ;
379
+ }
380
+ app.data ()->setXsd2InstPath (" " );
312
381
ConfigValidation configValidation;
313
- Config::saveString (Config::KEY_TOOLS_XMLBEANS_XSD2INST, " xyz" );
314
382
configValidation.init (app.data ());
315
- Config::saveString (Config::KEY_TOOLS_XMLBEANS_XSD2INST, " aaa" );
383
+ if (!setTextWidget (&configValidation, " pathXsd2Inst" , ExpectedValue2)) {
384
+ return error (" No widget" );
385
+ }
316
386
configValidation.save ();
317
387
//
318
- QString savedData = app.data ()->xsd2InstPath ();
319
- if (savedData != " xyz" ) {
320
- return error (QString (" Expected %1 found '%2'" ).arg (" xyz" ).arg (savedData));
388
+ if (!compare ( " Config 3" , ExpectedValue2, app.data ()->xsd2InstPath ()) ) {
389
+ return false ;
390
+ }
391
+ XSDToXML testObject (app.data ());
392
+ if (!compare ( " Config 4" , ExpectedValue2, testObject.getXSD2Inst ()) ) {
393
+ return false ;
394
+ }
395
+ return true ;
396
+ }
397
+
398
+ bool TestXMLBeans::testXSD2XMLConfigCheck ()
399
+ {
400
+ _subTestName = " TestXMLBeans/testXSD2XMLConfigCheck" ;
401
+ App app;
402
+ if (!app.init ()) {
403
+ return error (" init" );
404
+ }
405
+ app.data ()->setXsd2InstPath (" " );
406
+ if (XSDToXML::checkForConfiguration (app.data (), NULL )) {
407
+ return error (" Empty" );
408
+ }
409
+ QString fileName ;
410
+ {
411
+ QTemporaryFile file;
412
+ file.open ();
413
+ file.write (" a" );
414
+ file.close ();
415
+ fileName = file.fileName ();
416
+ app.data ()->setXsd2InstPath (fileName);
417
+ if (!XSDToXML::checkForConfiguration (app.data (), NULL )) {
418
+ return error (" Existent:" +fileName);
419
+ }
420
+ }
421
+ if (XSDToXML::checkForConfiguration (app.data (), NULL )) {
422
+ return error (" Non Existent:" +fileName);
321
423
}
322
424
return true ;
323
425
}
0 commit comments