[Ktechlab-devel] test-cases using KDevelop::Core

Julian Bäume julian at svg4all.de
Sun Apr 11 19:54:03 UTC 2010


hi,
after this weekend and fiddling around with project management, I want to 
correct some things I wrote in my last mail:

On Friday 09 April 2010 17:54:51 Julian Bäume wrote:
> On Wednesday 07 April 2010 12:44:51 P Zoltan wrote:
> > On Fri, 02 Apr 2010 02:13:51 +0200, Julian Bäume <julian at svg4all.de> 
wrote: 
> Currently, there is no way to create new documents. At least I haven't
> implemented it, yet :D
>
> > core->documentControler()->factory("application/x-circuit")->create( url,
> > core) 
> That line seems to be the right choice. If you pass KUrl(), Core::self(),
> it should do the following things:
>  * create a temporary file
>  * put a valid XML skeleton into this file
>  * create a new CircuitDocument and load the file
> 
> That should be done by an IDocumentFactory instance. This is created by
> KTLCircuitPlugin. There is already an implementation, which needs to be
> extended to handle empty KUrls.
This is basically it But I mentioned some misunderstandings I had with the 
KDevPlatform API. There is one more case to be handled. So all in all we have 
got 4 cases the factory needs to care of:

1. the file already exists and there is valid XML in there.
 - this is the case, that is implemented at the moment
 - the document will be loaded and the model is populated with the data from 
the circuit file

2. the file already exists and it is empty
 - this happens, when a new file is added to the project. The 
ProjectFileManager is supposed to create the file in the file system, when it 
doesn't exist. This is what the apidocs of KDevPlatform say and so I 
implemented it accordingly.
 - in this case, an empty model needs to be created containing the basic 
information about the circuit. At this point, there are no components in the 
model.

3. the url == KUrl()
 - this is the case i described above. this happens, when a file is created 
without a project. I'm not sure, if this is possible to do from the GUI, but 
when creating it manually from within the test-cases, this can happen.

4. the file doesn't exist
I'm not sure what to do in this case. IMHO this is undefined and we should 
return an invalid / 0-pointer document. Another possibility would be to handle 
it like 3. but not to create a temporary file but create the file represented 
by the url parameter.

Another thing that just came into my mind: what about an existing file without 
any valid XML circuit content in it. I think, we shouldn't just overwrite it 
with some valid circuit data, in this case.

Some status updates:
I'm just about to finish the project management. The tests are implemented and 
the tests concerning file handling already pass, so this seems to work. I've 
still some problems with sub-projects (i.e. folders). I need to figure out, 
what I do wrong and after that, this can be merged into the kde4-port branch. 
And we are ready to handle .ktechlab files again.

As a next step, I want to have the same thing for circuit files. Reading 
already works, but writing the model to disk is not implemented,yet. Zoltan, 
you already started working on implementing tests on this, so I guess, we will 
have something working, soon. It is already possible to delete Components from 
the scene, these events just need to be propagated to the model and writing 
the model to disk needs to be implemented. This shouldn't be too hard. All 
this should be covered by unit-tests, of course.

bye then
julian




More information about the Ktechlab-devel mailing list