Extensions for JSEvents

This commit is contained in:
Peter Schojer
2008-05-14 12:31:14 +00:00
parent 0d3e23167a
commit fba8e67818
11 changed files with 212 additions and 58 deletions

View File

@@ -67,6 +67,7 @@
#include "Poco/WebWidgets/ImageButtonCell.h"
#include "Poco/WebWidgets/TextEditCell.h"
#include "Poco/WebWidgets/SimpleTableModel.h"
#include "Poco/WebWidgets/JSDelegate.h"
#include "Poco/TeeStream.h"
#include "Poco/DateTimeFormat.h"
#include "Poco/DateTime.h"
@@ -1315,6 +1316,36 @@ void ExtJSTest::testTableImageButton()
}
void ExtJSTest::testJSEvent()
{
Button::Ptr pBut(new Button());
pBut->buttonClicked.add(jsDelegate("someFunction(obj)"));
pBut->buttonClicked.add(jsDelegate("function(obj){alert('Click');}"));
std::ostringstream out;
Utility::writeJSEvent(out, "clicked", pBut->buttonClicked.jsDelegates());
std::string result(out.str());
static const std::string expected("'clicked':"
"{"
"fn:function(obj){"
"var all={"
"d0:function(obj){"
"alert('Click');"
"},"
"d1:function(obj){"
"someFunction(obj);"
"},"
"invoke:function(obj){"
"this.d0(obj);"
"this.d1(obj);"
"}"
"};"
"all.invoke(obj);"
"}"
"}");
assert (result == expected);
}
void ExtJSTest::setUp()
{
}
@@ -1365,6 +1396,7 @@ CppUnit::Test* ExtJSTest::suite()
CppUnit_addTest(pSuite, ExtJSTest, testTableComboBox);
CppUnit_addTest(pSuite, ExtJSTest, testTableButton);
CppUnit_addTest(pSuite, ExtJSTest, testTableImageButton);
CppUnit_addTest(pSuite, ExtJSTest, testJSEvent);
return pSuite;
}

View File

@@ -81,7 +81,7 @@ public:
void testTableComboBox();
void testTableButton();
void testTableImageButton();
void testJSEvent();
void setUp();
void tearDown();