]> git.sven.stormbind.net Git - sven/vym.git/blob - test/vym-test.rb
Import Upstream version 2.6.11
[sven/vym.git] / test / vym-test.rb
1 #!/usr/bin/env ruby
2
3 require "#{ENV['PWD']}/scripts/vym-ruby"
4 require 'date'
5 require 'optparse'
6
7 instance_name = 'test'
8
9 options = {}
10 OptionParser.new do |opts|
11   opts.banner = "Usage: vym-test.rb [options]"
12
13   opts.on('-d', '--directory  NAME', 'Directory name') { |s| options[:testdir] = s }
14 end.parse!
15
16 @testdir = options[:testdir]
17
18 $tests_passed = 0
19 $tests_failed = 0
20 $tests_total  = 0
21
22 def waitkey
23   puts "Press return to continue..."
24   STDIN.gets
25 end
26
27 def expect (comment, v_real, v_exp)
28   if v_exp == v_real
29     puts "    Ok: #{comment}"
30     $tests_passed += 1
31   else  
32     puts "Failed: #{comment}. Expected '#{v_exp}', but got '#{v_real}'"
33     $tests_failed += 1
34     waitkey
35   end  
36   $tests_total += 1
37 end    
38
39 def expect_error (comment, error)
40   if error.length ==  0
41     puts "Failed: #{comment}. Command did not return error."
42     $tests_failed += 1
43   else  
44     puts "    Ok: #{comment}"
45     $tests_passed += 1
46   end
47   $tests_total += 1
48 end
49
50 def heading (s)
51   puts "\n#{s}\n#{'-' * s.length}\n"
52 end
53
54 def init_map
55   # FIXME-2 Missing: check or init default map 
56   # Map Structure:
57   # MapCenter 0
58   #   Main A
59   #     branch a
60   #       branch a1
61   #       branch a2
62   #       branch a3
63   #   Main B
64   # MapCenter 1
65 end
66
67 def summary
68   puts "\nTests done  : #{$tests_total}"
69   puts "Tests passed: #{$tests_passed}"
70   puts "Tests failed: #{$tests_failed}"
71 end
72
73 vym_mgr=VymManager.new
74 #vym_mgr.show_running
75
76 vym=vym_mgr.find(instance_name)
77 if !vym
78   puts "Couldn't find instance name \"#{instance_name}\", please start one:"
79   puts "vym -l -n \"#{instance-name}\" -t test/default.vym"
80   exit
81 end
82
83
84 #######################
85 @center_0="mc:0"
86 @center_1="mc:1"
87 @main_a="mc:0,bo:0"
88   @branch_a=@main_a+",bo:0"
89   @branch_b=@main_a+",bo:1"
90   @branch_c=@main_a+",bo:2"
91 @main_b="mc:0,bo:1"
92
93 @n_centers=2
94
95 #######################
96 def test_basics (vym)
97   heading "Basic checks:"
98   init_map
99   vym.select @main_a
100   expect "select mainbranch A", vym.getSelectString, @main_a
101   expect "getHeadingPlainText", vym.getHeadingPlainText, "Main A"
102   expect "branchCount", vym.branchCount, 3
103
104   vym.selectLastBranch
105   expect "selectLastBranch", vym.getHeadingPlainText, "branch c"
106
107   vym.selectParent
108   expect "selectParent", vym.getHeadingPlainText, "Main A"
109
110   expect "getDestPath: Got #{vym.getDestPath}", vym.getDestPath, @testdir + "/testmap.vym" 
111   expect "getFileDir:  Got #{vym.getFileDir}", vym.getFileDir, @testdir + "/" 
112 end
113
114 #######################
115 def test_export (vym)
116   heading "Export:"
117   init_map
118
119   #HTML
120   mapname = "export-html"
121   htmlpath = "#{@testdir}/#{mapname}.html"
122   flagpath = "#{@testdir}/flags/flag-stopsign.png"
123   pngpath = "#{@testdir}/#{mapname}.png"
124   csspath = "#{@testdir}/vym.css"
125   vym.exportHTML(@testdir,htmlpath)
126   expect "exportHTML: HTML file exists", File.exists?(htmlpath), true
127   expect "exportHTML: HTML image exists", File.exists?(pngpath), true
128   expect "exportHTML: HTML flags exists", File.exists?(flagpath), true
129   expect "exportHTML: HTML CSS exists", File.exists?(csspath), true
130   File.delete(htmlpath)
131   File.delete(flagpath)
132   File.delete(pngpath)
133   File.delete(csspath)
134   vym.exportLast
135   expect "exportLast: HTML #{htmlpath} file exists", File.exists?(htmlpath), true
136   expect "exportLast: HTML image exists", File.exists?(pngpath), true
137   expect "exportLast: HTML flags exists", File.exists?(flagpath), true
138   expect "exportLast: HTML CSS exists", File.exists?(csspath), true
139
140   #AO
141   filepath = "#{@testdir}/export-ao.txt"
142   vym.exportAO(filepath)
143   expect "exportAO:    AO file exists", File.exists?(filepath), true
144   File.delete(filepath)
145   vym.exportLast
146   expect "exportLast:  AO file exists", File.exists?(filepath), true
147
148   #ASCII
149   filepath = "#{@testdir}/export-ascii.txt"
150   vym.exportASCII(filepath,false)
151   expect "exportASCII: ASCII file exists", File.exists?(filepath), true
152   File.delete(filepath)
153   vym.exportLast
154   expect "exportLast:  ASCII file exists", File.exists?(filepath), true
155
156   #CSV
157   filepath = "#{@testdir}/export-csv.txt"
158   vym.exportCSV(filepath)
159   expect "exportCSV:    CSV file exists", File.exists?(filepath), true
160   File.delete(filepath)
161   vym.exportLast
162   expect "exportLast:  CSV file exists", File.exists?(filepath), true
163
164   #Image
165   filepath = "#{@testdir}/export-image.png"
166   vym.exportImage(filepath,"PNG")
167   expect "exportImage: PNG file exists", File.exists?(filepath), true
168   File.delete(filepath)
169   vym.exportLast
170   expect "exportLast:  PNG file exists", File.exists?(filepath), true
171
172   #LaTeX
173   filepath = "#{@testdir}/export-LaTeX.tex"
174   vym.exportLaTeX(filepath)
175   expect "exportLaTeX:  LaTeX file exists", File.exists?(filepath), true
176   File.delete(filepath)
177   vym.exportLast
178   expect "exportLast:   LaTeX file exists", File.exists?(filepath), true
179
180   #OrgMode
181   filepath = "#{@testdir}/export-orgmode.org"
182   vym.exportOrgMode(filepath)
183   expect "exportOrgMode:  OrgMode file exists", File.exists?(filepath), true
184   File.delete(filepath)
185   vym.exportLast
186   expect "exportLast:     OrgMode file exists", File.exists?(filepath), true
187
188   #PDF
189   filepath = "#{@testdir}/export-pdf.pdf"
190   vym.exportPDF(filepath)
191   expect "exportPDF:  PDF file exists", File.exists?(filepath), true
192   File.delete(filepath)
193   vym.exportLast
194   expect "exportLast: PDF file exists", File.exists?(filepath), true
195
196   #SVG
197   filepath = "#{@testdir}/export-svg.svg"
198   vym.exportSVG(filepath)
199   expect "exportSVG:  SVG file exists", File.exists?(filepath), true
200   File.delete(filepath)
201   vym.exportLast
202   expect "exportLast: SVG file exists", File.exists?(filepath), true
203
204   #XML
205   filepath = "#{@testdir}/export-xml.xml"
206   vym.exportXML(@testdir, filepath)
207   expect "exportXML: XML file exists", File.exists?(filepath), true
208   File.delete(filepath)
209   vym.exportLast
210   expect "exportLast: XML file exists", File.exists?(filepath), true
211
212   #OpenOffice Impress //FIXME-2
213   #KDE4 Bookmarks //FIXME-2
214   #Taskjuggler //FIXME-3
215 end
216
217 #######################
218 def test_extrainfo (vym)
219   heading "Extra information:"
220   init_map
221   vym.setMapAuthor("Fra Erasmas")
222   expect "Set and get map author", vym.getMapAuthor, "Fra Erasmas"
223   vym.setMapComment("xy z")
224   expect "Set and get map comment", vym.getMapComment, "xy z"
225   vym.setMapTitle("vym rules!")
226   expect "Set and get map title", vym.getMapTitle, "vym rules!"
227 end
228
229 #######################
230 def test_adding_branches (vym)
231   heading "Adding branches:"
232   init_map
233   vym.select @main_a
234   n=vym.branchCount
235   vym.addBranch()
236   expect( "addBranch", vym.branchCount, n+1 )
237
238   vym.selectLatestAdded
239   expect "selectLatestAdded", vym.getSelectString, @main_a+",bo:3"
240
241   vym.undo
242   expect( "Undo: addBranch", vym.branchCount, n )
243
244   init_map
245   vym.select @main_a
246   n=vym.branchCount
247   vym.select @branch_a
248   vym.addBranch(-3)
249   vym.addBranch(-1)
250   vym.select @main_a
251   expect "addBranchAbove/Below", vym.branchCount, n+2
252
253   vym.undo
254   vym.undo
255   expect "Undo: addBranchAbove/Below", vym.branchCount, n
256
257   init_map
258   vym.select @branch_a
259   vym.addBranchBefore
260   vym.select @main_a
261   expect "addBranchBefore: check branchcount",  vym.branchCount, n
262   vym.select @branch_a
263   expect "addBranchBefore: check heading", vym.getHeadingPlainText, ""
264   vym.undo
265   vym.select @main_a
266   expect "Undo: addBranchBefore", vym.branchCount, n  
267 end
268
269 #######################
270 def test_adding_maps (vym)
271   heading "Adding maps"
272   init_map
273   vym.select @branch_a
274   n=vym.branchCount
275   vym.addMapReplace "test/default.vym"
276   vym.select @main_a
277   expect "addMapReplace: check branch count in #{@main_a}", vym.branchCount, n + @n_centers -1
278   vym.select @branch_a
279   expect "addMapReplace: check if #{@branch_a} is new", vym.branchCount, 2
280   
281   vym.undo
282   vym.select @main_a
283   expect "Undo: check branch count in #{@main_a}", vym.branchCount, 3
284   vym.select @branch_a
285   expect "Undo: check if #{@branch_a} is back", vym.branchCount, 3 
286   
287   init_map
288   vym.select @main_a
289   vym.addMapInsert "test/default.vym",1
290   vym.select @main_a
291   expect "addMapInsert: branch count",  vym.branchCount, n+2 
292   vym.select @main_a + ",bo:1"
293   expect "addMapInsert: new heading", vym.getHeadingPlainText, "MapCenter 0"
294   
295   vym.undo
296   vym.select @main_a
297   expect "Undo: check branch count in #{@main_a}", vym.branchCount, 3 
298   vym.select @branch_b
299   expect "Undo: check heading of  #{@branch_b}",  vym.getHeadingPlainText, "branch b"
300 end
301
302 #######################
303 def test_scrolling (vym)
304   heading "Scrolling and unscrolling"
305   init_map
306   vym.select @main_a
307   vym.toggleScroll
308   expect "toggleScroll", vym.isScrolled, true
309   vym.undo
310   expect "undo toggleScroll", vym.isScrolled, false
311   vym.scroll
312   expect "scroll", vym.isScrolled, true
313   vym.unscroll
314   expect "unscroll", vym.isScrolled, false
315
316   init_map
317   vym.scroll
318   vym.select @branch_a
319   vym.scroll
320   vym.select @main_a
321   vym.unscrollChildren
322   vym.select @branch_a
323   expect "unscrollChildren", vym.isScrolled, false
324   vym.undo
325   expect "undo unscrollChildren", vym.isScrolled, true
326   vym.unscroll
327   vym.select @branch_a
328   vym.unscroll
329 end
330
331 #######################
332 def test_moving_parts (vym)
333   heading "Moving parts"
334   init_map
335   vym.select @branch_a
336   vym.moveDown
337   vym.select @branch_a
338   expect "Moving down", vym.getHeadingPlainText, "branch b"
339   vym.undo
340   vym.select @branch_a
341   expect "Undo Moving down", vym.getHeadingPlainText, "branch a"
342   
343   init_map
344   vym.select @branch_b
345   vym.moveUp
346   vym.select @branch_a
347   expect "Moving up", vym.getHeadingPlainText, "branch b"
348   vym.undo
349   vym.select @branch_b
350   expect "Undo Moving up", vym.getHeadingPlainText, "branch b"
351   
352   init_map
353   vym.select @main_b
354   n=vym.branchCount
355   vym.select @branch_a
356   vym.relinkTo @main_b,0,0,0
357   vym.select @main_b
358   expect "RelinkTo #{@main_b}: branchCount increased there",  vym.branchCount, n+1
359
360   vym.undo
361   vym.select @branch_b
362   expect "Undo: RelinkTo #{@main_b}: branchCount decreased there", vym.branchCount, n
363   
364   init_map
365   vym.select @main_a
366   err = vym.relinkTo @branch_a,0,0,0
367   expect_error "RelinkTo myself fails.", err
368
369   vym
370   init_map
371   vym.select @branch_a
372   n=vym.branchCount
373   vym.select @main_b
374   vym.relinkTo @branch_a, 1, 0, 0
375   vym.select @branch_a
376   expect "RelinkTo #{@branch_a}, pos 1: branchCount increased there",  vym.branchCount, n+1
377   vym.select "#{@branch_a},bo:1"
378   expect "RelinkTo #{@branch_a}, pos 1: Mainbranch really moved", vym.getHeadingPlainText, "Main B"
379   vym.undo
380   vym.select @center_0
381   expect "Undo RelinkTo pos 1: branchCount of center", vym.branchCount, 2
382   # FIXME-2 still has wrong position, check position
383   vym.select @main_b
384   vym.moveRel 100,100
385 end
386
387 #######################
388 def test_modify_branches (vym)
389   heading "Modifying branches"
390   init_map
391   vym.select @branch_a
392   vym.setHeadingPlainText "Changed!"
393   expect "setHeadingPlainText", vym.getHeadingPlainText, "Changed!"
394   vym.undo
395   expect "Undo: setHeadingPlainText", vym.getHeadingPlainText, "branch a"
396   vym.redo
397   expect "redo: setHeadingPlainText", vym.getHeadingPlainText, "Changed!" 
398   vym.undo
399 end  
400   
401 #######################
402 def test_flags (vym)
403   heading "Flags"
404   init_map
405   vym.select @main_a
406   
407   def set_flags (v,a)
408     a.each do |f|
409     v.setFlag f
410     expect "Flag set: #{f}", v.hasActiveFlag(f), true
411     end
412   end
413   
414   def unset_flags (v,a)
415     a.each do |f|
416     v.unsetFlag f
417     expect "Flag unset: #{f}", v.hasActiveFlag(f), false
418     end
419   end
420   
421   # Group standard-mark
422   set_flags vym,[ "exclamationmark","questionmark"]
423   
424   # Group standard-status
425   set_flags vym, [ "hook-green", 
426     "wip", 
427     "cross-red", 
428     "stopsign" ]
429   
430   # Group standard-smiley
431   smileys = [ "smiley-good",
432       "smiley-sad",
433       "smiley-omb" ]
434   set_flags vym, smileys
435   
436   # Group standard-arrow
437   set_flags vym, [ "arrow-up", 
438     "arrow-down", 
439     "2arrow-up", 
440     "2arrow-down" ]
441   
442   # Group standard-thumb
443   set_flags vym, [ "thumb-up", "thumb-down" ]
444   
445   # Without group
446   set_flags vym, [ "clock",
447     "phone",
448     "lamp",
449     "rose",
450     "heart",
451     "present",
452     "flash",
453     "info",
454     "lifebelt" ]
455   
456   unset_flags vym, smileys
457   
458   vym.clearFlags
459   expect "clearFlags cleared exclamationmark", vym.hasActiveFlag( "exclamationmark" ), false
460   expect "clearFlags cleared smiley-good", vym.hasActiveFlag( "smiley-good" ), false
461   
462   vym.toggleFlag "lifebelt"
463   expect "toggleFlag: flag activated", vym.hasActiveFlag("lifebelt"),true
464   vym.toggleFlag "lifebelt"
465   expect "toggleFlag: flag deactivated", vym.hasActiveFlag("lifebelt"),false
466 end
467
468 #######################
469 def test_delete_parts (vym)
470   heading "Deleting parts"
471   init_map
472   vym.select @main_a
473   n=vym.branchCount
474   vym.select @branch_a
475   m=vym.branchCount
476   vym.delete
477   vym.select @main_a
478   expect "Delete branch: branchcount",  vym.branchCount, n-1
479   vym.undo
480   vym.select @main_a
481   expect "Undo Delete branch: branchcount parent", vym.branchCount, n
482   vym.select @branch_a
483   expect "Undo Delete branch: branchcount restored branch", vym.branchCount, m
484   
485   init_map
486   vym.select @branch_a
487   n=vym.branchCount
488   vym.deleteChildren
489   vym.select @branch_a
490   expect "deleteChildren: branchcount", vym.branchCount, 0
491   vym.undo
492   vym.select @branch_a
493   expect "Undo: deleteChildren: branchcount", vym.branchCount, n
494   
495   init_map
496   vym.select @main_a
497   n=vym.branchCount
498   vym.select @branch_a
499   m=vym.branchCount
500   vym.deleteKeepChildren
501   vym.select @main_a
502   expect "deleteKeepChildren: branchcount", vym.branchCount, n+m-1
503   vym.undo
504   vym.select @main_a
505   expect "Undo: deleteKeepChildren: branchcount of parent", vym.branchCount, n
506   vym.select @branch_a
507   expect "Undo: deleteKeepChildren: branchcount of branch", vym.branchCount, m
508
509   init_map
510   n = vym.centerCount
511   vym.select @center_1
512   vym.delete
513   expect "Delete mapCenter: number of centers decreased", vym.centerCount, n-1
514   vym.undo
515   expect "Undo Delete mapCenter: number of centers increased", vym.centerCount, n
516 end  
517
518 #######################
519 def test_copy_paste (vym)
520   heading "Copy, cut & Paste"
521   init_map
522   vym.select @main_a
523   n=vym.branchCount
524   
525   vym.copy
526   vym.paste
527   vym.selectLastBranch
528   s=vym.getSelectString
529   expect "Normal paste of branch, check heading of #{s}", vym.getHeadingPlainText, "Main A"
530   
531   vym.undo
532   vym.select @main_a
533   expect "Undo paste: branchCount of #{@main_a}", vym.branchCount, n
534   
535   vym.redo
536   vym.select s
537   expect "redo paste: check heading", vym.getHeadingPlainText, "Main A"
538   
539   vym.cut
540   vym.select @main_a
541   expect "cut: branchCount of #{@main_a}", vym.branchCount, n
542   vym.paste
543   vym.selectLastBranch
544   s=vym.getSelectString
545   expect "Normal paste of branch, check heading of #{s}", vym.getHeadingPlainText, "Main A"
546   vym.cut 
547 end 
548
549 #######################
550 def test_references (vym)
551   heading "References"
552   init_map
553   vym.select @main_a
554   vym.setURL "www.insilmaril.de"
555   expect "setURL:", vym.getURL, "www.insilmaril.de"
556   vym.undo
557   expect "undo setURL", vym.getURL, ""
558   vym.redo
559   expect "redo setURL", vym.getURL, "www.insilmaril.de"
560   vym.setURL ""
561   expect "setURL: unset URL with empty string", vym.getURL, ""
562   
563   vl="default.vym"
564   vym.setVymLink vl
565   s=vym.getVymLink
566   expect "setVymLink returns absolute path", vym.getVymLink, vym.getFileDir + vl
567   vym.undo
568   expect "undo: setVymLink", vym.getVymLink, ""
569   vym.redo
570   expect "redo: setVymLink", vym.getVymLink, s
571   vym.undo
572 end
573
574 #######################
575 def test_history (vym)
576   heading "History"
577   init_map
578   vym.select @main_a
579   vym.setHeadingPlainText "A"
580   vym.setHeadingPlainText "B"
581   vym.setHeadingPlainText "C"
582   vym.undo
583   vym.undo
584   vym.undo
585   expect "Undo 3 times", vym.getHeadingPlainText, "Main A"
586   vym.redo
587   expect "Redo once", vym.getHeadingPlainText, "A"
588   vym.copy
589   vym.redo
590   expect "Redo once more", vym.getHeadingPlainText, "B"
591   vym.redo
592   expect "Redo yet again", vym.getHeadingPlainText, "C"
593   vym.setHeadingPlainText "Main A"
594   vym.paste
595   vym.selectLastBranch
596   expect "Paste from the past", vym.getHeadingPlainText, "A"
597   vym.delete
598 end  
599
600 #######################
601 def test_xlinks (vym)
602   heading "XLinks:"
603   init_map
604   vym.addXLink("mc:0,bo:0","mc:0,bo:1",2,"#ff0000","Qt::DashDotLine")
605   vym.selectLatestAdded
606   expect "Default color of XLink", vym.getXLinkColor, "#ff0000"
607   expect "Default width of XLink", vym.getXLinkWidth, 2
608   expect "Default style of XLink", vym.getXLinkPenStyle, "Qt::DashDotLine"
609   expect "Default style of XLink begin", vym.getXLinkStyleBegin, "HeadFull"
610   expect "Default style of XLink end",   vym.getXLinkStyleEnd, "HeadFull"
611
612   vym.setXLinkWidth(3)
613   expect "New width of XLink", vym.getXLinkWidth, 3
614   vym.undo
615   expect "Undo width of XLink", vym.getXLinkWidth, 2
616
617   vym.setXLinkColor("#00ff00")
618   expect "New color of XLink", vym.getXLinkColor, "#00ff00"
619   vym.undo
620   expect "Undo color of XLink", vym.getXLinkColor, "#ff0000"
621
622   vym.setXLinkLineStyle("Qt::SolidLine")
623   expect "New style of XLink", vym.getXLinkPenStyle, "Qt::SolidLine"
624   vym.undo
625   expect "Undo style of XLink", vym.getXLinkPenStyle, "Qt::DashDotLine"
626
627   vym.setXLinkStyleBegin("None")
628   expect "New style of XLink begin", vym.getXLinkStyleBegin, "None"
629   vym.undo
630   expect "Undo style of XLink begin", vym.getXLinkStyleBegin, "HeadFull"
631
632   vym.setXLinkStyleEnd("None")
633   expect "New style of XLink end", vym.getXLinkStyleEnd, "None"
634   vym.undo
635   expect "Undo style of XLink end", vym.getXLinkStyleEnd, "HeadFull"
636
637   vym.delete
638 end
639
640 #######################
641 def test_tasks (vym)
642   heading "Tasks:"
643   init_map
644   vym.select @main_a
645   expect "Branch has no task before test", vym.hasTask, false
646   vym.toggleTask
647   expect "Toggle task", vym.hasTask, true
648   expect "Setting sleep days to 10", vym.setTaskSleep(10), true
649   expect "Task sleep when setting to integer", vym.getTaskSleepDays, 10
650
651   date_today = DateTime.now
652   date_later = date_today + 123
653   date_s = date_later.strftime("%Y-%m-%d") 
654   vym.setTaskSleep(date_s)
655   expect "Task sleep when setting to ISO date (#{date_s})", vym.getTaskSleepDays, 123
656 end
657
658 ######################
659 def test_notes (vym)
660   heading "Notes:"
661
662   # Plaintext notes basic actions 
663   init_map
664   vym.select @main_a
665   note_plain = "vymnote plaintext"
666   vym.setNotePlainText(note_plain)
667   expect "Set note to \"#{note_plain}\". Still plaintext?", vym.hasRichTextNote, false
668   vym.select @center_0
669   vym.select @main_a
670   expect "After reselect, is note plaintext?", vym.hasRichTextNote, false
671
672   note_plain = "<b>plaintext, not bold!</b>"
673   vym.setNotePlainText(note_plain)
674   expect "Set note to plaintext containing html tags. Still plaintext", vym.hasRichTextNote, false
675   note_new = vym.getNotePlainText
676   vym.select @center_0
677   vym.select @main_a
678   expect "After reselect, is note text unchanged?", vym.getNotePlainText, note_new
679   expect "After reselect, is note plaintext?", vym.hasRichTextNote, false
680
681   # Plaintext notes copy & paste
682   vym.copy
683   vym.paste
684   vym.selectLastBranch
685   s=vym.getSelectString
686   expect "After copy& paste: New note unchanged?", vym.getNotePlainText, note_plain
687   expect "After copy& paste: New note Still plaintext?", vym.hasRichTextNote, false
688   vym.delete
689
690   # Plaintext notes undo & redo
691   vym.select @main_a
692   vym.setNotePlainText('Foobar')
693   vym.undo
694   expect "Undo after setNotePlainText restores previous note", vym.getNotePlainText, note_plain
695   vym.redo
696   vym.select @main_a
697   expect "Redo restores previous note", vym.getNotePlainText, 'Foobar'
698
699   # Plaintext notes load & save
700   note_org = IO.read('test/note-plain.txt')
701   vym.loadNote("test/note-plain.txt") 
702   expect "Load plain text note from file. Still plaintext?", vym.hasRichTextNote, false
703   expect "Note contains 'not bold'", vym.getNotePlainText.include?("not bold"), true
704   filepath = "#{@testdir}/save-note.txt"
705   vym.saveNote(filepath)
706   expect "Save note to file. Check if it contains 'textMode=\"plainText\"'", IO.read(filepath).include?("textMode=\"plainText\""), true
707   expect "Save note to file. Check if it contains 'not bold'", IO.read(filepath).include?("not bold"), true
708   expect "Save note to file. Check if it contains '<b>' element", IO.read(filepath).include?("<b>"), true
709   expect "Save note to file. Check if it contains '<![CDATA['", IO.read(filepath).include?("<![CDATA["), true
710   
711   # Delete note
712   vym.setNotePlainText("")
713   expect "setNotePlainText(\"\") deletes note", vym.hasNote, false
714   
715   # RichText basic actions
716   init_map
717   vym.select @main_a
718   rt_note = '<vymnote  textMode="richText"><![CDATA[<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:\'Arial\'; font-size:12pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:\'DejaVu Sans Mono\'; color:#000000;">Rich Text note with <b>not bold text</b></span></p></body></html>]]></vymnote>'
719   vym.parseVymText(rt_note)
720   expect "parseVymText of richText note produces note", vym.hasNote, true
721   expect "parseVymText of richText note produces richText note", vym.hasRichTextNote, true
722   vym.select @center_0
723   vym.select @main_a
724   expect "After reselect, is note RichText?", vym.hasRichTextNote, true
725
726
727   # RichText notes copy & paste
728   rt_note = vym.getNoteXML  
729   vym.copy
730   vym.paste
731   vym.selectLastBranch
732   s=vym.getSelectString
733   expect "After copy& paste: New note Still RichText?", vym.hasRichTextNote, true
734   expect "After copy& paste: New note unchanged?", vym.getNoteXML, rt_note
735   vym.delete
736
737   # RichText notes undo & redo
738   vym.select @main_a
739   vym.setNotePlainText('Foobar')
740   vym.undo
741   expect "Undo after setNotePlainText restores RichText note", vym.getNoteXML, rt_note
742   vym.redo
743   vym.select @main_a
744   expect "Redo restores previous plaintext note", vym.getNotePlainText, 'Foobar'
745
746   # RichText notes load & save
747   vym.loadNote("test/note.html") 
748   expect "Load HTML note from file and try to detect textMode. Is RichText?", vym.hasRichTextNote, true
749   filepath = "#{@testdir}/save-note.txt"
750   vym.saveNote(filepath)
751   expect "Save note to file. Check if it contains 'textMode=\"richText\"'", IO.read(filepath).include?("textMode=\"richText\""), true
752   expect "Save note to file. Check if it contains 'bold'", IO.read(filepath).include?("bold"), true
753   expect "Save note to file. Check if it contains '<b>' element", IO.read(filepath).include?("<b>"), true
754   expect "Save note to file. Check if it contains '<![CDATA['", IO.read(filepath).include?("<![CDATA["), true
755   
756   # Delete note
757   vym.setNotePlainText("")
758   expect "setNotePlainText(\"\") deletes note", vym.hasNote, false
759
760   # Compatibility with version < 2.5.0  # FIXME missing
761 end
762
763 def test_headings (vym)
764   heading "Headings:"
765   # FIXME same checks like for notes above for headings
766 end
767   
768 ######################
769 def test_bugfixes (vym)
770   heading "Bugfixes:"
771   init_map
772   vym.select @main_b
773   expect "Mapcenter of #{@center_1} has no frame", vym.getFrameType, "NoFrame"
774 end
775
776 #######################
777 test_basics(vym)
778 test_export(vym)
779 test_extrainfo(vym)
780 test_adding_branches(vym)
781 test_adding_maps(vym)
782 test_scrolling(vym)
783 test_moving_parts(vym)
784 test_modify_branches(vym)
785 test_flags(vym)
786 test_delete_parts(vym)
787 test_copy_paste(vym)
788 test_references(vym)
789 test_history(vym)
790 test_xlinks(vym)
791 test_tasks(vym)
792 test_notes(vym)
793 test_headings(vym)
794 test_bugfixes(vym)
795 summary
796
797 =begin
798 # Untested commands:
799 #
800 addSlide
801 centerOnID
802 colorBranch
803 colorSubtree
804 cycleTask
805 delete (image)
806 deleteSlide
807 importDir
808 loadImage
809 loadNote
810 move
811 moveRel
812 moveSlideDown
813 moveSlideUp
814 note2URLs
815     paste
816 redo  
817 relinkTo (for images)
818 saveImage
819 saveNote
820 selectID
821 selectLastImage
822 selectLatestAdd
823 setFrameBorderWidth
824 setFrameBrushColor
825 setFrameIncludeChildren
826 setFramePadding
827 setFramePenColor
828 setFrameType
829     setHeading
830 setHideExport
831 setHideLinksUnselected
832 setIncludeImagesHorizontally
833 setIncludeImagesVertically
834 setMapAnimCurve
835 setMapAnimDuration
836 setMapBackgroundColor
837 setMapDefLinkColor
838 setMapLinkStyle
839 setMapRotation
840 setMapZoom
841 setNote
842 setScale
843 setSelectionColor
844 setTaskSleep
845     setURL
846     setVymLink
847   so far:
848 sortChildren
849 toggleFrameIncludeChildren
850 toggleTarget
851 toggleTask
852 =end