aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cpp-unit-tests/browser_mock.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cpp-unit-tests/browser_mock.cc')
-rw-r--r--tests/cpp-unit-tests/browser_mock.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/cpp-unit-tests/browser_mock.cc b/tests/cpp-unit-tests/browser_mock.cc
index 6b01224..e333be7 100644
--- a/tests/cpp-unit-tests/browser_mock.cc
+++ b/tests/cpp-unit-tests/browser_mock.cc
@@ -73,17 +73,30 @@ static void mock_releaseobject(NPObject* obj) {
if (obj->_class->deallocate) {
obj->_class->deallocate(obj);
} else {
- free(obj);
+ mock_memfree(obj);
}
}
}
+static NPObject* mock_createobject(NPP instance, NPClass* np_class) {
+ NPObject* obj;
+ if (np_class->allocate) {
+ obj = np_class->allocate(instance, np_class);
+ } else {
+ obj = (NPObject*) mock_memalloc(sizeof(NPObject));
+ }
+ obj->referenceCount = 1;
+ obj->_class = np_class;
+ return obj;
+}
+
void browsermock_setup_functions() {
memset(&browser_functions, 0, sizeof(NPNetscapeFuncs));
browser_functions.memalloc = &mock_memalloc;
browser_functions.memfree = &mock_memfree;
+ browser_functions.createobject = &mock_createobject;
browser_functions.retainobject = &mock_retainobject;
browser_functions.releaseobject= &mock_releaseobject;
}