Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
officejs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
officejs
Commits
e2f63b29
Commit
e2f63b29
authored
Sep 04, 2012
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Interaction tests.
Split tests into folders. Clean up unused (not implemented) API.
parent
b2b89799
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
112 additions
and
53 deletions
+112
-53
OfficeJS/src/renderjs/renderjs.js
OfficeJS/src/renderjs/renderjs.js
+1
-9
OfficeJS/src/renderjs/test/interactions/A.html
OfficeJS/src/renderjs/test/interactions/A.html
+10
-0
OfficeJS/src/renderjs/test/interactions/B.html
OfficeJS/src/renderjs/test/interactions/B.html
+11
-0
OfficeJS/src/renderjs/test/interactions/index.html
OfficeJS/src/renderjs/test/interactions/index.html
+24
-0
OfficeJS/src/renderjs/test/loading/test-gadget.html
OfficeJS/src/renderjs/test/loading/test-gadget.html
+0
-0
OfficeJS/src/renderjs/test/renderjs_test.js
OfficeJS/src/renderjs/test/renderjs_test.js
+66
-44
No files found.
OfficeJS/src/renderjs/renderjs.js
View file @
e2f63b29
...
@@ -441,13 +441,6 @@ var RenderJs = (function () {
...
@@ -441,13 +441,6 @@ var RenderJs = (function () {
}
}
);
);
return
result
;
return
result
;
},
getSelf
:
function
()
{
/*
* Return Gadget's Javascript representation
*/
// XXX:
}
}
};
};
}()),
}()),
...
@@ -489,8 +482,7 @@ var RenderJs = (function () {
...
@@ -489,8 +482,7 @@ var RenderJs = (function () {
var
source
,
source_gadget_id
,
source_method_id
,
var
source
,
source_gadget_id
,
source_method_id
,
source_gadget
,
destination
,
destination_gadget_id
,
source_gadget
,
destination
,
destination_gadget_id
,
destination_method_id
,
destination_gadget
,
destination_method_id
,
destination_gadget
,
original_source_method_id
,
original_source_method_id
;
func_body
,
func
;
source
=
$
(
value
).
attr
(
"
source
"
).
split
(
"
.
"
);
source
=
$
(
value
).
attr
(
"
source
"
).
split
(
"
.
"
);
source_gadget_id
=
source
[
0
];
source_gadget_id
=
source
[
0
];
source_method_id
=
source
[
1
];
source_method_id
=
source
[
1
];
...
...
OfficeJS/src/renderjs/test/interactions/A.html
0 → 100644
View file @
e2f63b29
<div>
A (gadget)
</div>
<script
type=
"text/javascript"
language=
"javascript"
>
//
<!
[
CDATA
[
$
(
document
).
ready
(
function
()
{
gadget
=
RenderJs
.
GadgetIndex
.
getGadgetById
(
"
A
"
);
gadget
.
inc
=
function
(){
counter
=
counter
+
1
;};
});
//]]>
</script>
\ No newline at end of file
OfficeJS/src/renderjs/test/interactions/B.html
0 → 100644
View file @
e2f63b29
<div>
B (gadget)
</div>
<script
type=
"text/javascript"
language=
"javascript"
>
//
<!
[
CDATA
[
$
(
document
).
ready
(
function
()
{
gadget
=
RenderJs
.
GadgetIndex
.
getGadgetById
(
"
B
"
);
gadget
.
inc
=
function
(){
counter
=
counter
+
1
};
gadget
.
htmlEvent1
=
function
(){
counter
=
counter
+
1
;};
});
//]]>
</script>
\ No newline at end of file
OfficeJS/src/renderjs/test/interactions/index.html
0 → 100644
View file @
e2f63b29
<div
id=
"A"
data-gadget=
"interactions/A.html"
data-gadget-cacheable=
"0"
data-gadget-cache-id=
"A"
></div>
<div
id=
"B"
data-gadget=
"interactions/B.html"
data-gadget-cacheable=
"0"
data-gadget-cache-id=
"B"
></div>
<div
data-gadget=
""
id=
"main-interactor"
>
<connect
source=
"A.inc"
destination=
"B.inc"
></connect>
<connect
source=
"A.htmlEvent1"
destination=
"B.htmlEvent1"
></connect>
</div>
OfficeJS/src/renderjs/test/test-gadget.html
→
OfficeJS/src/renderjs/test/
loading/
test-gadget.html
View file @
e2f63b29
File moved
OfficeJS/src/renderjs/test/renderjs_test.js
View file @
e2f63b29
/*
/*
* RenderJs tests
* RenderJs tests
*/
*/
counter
=
0
;
function
cleanUp
()
{
/*
* Clean up namespace between tests
*/
// re-init GadgetIndex
$
.
each
(
RenderJs
.
GadgetIndex
.
getGadgetList
(),
function
()
{
RenderJs
.
GadgetIndex
.
unregisterGadget
(
this
);
});
}
function
setupRenderJSTest
(){
function
setupRenderJSTest
(){
/*
/*
...
@@ -8,62 +19,73 @@ function setupRenderJSTest(){
...
@@ -8,62 +19,73 @@ function setupRenderJSTest(){
*/
*/
module
(
"
Cache
"
);
module
(
"
Cache
"
);
test
(
'
Cache
'
,
function
()
{
test
(
'
Cache
'
,
function
()
{
cache_id
=
'
my_test
'
;
cache_id
=
'
my_test
'
;
data
=
{
'
gg
'
:
1
};
data
=
{
'
gg
'
:
1
};
RenderJs
.
Cache
.
set
(
cache_id
,
data
);
RenderJs
.
Cache
.
set
(
cache_id
,
data
);
deepEqual
(
data
,
RenderJs
.
Cache
.
get
(
cache_id
));
deepEqual
(
data
,
RenderJs
.
Cache
.
get
(
cache_id
));
});
});
module
(
"
GadgetIndex
"
);
module
(
"
GadgetIndex
"
);
test
(
'
GadgetIndex
'
,
function
()
{
test
(
'
GadgetIndex
'
,
function
()
{
// re-init GadgetIndex
cleanUp
();
$
.
each
(
RenderJs
.
GadgetIndex
.
getGadgetList
(),
function
()
{
$
(
"
#qunit-fixture
"
).
append
(
'
<div data-gadget="" id="new">X</div>
'
);
RenderJs
.
GadgetIndex
.
unregisterGadget
(
this
);
RenderJs
.
bootstrap
(
$
(
"
#qunit-fixture
"
));
});
RenderJs
.
GadgetIndex
.
getRootGadget
().
getDom
().
one
(
"
ready
"
,
function
(){
RenderJs
.
update
(
$
(
"
#qunit-fixture
"
));
$
(
"
#qunit-fixture
"
).
append
(
'
<div data-gadget="" id="new">XXXXXXXXXXXX</div>
'
);
});
RenderJs
.
bootstrap
(
$
(
"
#qunit-fixture
"
));
equal
(
RenderJs
.
GadgetIndex
.
getGadgetList
().
length
,
2
);
RenderJs
.
GadgetIndex
.
getRootGadget
().
getDom
().
one
(
"
ready
"
,
function
(){
equal
(
true
,
RenderJs
.
GadgetIndex
.
isGadgetListLoaded
());
RenderJs
.
update
(
$
(
"
#qunit-fixture
"
));
equal
(
$
(
"
#qunit-fixture
"
).
attr
(
"
id
"
),
RenderJs
.
GadgetIndex
.
getRootGadget
().
getDom
().
attr
(
"
id
"
));
});
equal
(
RenderJs
.
GadgetIndex
.
getGadgetById
(
"
qunit-fixture
"
),
RenderJs
.
GadgetIndex
.
getRootGadget
());
equal
(
RenderJs
.
GadgetIndex
.
getGadgetList
().
length
,
2
);
equal
(
true
,
RenderJs
.
GadgetIndex
.
isGadgetListLoaded
());
equal
(
$
(
"
#qunit-fixture
"
).
attr
(
"
id
"
),
RenderJs
.
GadgetIndex
.
getRootGadget
().
getDom
().
attr
(
"
id
"
));
equal
(
RenderJs
.
GadgetIndex
.
getGadgetById
(
"
qunit-fixture
"
),
RenderJs
.
GadgetIndex
.
getRootGadget
());
// unregister gadget all gadgets from this test not to mess with rest of tests
// unregister gadget all gadgets from this test not to mess with rest of tests
RenderJs
.
GadgetIndex
.
unregisterGadget
(
RenderJs
.
GadgetIndex
.
getGadgetById
(
"
qunit-fixture
"
));
RenderJs
.
GadgetIndex
.
unregisterGadget
(
RenderJs
.
GadgetIndex
.
getGadgetById
(
"
qunit-fixture
"
));
equal
(
RenderJs
.
GadgetIndex
.
getGadgetList
().
length
,
1
);
equal
(
RenderJs
.
GadgetIndex
.
getGadgetList
().
length
,
1
);
equal
(
RenderJs
.
GadgetIndex
.
getGadgetById
(
"
new
"
),
RenderJs
.
GadgetIndex
.
getRootGadget
());
equal
(
RenderJs
.
GadgetIndex
.
getGadgetById
(
"
new
"
),
RenderJs
.
GadgetIndex
.
getRootGadget
());
RenderJs
.
GadgetIndex
.
unregisterGadget
(
RenderJs
.
GadgetIndex
.
getGadgetById
(
"
new
"
));
RenderJs
.
GadgetIndex
.
unregisterGadget
(
RenderJs
.
GadgetIndex
.
getGadgetById
(
"
new
"
));
equal
(
RenderJs
.
GadgetIndex
.
getGadgetList
().
length
,
0
);
equal
(
RenderJs
.
GadgetIndex
.
getGadgetList
().
length
,
0
);
});
});
module
(
"
TabularGadget
"
);
module
(
"
addGadget
"
);
test
(
'
addNewTabGadget
'
,
function
()
{
test
(
'
addGadget
'
,
function
()
{
RenderJs
.
TabbularGadget
.
addNewTabGadget
(
"
qunit-fixture
"
,
"
test-gadget.html
"
,
""
,
""
);
cleanUp
();
equal
(
$
(
"
#qunit-fixture
"
).
children
(
"
.gadget
"
).
length
,
1
);
RenderJs
.
addGadget
(
"
qunit-fixture
"
,
"
loading/test-gadget.html
"
,
""
,
""
);
equal
(
RenderJs
.
GadgetIndex
.
getGadgetList
().
length
,
1
);
equal
(
$
(
"
#qunit-fixture
"
).
children
(
"
.gadget
"
).
length
,
1
);
equal
(
RenderJs
.
GadgetIndex
.
getGadgetList
().
length
,
1
);
});
});
module
(
"
GadgetInitialization
"
);
module
(
"
GadgetInitialization
"
);
test
(
'
GadgetInitialization
'
,
function
()
{
test
(
'
GadgetInitialization
'
,
function
()
{
// re-init GadgetIndex
cleanUp
();
$
.
each
(
RenderJs
.
GadgetIndex
.
getGadgetList
(),
function
()
{
$
(
"
#qunit-fixture
"
).
append
(
'
<div data-gadget="" id="new-init" data-gadget-property="{"name": "Ivan", "age": 33}">X</div>
'
);
RenderJs
.
GadgetIndex
.
unregisterGadget
(
this
);
RenderJs
.
bootstrap
(
$
(
"
#qunit-fixture
"
));
});
RenderJs
.
GadgetIndex
.
getRootGadget
().
getDom
().
one
(
"
ready
"
,
function
(){
RenderJs
.
update
(
$
(
"
#qunit-fixture
"
));
});
$
(
"
#qunit-fixture
"
).
append
(
'
<div data-gadget="" id="new-init" data-gadget-property="{"name": "Ivan", "age": 33}">XXXXXXXXXXXX</div>
'
);
// test that gadget get a proper initialization from data-gadget-property
RenderJs
.
bootstrap
(
$
(
"
#qunit-fixture
"
));
equal
(
'
Ivan
'
,
RenderJs
.
GadgetIndex
.
getGadgetById
(
"
new-init
"
).
name
);
RenderJs
.
GadgetIndex
.
getRootGadget
().
getDom
().
one
(
"
ready
"
,
function
(){
equal
(
33
,
RenderJs
.
GadgetIndex
.
getGadgetById
(
"
new-init
"
).
age
);
RenderJs
.
update
(
$
(
"
#qunit-fixture
"
));
});
});
// test that gadget get a proper initialization from data-gadget-property
equal
(
'
Ivan
'
,
RenderJs
.
GadgetIndex
.
getGadgetById
(
"
new-init
"
).
name
);
equal
(
33
,
RenderJs
.
GadgetIndex
.
getGadgetById
(
"
new-init
"
).
age
);
});
// XXX: test InteractionGadget
module
(
"
InteractionGadget
"
);
test
(
'
InteractionGadget
'
,
function
()
{
cleanUp
();
RenderJs
.
addGadget
(
"
qunit-fixture
"
,
"
interactions/index.html
"
,
""
,
""
);
stop
();
// we need to wait for all gadgets loading ...
window
.
setTimeout
(
function
()
{
RenderJs
.
InteractionGadget
.
bind
(
$
(
"
#main-interactor
"
));
start
();
equal
(
0
,
counter
);
// A.inc will call B.inc, both will increase counter by 1
RenderJs
.
GadgetIndex
.
getGadgetById
(
"
A
"
).
inc
();
equal
(
2
,
counter
);
// fire pure HTML event on A and test it calls respective B method
$
(
'
#A
'
).
trigger
(
'
htmlEvent1
'
);
equal
(
3
,
counter
);
},
500
);
});
};
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment