[Pkg-mozext-commits] [requestpolicy] 244/280: [refact] mozmill: create RequestLog library

David Prévot taffit at moszumanska.debian.org
Sat May 2 20:30:34 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository requestpolicy.

commit 581e2b8547917df903a8d4664728f1c469a5109e
Author: Martin Kimmerle <dev at 256k.de>
Date:   Sun Mar 22 01:12:25 2015 +0100

    [refact] mozmill: create RequestLog library
---
 tests/mozmill/lib/request-log-utils.js             | 64 ++++++++++++++++++++++
 .../tests/testRequestLog/testUriWithoutHost.js     | 50 +++--------------
 2 files changed, 72 insertions(+), 42 deletions(-)

diff --git a/tests/mozmill/lib/request-log-utils.js b/tests/mozmill/lib/request-log-utils.js
new file mode 100644
index 0000000..86beb5c
--- /dev/null
+++ b/tests/mozmill/lib/request-log-utils.js
@@ -0,0 +1,64 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+var rpRootDir = "../";
+var rpConst = require(rpRootDir + "lib/constants");
+var rootDir = rpRootDir + rpConst.mozmillTestsRootDir;
+
+var prefs = require(rootDir + "lib/prefs");
+var tabs = require(rootDir + "firefox/lib/tabs");
+
+const TBB_ID = "requestpolicyToolbarButton";
+
+
+function RequestLog(aController) {
+  this.controller = aController;
+  this.windowDoc = this.controller.window.document;
+}
+
+RequestLog.prototype.open = function () {
+  let tbb = findElement.ID(this.windowDoc, TBB_ID);
+  // open the menu
+  tbb.click();
+  // wait for the menu
+  findElement.ID(this.windowDoc, "rp-popup").waitForElement();
+  // open the request log
+  findElement.ID(this.windowDoc, "rp-link-request-log").click();
+  // close the menu
+  tbb.click();
+
+  let iframe = this.windowDoc.getElementById("requestpolicy-requestLog-frame");
+  this.requestLogDoc = iframe.contentDocument;
+  this.controller.waitForPageLoad(this.requestLogDoc);
+
+  var tree = this.requestLogDoc.getElementById("requestpolicy-requestLog-tree");
+  this.treeView = tree.view;
+  this.destCol = tree.columns
+      .getNamedColumn("requestpolicy-requestLog-destination");
+};
+
+RequestLog.prototype.close = function () {
+  findElement.ID(this.windowDoc, "requestpolicy-requestLog-close").click();
+};
+
+RequestLog.prototype.clear = function () {
+  findElement.ID(this.windowDoc, "requestpolicy-requestLog-clear").click();
+}
+
+
+RequestLog.prototype.getDestination = function (aRow) {
+  return this.treeView.getCellText(aRow, this.destCol);
+};
+
+RequestLog.prototype.getDestinations = function () {
+  var destinations = [];
+  for (let i = 0, len = this.treeView.rowCount; i < len; ++i) {
+    destinations.push(this.getDestination(i));
+  }
+  return destinations;
+};
+
+exports.RequestLog = RequestLog;
diff --git a/tests/mozmill/tests/testRequestLog/testUriWithoutHost.js b/tests/mozmill/tests/testRequestLog/testUriWithoutHost.js
index 8ba7dc4..7348519 100644
--- a/tests/mozmill/tests/testRequestLog/testUriWithoutHost.js
+++ b/tests/mozmill/tests/testRequestLog/testUriWithoutHost.js
@@ -14,64 +14,30 @@ var rootDir = rpRootDir + rpConst.mozmillTestsRootDir;
 var tabs = require(rootDir + "firefox/lib/tabs");
 
 var rpUtils = require(rpRootDir + "lib/rp-utils");
+var requestLogUtils = require(rpRootDir + "lib/request-log-utils");
 
-const TBB_ID = "requestpolicyToolbarButton";
 var TEST_URL = "http://www.maindomain.test/scheme-unknown-and-without-host.html";
 
 
-var setupModule = function(aModule) {
+var setupModule = function (aModule) {
   /* global controller, tabBrowser */
   aModule.controller = mozmill.getBrowserController();
   aModule.tabBrowser = new tabs.tabBrowser(aModule.controller);
   aModule.tabBrowser.closeAllTabs();
 
-  let tbb = findElement.ID(aModule.controller.window.document, TBB_ID);
-  // open the menu
-  tbb.click();
-  // wait for the menu
-  findElement.ID(controller.window.document, "rp-popup").waitForElement();
-  // open the request log
-  findElement.ID(controller.window.document, "rp-link-request-log").click();
-  // close the menu
-  tbb.click();
-
-  aModule.requestLogDoc = aModule.controller.window.document
-      .getElementById("requestpolicy-requestLog-frame").contentDocument;
-  aModule.controller.waitForPageLoad(aModule.requestLogDoc);
-
-  aModule.clearButton = findElement.ID(aModule.controller.window.document,
-                                       "requestpolicy-requestLog-clear");
-  aModule.clearButton.click();
-
-  var tree = aModule.requestLogDoc
-      .getElementById("requestpolicy-requestLog-tree")
-  aModule.treeView = tree.view;
-  aModule.destCol = tree.columns
-      .getNamedColumn("requestpolicy-requestLog-destination");
+  aModule.requestLog = new requestLogUtils.RequestLog(aModule.controller);
+  aModule.requestLog.open();
+  aModule.requestLog.clear();
 }
 
-var teardownModule = function(aModule) {
-  let closeButton = findElement.ID(aModule.controller.window.document,
-                                   "requestpolicy-requestLog-close");
-  closeButton.click();
+var teardownModule = function (aModule) {
+  aModule.requestLog.close();
   aModule.tabBrowser.closeAllTabs();
 }
 
 
-function getDestination(aRow) {
-  return treeView.getCellText(aRow, destCol);
-}
-
-function getDestinations() {
-  var destinations = [];
-  for (let i = 0, len = treeView.rowCount; i < len; ++i) {
-    destinations.push(getDestination(i));
-  }
-  return destinations;
-}
-
 function countDestination(aCompareValue) {
-  return getDestinations().filter(function (aValue) {
+  return requestLog.getDestinations().filter(function (aValue) {
     return aCompareValue === aValue;
   }).length;
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git



More information about the Pkg-mozext-commits mailing list