unageanu-jiji 1.1.4 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (233) hide show
  1. data/ChangeLog +24 -1
  2. data/README +0 -0
  3. data/base/shared_lib/moving_average.rb +34 -33
  4. data/base/shared_lib/system/cross.rb +76 -0
  5. data/base/shared_lib/system/position_manager.rb +160 -0
  6. data/base/shared_lib/system/signal.rb +347 -0
  7. data/html/css/datatable.css +4 -4
  8. data/html/css/default.css +57 -5
  9. data/html/css/treeview.css +205 -0
  10. data/html/img/bin_closed.png +0 -0
  11. data/html/img/bin_empty.png +0 -0
  12. data/html/img/button_add_small.gif +0 -0
  13. data/html/img/button_add_small_gray.gif +0 -0
  14. data/html/img/button_add_small_over.gif +0 -0
  15. data/html/img/button_mkcol.gif +0 -0
  16. data/html/img/button_mkcol_gray.gif +0 -0
  17. data/html/img/button_mkcol_over.gif +0 -0
  18. data/html/img/button_remove_small.gif +0 -0
  19. data/html/img/button_remove_small_gray.gif +0 -0
  20. data/html/img/button_remove_small_over.gif +0 -0
  21. data/html/img/button_rename.gif +0 -0
  22. data/html/img/button_rename_gray.gif +0 -0
  23. data/html/img/button_rename_over.gif +0 -0
  24. data/html/img/control_play.png +0 -0
  25. data/html/img/control_play_blue.png +0 -0
  26. data/html/img/folder.png +0 -0
  27. data/html/img/folder_brick.png +0 -0
  28. data/html/img/folder_user.png +0 -0
  29. data/html/{js/codepress/images → img}/line-numbers.png +0 -0
  30. data/html/img/page_white_ruby.png +0 -0
  31. data/html/img/sidebar_agent_edit.png +0 -0
  32. data/html/img/sidebar_agent_edit_over.png +0 -0
  33. data/html/img/sidebar_agent_edit_s.png +0 -0
  34. data/html/img/yui/treeview-sprite.gif +0 -0
  35. data/html/index.html +34 -18
  36. data/html/js/agent-editor/agent-editor-page.js +324 -0
  37. data/html/js/agent-editor/agent-editor.js +363 -0
  38. data/html/js/agent-editor/agent-list-tree.js +251 -0
  39. data/html/js/agent-selector.js +23 -28
  40. data/html/js/app.js +63 -91
  41. data/html/js/bt-create-page.js +25 -19
  42. data/html/js/container-min.js +1 -1
  43. data/html/js/container.js +944 -0
  44. data/html/js/edit_area/autocompletion.js +11 -13
  45. data/html/js/edit_area/edit_area.css +79 -40
  46. data/html/js/edit_area/edit_area.js +255 -226
  47. data/html/js/edit_area/edit_area_compressor.php +4 -4
  48. data/html/js/edit_area/edit_area_full.gz +0 -0
  49. data/html/js/edit_area/edit_area_full.js +31 -31
  50. data/html/js/edit_area/edit_area_full_with_plugins.gz +0 -0
  51. data/html/js/edit_area/edit_area_full_with_plugins.js +31 -31
  52. data/html/js/edit_area/edit_area_functions.js +448 -341
  53. data/html/js/edit_area/edit_area_loader.js +409 -397
  54. data/html/js/edit_area/elements_functions.js +120 -123
  55. data/html/js/edit_area/highlight.js +305 -197
  56. data/html/js/edit_area/images/goto.png +0 -0
  57. data/html/js/edit_area/images/help.png +0 -0
  58. data/html/js/edit_area/images/redo.png +0 -0
  59. data/html/js/edit_area/images/save.png +0 -0
  60. data/html/js/edit_area/images/search.png +0 -0
  61. data/html/js/edit_area/images/undo.png +0 -0
  62. data/html/js/edit_area/images/word_wrap.gif +0 -0
  63. data/html/js/edit_area/keyboard.js +5 -5
  64. data/html/js/edit_area/langs/bg.js +73 -0
  65. data/html/js/edit_area/langs/cs.js +2 -0
  66. data/html/js/edit_area/langs/de.js +2 -0
  67. data/html/js/edit_area/langs/dk.js +2 -0
  68. data/html/js/edit_area/langs/en.js +2 -0
  69. data/html/js/edit_area/langs/eo.js +2 -0
  70. data/html/js/edit_area/langs/es.js +2 -0
  71. data/html/js/edit_area/langs/fi.js +67 -0
  72. data/html/js/edit_area/langs/fr.js +2 -0
  73. data/html/js/edit_area/langs/hr.js +2 -0
  74. data/html/js/edit_area/langs/it.js +2 -0
  75. data/html/js/edit_area/langs/ja.js +2 -0
  76. data/html/js/edit_area/langs/mk.js +2 -0
  77. data/html/js/edit_area/langs/nl.js +2 -0
  78. data/html/js/edit_area/langs/pl.js +2 -0
  79. data/html/js/edit_area/langs/pt.js +2 -0
  80. data/html/js/edit_area/langs/ru.js +2 -0
  81. data/html/js/edit_area/langs/sk.js +2 -0
  82. data/html/js/edit_area/langs/zh.js +67 -0
  83. data/html/js/edit_area/manage_area.js +362 -205
  84. data/html/js/edit_area/plugins/charmap/langs/bg.js +12 -0
  85. data/html/js/edit_area/plugins/charmap/langs/zh.js +6 -0
  86. data/html/js/edit_area/plugins/test/langs/bg.js +10 -0
  87. data/html/js/edit_area/plugins/test/langs/zh.js +4 -0
  88. data/html/js/edit_area/reg_syntax/java.js +56 -0
  89. data/html/js/edit_area/reg_syntax/ruby.js +9 -9
  90. data/html/js/edit_area/reg_syntax.js +15 -13
  91. data/html/js/edit_area/regexp.js +36 -32
  92. data/html/js/edit_area/resize_area.js +43 -47
  93. data/html/js/edit_area/search_replace.js +29 -29
  94. data/html/js/edit_area/template.html +6 -4
  95. data/html/js/json-broker-client.js +23 -17
  96. data/html/js/result-page.js +107 -57
  97. data/html/js/rt-setting-page.js +38 -15
  98. data/html/js/sidebar.js +41 -27
  99. data/html/js/templates.js +167 -32
  100. data/html/js/utils.js +143 -7
  101. data/html/js/yui/treeview.js +3671 -0
  102. data/html/swf/chart.swf +0 -0
  103. data/html/test/agent_editor_spec.js +815 -0
  104. data/html/test/index.html +40 -0
  105. data/html/test/jsspec/JSSpec.css +224 -0
  106. data/html/test/jsspec/JSSpec.js +1549 -0
  107. data/html/test/jsspec/diff_match_patch.js +1 -0
  108. data/html/test/utils_spec.js +111 -0
  109. data/lib/jiji/agent/agent.rb +69 -12
  110. data/lib/jiji/agent/agent_manager.rb +18 -12
  111. data/lib/jiji/agent/agent_registry.rb +35 -121
  112. data/lib/jiji/collector.rb +16 -6
  113. data/lib/jiji/command.rb +46 -5
  114. data/lib/jiji/dao/file_system_dao.rb +158 -0
  115. data/lib/jiji/dao/timed_data_dao.rb +2 -0
  116. data/lib/jiji/dao/trade_result_dao.rb +1 -1
  117. data/lib/jiji/error.rb +24 -8
  118. data/lib/jiji/migration/migrator1_2_0.rb +67 -0
  119. data/lib/jiji/models.rb +82 -24
  120. data/lib/jiji/operator.rb +55 -51
  121. data/lib/jiji/output.rb +85 -29
  122. data/lib/jiji/output_manager.rb +84 -0
  123. data/lib/jiji/plugin/embedded/single_click_client.rb +2 -2
  124. data/lib/jiji/plugin/securities_plugin.rb +0 -1
  125. data/lib/jiji/process.rb +229 -208
  126. data/lib/jiji/process_manager.rb +190 -96
  127. data/lib/jiji/registry.rb +87 -19
  128. data/lib/jiji/server.rb +1 -0
  129. data/lib/jiji/service/agent_service.rb +147 -48
  130. data/lib/jiji/service/output_service.rb +37 -17
  131. data/lib/jiji/service/process_service.rb +3 -5
  132. data/lib/jiji/service/trade_result_service.rb +4 -5
  133. data/lib/jiji/util/file_lock.rb +4 -4
  134. data/lib/jiji/util/include_proxy.rb +17 -0
  135. data/lib/jiji/util/json_broker.rb +6 -4
  136. data/lib/jiji/util/util.rb +1 -1
  137. data/swf/chart/fx/chart/Chart.as +7 -0
  138. data/swf/chart/fx/chart/ui/graph/GraphManager.as +15 -2
  139. data/test/ProcessTest/agents/foo.rb +10 -0
  140. data/test/ProcessTest/conf/configuration.yaml +3 -0
  141. data/test/agent/agent_tests.rb +10 -0
  142. data/test/agent/test_AgentManager.rb +28 -12
  143. data/test/agent/test_AgentRegistry.rb +194 -99
  144. data/test/agent/test_PeriodicallyAgent.rb +1 -2
  145. data/test/agent/test_Permitter.rb +1 -2
  146. data/test/all_tests.rb +7 -19
  147. data/test/dao/dao_tests.rb +9 -0
  148. data/test/dao/test_FileSystemDao.rb +431 -0
  149. data/test/dao/test_RateDao.rb +5 -7
  150. data/test/dao/test_TradeResultDao.rb +1 -2
  151. data/test/migration/migration_tests.rb +10 -0
  152. data/test/migration/migrator1_2_0test_data/basic/out/M2NlOTA2ODEtZDdlNi00NWU1LWIwNDQtMjBmODY2ZGNkNzBj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
  153. data/test/migration/migrator1_2_0test_data/basic/out/MDVhYzcxMjYtMGFlMS00Mzk0LWEyNmUtYjVjZjgwNDA0ZmE2/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
  154. data/test/migration/migrator1_2_0test_data/basic/out/MzA1YTk0NDgtNzhjNi00NDk3LTk2NTktYzE1ZjBhNzdiYjNj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
  155. data/test/migration/migrator1_2_0test_data/basic/out/YjRkOTI1MzEtZTM4MS00YjQwLTg1ZTQtMWFmZDRlNDUwMzBm/56e75YuV5bmz5Z2H57ea/meta.yaml +9 -0
  156. data/test/migration/migrator1_2_0test_data/basic/props.yaml +85 -0
  157. data/test/migration/migrator1_2_0test_data/illegal_props/out/M2NlOTA2ODEtZDdlNi00NWU1LWIwNDQtMjBmODY2ZGNkNzBj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
  158. data/test/migration/migrator1_2_0test_data/illegal_props/out/MDVhYzcxMjYtMGFlMS00Mzk0LWEyNmUtYjVjZjgwNDA0ZmE2/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
  159. data/test/migration/migrator1_2_0test_data/illegal_props/out/MzA1YTk0NDgtNzhjNi00NDk3LTk2NTktYzE1ZjBhNzdiYjNj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
  160. data/test/migration/migrator1_2_0test_data/illegal_props/out/YjRkOTI1MzEtZTM4MS00YjQwLTg1ZTQtMWFmZDRlNDUwMzBm/56e75YuV5bmz5Z2H57ea/meta.yaml +9 -0
  161. data/test/migration/migrator1_2_0test_data/illegal_props/props.yaml +1 -0
  162. data/test/migration/migrator1_2_0test_data/no_outs/props.yaml +85 -0
  163. data/test/migration/migrator1_2_0test_data/no_props/out/M2NlOTA2ODEtZDdlNi00NWU1LWIwNDQtMjBmODY2ZGNkNzBj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
  164. data/test/migration/migrator1_2_0test_data/no_props/out/MDVhYzcxMjYtMGFlMS00Mzk0LWEyNmUtYjVjZjgwNDA0ZmE2/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
  165. data/test/migration/migrator1_2_0test_data/no_props/out/MzA1YTk0NDgtNzhjNi00NDk3LTk2NTktYzE1ZjBhNzdiYjNj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
  166. data/test/migration/migrator1_2_0test_data/no_props/out/YjRkOTI1MzEtZTM4MS00YjQwLTg1ZTQtMWFmZDRlNDUwMzBm/56e75YuV5bmz5Z2H57ea/meta.yaml +9 -0
  167. data/test/migration/test_Migrator.rb +1 -1
  168. data/test/migration/test_Migrator1_0_3.rb +1 -1
  169. data/test/migration/test_Migrator1_1_0.rb +1 -1
  170. data/test/migration/test_Migrator1_2_0.rb +94 -0
  171. data/test/plugin/embedded/test_SingleClickClient.rb +1 -2
  172. data/test/plugin/plugin_tests.rb +8 -0
  173. data/test/plugin/test_Loader.rb +1 -1
  174. data/test/shared/rate.csv +144 -0
  175. data/test/shared/shared_tests.rb +9 -0
  176. data/test/shared/test_Cross.rb +144 -0
  177. data/test/shared/test_PositionManager.rb +285 -0
  178. data/test/shared/test_Signal.rb +65 -0
  179. data/test/test_Output.rb +28 -21
  180. data/test/test_OutputManager.rb +162 -0
  181. data/test/test_Output_registry.rb +6 -17
  182. data/test/test_Process.rb +434 -222
  183. data/test/test_ProcessManager.rb +458 -101
  184. data/test/test_utils.rb +71 -8
  185. data/test/util/test_BlockToSession.rb +1 -2
  186. data/test/util/test_CSV.rb +1 -2
  187. data/test/util/test_SynchronizeInterceptor.rb +1 -2
  188. data/test/util/util_tests.rb +9 -0
  189. metadata +127 -47
  190. data/html/js/agent-editor-page.js +0 -440
  191. data/html/js/codepress/codepress.css +0 -21
  192. data/html/js/codepress/codepress.html +0 -35
  193. data/html/js/codepress/codepress.js +0 -138
  194. data/html/js/codepress/engines/gecko.js +0 -293
  195. data/html/js/codepress/engines/khtml.js +0 -0
  196. data/html/js/codepress/engines/msie.js +0 -304
  197. data/html/js/codepress/engines/older.js +0 -0
  198. data/html/js/codepress/engines/opera.js +0 -260
  199. data/html/js/codepress/images/line-numbers.gif +0 -0
  200. data/html/js/codepress/index.html +0 -443
  201. data/html/js/codepress/languages/asp.css +0 -71
  202. data/html/js/codepress/languages/asp.js +0 -117
  203. data/html/js/codepress/languages/autoit.css +0 -13
  204. data/html/js/codepress/languages/autoit.js +0 -32
  205. data/html/js/codepress/languages/csharp.css +0 -9
  206. data/html/js/codepress/languages/csharp.js +0 -25
  207. data/html/js/codepress/languages/css.css +0 -10
  208. data/html/js/codepress/languages/css.js +0 -23
  209. data/html/js/codepress/languages/generic.css +0 -9
  210. data/html/js/codepress/languages/generic.js +0 -25
  211. data/html/js/codepress/languages/html.css +0 -13
  212. data/html/js/codepress/languages/html.js +0 -59
  213. data/html/js/codepress/languages/java.css +0 -7
  214. data/html/js/codepress/languages/java.js +0 -24
  215. data/html/js/codepress/languages/javascript.css +0 -8
  216. data/html/js/codepress/languages/javascript.js +0 -30
  217. data/html/js/codepress/languages/perl.css +0 -11
  218. data/html/js/codepress/languages/perl.js +0 -27
  219. data/html/js/codepress/languages/php.css +0 -12
  220. data/html/js/codepress/languages/php.js +0 -61
  221. data/html/js/codepress/languages/ruby.css +0 -10
  222. data/html/js/codepress/languages/ruby.js +0 -26
  223. data/html/js/codepress/languages/sql.css +0 -10
  224. data/html/js/codepress/languages/sql.js +0 -30
  225. data/html/js/codepress/languages/text.css +0 -5
  226. data/html/js/codepress/languages/text.js +0 -9
  227. data/html/js/codepress/languages/vbscript.css +0 -71
  228. data/html/js/codepress/languages/vbscript.js +0 -117
  229. data/html/js/codepress/languages/xsl.css +0 -15
  230. data/html/js/codepress/languages/xsl.js +0 -103
  231. data/html/js/codepress/license.txt +0 -458
  232. data/html/js/edit_area/images/Thumbs.db +0 -0
  233. data/test/plugin/test_gem/a/lib/jiji_plugin_test.rb +0 -6
@@ -0,0 +1,815 @@
1
+
2
+
3
+ describe('fx.AgentEditorの動作確認', {
4
+
5
+ // 前準備
6
+ before : function() {
7
+ JSONBrokerClientFactory.async = false;
8
+ c = new container.Container( function( binder ){
9
+ fx.modules.core( binder );
10
+ });
11
+ target = c.get("agentEditor");
12
+ agentService = c.get("agentServiceStub");
13
+
14
+ // ユーティリティ
15
+ utils = {
16
+ // 指定されたパスのファイル一覧を取得。
17
+ list : function( path ){
18
+ var names = null;
19
+ target.list( path, function(result){
20
+ names = result.map( function(item){
21
+ return item.name + ":" + (item.type == "directory" ? "d" : "f");
22
+ }, null);
23
+ });
24
+ return names;
25
+ },
26
+ // 指定されたパスのファイル本文を取得。
27
+ get : function( path ){
28
+ var body = null;
29
+ target.get( path, function(result){
30
+ body = result;
31
+ });
32
+ return body;
33
+ },
34
+ // 登録済みエージェントの一覧を取得。
35
+ list_agents : function(){
36
+ var agents = null;
37
+ agentService.list_agent_class( function(result){
38
+ agents = result;
39
+ }, null);
40
+ return agents;
41
+ },
42
+ // 選択して操作したのち、選択を解除する。
43
+ selectWith : function( item, block ) {
44
+ target.select( item );
45
+ block();
46
+ target.unselect( item );
47
+ }
48
+ }
49
+
50
+ // 初期データ作成
51
+ utils.selectWith( {path:"agents",type:"directory"}, function( ) {
52
+ target.mkcol( "agent_editor_test" );
53
+ });
54
+ utils.selectWith( {path:"shared_lib",type:"directory"}, function( ) {
55
+ target.mkcol( "agent_editor_test" );
56
+ });
57
+ },
58
+ // 後始末
59
+ after : function() {
60
+ target.select( {path:"agents/agent_editor_test",type:"directory"} );
61
+ target.select( {path:"shared_lib/agent_editor_test",type:"directory"} );
62
+ target.removeSelections();
63
+ JSONBrokerClientFactory.async = true;
64
+ },
65
+
66
+ 'エージェントの追加/削除のテスト': function() {
67
+ // 最初の一覧取得
68
+ value_of( utils.list( "agents" ) ).should_include("agent_editor_test:d");
69
+ value_of( utils.list( "shared_lib" ) ).should_include("agent_editor_test:d");
70
+
71
+ // ファイル/フォルダを作成
72
+ utils.selectWith( {path:"agents/agent_editor_test",type:"directory"}, function( ) {
73
+ target.add( "file1" );
74
+ target.add( "file2.rb" );
75
+ target.mkcol( "dir1" );
76
+ target.mkcol( "dir2" );
77
+ });
78
+ utils.selectWith( {path:"agents/agent_editor_test/dir1",type:"directory"}, function( ) {
79
+ target.add( "file1-1" );
80
+ target.add( "file1-2.rb" );
81
+ target.mkcol( "dir1-1" );
82
+ });
83
+ utils.selectWith( {path:"agents/agent_editor_test/dir2",type:"directory"}, function( ) {
84
+ target.add( "file2-1" );
85
+ target.add( "file2-2.rb" );
86
+ target.mkcol( "dir2-1" );
87
+ });
88
+ var list = utils.list( "agents/agent_editor_test" );
89
+ value_of( list ).should_include("dir1:d");
90
+ value_of( list ).should_include("dir2:d");
91
+ value_of( list ).should_include("file1.rb:f");
92
+ value_of( list ).should_include("file2.rb:f");
93
+
94
+ list = utils.list( "agents/agent_editor_test/dir1" );
95
+ value_of( list ).should_include("dir1-1:d");
96
+ value_of( list ).should_include("file1-1.rb:f");
97
+ value_of( list ).should_include("file1-2.rb:f");
98
+
99
+ // ファイルを取得
100
+ value_of( utils.get("agents/agent_editor_test/file1.rb") ).should_be("");
101
+ value_of( utils.get("agents/agent_editor_test/file2.rb") ).should_be("");
102
+ value_of( utils.get("agents/agent_editor_test/dir1/file1-1.rb") ).should_be("");
103
+ value_of( utils.get("agents/agent_editor_test/dir1/file1-2.rb") ).should_be("");
104
+
105
+ // ファイルを更新
106
+ var body = 'class Test < JIJI::PeriodicallyAgent\n'
107
+ + ' def description; "説明";end\n'
108
+ + ' # UIから設定可能なプロパティの一覧を返す。\n'
109
+ + ' def property_infos\n'
110
+ + ' [Property.new( "short", "短期移動平均線", "", :string ),\n'
111
+ + ' Property.new( "long", "長期移動平均線", 30 )]\n'
112
+ + ' end\n'
113
+ + 'end';
114
+ var body2 = 'class Test < JIJI::PeriodicallyAgent\n'
115
+ + ' def description; "説明2";end\n'
116
+ + ' # UIから設定可能なプロパティの一覧を返す。\n'
117
+ + ' def property_infos\n'
118
+ + ' [Property.new( "short", "短期移動平均線2", 25, :number ),\n'
119
+ + ' Property.new( "long", "長期移動平均線2", 75 )]\n'
120
+ + ' end\n'
121
+ + 'end';
122
+
123
+ target.put( "agents/agent_editor_test/file1.rb", body, null,null);
124
+ target.put( "agents/agent_editor_test/dir1/file1-1.rb", body2, null,null);
125
+ target.put( "agents/agent_editor_test/dir1/file1-2.rb", "#コメント", null,null);
126
+ value_of( utils.get("agents/agent_editor_test/file1.rb") ).should_be(body);
127
+ value_of( utils.get("agents/agent_editor_test/file2.rb") ).should_be("");
128
+ value_of( utils.get("agents/agent_editor_test/dir1/file1-1.rb") ).should_be(body2);
129
+ value_of( utils.get("agents/agent_editor_test/dir1/file1-2.rb") ).should_be("#コメント");
130
+
131
+ // エージェントが登録されていることを確認
132
+ var agents = utils.list_agents();
133
+ agent = agents.find( function(i){ return i.class_name == "Test" && i.file_name=="agent_editor_test/file1.rb" } );
134
+ value_of( agent.class_name ).should_be( "Test" );
135
+ value_of( agent.file_name ).should_be( "agent_editor_test/file1.rb" );
136
+ value_of( agent.description ).should_be( "説明" );
137
+ value_of( agent.properties[0] ).should_be( {
138
+ id:"short", name:"短期移動平均線", "default":"", type:"string"
139
+ });
140
+ value_of( agent.properties[1] ).should_be( {
141
+ id:"long", name:"長期移動平均線", "default":30, type:"string"
142
+ });
143
+
144
+ agent = agents.find( function(i){ return i.class_name == "Test" && i.file_name=="agent_editor_test/dir1/file1-1.rb" } );
145
+ value_of( agent.class_name ).should_be( "Test" );
146
+ value_of( agent.file_name ).should_be( "agent_editor_test/dir1/file1-1.rb" );
147
+ value_of( agent.description ).should_be( "説明2" );
148
+ value_of( agent.properties[0] ).should_be( {
149
+ id:"short", name:"短期移動平均線2", "default":25, type:"number"
150
+ });
151
+ value_of( agent.properties[1] ).should_be( {
152
+ id:"long", name:"長期移動平均線2", "default":75, type:"string"
153
+ });
154
+
155
+ agent = agents.find( function(i){ return i.file_name=="agent_editor_test/dir1/file1-2.rb" } );
156
+ value_of( agent ).should_be_undefined();
157
+
158
+
159
+ // リネーム
160
+ target.select( {path:"agents/agent_editor_test/file1.rb",type:"file"} );
161
+ target.renameSelection( "file1_renamed", null, null );
162
+
163
+ list = utils.list( "agents/agent_editor_test" );
164
+ value_of( list ).should_include("dir1:d");
165
+ value_of( list ).should_include("dir2:d");
166
+ value_of( list ).should_include("file1_renamed.rb:f");
167
+ value_of( list ).should_include("file2.rb:f");
168
+
169
+ value_of( target.isSelected( "agents/agent_editor_test/file1.rb" ) ).should_be(false);
170
+ value_of( target.isSelected( "agents/agent_editor_test/file1_renamed.rb" ) ).should_be(true);
171
+
172
+ agents = utils.list_agents();
173
+ agent = agents.find( function(i){ return i.class_name == "Test" && i.file_name=="agent_editor_test/file1.rb" } );
174
+ value_of( agent ).should_be_undefined();
175
+ agent = agents.find( function(i){ return i.class_name == "Test" && i.file_name=="agent_editor_test/file1_renamed.rb" } );
176
+ value_of( agent.class_name ).should_be( "Test" );
177
+ value_of( agent.file_name ).should_be( "agent_editor_test/file1_renamed.rb" );
178
+ value_of( agent.description ).should_be( "説明" );
179
+ value_of( agent.properties[0] ).should_be( {
180
+ id:"short", name:"短期移動平均線", "default":"", type:"string"
181
+ });
182
+ value_of( agent.properties[1] ).should_be( {
183
+ id:"long", name:"長期移動平均線", "default":30, type:"string"
184
+ });
185
+
186
+ // フォルダをリネーム
187
+ target.unselect( {path:"agents/agent_editor_test/file1_renamed.rb",type:"file"} );
188
+ target.select( {path:"agents/agent_editor_test/dir1",type:"directory"} );
189
+ target.renameSelection( "dir1_renamed", null, null );
190
+ list = utils.list( "agents/agent_editor_test" );
191
+ value_of( list ).should_include("dir1_renamed:d");
192
+ value_of( list ).should_include("dir2:d");
193
+ value_of( list ).should_include("file1_renamed.rb:f");
194
+ value_of( list ).should_include("file2.rb:f");
195
+
196
+ value_of( target.isSelected( "agents/agent_editor_test/dir1" ) ).should_be(false);
197
+ value_of( target.isSelected( "agents/agent_editor_test/dir1_renamed" ) ).should_be(true);
198
+
199
+ agents = utils.list_agents();
200
+ agent = agents.find( function(i){ return i.class_name == "Test" && i.file_name=="agent_editor_test/dir1/file1-1.rb" } );
201
+ value_of( agent ).should_be_undefined();
202
+ agent = agents.find( function(i){ return i.class_name == "Test" && i.file_name=="agent_editor_test/dir1_renamed/file1-1.rb" } );
203
+ value_of( agent.class_name ).should_be( "Test" );
204
+ value_of( agent.file_name ).should_be( "agent_editor_test/dir1_renamed/file1-1.rb" );
205
+ value_of( agent.description ).should_be( "説明2" );
206
+ value_of( agent.properties[0] ).should_be( {
207
+ id:"short", name:"短期移動平均線2", "default":25, type:"number"
208
+ });
209
+ value_of( agent.properties[1] ).should_be( {
210
+ id:"long", name:"長期移動平均線2", "default":75, type:"string"
211
+ });
212
+
213
+
214
+ // ファイルを削除
215
+ target.unselect( {path:"agents/agent_editor_test/dir1_renamed",type:"directory"} );
216
+ target.select( {path:"agents/agent_editor_test/file1_renamed.rb",type:"file"} );
217
+ target.removeSelections( null, null );
218
+ list = utils.list( "agents/agent_editor_test" );
219
+ value_of( list ).should_include("dir1_renamed:d");
220
+ value_of( list ).should_include("dir2:d");
221
+ value_of( list ).should_not_include("file1_renamed.rb:f");
222
+ value_of( list ).should_include("file2.rb:f");
223
+
224
+ value_of( target.isSelected( "agents/agent_editor_test/file1_renamed.rb" ) ).should_be(false);
225
+
226
+ agents = utils.list_agents();
227
+ agent = agents.find( function(i){ return i.class_name == "Test" && i.file_name=="agent_editor_test/file1_renamed.rb" } );
228
+ value_of( agent ).should_be_undefined();
229
+
230
+ // フォルダを削除
231
+ target.select( {path:"agents/agent_editor_test/dir1_renamed",type:"directory"} );
232
+ target.removeSelections( null, null );
233
+ list = utils.list( "agents/agent_editor_test" );
234
+ value_of( list ).should_not_include("dir1_renamed:d");
235
+ value_of( list ).should_include("dir2:d");
236
+ value_of( list ).should_include("file2.rb:f");
237
+
238
+ value_of( target.isSelected( "agents/agent_editor_test/dir1_renamed" ) ).should_be(false);
239
+
240
+ agents = utils.list_agents();
241
+ agent = agents.find( function(i){ return i.class_name == "Test" && i.file_name=="agent_editor_test/dir1_renamed/file1-1.rb" } );
242
+ value_of( agent ).should_be_undefined();
243
+
244
+
245
+ // 一括削除
246
+ target.select( {path:"agents/agent_editor_test/file2.rb",type:"file"} );
247
+ target.select( {path:"agents/agent_editor_test/dir2",type:"directory"} );
248
+ target.select( {path:"agents/agent_editor_test/dir2/file2-1",type:"directory"} );
249
+ target.select( {path:"agents/agent_editor_test/dir2/dir2-1",type:"directory"} );
250
+ target.removeSelections( null, null );
251
+ list = utils.list( "agents/agent_editor_test" );
252
+ value_of( list ).should_not_include("dir2:d");
253
+ value_of( list ).should_not_include("file2.rb:f");
254
+
255
+ value_of( target.isSelected( "agents/agent_editor_test/file2.rb" ) ).should_be(false);
256
+ value_of( target.isSelected( "agents/agent_editor_test/dir2" ) ).should_be(false);
257
+
258
+
259
+ },
260
+
261
+ '共有ライブラリの追加/削除のテスト': function() {
262
+ // 最初の一覧取得
263
+ value_of( utils.list( "agents" ) ).should_include("agent_editor_test:d");
264
+ value_of( utils.list( "shared_lib" ) ).should_include("agent_editor_test:d");
265
+
266
+ // ファイル/フォルダを作成
267
+ utils.selectWith( {path:"shared_lib/agent_editor_test",type:"directory"}, function( ) {
268
+ target.add( "file1" );
269
+ target.add( "file2.rb" );
270
+ target.mkcol( "dir1" );
271
+ target.mkcol( "dir2" );
272
+ });
273
+ utils.selectWith( {path:"shared_lib/agent_editor_test/dir1",type:"directory"}, function( ) {
274
+ target.add( "file1-1" );
275
+ target.add( "file1-2.rb" );
276
+ target.mkcol( "dir1-1" );
277
+ });
278
+ var list = utils.list( "shared_lib/agent_editor_test" );
279
+ value_of( list ).should_include("dir1:d");
280
+ value_of( list ).should_include("dir2:d");
281
+ value_of( list ).should_include("file1.rb:f");
282
+ value_of( list ).should_include("file2.rb:f");
283
+
284
+ list = utils.list( "shared_lib/agent_editor_test/dir1" );
285
+ value_of( list ).should_include("dir1-1:d");
286
+ value_of( list ).should_include("file1-1.rb:f");
287
+ value_of( list ).should_include("file1-2.rb:f");
288
+
289
+ // ファイルを取得
290
+ value_of( utils.get("shared_lib/agent_editor_test/file1.rb") ).should_be("");
291
+ value_of( utils.get("shared_lib/agent_editor_test/file2.rb") ).should_be("");
292
+ value_of( utils.get("shared_lib/agent_editor_test/dir1/file1-1.rb") ).should_be("");
293
+ value_of( utils.get("shared_lib/agent_editor_test/dir1/file1-2.rb") ).should_be("");
294
+
295
+ // ファイルを更新
296
+ var body = 'class Test < JIJI::PeriodicallyAgent\n'
297
+ + ' def description; "説明";end\n'
298
+ + ' # UIから設定可能なプロパティの一覧を返す。\n'
299
+ + ' def property_infos\n'
300
+ + ' [Property.new( "short", "短期移動平均線", "", :string ),\n'
301
+ + ' Property.new( "long", "長期移動平均線", 30 )]\n'
302
+ + ' end\n'
303
+ + 'end';
304
+ var body2 = 'class Test < JIJI::PeriodicallyAgent\n'
305
+ + ' def description; "説明2";end\n'
306
+ + ' # UIから設定可能なプロパティの一覧を返す。\n'
307
+ + ' def property_infos\n'
308
+ + ' [Property.new( "short", "短期移動平均線2", 25, :number ),\n'
309
+ + ' Property.new( "long", "長期移動平均線2", 75 )]\n'
310
+ + ' end\n'
311
+ + 'end';
312
+
313
+ target.put( "shared_lib/agent_editor_test/file1.rb", body, null,null);
314
+ target.put( "shared_lib/agent_editor_test/dir1/file1-1.rb", body2, null,null);
315
+ target.put( "shared_lib/agent_editor_test/dir1/file1-2.rb", "#コメント", null,null);
316
+ value_of( utils.get("shared_lib/agent_editor_test/file1.rb") ).should_be(body);
317
+ value_of( utils.get("shared_lib/agent_editor_test/file2.rb") ).should_be("");
318
+ value_of( utils.get("shared_lib/agent_editor_test/dir1/file1-1.rb") ).should_be(body2);
319
+ value_of( utils.get("shared_lib/agent_editor_test/dir1/file1-2.rb") ).should_be("#コメント");
320
+
321
+ // 共有ライブラリのクラスはエージェントとしてカウントされない。
322
+ agents = utils.list_agents();
323
+ agent = agents.find( function(i){ return i.file_name=="agent_editor_test/file1.rb" } );
324
+ value_of( agent ).should_be_undefined();
325
+
326
+ agent = agents.find( function(i){ return i.file_name=="agent_editor_test/dir1/file1-1.rb" } );
327
+ value_of( agent ).should_be_undefined();
328
+
329
+ agent = agents.find( function(i){ return i.file_name=="agent_editor_test/dir1/file1-2.rb" } );
330
+ value_of( agent ).should_be_undefined();
331
+
332
+
333
+ // リネーム
334
+ target.select( {path:"shared_lib/agent_editor_test/file1.rb",type:"file"} );
335
+ target.renameSelection( "file1_renamed", null, null );
336
+
337
+ list = utils.list( "shared_lib/agent_editor_test" );
338
+ value_of( list ).should_include("dir1:d");
339
+ value_of( list ).should_include("dir2:d");
340
+ value_of( list ).should_include("file1_renamed.rb:f");
341
+ value_of( list ).should_include("file2.rb:f");
342
+
343
+ value_of( target.isSelected( "shared_lib/agent_editor_test/file1.rb" ) ).should_be(false);
344
+ value_of( target.isSelected( "shared_lib/agent_editor_test/file1_renamed.rb" ) ).should_be(true);
345
+
346
+ agents = utils.list_agents();
347
+ agent = agents.find( function(i){ return i.class_name == "Test" && i.file_name=="agent_editor_test/dir1/file1-1.rb" } );
348
+ value_of( agent ).should_be_undefined();
349
+ agent = agents.find( function(i){ return i.class_name == "Test" && i.file_name=="agent_editor_test/dir1_renamed/file1-1.rb" } );
350
+ value_of( agent ).should_be_undefined();
351
+
352
+ // フォルダをリネーム
353
+ target.unselect( {path:"shared_lib/agent_editor_test/file1_renamed.rb",type:"file"} );
354
+ target.select( {path:"shared_lib/agent_editor_test/dir1",type:"directory"} );
355
+ target.renameSelection( "dir1_renamed", null, null );
356
+ list = utils.list( "shared_lib/agent_editor_test" );
357
+ value_of( list ).should_include("dir1_renamed:d");
358
+ value_of( list ).should_include("dir2:d");
359
+ value_of( list ).should_include("file1_renamed.rb:f");
360
+ value_of( list ).should_include("file2.rb:f");
361
+
362
+ value_of( target.isSelected( "shared_lib/agent_editor_test/dir1" ) ).should_be(false);
363
+ value_of( target.isSelected( "shared_lib/agent_editor_test/dir1_renamed" ) ).should_be(true);
364
+
365
+ agents = utils.list_agents();
366
+ agent = agents.find( function(i){ return i.class_name == "Test" && i.file_name=="agent_editor_test/file1.rb" } );
367
+ value_of( agent ).should_be_undefined();
368
+ agent = agents.find( function(i){ return i.class_name == "Test" && i.file_name=="agent_editor_test/file1_renamed.rb" } );
369
+ value_of( agent ).should_be_undefined();
370
+
371
+
372
+ // ファイルを削除
373
+ target.unselect( {path:"shared_lib/agent_editor_test/dir1_renamed",type:"directory"} );
374
+ target.select( {path:"shared_lib/agent_editor_test/file1_renamed.rb",type:"file"} );
375
+ target.removeSelections( null, null );
376
+ list = utils.list( "shared_lib/agent_editor_test" );
377
+ value_of( list ).should_include("dir1_renamed:d");
378
+ value_of( list ).should_include("dir2:d");
379
+ value_of( list ).should_not_include("file1_renamed.rb:f");
380
+ value_of( list ).should_include("file2.rb:f");
381
+
382
+ value_of( target.isSelected( "shared_lib/agent_editor_test/file1_renamed.rb" ) ).should_be(false);
383
+
384
+ agents = utils.list_agents();
385
+ agent = agents.find( function(i){ return i.class_name == "Test" && i.file_name=="agent_editor_test/file1_renamed.rb" } );
386
+ value_of( agent ).should_be_undefined();
387
+
388
+ // フォルダを削除
389
+ target.select( {path:"shared_lib/agent_editor_test/dir1_renamed",type:"directory"} );
390
+ target.removeSelections( null, null );
391
+ list = utils.list( "shared_lib/agent_editor_test" );
392
+ value_of( list ).should_not_include("dir1_renamed:d");
393
+ value_of( list ).should_include("dir2:d");
394
+ value_of( list ).should_include("file2.rb:f");
395
+
396
+ value_of( target.isSelected( "shared_lib/agent_editor_test/dir1_renamed" ) ).should_be(false);
397
+
398
+ agents = utils.list_agents();
399
+ agent = agents.find( function(i){ return i.class_name == "Test" && i.file_name=="agent_editor_test/dir1_renamed/file1-1.rb" } );
400
+ value_of( agent ).should_be_undefined();
401
+
402
+
403
+ // 一括削除
404
+ target.select( {path:"shared_lib/agent_editor_test/file2.rb",type:"file"} );
405
+ target.select( {path:"shared_lib/agent_editor_test/dir2",type:"directory"} );
406
+ target.removeSelections( null, null );
407
+ list = utils.list( "shared_lib/agent_editor_test" );
408
+ value_of( list ).should_not_include("dir2:d");
409
+ value_of( list ).should_not_include("file2.rb:f");
410
+
411
+ value_of( target.isSelected( "shared_lib/agent_editor_test/file2.rb" ) ).should_be(false);
412
+ value_of( target.isSelected( "shared_lib/agent_editor_test/dir2" ) ).should_be(false);
413
+
414
+ },
415
+
416
+ '追加の異常系テスト': function() {
417
+ var t = target;
418
+ var add = function( path, name ) {
419
+ var result = null;
420
+ t.select( {path:path,type:"directory"} );
421
+ try {
422
+ t.add( name, function(){
423
+ result = "success";
424
+ }, function( res ){
425
+ result = res;
426
+ } );
427
+ } finally {
428
+ t.unselect( {path:path,type:"directory"} );
429
+ }
430
+ return result;
431
+ }
432
+
433
+ // ファイル名が指定されていない
434
+ var path = "agents/agent_editor_test";
435
+ var msg = fx.template.Templates.common.errorMsg.emptyName;
436
+ value_of( add( path, "" ).msg ).should_be( msg );
437
+ value_of( add( path, null ).msg ).should_be( msg );
438
+ value_of( add( path, undefined ).msg ).should_be( msg );
439
+
440
+ // ファイル名が不正
441
+ msg = fx.template.Templates.common.errorMsg.illegalName.evaluate({name:"ファイル"} );
442
+ value_of( add( path, " " ).msg ).should_be( msg );
443
+ value_of( add( path, "a " ).msg ).should_be( msg );
444
+ value_of( add( path, "あ" ).msg ).should_be( msg );
445
+ value_of( add( path, ":" ).msg ).should_be( msg );
446
+ value_of( add( path, "/" ).msg ).should_be( msg );
447
+ value_of( add( path, ">" ).msg ).should_be( msg );
448
+ value_of( add( path, "<" ).msg ).should_be( msg );
449
+ value_of( add( path, "@" ).msg ).should_be( msg );
450
+ value_of( add( path, "*" ).msg ).should_be( msg );
451
+ value_of( add( path, "\"" ).msg ).should_be( msg );
452
+ value_of( add( path, "?" ).msg ).should_be( msg );
453
+ value_of( add( path, "|" ).msg ).should_be( msg );
454
+ value_of( add( path, ";" ).msg ).should_be( msg );
455
+ value_of( add( path, "abc_+-#!~[]()'{}." ) ).should_be( "success" );
456
+
457
+ // ファイルがすでに存在する
458
+ utils.selectWith( {path:path,type:"directory"}, function( ) {
459
+ target.add( "file1", null, null );
460
+ });
461
+ msg = fx.template.Templates.common.errorMsg.alreadyExist ;
462
+ value_of( add( path, "file1" ).msg ).should_be( msg );
463
+ value_of( add( path, "file1.rb" ).msg ).should_be( msg );
464
+
465
+ // フォルダがすでに存在する
466
+ utils.selectWith( {path:path,type:"directory"}, function( ) {
467
+ target.mkcol( "dir1" );
468
+ target.mkcol( "dir1.rb" );
469
+ });
470
+ msg = fx.template.Templates.common.errorMsg.alreadyExist ;
471
+ value_of( add( path, "dir1" ).msg ).should_be( msg );
472
+ value_of( add( path, "dir1.rb" ).msg ).should_be( msg );
473
+
474
+ // 作成先が存在しない
475
+ msg = fx.template.Templates.common.errorMsg.notFound.evaluate( {name:"ファイル"} ) ;
476
+ value_of( add( "agents/agent_editor_test/not_found", "aaa" ).msg ).should_be( msg );
477
+ },
478
+
479
+ 'フォルダ作成の異常系テスト': function() {
480
+ var t = target;
481
+ var mkcol = function( path, name ) {
482
+ var result = null;
483
+ t.select( {path:path,type:"directory"} );
484
+ try {
485
+ t.mkcol( name, function(){
486
+ result = "success";
487
+ }, function( res ){
488
+ result = res;
489
+ } );
490
+ } finally {
491
+ t.unselect( {path:path,type:"directory"} );
492
+ }
493
+ return result;
494
+ }
495
+
496
+ // フォルダ名が指定されていない
497
+ var path = "agents/agent_editor_test";
498
+ var msg = fx.template.Templates.common.errorMsg.emptyName;
499
+ value_of( mkcol( path, "" ).msg ).should_be( msg );
500
+ value_of( mkcol( path, null ).msg ).should_be( msg );
501
+ value_of( mkcol( path, undefined ).msg ).should_be( msg );
502
+
503
+ // フォルダ名が不正
504
+ msg = fx.template.Templates.common.errorMsg.illegalName.evaluate({name:"ディレクトリ"} );
505
+ value_of( mkcol( path, " " ).msg ).should_be( msg );
506
+ value_of( mkcol( path, "a " ).msg ).should_be( msg );
507
+ value_of( mkcol( path, "あ" ).msg ).should_be( msg );
508
+ value_of( mkcol( path, ":" ).msg ).should_be( msg );
509
+ value_of( mkcol( path, "/" ).msg ).should_be( msg );
510
+ value_of( mkcol( path, ">" ).msg ).should_be( msg );
511
+ value_of( mkcol( path, "<" ).msg ).should_be( msg );
512
+ value_of( mkcol( path, "@" ).msg ).should_be( msg );
513
+ value_of( mkcol( path, "*" ).msg ).should_be( msg );
514
+ value_of( mkcol( path, "\"" ).msg ).should_be( msg );
515
+ value_of( mkcol( path, "?" ).msg ).should_be( msg );
516
+ value_of( mkcol( path, "|" ).msg ).should_be( msg );
517
+ value_of( mkcol( path, ";" ).msg ).should_be( msg );
518
+ value_of( mkcol( path, "abc_+-#!~[]()'{}." ) ).should_be( "success" );
519
+
520
+ // ファイルがすでに存在する
521
+ utils.selectWith( {path:path,type:"directory"}, function( ) {
522
+ target.add( "file1", null, null );
523
+ });
524
+ msg = fx.template.Templates.common.errorMsg.alreadyExist ;
525
+ value_of( mkcol( path, "file1.rb" ).msg ).should_be( msg );
526
+
527
+ // フォルダがすでに存在する
528
+ utils.selectWith( {path:path,type:"directory"}, function( ) {
529
+ target.mkcol( "dir1" );
530
+ });
531
+ msg = fx.template.Templates.common.errorMsg.alreadyExist ;
532
+ value_of( mkcol( path, "dir1" ).msg ).should_be( msg );
533
+
534
+ // 作成先が存在しない
535
+ msg = fx.template.Templates.common.errorMsg.notFound.evaluate( {name:"ディレクトリ"} ) ;
536
+ value_of( mkcol( "agents/agent_editor_test/not_found", "aaa" ).msg ).should_be( msg );
537
+ },
538
+
539
+ 'リネームの異常系テスト': function() {
540
+ var t = target;
541
+
542
+ utils.selectWith( {path:"agents/agent_editor_test",type:"directory"}, function( ) {
543
+ target.add( "file1" );
544
+ target.add( "file2.rb" );
545
+ target.mkcol( "dir1" );
546
+ target.mkcol( "dir2" );
547
+ target.mkcol( "dir3.rb" );
548
+ });
549
+
550
+ var rename = function( name ) {
551
+ var result = null;
552
+ t.renameSelection( name, function(){
553
+ result = "success";
554
+ }, function( res ){
555
+ result = res;
556
+ } );
557
+ return result;
558
+ }
559
+
560
+ // 名前が指定されていない
561
+ var path = "agents/agent_editor_test/file1.rb";
562
+ t.select( {path:path, type: "file"} );
563
+ var msg = fx.template.Templates.common.errorMsg.emptyName;
564
+ value_of( rename( "" ).msg ).should_be( msg );
565
+ value_of( rename( null ).msg ).should_be( msg );
566
+ value_of( rename( undefined ).msg ).should_be( msg );
567
+
568
+ // 名前が不正
569
+ msg = fx.template.Templates.common.errorMsg.illegalName.evaluate({name:"ファイル"} );
570
+ value_of( rename( " " ).msg ).should_be( msg );
571
+ value_of( rename( "a " ).msg ).should_be( msg );
572
+ value_of( rename( "あ" ).msg ).should_be( msg );
573
+ value_of( rename( ":" ).msg ).should_be( msg );
574
+ value_of( rename( "/" ).msg ).should_be( msg );
575
+ value_of( rename( ">" ).msg ).should_be( msg );
576
+ value_of( rename( "<" ).msg ).should_be( msg );
577
+ value_of( rename( "@" ).msg ).should_be( msg );
578
+ value_of( rename( "*" ).msg ).should_be( msg );
579
+ value_of( rename( "\"" ).msg ).should_be( msg );
580
+ value_of( rename( "?" ).msg ).should_be( msg );
581
+ value_of( rename( "|" ).msg ).should_be( msg );
582
+ value_of( rename( ";" ).msg ).should_be( msg );
583
+ value_of( rename( "abc_+-#!~[]()'{}." ) ).should_be( "success" );
584
+ t.renameSelection( "file1", null, null ) ;
585
+
586
+ // ファイルがすでに存在する
587
+ msg = fx.template.Templates.common.errorMsg.alreadyExist ;
588
+ value_of( rename( "file2" ).msg ).should_be( msg );
589
+ value_of( rename( "file2.rb" ).msg ).should_be( msg );
590
+
591
+ // フォルダがすでに存在する
592
+ msg = fx.template.Templates.common.errorMsg.alreadyExist ;
593
+ value_of( rename( "dir3" ).msg ).should_be( msg );
594
+ value_of( rename( "dir3.rb" ).msg ).should_be( msg );
595
+
596
+
597
+ // ディレクトリをリネーム
598
+ // 名前が指定されていない
599
+ t.unselect( {path:path, type: "file"} );
600
+ path = "agents/agent_editor_test/dir1";
601
+ t.select( {path:path, type: "directory"} );
602
+ var msg = fx.template.Templates.common.errorMsg.emptyName;
603
+ value_of( rename( "" ).msg ).should_be( msg );
604
+ value_of( rename( null ).msg ).should_be( msg );
605
+ value_of( rename( undefined ).msg ).should_be( msg );
606
+
607
+ // 名前が不正
608
+ msg = fx.template.Templates.common.errorMsg.illegalName.evaluate({name:"ディレクトリ"} );
609
+ value_of( rename( " " ).msg ).should_be( msg );
610
+ value_of( rename( "a " ).msg ).should_be( msg );
611
+ value_of( rename( "あ" ).msg ).should_be( msg );
612
+ value_of( rename( ":" ).msg ).should_be( msg );
613
+ value_of( rename( "/" ).msg ).should_be( msg );
614
+ value_of( rename( ">" ).msg ).should_be( msg );
615
+ value_of( rename( "<" ).msg ).should_be( msg );
616
+ value_of( rename( "@" ).msg ).should_be( msg );
617
+ value_of( rename( "*" ).msg ).should_be( msg );
618
+ value_of( rename( "\"" ).msg ).should_be( msg );
619
+ value_of( rename( "?" ).msg ).should_be( msg );
620
+ value_of( rename( "|" ).msg ).should_be( msg );
621
+ value_of( rename( ";" ).msg ).should_be( msg );
622
+ value_of( rename( "abc_+-#!~[]()'{}." ) ).should_be( "success" );
623
+ t.renameSelection( "dir1", null, null ) ;
624
+
625
+ // ファイルがすでに存在する
626
+ msg = fx.template.Templates.common.errorMsg.alreadyExist ;
627
+ value_of( rename( "file1.rb" ).msg ).should_be( msg );
628
+
629
+ // フォルダがすでに存在する
630
+ msg = fx.template.Templates.common.errorMsg.alreadyExist ;
631
+ value_of( rename( "dir2" ).msg ).should_be( msg );
632
+
633
+ // エージェント/共有ライブラリをリネーム
634
+ t.unselect( {path:path, type: "directory"} );
635
+ msg = fx.template.Templates.common.errorMsg.systemError ;
636
+ utils.selectWith( {path:"agents",type:"directory"}, function( ) {
637
+ value_of( rename( "aaa" ).msg ).should_be( msg );
638
+ });
639
+ utils.selectWith( {path:"shared_lib",type:"directory"}, function( ) {
640
+ value_of( rename( "bbb" ).msg ).should_be( msg );
641
+ });
642
+
643
+ // 対象が存在しない
644
+ msg = fx.template.Templates.common.errorMsg.notFound.evaluate( {name:"ディレクトリ"} ) ;
645
+ utils.selectWith( {path:"agents/not_found",type:"directory"}, function( ) {
646
+ value_of( rename( "aaa" ).msg ).should_be( msg );
647
+ });
648
+ msg = fx.template.Templates.common.errorMsg.notFound.evaluate( {name:"ファイル"} ) ;
649
+ utils.selectWith( {path:"agents/not_found",type:"file"}, function( ) {
650
+ value_of( rename( "aaa" ).msg ).should_be( msg );
651
+ });
652
+ },
653
+
654
+ '削除の異常系テスト': function() {
655
+
656
+ var t = target;
657
+
658
+ utils.selectWith( {path:"agents/agent_editor_test",type:"directory"}, function( ) {
659
+ target.add( "file1" );
660
+ target.add( "file2.rb" );
661
+ target.mkcol( "dir1" );
662
+ target.mkcol( "dir2" );
663
+ });
664
+
665
+ var remove = function( paths ) {
666
+ var result = null;
667
+ for ( var i=0; i < paths.length; i++ ) {
668
+ t.select( paths[i] );
669
+ }
670
+ t.removeSelections( function( res ){
671
+ result = res;
672
+ }, function( res ){
673
+ result = res;
674
+ } );
675
+ for ( i=0; i < paths.length; i++ ) {
676
+ t.unselect( paths[i] );
677
+ }
678
+ return result;
679
+ }
680
+
681
+ // 削除対象が存在しない
682
+ var msg = fx.template.Templates.common.errorMsg.notFound.evaluate( {name:"ディレクトリ"} ) ;
683
+ var res = remove( [{path:"agents/not_found",type:"directory"}] );
684
+ value_of( res.success["agents/not_found"] ).should_be_undefined( );
685
+ value_of( res.failed["agents/not_found"].msg ).should_be( msg );
686
+
687
+ var msg2 = fx.template.Templates.common.errorMsg.notFound.evaluate( {name:"ファイル"} ) ;
688
+ res = remove( [{path:"agents/not_found",type:"file"}] );
689
+ value_of( res.success["agents/not_found"] ).should_be_undefined( );
690
+ value_of( res.failed["agents/not_found"].msg ).should_be( msg2 );
691
+
692
+ // 複数選択し、一部のみ削除失敗
693
+ res = remove( [
694
+ {path:"agents/not_found",type:"file"},
695
+ {path:"agents/not_found2",type:"directory"},
696
+ {path:"agents/agent_editor_test/file1.rb",type:"file"},
697
+ {path:"agents/agent_editor_test/dir1",type:"directory"}
698
+ ] );
699
+ value_of( res.success["agents/not_found"] ).should_be_undefined( );
700
+ value_of( res.success["agents/not_found2"] ).should_be_undefined( );
701
+ value_of( res.success["agents/agent_editor_test/file1.rb"].path ).should_be( "agents/agent_editor_test/file1.rb" );
702
+ value_of( res.success["agents/agent_editor_test/dir1"].path ).should_be( "agents/agent_editor_test/dir1" );
703
+ value_of( res.failed["agents/not_found"].msg ).should_be( msg2 );
704
+ value_of( res.failed["agents/not_found2"].msg ).should_be( msg );
705
+
706
+ // エージェント/共有ライブラリを削除
707
+ msg = fx.template.Templates.common.errorMsg.systemError ;
708
+ value_of( remove( [{path:"agents",type:"directory"}] ).msg ).should_be( msg );
709
+ value_of( remove( [{path:"shared_lib",type:"directory"}] ).msg ).should_be( msg );
710
+ },
711
+
712
+ '選択のテスト': function() {
713
+ value_of( target.isSelected( "agents/agent_editor_test" ) ).should_be(false);
714
+ value_of( target.isSelected( "shared_lib/agent_editor_test" ) ).should_be(false);
715
+
716
+ target.select( {path:"agents/agent_editor_test",type:"directory"} );
717
+ value_of( target.isSelected( "agents/agent_editor_test" ) ).should_be(true);
718
+ value_of( target.isSelected( "shared_lib/agent_editor_test" ) ).should_be(false);
719
+
720
+ target.select( {path:"shared_lib/agent_editor_test",type:"directory"} );
721
+ value_of( target.isSelected( "agents/agent_editor_test" ) ).should_be(true);
722
+ value_of( target.isSelected( "shared_lib/agent_editor_test" ) ).should_be(true);
723
+
724
+ target.unselect( {path:"agents/agent_editor_test",type:"directory"} );
725
+ value_of( target.isSelected( "agents/agent_editor_test" ) ).should_be(false);
726
+ value_of( target.isSelected( "shared_lib/agent_editor_test" ) ).should_be(true);
727
+
728
+ target.unselect( {path:"shared_lib/agent_editor_test",type:"directory"} );
729
+ value_of( target.isSelected( "agents/agent_editor_test" ) ).should_be(false);
730
+ value_of( target.isSelected( "shared_lib/agent_editor_test" ) ).should_be(false);
731
+ },
732
+
733
+ '実行可/不可判定のテスト': function() {
734
+
735
+ var t = target;
736
+
737
+ // テストデータ作成
738
+ utils.selectWith( {path:"agents/agent_editor_test",type:"directory"}, function( ) {
739
+ t.add( "file1" );
740
+ t.add( "file2" );
741
+ t.mkcol( "dir1" );
742
+ t.mkcol( "dir2" );
743
+ });
744
+
745
+ // 選択なしの場合
746
+ value_of( target.enable( "add" ) ).should_be(false);
747
+ value_of( target.enable( "mkcol" ) ).should_be(false);
748
+ value_of( target.enable( "renameSelection" ) ).should_be(false);
749
+ value_of( target.enable( "moveSelections" ) ).should_be(false);
750
+ value_of( target.enable( "removeSelections" ) ).should_be(false);
751
+
752
+ // ファイルを1つだけ選択
753
+ target.select( {path:"agents/agent_editor_test/file1",type:"file"} );
754
+ value_of( target.enable( "add" ) ).should_be(false);
755
+ value_of( target.enable( "mkcol" ) ).should_be(false);
756
+ value_of( target.enable( "renameSelection" ) ).should_be(true);
757
+ value_of( target.enable( "moveSelections" ) ).should_be(true);
758
+ value_of( target.enable( "removeSelections" ) ).should_be(true);
759
+
760
+ // ファイルを複数選択
761
+ target.select( {path:"agents/agent_editor_test/file2",type:"file"} );
762
+ value_of( target.enable( "add" ) ).should_be(false);
763
+ value_of( target.enable( "mkcol" ) ).should_be(false);
764
+ value_of( target.enable( "renameSelection" ) ).should_be(false);
765
+ value_of( target.enable( "moveSelections" ) ).should_be(true);
766
+ value_of( target.enable( "removeSelections" ) ).should_be(true);
767
+
768
+ //フォルダを1つ選択
769
+ target.unselect( {path:"agents/agent_editor_test/file1",type:"file"} );
770
+ target.unselect( {path:"agents/agent_editor_test/file2",type:"file"} );
771
+ target.select( {path:"agents/agent_editor_test/dir1",type:"directory"} );
772
+ value_of( target.enable( "add" ) ).should_be(true);
773
+ value_of( target.enable( "mkcol" ) ).should_be(true);
774
+ value_of( target.enable( "renameSelection" ) ).should_be(true);
775
+ value_of( target.enable( "moveSelections" ) ).should_be(true);
776
+ value_of( target.enable( "removeSelections" ) ).should_be(true);
777
+
778
+ // フォルダを複数選択
779
+ target.select( {path:"agents/agent_editor_test/dir2",type:"directory"} );
780
+ value_of( target.enable( "add" ) ).should_be(false);
781
+ value_of( target.enable( "mkcol" ) ).should_be(false);
782
+ value_of( target.enable( "renameSelection" ) ).should_be(false);
783
+ value_of( target.enable( "moveSelections" ) ).should_be(true);
784
+ value_of( target.enable( "removeSelections" ) ).should_be(true);
785
+
786
+ // ファイルとフォルダを選択
787
+ target.unselect( {path:"agents/agent_editor_test/dir1",type:"directory"} );
788
+ target.select( {path:"agents/agent_editor_test/file1",type:"file"} );
789
+ value_of( target.enable( "add" ) ).should_be(false);
790
+ value_of( target.enable( "mkcol" ) ).should_be(false);
791
+ value_of( target.enable( "renameSelection" ) ).should_be(false);
792
+ value_of( target.enable( "moveSelections" ) ).should_be(true);
793
+ value_of( target.enable( "removeSelections" ) ).should_be(true);
794
+
795
+ // agentsが選択されている
796
+ target.unselect( {path:"agents/agent_editor_test/file1",type:"file"} );
797
+ target.unselect( {path:"agents/agent_editor_test/dir2",type:"directory"} );
798
+ target.select( {path:"agents",type:"directory"} );
799
+ value_of( target.enable( "add" ) ).should_be(true);
800
+ value_of( target.enable( "mkcol" ) ).should_be(true);
801
+ value_of( target.enable( "renameSelection" ) ).should_be(false);
802
+ value_of( target.enable( "moveSelections" ) ).should_be(false);
803
+ value_of( target.enable( "removeSelections" ) ).should_be(false);
804
+
805
+ // shared_lib
806
+ target.unselect( {path:"agents",type:"directory"} );
807
+ target.select( {path:"shared_lib",type:"directory"} );
808
+ value_of( target.enable( "add" ) ).should_be(true);
809
+ value_of( target.enable( "mkcol" ) ).should_be(true);
810
+ value_of( target.enable( "renameSelection" ) ).should_be(false);
811
+ value_of( target.enable( "moveSelections" ) ).should_be(false);
812
+ value_of( target.enable( "removeSelections" ) ).should_be(false);
813
+ }
814
+
815
+ });