2011-12-23 17:59:20 +00:00
|
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
|
2017-02-15 00:43:09 +00:00
|
|
|
|
const UI = imports.testcommon.ui;
|
|
|
|
|
|
2023-06-08 04:52:46 +00:00
|
|
|
|
const Cogl = imports.gi.Cogl;
|
|
|
|
|
const Clutter = imports.gi.Clutter;
|
|
|
|
|
const Meta = imports.gi.Meta;
|
|
|
|
|
const St = imports.gi.St;
|
2011-12-23 17:59:20 +00:00
|
|
|
|
|
|
|
|
|
|
2012-06-24 19:11:41 +00:00
|
|
|
|
function test() {
|
2019-11-22 17:36:17 +00:00
|
|
|
|
Meta.init();
|
|
|
|
|
|
2022-09-07 18:25:19 +00:00
|
|
|
|
let stage = global.backend.get_stage();
|
2012-06-24 19:11:41 +00:00
|
|
|
|
UI.init(stage);
|
|
|
|
|
|
|
|
|
|
let vbox = new St.BoxLayout({ style: 'background: #ffee88;' });
|
|
|
|
|
vbox.add_constraint(new Clutter.BindConstraint({ source: stage,
|
|
|
|
|
coordinate: Clutter.BindCoordinate.SIZE }));
|
|
|
|
|
stage.add_actor(vbox);
|
|
|
|
|
|
|
|
|
|
let scroll = new St.ScrollView();
|
|
|
|
|
vbox.add(scroll, { expand: true });
|
|
|
|
|
|
2018-02-06 22:21:39 +00:00
|
|
|
|
vbox = new St.BoxLayout({ vertical: true,
|
|
|
|
|
style: 'padding: 10px;'
|
|
|
|
|
+ 'spacing: 20px;' });
|
2012-06-24 19:11:41 +00:00
|
|
|
|
scroll.add_actor(vbox);
|
|
|
|
|
|
|
|
|
|
let tbox = null;
|
|
|
|
|
|
|
|
|
|
function addTestCase(image, size, backgroundSize, useCairo) {
|
2020-10-23 20:05:13 +00:00
|
|
|
|
let obin = new St.Bin({ style: 'border: 3px solid green;' });
|
2012-06-24 19:11:41 +00:00
|
|
|
|
tbox.add(obin);
|
|
|
|
|
|
|
|
|
|
let [width, height] = size;
|
|
|
|
|
let bin = new St.Bin({ style_class: 'background-image-' + image,
|
|
|
|
|
width: width,
|
|
|
|
|
height: height,
|
2020-10-23 20:05:13 +00:00
|
|
|
|
style: `${useCairo
|
|
|
|
|
? 'border: 1px solid transparent;' : ''
|
|
|
|
|
} background-size: ${backgroundSize};`,
|
2012-06-24 19:11:41 +00:00
|
|
|
|
x_fill: true,
|
|
|
|
|
y_fill: true
|
|
|
|
|
});
|
|
|
|
|
obin.set_child(bin);
|
|
|
|
|
|
|
|
|
|
bin.set_child(new St.Label({ text: backgroundSize + (useCairo ? ' (cairo)' : ' (cogl)'),
|
|
|
|
|
style: 'font-size: 15px;'
|
|
|
|
|
+ 'text-align: center;'
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-23 20:05:13 +00:00
|
|
|
|
function addTestLine(image, size) {
|
2012-06-24 19:11:41 +00:00
|
|
|
|
const backgroundSizes = ["auto", "contain", "cover", "200px 200px", "100px 100px", "100px 200px"];
|
|
|
|
|
|
|
|
|
|
let [width, height] = size;
|
|
|
|
|
vbox.add(new St.Label({ text: image + '.svg / ' + width + '×' + height,
|
|
|
|
|
style: 'font-size: 15px;'
|
|
|
|
|
+ 'text-align: center;'
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
tbox = new St.BoxLayout({ style: 'spacing: 20px;' });
|
|
|
|
|
vbox.add(tbox);
|
|
|
|
|
|
2018-02-06 22:25:29 +00:00
|
|
|
|
for (let s of backgroundSizes)
|
2012-06-24 19:11:41 +00:00
|
|
|
|
addTestCase(image, size, s, false);
|
2018-02-06 22:25:29 +00:00
|
|
|
|
for (let s of backgroundSizes)
|
2012-06-24 19:11:41 +00:00
|
|
|
|
addTestCase(image, size, s, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addTestImage(image) {
|
|
|
|
|
const containerSizes = [[100, 100], [200, 200], [250, 250], [100, 250], [250, 100]];
|
|
|
|
|
|
2018-02-06 22:25:29 +00:00
|
|
|
|
for (let size of containerSizes)
|
2012-06-24 19:11:41 +00:00
|
|
|
|
addTestLine(image, size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addTestImage ('200-200');
|
|
|
|
|
addTestImage ('200-100');
|
|
|
|
|
addTestImage ('100-200');
|
|
|
|
|
|
|
|
|
|
UI.main(stage);
|
2011-12-23 17:59:20 +00:00
|
|
|
|
}
|
2012-06-24 19:11:41 +00:00
|
|
|
|
test();
|