• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Ruby GTK3移行後のメインリポジトリ


Commit MetaInfo

Revisão6a2e7ca7ed81b35663018e2c6b4e1e9ad28a6c55 (tree)
Hora2015-03-14 17:36:52
AutorShyouzou Sugitani <shy@user...>
CommiterShyouzou Sugitani

Mensagem de Log

split test code to separate files(3)

Mudança Sumário

Diff

--- a/lib/ninix/balloon.rb
+++ b/lib/ninix/balloon.rb
@@ -2,7 +2,7 @@
22 #
33 # Copyright (C) 2001, 2002 by Tamito KAJIYAMA
44 # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net>
5-# Copyright (C) 2002-2014 by Shyouzou Sugitani <shy@users.sourceforge.jp>
5+# Copyright (C) 2002-2015 by Shyouzou Sugitani <shy@users.sourceforge.jp>
66 # Copyright (C) 2003 by Shun-ichi TAHARA <jado@flowernet.gr.jp>
77 #
88 # This program is free software; you can redistribute it and/or modify it
@@ -1971,41 +1971,4 @@ module Balloon
19711971 @entry.set_visibility(false)
19721972 end
19731973 end
1974-
1975-
1976- class TEST
1977-
1978- def initialize
1979- require "ninix/home"
1980- balloons = Home.search_balloons()
1981- key = balloons.keys.sample
1982-# print(key, balloons[key], "\n")
1983- balloon = Balloon.new
1984- balloon.set_responsible(self)
1985- balloon.new_(*balloons[key])
1986- balloon.set_balloon(0, 0)
1987- balloon.set_balloon(1, 0)
1988- balloon.set_position(0, 200, 200)
1989- balloon.set_position(1, 100, 100)
1990- balloon.show(0)
1991- balloon.show(1)
1992- balloon.show_sstp_message("TEST: SSTP", "TEST class")
1993- for i in 0..20
1994- balloon.append_text(0, "TEST: SAKURA")
1995- end
1996- balloon.append_text(1, "TEST: KERO")
1997- Gtk.main
1998- end
1999-
2000- def handle_request(event_type, event, *arglist, **argdict)
2001- if event == 'lock_repaint'
2002- return false
2003- else
2004- return 100 # XXX
2005- end
2006- end
2007-
2008- end
20091974 end
2010-
2011-Balloon::TEST.new()
--- a/lib/ninix/home.rb
+++ b/lib/ninix/home.rb
@@ -2,7 +2,7 @@
22 #
33 # Copyright (C) 2001, 2002 by Tamito KAJIYAMA
44 # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net>
5-# Copyright (C) 2002-2014 by Shyouzou Sugitani <shy@users.sourceforge.jp>
5+# Copyright (C) 2002-2015 by Shyouzou Sugitani <shy@users.sourceforge.jp>
66 #
77 # This program is free software; you can redistribute it and/or modify it
88 # under the terms of the GNU General Public License (version 2) as
@@ -73,7 +73,7 @@ module Home
7373 basename = File.basename(filename, ".*")
7474 ext = File.extname(filename)
7575 ext = ext.downcase
76- if ['.py', '.pyc'].include?(ext)
76+ if ['.rb'].include?(ext)
7777 name = basename
7878 end
7979 if name and not table.include?(name)
@@ -914,128 +914,4 @@ module Home
914914 menu_items << ['Uninstall', []]
915915 return plugin_name, plugin_dir, startup, menu_items
916916 end
917-
918-### TEST ###
919-
920- class Test
921-
922- def initialize(path)
923- re_alias = Regexp.new('^(sakura|kero|char[0-9]+)\.surface\.alias$') # XXX
924- config = Home.load_config()
925- if config == nil
926- raise SystemExit('Home directory not found.\n')
927- end
928- ghosts, balloons, plugins, nekoninni, katochan, kinoko = config
929- # ghosts
930- for key in ghosts.keys
931- desc, shiori_dir, use_makoto, surface_set, prefix, shiori_dll, shiori_name = ghosts[key]
932- print('GHOST ', '=' * 50, "\n")
933- print("'", prefix, "'", "\n")
934- for k, v in desc.each_entry
935- print(k, ',', v, "\n")
936- end
937- print("\n")
938- print("'", shiori_dir, "'", "\n")
939- print(shiori_dll, "\n")
940- print(shiori_name, "\n")
941- print('use_makoto = ', use_makoto, "\n")
942- if surface_set
943- for name, surface_dir, desc, alias_, surface, tooltips in surface_set.values()
944- print('-' * 50, "\n")
945- print('surface: ', name, "\n")
946- for k, v in desc.each_entry
947- print(k, ',', v, "\n")
948- end
949- print("\n")
950- for k, v in surface.each_entry
951- print(k, ' = ', "'", v[0], "'", "\n")
952- if not v[1].empty?
953- for k1, v1 in v[1].each_entry
954- print(k1, ',', v1, "\n")
955- end
956- end
957- print("\n")
958- end
959- if alias_
960- buf = []
961- for k, v in alias_.each_entry
962- match = re_alias.match(k)
963- if match
964- print([k, ':'].join(''), "\n")
965- for alias_id, alias_list in v.each_entry
966- print(alias_id, \
967- [' = [', alias_list.join(', '), ']'].join(''), "\n")
968- end
969- print("\n")
970- else
971- buf << [k, v]
972- end
973- end
974- if not buf.empty?
975- print('filename alias:', "\n")
976- for k, v in buf
977- print(k, ' = ', v, "\n")
978- end
979- print("\n")
980- end
981- end
982- end
983- end
984- end
985- # balloons
986- for key in balloons.keys
987- desc, balloon = balloons[key]
988- print('BALLOON ', '=' * 50, "\n")
989- for k, v in desc.each_entry
990- print(k, ',', v, "\n")
991- end
992- print("\n")
993- for k, v in balloon.each_entry
994- print(k, ' = ', v[0], "\n")
995- if not v[1].empty?
996- for k1, v1 in v[1].each_entry
997- print(k1, ',', v1, "\n")
998- end
999- end
1000- print("\n")
1001- end
1002- end
1003- # plugins
1004- for plugin_name, plugin_dir, startup, menu_items in plugins
1005- print('PLUGIN ', '=' * 50, "\n")
1006- print('name = ', plugin_name, "\n")
1007- if startup
1008- print('startup = ', ['["', startup.join('", "'), '"]'].join(''), "\n")
1009- end
1010- for label, argv in menu_items
1011- print("menuitem ", "'", label.to_s, "'", " = ", "\n")
1012- print(['["', argv.join('", "'), '"]'].join(''), "\n")
1013- end
1014- end
1015- # nekoninni
1016- for nekoninni_name, nekoninni_dir in nekoninni
1017- print('NEKONINNI ', '=' * 50, "\n")
1018- print('name = ', nekoninni_name, "\n")
1019- print("'", nekoninni_dir, "'", "\n")
1020- end
1021- # katochan
1022- for katochan_item in katochan
1023- print('KATOCHAN ', '=' * 50, "\n")
1024- for k, v in katochan_item.each_entry
1025- print(k, ',', v, "\n")
1026- end
1027- end
1028- # kinoko
1029- for kinoko_item in kinoko
1030- print('KINOKO ', '=' * 50, "\n")
1031- for k, v in kinoko_item.each_entry
1032- print(k, ',', v, "\n")
1033- end
1034- end
1035- end
1036- end
1037917 end
1038-
1039-$:.unshift(File.dirname(__FILE__))
1040-
1041-Home::Test.new(ARGV.shift)
--- a/lib/ninix/ngm.rb
+++ b/lib/ninix/ngm.rb
@@ -1,7 +1,7 @@
11 # -*- coding: utf-8 -*-
22 #
33 # Copyright (C) 2001-2004 by MATSUMURA Namihiko <nie@counterghost.net>
4-# Copyright (C) 2004-2014 by Shyouzou Sugitani <shy@users.sourceforge.jp>
4+# Copyright (C) 2004-2015 by Shyouzou Sugitani <shy@users.sourceforge.jp>
55 #
66 # This program is free software; you can redistribute it and/or modify it
77 # under the terms of the GNU General Public License (version 2) as
@@ -932,20 +932,4 @@ module NGM
932932 @parent.handle_request('NOTIFY', 'update_sakura', self.get('Name'), 'NGM')
933933 end
934934 end
935-
936- class TEST
937-
938- def initialize
939- ngm = NGM.new()
940- ngm.set_responsible(self)
941- ngm.show_dialog()
942- Gtk.main
943- end
944-
945- def handle_request(event_type, event, *arglist, **argdict)
946- return ''
947- end
948- end
949935 end
950-
951-NGM::TEST.new
--- a/lib/ninix/pix.rb
+++ b/lib/ninix/pix.rb
@@ -1,6 +1,6 @@
11 # -*- coding: utf-8 -*-
22 #
3-# Copyright (C) 2003-2014 by Shyouzou Sugitani <shy@users.sourceforge.jp>
3+# Copyright (C) 2003-2015 by Shyouzou Sugitani <shy@users.sourceforge.jp>
44 #
55 # This program is free software; you can redistribute it and/or modify it
66 # under the terms of the GNU General Public License (version 2) as
@@ -351,42 +351,4 @@ module Pix
351351 left, top, width, height = root.geometry
352352 return left, top, width, height
353353 end
354-
355- class TEST
356-
357- def initialize(path)
358- @win = Pix::TransparentWindow.new
359- @win.signal_connect('destroy') do
360- Gtk.main_quit
361- end
362- @win.darea.signal_connect('draw') do |w, cr|
363- expose_cb(w, cr)
364- end
365- @surface = Pix.create_surface_from_file(path, true, true)
366- @win.set_default_size(@surface.width, @surface.height)
367- @win.show_all
368- Gtk.main
369- end
370-
371- def expose_cb(widget, cr)
372- cr.set_source(@surface, 0, 0)
373- cr.set_operator(Cairo::OPERATOR_SOURCE)
374- cr.paint
375- region = Cairo::Region.new()
376- data = @surface.data
377- for i in 0..(data.size / 4 - 1)
378- if (data[i * 4 + 3].ord) != 0
379- x = i % @surface.width
380- y = i / @surface.width
381- region.union!(x, y, 1, 1)
382- end
383- end
384- @win.input_shape_combine_region(region)
385- end
386- end
387354 end
388-
389-
390-$:.unshift(File.dirname(__FILE__))
391-
392-Pix::TEST.new(ARGV.shift)
--- a/lib/ninix/seriko.rb
+++ b/lib/ninix/seriko.rb
@@ -2,7 +2,7 @@
22 #
33 # Copyright (C) 2002 by Tamito KAJIYAMA
44 # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net>
5-# Copyright (C) 2002-2014 by Shyouzou Sugitani <shy@users.sourceforge.jp>
5+# Copyright (C) 2002-2015 by Shyouzou Sugitani <shy@users.sourceforge.jp>
66 #
77 # This program is free software; you can redistribute it and/or modify it
88 # under the terms of the GNU General Public License (version 2) as
@@ -920,39 +920,4 @@ ed)', "\n")
920920 mayuna = temp
921921 return mayuna
922922 end
923-
924-
925- class TEST
926-
927- # find ~/.ninix -name 'surface*a.txt' | xargs ruby seriko.rb
928- def initialize(list_path)
929- require "ninix/config"
930-# if len(sys.argv) == 1
931-# print('Usage:', sys.argv[0], '[surface??a.txt ...]')
932-# end
933- for filename in list_path
934- print('Reading', filename, '...', "\n")
935- for actor in Seriko.get_actors(NConfig.create_from_file(filename))
936- print('#', actor.get_id().to_i.to_s, "\n")
937- #print(actor.__class__.__name__,)
938- print('(', actor.get_interval(), ')', "\n")
939- print('number of patterns = ', actor.get_patterns().length, "\n")
940- for pattern in actor.get_patterns()
941- print('surface=', pattern[0], ', interval=', pattern[1].to_i.to_s, ', method=', pattern[2], ', args=', pattern[3], "\n")
942- end
943- end
944- for actor in Seriko.get_mayuna(NConfig.create_from_file(filename))
945- print('#', actor.get_id().to_i.to_s, "\n")
946- #print(actor.__class__.__name__,)
947- print('(', actor.get_interval(), ')', "\n")
948- print('number of patterns =', actor.get_patterns().length, "\n")
949- for pattern in actor.get_patterns()
950- print('surface=', pattern[0], ', interval=', pattern[1].to_i.to_s, ', method=', pattern[2], ', args=', pattern[3], "\n")
951- end
952- end
953- end
954- end
955- end
956923 end
957-
958-Seriko::TEST.new(ARGV)
--- a/lib/ninix/version.rb
+++ b/lib/ninix/version.rb
@@ -35,7 +35,7 @@ module Version
3535 '\_q' +
3636 'Copyright (c) 2001, 2002 Tamito KAJIYAMA\n' +
3737 'Copyright (c) 2002-2006 MATSUMURA Namihiko\n' +
38- 'Copyright (c) 2002-2014 Shyouzou Sugitani\n' +
38+ 'Copyright (c) 2002-2015 Shyouzou Sugitani\n' +
3939 'Copyright (c) 2002, 2003 ABE Hideaki\n' +
4040 'Copyright (c) 2003-2005 Shun-ichi TAHARA\e'
4141 end
--- /dev/null
+++ b/test/test-balloon.rb
@@ -0,0 +1,40 @@
1+require "ninix/home"
2+require "ninix/balloon"
3+
4+module NinixTest
5+
6+ class BalloonTest
7+
8+ def initialize
9+ balloons = Home.search_balloons()
10+ key = balloons.keys.sample
11+# print(key, balloons[key], "\n")
12+ balloon = Balloon::Balloon.new
13+ balloon.set_responsible(self)
14+ balloon.new_(*balloons[key])
15+ balloon.set_balloon(0, 0)
16+ balloon.set_balloon(1, 0)
17+ balloon.set_position(0, 200, 200)
18+ balloon.set_position(1, 100, 100)
19+ balloon.show(0)
20+ balloon.show(1)
21+ balloon.show_sstp_message("TEST: SSTP", "TEST class")
22+ for i in 0..20
23+ balloon.append_text(0, "TEST: SAKURA")
24+ end
25+ balloon.append_text(1, "TEST: KERO")
26+ Gtk.main
27+ end
28+
29+ def handle_request(event_type, event, *arglist, **argdict)
30+ if event == 'lock_repaint'
31+ return false
32+ else
33+ return 100 # XXX
34+ end
35+ end
36+
37+ end
38+end
39+
40+NinixTest::BalloonTest.new()
--- /dev/null
+++ b/test/test-home.rb
@@ -0,0 +1,126 @@
1+require "ninix/home"
2+
3+module NinixTest
4+
5+ class HomeTest
6+
7+ def initialize(path)
8+ re_alias = Regexp.new('^(sakura|kero|char[0-9]+)\.surface\.alias$') # XXX
9+ config = Home.load_config()
10+ if config == nil
11+ raise SystemExit('Home directory not found.\n')
12+ end
13+ ghosts, balloons, plugins, nekoninni, katochan, kinoko = config
14+ # ghosts
15+ for key in ghosts.keys
16+ desc, shiori_dir, use_makoto, surface_set, prefix, shiori_dll, shiori_name = ghosts[key]
17+ print('GHOST ', '=' * 50, "\n")
18+ print("'", prefix, "'", "\n")
19+ for k, v in desc.each_entry
20+ print(k, ',', v, "\n")
21+ end
22+ print("\n")
23+ print("'", shiori_dir, "'", "\n")
24+ print(shiori_dll, "\n")
25+ print(shiori_name, "\n")
26+ print('use_makoto = ', use_makoto, "\n")
27+ if surface_set
28+ for name, surface_dir, desc, alias_, surface, tooltips in surface_set.values()
29+ print('-' * 50, "\n")
30+ print('surface: ', name, "\n")
31+ for k, v in desc.each_entry
32+ print(k, ',', v, "\n")
33+ end
34+ print("\n")
35+ for k, v in surface.each_entry
36+ print(k, ' = ', "'", v[0], "'", "\n")
37+ if not v[1].empty?
38+ for k1, v1 in v[1].each_entry
39+ print(k1, ',', v1, "\n")
40+ end
41+ end
42+ print("\n")
43+ end
44+ if alias_
45+ buf = []
46+ for k, v in alias_.each_entry
47+ match = re_alias.match(k)
48+ if match
49+ print([k, ':'].join(''), "\n")
50+ for alias_id, alias_list in v.each_entry
51+ print(alias_id, \
52+ [' = [', alias_list.join(', '), ']'].join(''), "\n")
53+ end
54+ print("\n")
55+ else
56+ buf << [k, v]
57+ end
58+ end
59+ if not buf.empty?
60+ print('filename alias:', "\n")
61+ for k, v in buf
62+ print(k, ' = ', v, "\n")
63+ end
64+ print("\n")
65+ end
66+ end
67+ end
68+ end
69+ end
70+ # balloons
71+ for key in balloons.keys
72+ desc, balloon = balloons[key]
73+ print('BALLOON ', '=' * 50, "\n")
74+ for k, v in desc.each_entry
75+ print(k, ',', v, "\n")
76+ end
77+ print("\n")
78+ for k, v in balloon.each_entry
79+ print(k, ' = ', v[0], "\n")
80+ if not v[1].empty?
81+ for k1, v1 in v[1].each_entry
82+ print(k1, ',', v1, "\n")
83+ end
84+ end
85+ print("\n")
86+ end
87+ end
88+ # plugins
89+ for plugin_name, plugin_dir, startup, menu_items in plugins
90+ print('PLUGIN ', '=' * 50, "\n")
91+ print('name = ', plugin_name, "\n")
92+ if startup
93+ print('startup = ', ['["', startup.join('", "'), '"]'].join(''), "\n")
94+ end
95+ for label, argv in menu_items
96+ print("menuitem ", "'", label.to_s, "'", " = ", "\n")
97+ print(['["', argv.join('", "'), '"]'].join(''), "\n")
98+ end
99+ end
100+ # nekoninni
101+ for nekoninni_name, nekoninni_dir in nekoninni
102+ print('NEKONINNI ', '=' * 50, "\n")
103+ print('name = ', nekoninni_name, "\n")
104+ print("'", nekoninni_dir, "'", "\n")
105+ end
106+ # katochan
107+ for katochan_item in katochan
108+ print('KATOCHAN ', '=' * 50, "\n")
109+ for k, v in katochan_item.each_entry
110+ print(k, ',', v, "\n")
111+ end
112+ end
113+ # kinoko
114+ for kinoko_item in kinoko
115+ print('KINOKO ', '=' * 50, "\n")
116+ for k, v in kinoko_item.each_entry
117+ print(k, ',', v, "\n")
118+ end
119+ end
120+ end
121+ end
122+end
123+
124+$:.unshift(File.dirname(__FILE__))
125+
126+NinixTest::HomeTest.new(ARGV.shift)
--- /dev/null
+++ b/test/test-ngm.rb
@@ -0,0 +1,20 @@
1+require "ninix/ngm"
2+
3+module NinixTest
4+
5+ class NGMTest
6+
7+ def initialize
8+ ngm = NGM::NGM.new()
9+ ngm.set_responsible(self)
10+ ngm.show_dialog()
11+ Gtk.main
12+ end
13+
14+ def handle_request(event_type, event, *arglist, **argdict)
15+ return ''
16+ end
17+ end
18+end
19+
20+NinixTest::NGMTest.new
--- /dev/null
+++ b/test/test-pix.rb
@@ -0,0 +1,42 @@
1+require "ninix/pix"
2+
3+module NinixTest
4+
5+ class PixTest
6+
7+ def initialize(path)
8+ @win = Pix::TransparentWindow.new
9+ @win.signal_connect('destroy') do
10+ Gtk.main_quit
11+ end
12+ @win.darea.signal_connect('draw') do |w, cr|
13+ expose_cb(w, cr)
14+ end
15+ @surface = Pix.create_surface_from_file(path, true, true)
16+ @win.set_default_size(@surface.width, @surface.height)
17+ @win.show_all
18+ Gtk.main
19+ end
20+
21+ def expose_cb(widget, cr)
22+ cr.set_source(@surface, 0, 0)
23+ cr.set_operator(Cairo::OPERATOR_SOURCE)
24+ cr.paint
25+ region = Cairo::Region.new()
26+ data = @surface.data
27+ for i in 0..(data.size / 4 - 1)
28+ if (data[i * 4 + 3].ord) != 0
29+ x = i % @surface.width
30+ y = i / @surface.width
31+ region.union!(x, y, 1, 1)
32+ end
33+ end
34+ @win.input_shape_combine_region(region)
35+ end
36+ end
37+end
38+
39+
40+$:.unshift(File.dirname(__FILE__))
41+
42+NinixTest::PixTest.new(ARGV.shift)
--- /dev/null
+++ b/test/test-seriko.rb
@@ -0,0 +1,38 @@
1+require "ninix/config"
2+require "ninix/seriko"
3+
4+module NinixTest
5+
6+ class SerikoTest
7+
8+ # find ~/.ninix -name 'surface*a.txt' | xargs ruby seriko.rb
9+ def initialize(list_path)
10+# if len(sys.argv) == 1
11+# print('Usage:', sys.argv[0], '[surface??a.txt ...]')
12+# end
13+ for filename in list_path
14+ print('Reading', filename, '...', "\n")
15+ for actor in Seriko.get_actors(NConfig.create_from_file(filename))
16+ print('#', actor.get_id().to_i.to_s, "\n")
17+ #print(actor.__class__.__name__,)
18+ print('(', actor.get_interval(), ')', "\n")
19+ print('number of patterns = ', actor.get_patterns().length, "\n")
20+ for pattern in actor.get_patterns()
21+ print('surface=', pattern[0], ', interval=', pattern[1].to_i.to_s, ', method=', pattern[2], ', args=', pattern[3], "\n")
22+ end
23+ end
24+ for actor in Seriko.get_mayuna(NConfig.create_from_file(filename))
25+ print('#', actor.get_id().to_i.to_s, "\n")
26+ #print(actor.__class__.__name__,)
27+ print('(', actor.get_interval(), ')', "\n")
28+ print('number of patterns =', actor.get_patterns().length, "\n")
29+ for pattern in actor.get_patterns()
30+ print('surface=', pattern[0], ', interval=', pattern[1].to_i.to_s, ', method=', pattern[2], ', args=', pattern[3], "\n")
31+ end
32+ end
33+ end
34+ end
35+ end
36+end
37+
38+NinixTest::SerikoTest.new(ARGV)