More tests

This commit is contained in:
Yevgen Muntyan 2011-01-22 23:22:09 -08:00
parent 5d0fb3fc25
commit 7f62a476c3
6 changed files with 149 additions and 7 deletions

View File

@ -0,0 +1,36 @@
require("munit")
require("_moo.os")
editor = moo.Editor.instance()
filenames = { moo.tempnam(), moo.tempnam(), moo.tempnam() }
encs = { 'UTF-8', 'UTF-16', 'UCS-4' }
for i = 1,3 do
if i == 1 then
oi1 = moo.OpenInfo.new_path(filenames[i]).dup()
oi2 = moo.OpenInfo.new_path(filenames[i], encs[i]).dup()
si = moo.SaveInfo.new_path(filenames[i], encs[i]).dup()
elseif i == 2 then
oi1 = moo.OpenInfo.new(gtk.GFile.new_for_path(filenames[i])).dup()
oi2 = moo.OpenInfo.new(gtk.GFile.new_for_path(filenames[i]), encs[i]).dup()
si = moo.SaveInfo.new(gtk.GFile.new_for_path(filenames[i]), encs[i]).dup()
else
oi1 = moo.OpenInfo.new_uri(gtk.GFile.new_for_path(filenames[i]).get_uri()).dup()
oi2 = moo.OpenInfo.new_uri(gtk.GFile.new_for_path(filenames[i]).get_uri(), encs[i]).dup()
si = moo.SaveInfo.new_uri(gtk.GFile.new_for_path(filenames[i]).get_uri(), encs[i]).dup()
end
ri = moo.ReloadInfo.new(encs[i]).dup()
doc = editor.new_file(oi1)
doc.set_text('blah')
tassert(doc.save())
tassert(doc.save_as(si))
tassert(doc.close())
doc = editor.open_file(oi2)
tassert(doc.get_text() == 'blah')
tassert(doc.reload())
tassert(doc.reload(ri))
tassert(doc.close())
end

View File

@ -112,7 +112,7 @@ function test_mix()
doc.close()
end
-- test_default()
-- test_set()
-- test_load()
test_default()
test_set()
test_load()
test_mix()

View File

@ -0,0 +1,63 @@
require('munit')
root = 'lua/fake/key/root'
count = 0
function new_key()
count = count + 1
return root .. '/key' .. tostring(count)
end
key = new_key()
moo.prefs_new_key_bool(key)
tassert(moo.prefs_get_bool(key) == false)
moo.prefs_set_bool(key, true)
tassert(moo.prefs_get_bool(key) == true)
moo.prefs_set_bool(key, false)
key = new_key()
moo.prefs_new_key_bool(key, true)
tassert(moo.prefs_get_bool(key) == true)
moo.prefs_set_bool(key, false)
tassert(moo.prefs_get_bool(key) == false)
moo.prefs_set_bool(key, true)
key = new_key()
moo.prefs_new_key_int(key)
tassert(moo.prefs_get_int(key) == 0)
moo.prefs_set_int(key, 8)
tassert(moo.prefs_get_int(key) == 8)
moo.prefs_set_int(key, 0)
key = new_key()
moo.prefs_new_key_int(key, 15)
tassert(moo.prefs_get_int(key) == 15)
moo.prefs_set_int(key, 8)
tassert(moo.prefs_get_int(key) == 8)
moo.prefs_set_int(key, 15)
key = new_key()
moo.prefs_new_key_string(key)
tassert(moo.prefs_get_string(key) == nil)
moo.prefs_set_string(key, 'blah')
tassert(moo.prefs_get_string(key) == 'blah')
moo.prefs_set_string(key, nil)
tassert(moo.prefs_get_string(key) == nil)
key = new_key()
moo.prefs_new_key_string(key, 'foo')
tassert(moo.prefs_get_string(key) == 'foo')
moo.prefs_set_string(key, 'blah')
tassert(moo.prefs_get_string(key) == 'blah')
moo.prefs_set_string(key, nil)
tassert(moo.prefs_get_string(key) == nil)
moo.prefs_set_string(key, 'foo')
key = new_key()
moo.prefs_new_key_string(key)
tassert(moo.prefs_get_filename(key) == nil)
moo.prefs_set_string(key, '/tmp/foo')
tassert(moo.prefs_get_filename(key) == '/tmp/foo')
moo.prefs_set_string(key, 'file:///tmp/foo')
tassert(moo.prefs_get_file(key).get_path() == '/tmp/foo')
moo.prefs_set_string(key, nil)

View File

@ -0,0 +1,43 @@
require("munit")
window = editor.new_window()
tassert(#window.get_docs() == 1)
tassert(window.get_docs()[1] == window.get_active_doc())
editor.new_doc(window)
tassert(#window.get_docs() == 2)
tassert(window.get_docs()[2] == window.get_active_doc())
tassert(window.close_all())
tassert(#window.get_docs() <= 1)
doc1 = window.get_active_doc()
if not doc1 then
doc1 = editor.new_doc(window)
end
doc2 = editor.new_doc(window)
doc3 = editor.new_doc(window)
doc4 = editor.new_doc(window)
tab1 = doc1.get_tab()
tab2 = doc2.get_tab()
tab3 = doc3.get_tab()
tab4 = doc4.get_tab()
view1 = doc1.get_view()
view2 = doc2.get_view()
view3 = doc3.get_view()
view4 = doc4.get_view()
tassert(window.get_n_tabs() == 4)
window.set_active_tab(tab3)
tassert(window.get_active_tab() == tab3)
tassert(window.get_active_doc() == doc3)
tassert(window.get_active_view() == view3)
window.set_active_doc(doc2)
tassert(window.get_active_tab() == tab2)
tassert(window.get_active_doc() == doc2)
tassert(window.get_active_view() == view2)
window.close()

View File

@ -14,7 +14,7 @@
*/
/**
* class:MooPane: (parent GtkObject)
* class:MooPane: (parent GtkObject) (moo.lua 0)
**/
#ifdef HAVE_CONFIG_H

View File

@ -14,15 +14,15 @@
*/
/**
* class:MooPaned: (parent GtkBin) (constructable)
* class:MooPaned: (parent GtkBin) (constructable) (moo.lua 0)
**/
/**
* boxed:MooPaneLabel:
* boxed:MooPaneLabel: (moo.lua 0)
**/
/**
* boxed:MooPaneParams:
* boxed:MooPaneParams: (moo.lua 0)
**/
#ifdef HAVE_CONFIG_H