[gnome-shell] Scripting.createTestWindow(): take params



commit f285f2c69f4d8528a82c16f06025b64e3b802c92
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Mon May 19 21:00:01 2014 -0400

    Scripting.createTestWindow(): take params
    
    Take a parameter object rather than a long parameter list containing
    multiple booleans.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=732349

 js/perf/core.js    |    5 ++++-
 js/ui/scripting.js |   19 ++++++++++++++-----
 2 files changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/js/perf/core.js b/js/perf/core.js
index 86f2c84..b9f5494 100644
--- a/js/perf/core.js
+++ b/js/perf/core.js
@@ -87,7 +87,10 @@ function run() {
             yield Scripting.destroyTestWindows();
 
             for (let k = 0; k < config.count; k++)
-                yield Scripting.createTestWindow(config.width, config.height, config.alpha, 
config.maximized);
+                yield Scripting.createTestWindow({ width: config.width,
+                                                   height: config.height,
+                                                   alpha: config.alpha,
+                                                   maximized: config.maximized });
 
             yield Scripting.waitTestWindows();
             yield Scripting.sleep(1000);
diff --git a/js/ui/scripting.js b/js/ui/scripting.js
index f952ed0..4e7453a 100644
--- a/js/ui/scripting.js
+++ b/js/ui/scripting.js
@@ -7,6 +7,7 @@ const Meta = imports.gi.Meta;
 const Shell = imports.gi.Shell;
 
 const Main = imports.ui.main;
+const Params = imports.misc.params;
 
 // This module provides functionality for driving the shell user interface
 // in an automated fashion. The primary current use case for this is
@@ -99,9 +100,11 @@ function _getPerfHelper() {
 
 /**
  * createTestWindow:
- * @width: width of window, in pixels
- * @height: height of window, in pixels
- * @alpha: whether the window should be alpha transparent
+ * @params: options for window creation.
+ *   width - width of window, in pixels (default 640)
+ *   height - height of window, in pixels (default 480)
+ *   alpha - whether the window should have an alpha channel (default false)
+ *   maximized - whether the window should be created maximized (default false)
  * @maximized: whethe the window should be created maximized
  *
  * Creates a window using gnome-shell-perf-helper for testing purposes.
@@ -110,11 +113,17 @@ function _getPerfHelper() {
  * because of the normal X asynchronous mapping process, to actually wait
  * until the window has been mapped and exposed, use waitTestWindows().
  */
-function createTestWindow(width, height, alpha, maximized) {
+function createTestWindow(width, height, params) {
+    params = Params.parse(params, { width: 640,
+                                    height: 480,
+                                    alpha: false,
+                                    maximized: false });
+
     let cb;
     let perfHelper = _getPerfHelper();
 
-    perfHelper.CreateWindowRemote(width, height, alpha, maximized,
+    perfHelper.CreateWindowRemote(params.width, params.height,
+                                  params.alpha, params.maximized,
                                   function(result, excp) {
                                       if (cb)
                                           cb();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]