---++!! <nop>Integrated Development Environment (IDE) Modules in NPL Source code and documentation of most IDE modules can be found at script/ide/ folder. This topic provides an overview of useful IDE modules that developers can use to debug application, make UI, and complete various other common tasks. Most IDE modules are wrappers of relatively low level NPL functions or other IDE modules. This means that developers can always mix the use of IDE modules and raw NPL functions in their applications. <div style="float:right; margin:5px; width:240px; padding:5px; color:#4E5155; background-color:#F0EDED; border:1px solid #ccc;"><br />*Contents*<br />%TOC%<br /></div> ---++ IDE UI modules UI are the largest collection in IDE modules. They are in namespace __CommonCtrl__. ---+++ MultiLineEditbox Multiline editbox is a collection of single line editbox in a TreeView control. Features: * Mouse/Key board based text selection * Copy & Paste from/to clipboard * Arrow key, Home/End key navigation from line to line * Right click context menu for text selection * Syntax highlighting: support user defined syntax coloring scheme * International character input, such as Chinese, English. * Automatic word wrapping and line breaking _related_: TreeView, imeeditbox, MCML_Controls, ContextMenu ---+++ TreeView ---+++ gui_helper ---+++ MessageBox ---+++ HTMLRenderer ---++ DataBinding ---++ Common Library Common library contains modules for debugging, testing, data structuring, serialization, etc. They are in namespace __commonlib__ ---++ Unit Test Module The unit test module parses a test file, optionally replace test case input with user supplied ones, and finally output the test result to file and log. Test file markup: A test file may contain a group of test cases. Test cases can be declared in NPL comment block with the following format: <verbatim> %TESTCASE{"<test_case_name>", func = "<test_function>", input = <default_input>, output="<result_file>"}% </verbatim> The content inside TESTCASE is actually an NPL table, where * test_case_name is test case name, test_function is the name of the function to be called for the test case. * The test function is usually defined in the test file itself and should use global name. * default_input is input to the test case function. * result_file is where to save the test result. if this is nil, it will be saved to testfile.result For an example test file, please see script/ide/UnitTest/sample_test_file.lua. <verbatim> --[[ Title: Unit Test sample file Author(s): LiXizhi Date: 2008/3/5 Desc: use the lib: ------------------------------------------------------------ NPL.load("(gl)script/ide/UnitTest/sample_test_file.lua"); test.Example_Test_Function() -- result at temp/test_result.txt %TESTCASE{"Example Test", func="test.Example_Test_Function", input={varInt = 1, varString = "this is a string"}, output="temp/test_result.txt"}% -- result at script/ide/UnitTest/sample_test_file.lua.result %TESTCASE{"Example Test 2", func="test.Example_Test_Function", input={varInt2 = 2, varString2 = "Another input"}}% ------------------------------------------------------- ]] if(not test) then test ={} end -- passed by LiXizhi 2008.3.5 function test.Example_Test_Function(input) log(commonlib.serialize(input).." Test Succeed\n") end </verbatim> The result of "Example Test" will be saved to "temp/test_result.txt". It is in TWiki format which one can post to twiki topic. <verbatim> ---+++ case 1 _case_: Example Test Input: <verbatim> { ["varString"] = "this is a string", ["varInt"] = 1, } </verbatim> _Result_: <verbatim> { ["varString"] = "this is a string", ["varInt"] = 1, } Test Succeed </verbatim> </verbatim> %T% To invoke unit test programmatically, use following code <verbatim> ------------------------------------------------------- NPL.load("(gl)script/ide/UnitTest/unit_test.lua"); local test = commonlib.UnitTest:new(); if(test:ParseFile("script/ide/UnitTest/sample_test_file.lua")) then test:Run(); end -- or one can call individually with user input. local test = commonlib.UnitTest:new(); if(test:ParseFile("script/ide/UnitTest/sample_test_file.lua")) then test:ClearResult(); local i, count = 1, test:GetTestCaseCount() for i = 1, count do test:RunTestCase(i, {"any user input"}); end end ------------------------------------------------------- </verbatim> %T% To invoke unit test from a graphically user interface, please install the DeveloperApp. Alternatively, one can integrate unit testing UI in any place by calling unit_test_dlg.lua. * TestConsole: It can be opened by selecting Menu->Help->TestConsole <br /> <img src="%ATTACHURLPATH%/TestConsole.jpg" alt="TestConsole.jpg" width='687' height='596' />
Attachments
Attachments
Topic attachments
I
Attachment
History
Action
Size
Date
Who
Comment
jpg
TestConsole.jpg
r1
manage
62.2 K
2008-03-06 - 03:38
LiXizhi
TestConsole
Edit
|
Attach
|
P
rint version
|
H
istory
:
r4
<
r3
<
r2
<
r1
|
B
acklinks
|
V
iew topic
|
Raw edit
|
More topic actions...
Topic revision: r3 - 2008-03-06
-
LiXizhi
Home
Site map
CCWeb web
HaqiTeen web
Main web
ParaEngine web
TWiki web
Main Web
Users
Groups
Index
Search
Changes
Notifications
RSS Feed
Statistics
导航页WebTopMenu
Preferences
开发指南
Getting Started
ParacraftSDK
NPL
MCML
NPL Reference Manual
美术Mod
Account
Log In
English
简体中文
簡體中文
Edit
Attach
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback