tests: Run each test in a function

As the global object of a context is rooted, if we want the GC to act
on these objects we need to take them out of the globals.

https://bugzilla.gnome.org/show_bug.cgi?id=678737
This commit is contained in:
Jasper St. Pierre 2012-06-24 15:11:41 -04:00
parent 0d82ce5210
commit c7196a519f
16 changed files with 794 additions and 769 deletions

View File

@ -6,6 +6,7 @@ const St = imports.gi.St;
const UI = imports.testcommon.ui;
function test() {
let stage = new Clutter.Stage({ user_resizable: true, width: 1024, height: 768 });
UI.init(stage);
@ -96,6 +97,6 @@ addTestImage ('200-200');
addTestImage ('200-100');
addTestImage ('100-200');
stage.show();
Clutter.main();
stage.destroy();
UI.main(stage);
}
test();

View File

@ -5,6 +5,7 @@ const St = imports.gi.St;
const UI = imports.testcommon.ui;
function test() {
let stage = new Clutter.Stage({ width: 640, height: 480 });
UI.init(stage);
@ -56,6 +57,6 @@ addTestCase("200px 200px 200px 200px", false);
addTestCase("200px 200px 0px 200px", false);
addTestCase("999px 0px 999px 0px", false);
stage.show();
Clutter.main();
stage.destroy();
UI.main(stage);
}
test();

View File

@ -5,6 +5,7 @@ const St = imports.gi.St;
const UI = imports.testcommon.ui;
function test() {
let stage = new Clutter.Stage({ width: 640, height: 480 });
UI.init(stage);
@ -53,6 +54,6 @@ addTestCase([" 5px", "10px", "15px", " 0px"], true);
addTestCase(["10px", "15px", " 0px", " 5px"], true);
addTestCase(["15px", " 0px", " 5px", "10px"], true);
stage.show();
Clutter.main();
stage.destroy();
UI.main(stage);
}
test();

View File

@ -5,6 +5,7 @@ const St = imports.gi.St;
const UI = imports.testcommon.ui;
function test() {
let stage = new Clutter.Stage({ width: 640, height: 480 });
UI.init(stage);
@ -83,6 +84,7 @@ box.add(framedGradients);
function addGradientCase(direction, borderWidth, borderRadius, extra) {
let gradientBox = new St.BoxLayout({ style_class: 'background-gradient',
style: 'border: ' + borderWidth + 'px solid #8b0000;'
>>>>>>> 2aff593... tests: Run each test in a function
+ 'border-radius: ' + borderRadius + 'px;'
+ 'background-gradient-direction: ' + direction + ';'
+ 'width: 32px;'
@ -128,6 +130,6 @@ addBackgroundImageCase (0, 5, 64, 64, '-st-background-image-shadow: -2px -2px 6p
addBackgroundImageCase (5, 5, 64, 64, '-st-background-image-shadow: -2px -2px 0px 6px rgba(0,0,0,0.5);');
addBackgroundImageCase (0, 5, 32, 32, 'background-position: 2px 5px');
stage.show();
Clutter.main();
stage.destroy();
UI.main(stage);
}
test();

View File

@ -5,6 +5,7 @@ const St = imports.gi.St;
const UI = imports.testcommon.ui;
function test() {
let stage = new Clutter.Stage();
UI.init(stage);
@ -86,7 +87,5 @@ for (let width = 200; width <= 500; width += 60 ) {
x_align: St.Align.MIDDLE });
}
////////////////////////////////////////////////////////////////////////////////
stage.show();
Clutter.main();
UI.main(stage);
}

View File

@ -5,6 +5,7 @@ const St = imports.gi.St;
const UI = imports.testcommon.ui;
function test() {
let stage = new Clutter.Stage({ width: 640, height: 480 });
UI.init(stage);
@ -51,6 +52,6 @@ addTestCase (true, -3, -4, 4, 0);
addTestCase (true, 0, 0, 0, 4);
addTestCase (true, 0, 0, 4, 0);
stage.show();
Clutter.main();
stage.destroy();
UI.main(stage);
}
test();

View File

@ -7,6 +7,7 @@ const St = imports.gi.St;
const Calendar = imports.ui.calendar;
const UI = imports.testcommon.ui;
function test() {
let stage = new Clutter.Stage({ width: 400, height: 400 });
UI.init(stage);
@ -22,6 +23,6 @@ vbox.add(calendar.actor,
x_fill: false, x_align: St.Align.MIDDLE,
y_fill: false, y_align: St.Align.START });
stage.show();
Clutter.main();
stage.destroy();
UI.main(stage);
}
test();

View File

@ -5,6 +5,7 @@ const St = imports.gi.St;
const UI = imports.testcommon.ui;
function test() {
let stage = new Clutter.Stage();
UI.init(stage);
@ -35,5 +36,6 @@ b2.add(t);
t = new St.Label({ "text": "Italic Monospace", style_class: "italic" });
b2.add(t);
stage.show();
Clutter.main();
UI.main(stage);
}
test();

View File

@ -7,6 +7,7 @@ const St = imports.gi.St;
const Calendar = imports.ui.calendar;
const UI = imports.testcommon.ui;
function test() {
let stage = new Clutter.Stage({ width: 400, height: 400 });
UI.init(stage);
@ -22,6 +23,6 @@ vbox.add(entry,
y_fill: false, y_align: St.Align.MIDDLE });
entry.grab_key_focus();
stage.show();
Clutter.main();
stage.destroy();
UI.main(stage);
}
test();

View File

@ -5,6 +5,7 @@ const St = imports.gi.St;
const UI = imports.testcommon.ui;
function test() {
let stage = new Clutter.Stage();
UI.init(stage);
@ -81,5 +82,6 @@ iconRow(batteryIcons, reversedCss);
iconRow(volumeIcons, normalCss);
iconRow(volumeIcons, reversedCss);
stage.show();
Clutter.main();
UI.main(stage);
}
test();

View File

@ -5,6 +5,7 @@ const St = imports.gi.St;
const UI = imports.testcommon.ui;
function test() {
let stage = new Clutter.Stage();
UI.init(stage);
@ -41,7 +42,6 @@ button.connect('clicked', function() {
update_size ();
});
stage.show();
Clutter.main();
stage.destroy();
UI.main(stage);
}
test();

View File

@ -251,6 +251,7 @@ SizingIllustrator.prototype = {
/****************************************************************************/
function test() {
let stage = new Clutter.Stage({ width: 600, height: 600 });
UI.init(stage);
@ -383,6 +384,6 @@ function toggleFade(button) {
vfade.connect('clicked', function() { toggleFade(vfade); });
stage.show();
Clutter.main();
stage.destroy();
UI.main(stage);
}
test();

View File

@ -6,6 +6,7 @@ const St = imports.gi.St;
const UI = imports.testcommon.ui;
function test() {
let stage = new Clutter.Stage();
UI.init(stage);
@ -47,6 +48,6 @@ for (let i = 0; i < 26 * 3; i++) {
b.add(t);
}
stage.show();
Clutter.main();
stage.destroy();
UI.main(stage);
}
test();

View File

@ -5,6 +5,7 @@ const St = imports.gi.St;
const UI = imports.testcommon.ui;
function test() {
let stage = new Clutter.Stage({ width: 600, height: 600 });
UI.init(stage);
@ -51,5 +52,6 @@ table.add(L("6", "#00ffff"),
////////////////////////////////////////////////////////////////////////////////
stage.show();
Clutter.main();
UI.main(stage);
}
test();

View File

@ -5,6 +5,7 @@ const St = imports.gi.St;
const UI = imports.testcommon.ui;
function test() {
let stage = new Clutter.Stage();
UI.init(stage);
@ -30,5 +31,6 @@ for (let i = 0; i < 5; i ++) {
////////////////////////////////////////////////////////////////////////////////
stage.show();
Clutter.main();
UI.main(stage);
}
test();

View File

@ -13,3 +13,11 @@ function init(stage) {
let theme = new St.Theme({ application_stylesheet: stylesheetPath });
context.set_theme(theme);
}
function main(stage) {
stage.show();
stage.connect('destroy', function() {
Clutter.main_quit();
});
Clutter.main();
}