summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorP. F. Chimento <philip.chimento@gmail.com>2013-09-16 15:47:56 -0700
committerP. F. Chimento <philip.chimento@gmail.com>2013-09-16 15:47:56 -0700
commit71dc1ec920d95b95bd0e7ff91dadb031432adda1 (patch)
tree2ecb56fbaba98e243acf5acf63328c952d97e22f /test
parent1c4bc890875ee5e7edad81fd6a8b5644058e936d (diff)
parent0dd5fa5fcec9bad9bd87ad0a9b04b63d47cd2a6c (diff)
Merge pull request #300 from endlessm/issues/299
#299 Gtk and clutter tests for framerate
Diffstat (limited to 'test')
-rw-r--r--test/smoke-tests/frame-rate-tests/1080/background1.jpgbin0 -> 525725 bytes
-rw-r--r--test/smoke-tests/frame-rate-tests/1080/background2.jpgbin0 -> 300852 bytes
-rw-r--r--test/smoke-tests/frame-rate-tests/720/background1.jpgbin0 -> 169104 bytes
-rw-r--r--test/smoke-tests/frame-rate-tests/720/background2.jpgbin0 -> 165416 bytes
-rw-r--r--test/smoke-tests/frame-rate-tests/README16
-rw-r--r--test/smoke-tests/frame-rate-tests/clutter.js109
-rw-r--r--test/smoke-tests/frame-rate-tests/gtk.css15
-rw-r--r--test/smoke-tests/frame-rate-tests/gtk.js84
8 files changed, 224 insertions, 0 deletions
diff --git a/test/smoke-tests/frame-rate-tests/1080/background1.jpg b/test/smoke-tests/frame-rate-tests/1080/background1.jpg
new file mode 100644
index 0000000..b7b463d
--- /dev/null
+++ b/test/smoke-tests/frame-rate-tests/1080/background1.jpg
Binary files differ
diff --git a/test/smoke-tests/frame-rate-tests/1080/background2.jpg b/test/smoke-tests/frame-rate-tests/1080/background2.jpg
new file mode 100644
index 0000000..4e505d1
--- /dev/null
+++ b/test/smoke-tests/frame-rate-tests/1080/background2.jpg
Binary files differ
diff --git a/test/smoke-tests/frame-rate-tests/720/background1.jpg b/test/smoke-tests/frame-rate-tests/720/background1.jpg
new file mode 100644
index 0000000..d52e2a3
--- /dev/null
+++ b/test/smoke-tests/frame-rate-tests/720/background1.jpg
Binary files differ
diff --git a/test/smoke-tests/frame-rate-tests/720/background2.jpg b/test/smoke-tests/frame-rate-tests/720/background2.jpg
new file mode 100644
index 0000000..df23b5c
--- /dev/null
+++ b/test/smoke-tests/frame-rate-tests/720/background2.jpg
Binary files differ
diff --git a/test/smoke-tests/frame-rate-tests/README b/test/smoke-tests/frame-rate-tests/README
new file mode 100644
index 0000000..0c5aa17
--- /dev/null
+++ b/test/smoke-tests/frame-rate-tests/README
@@ -0,0 +1,16 @@
+Some basic animation tests to help see what kinds of animation are possible on
+what architectures.
+
+Usage:
+ CLUTTER_SHOW_FPS=1 gjs clutter.js [crossfade/slide] [1080/720]
+ GDK_DEBUG=frames gjs gtk.js [crossfade/slide] [1080/720]
+
+You can choose between a cross fade and a slide, and a 1080 or 720 image asset
+to animate. (The screen resolution and not the asset size should really
+determine frame rate, but just in case.)
+
+Clutter will print out a proper frame rate, whereas GTK will print out
+a series of intervals between draw updates. During an animation these
+should be at 16 milliseconds for 60 FPS.
+
+Click to trigger a slide. Press any key to quit.
diff --git a/test/smoke-tests/frame-rate-tests/clutter.js b/test/smoke-tests/frame-rate-tests/clutter.js
new file mode 100644
index 0000000..d3abb4b
--- /dev/null
+++ b/test/smoke-tests/frame-rate-tests/clutter.js
@@ -0,0 +1,109 @@
+const Clutter = imports.gi.Clutter;
+const GdkPixbuf = imports.gi.GdkPixbuf;
+const Cogl = imports.gi.Cogl;
+const Lang = imports.lang;
+const Endless = imports.gi.Endless;
+Clutter.init(null, null);
+
+let crossfade = ARGV[0] === "crossfade";
+
+let file_dir = Endless.getCurrentFileDir();
+
+let BACKGROUND1_PATH = file_dir + '/1080/background1.jpg';
+let BACKGROUND2_PATH = file_dir + '/1080/background2.jpg';
+if (ARGV[1] === "720") {
+ BACKGROUND1_PATH = file_dir + '/720/background1.jpg';
+ BACKGROUND2_PATH = file_dir + '/720/background2.jpg';
+}
+
+// Convenience function to load a gresource image into a Clutter.Image
+function load_clutter_image(path) {
+ let pixbuf = GdkPixbuf.Pixbuf.new_from_file(path);
+ let image = new Clutter.Image();
+ if (pixbuf != null) {
+ image.set_data(pixbuf.get_pixels(),
+ pixbuf.get_has_alpha()
+ ? Cogl.PixelFormat.RGBA_8888
+ : Cogl.PixelFormat.RGB_888,
+ pixbuf.get_width(),
+ pixbuf.get_height(),
+ pixbuf.get_rowstride());
+ }
+ return image;
+}
+
+const TestStage = new Lang.Class ({
+ Name: 'TestStage',
+ Extends: Clutter.Stage,
+
+ _init: function(params) {
+ this.parent(params);
+ this.set_fullscreen(true);
+ this.connect("allocation-changed", Lang.bind(this, function(actor, allocation) {
+ this._update_actors();
+ }));
+
+ this._page1 = new Clutter.Actor({
+ "x-expand": true,
+ "y-expand": true,
+ "content": load_clutter_image(BACKGROUND1_PATH),
+ "reactive": true
+ });
+ this.add_child(this._page1);
+ this._page1.connect("button-press-event", Lang.bind(this, function(actor, event) {
+ this._swap();
+ }));
+
+ this._page2 = new Clutter.Actor({
+ "x-expand": true,
+ "y-expand": true,
+ "content": load_clutter_image(BACKGROUND2_PATH),
+ "reactive": true
+ });
+ this.add_child(this._page2);
+ this._page2.connect("button-press-event", Lang.bind(this, function(actor, event) {
+ this._swap();
+ }));
+
+ this._update_actors();
+ this.connect("key-press-event", Clutter.main_quit);
+ },
+
+ _swap: function() {
+ this._swapped = !this._swapped;
+ this._page1.save_easing_state();
+ this._page2.save_easing_state();
+ this._page1.set_easing_duration(10000);
+ this._page2.set_easing_duration(10000);
+ this._update_actors();
+ this._page1.restore_easing_state();
+ this._page2.restore_easing_state();
+ },
+
+ _update_actors: function() {
+ this._page1.x = 0;
+ this._page1.width = this.get_width();
+ this._page1.height = this.get_height();
+ this._page2.x = 0;
+ this._page2.width = this.get_width();
+ this._page2.height = this.get_height();
+ if (crossfade) {
+ if(this._swapped)
+ this._page2.opacity = 255;
+ else
+ this._page2.opacity = 0;
+ }
+ else {
+ if(this._swapped)
+ this._page1.x = -this.get_width();
+ else
+ this._page2.x = this.get_width();
+ }
+ }
+});
+
+
+let stage = new TestStage();
+stage.show();
+Clutter.main();
+stage.destroy();
diff --git a/test/smoke-tests/frame-rate-tests/gtk.css b/test/smoke-tests/frame-rate-tests/gtk.css
new file mode 100644
index 0000000..c024276
--- /dev/null
+++ b/test/smoke-tests/frame-rate-tests/gtk.css
@@ -0,0 +1,15 @@
+#page1_1080 {
+ background-image: url("1080/background1.jpg");
+}
+
+#page2_1080 {
+ background-image: url("1080/background2.jpg");
+}
+
+#page1_720 {
+ background-image: url("720/background1.jpg");
+}
+
+#page2_720 {
+ background-image: url("720/background2.jpg");
+}
diff --git a/test/smoke-tests/frame-rate-tests/gtk.js b/test/smoke-tests/frame-rate-tests/gtk.js
new file mode 100644
index 0000000..8af1376
--- /dev/null
+++ b/test/smoke-tests/frame-rate-tests/gtk.js
@@ -0,0 +1,84 @@
+// Copyright 2013 Endless Mobile, Inc.
+
+const Lang = imports.lang;
+const Gtk = imports.gi.Gtk;
+const PLib = imports.gi.PLib;
+const GObject = imports.gi.GObject;
+const Endless = imports.gi.Endless;
+
+const TEST_APPLICATION_ID = "com.frametest";
+
+let TRANSITION1 = PLib.StackTransitionType.SLIDE_LEFT;
+let TRANSITION2 = PLib.StackTransitionType.SLIDE_RIGHT;
+if (ARGV[0] === "crossfade") {
+ TRANSITION1 = PLib.StackTransitionType.CROSSFADE;
+ TRANSITION2 = PLib.StackTransitionType.CROSSFADE;
+}
+
+let BACKGROUND1_NAME = "page1_1080";
+let BACKGROUND2_NAME = "page2_1080";
+if (ARGV[1] === "720") {
+ BACKGROUND1_NAME = "page1_720";
+ BACKGROUND2_NAME = "page2_720";
+}
+
+const TestApplication = new Lang.Class ({
+ Name: "TestApplication",
+ Extends: Gtk.Application,
+
+ vfunc_startup: function() {
+ this.parent();
+
+ // First page
+ this._page1 = new Gtk.EventBox({
+ name: BACKGROUND1_NAME,
+ expand: true
+ });
+ this._page1.connect("button-press-event", Lang.bind(this, function () {
+ this._stack.set_transition_type(TRANSITION1);
+ this._stack.set_visible_child(this._page2);
+ }));
+
+ // Second page
+ this._page2 = new Gtk.Button({
+ name: BACKGROUND2_NAME,
+ expand: true
+ });
+ this._page2.connect("button-press-event", Lang.bind(this, function () {
+ this._stack.set_transition_type(TRANSITION2);
+ this._stack.set_visible_child(this._page1);
+ }));
+
+ this._stack = new PLib.Stack();
+ this._stack.add(this._page1);
+ this._stack.add(this._page2);
+
+ this._stack.set_transition_duration(10000);
+
+ this._window = new Gtk.Window({
+ application: this,
+ });
+ this._window.add(this._stack);
+ this._window.show_all();
+ this._window.fullscreen();
+ this._window.connect("key-press-event", Lang.bind(this, function() {
+ this._window.destroy();
+ }));
+
+ let provider = new Gtk.CssProvider ();
+ provider.load_from_path (Endless.getCurrentFileDir() + "/gtk.css");
+ let context = new Gtk.StyleContext();
+ context.add_provider_for_screen(this._window.get_screen(),
+ provider,
+ Gtk.STYLE_PROVIDER_PRIORITY_USER);
+
+ },
+
+ vfunc_activate: function() {
+ this.parent();
+ }
+});
+
+let app = new TestApplication({ application_id: TEST_APPLICATION_ID,
+ flags: 0 });
+app.run(ARGV);