ubuntu-html5-theme-0.1.2+16.04.20160203/tests/data/html/apps/ 0000755 0000156 0000165 00000000000 12654470530 023511 5 ustar pbuser pbgroup 0000000 0000000 ubuntu-html5-theme-0.1.2+16.04.20160203/tests/data/html/apps/rss-reader/ 0000755 0000156 0000165 00000000000 12654470531 025561 5 ustar pbuser pbgroup 0000000 0000000 ubuntu-html5-theme-0.1.2+16.04.20160203/tests/data/html/apps/rss-reader/app.js 0000644 0000156 0000165 00000010536 12654470322 026702 0 ustar pbuser pbgroup 0000000 0000000 /*
* Copyright (C) 2013 Adnane Belmadiaf
* License granted by Canonical Limited
*
* This file is part of ubuntu-html5-ui-toolkit.
*
* This package is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3 of the
* License, or
* (at your option) any later version.
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this program. If not, see
*
*/
var UI;
$(document).ready(function () {
UI = new UbuntuUI()
UI.init();
UI.pagestack.push("main");
if (typeof localStorage["feeds"] == "undefined") {
restoreDefault();
}
//load local storage feeds
var feeds = eval(localStorage["feeds"]);
if (feeds !== null) {
var feeds_list = UI.list('#yourfeeds');
feeds_list.removeAllItems();
feeds_list.setHeader('My feeds');
for (var i = 0; i < feeds.length; i++) {
feeds_list.append(feeds[i],
null,
null,
function (target, thisfeed) { console.log('load'); loadFeed(thisfeed); },
feeds[i]);
}
}
UI.button('yes').click(function (e) {
var url = $("#rssFeed").val();
if (url === "") {
if (!$("#addfeeddialog section").hasClass("shake")) {
$("#addfeeddialog section").addClass("shake");
} else {
$('#addfeeddialog section').css('animation-name', 'none');
$('#addfeeddialog section').css('-moz-animation-name', 'none');
$('#addfeeddialog section').css('-webkit-animation-name', 'none');
setTimeout(function () {
$('#addfeeddialog section').css('-webkit-animation-name', 'shake');
}, 0);
}
} else {
var feeds = eval(localStorage["feeds"]);
feeds.push(url);
localStorage.setItem("feeds", JSON.stringify(feeds));
window.location.reload();
}
});
UI.button('addfeed').click(function () {
$('#addfeeddialog').show();
});
UI.button('no').click(function () {
$('#addfeeddialog').hide();
});
});
//FUNCS
function restoreDefault() {
localStorage.clear();
var feeds = [];
feeds.push("http://daker.me/feed.xml");
feeds.push("http://www.omgubuntu.co.uk/feed");
feeds.push("http://hespress.com/feed/index.rss");
feeds.push("http://rss.slashdot.org/Slashdot/slashdot");
feeds.push("http://www.reddit.com/.rss");
try {
localStorage.setItem("feeds", JSON.stringify(feeds));
window.location.reload();
} catch (e) {
if (e == QUOTA_EXCEEDED_ERR) {
console.log("Error: Local Storage limit exceeds.");
} else {
console.log("Error: Saving to local storage.");
}
}
}
function loadFeed(url) {
UI.pagestack.push("results");
UI.dialog("loading").show();
var feed = new google.feeds.Feed(url);
feed.setNumEntries(30);
feed.load(function (result) {
if (!result.error) {
UI.dialog("loading").hide();
var results_list = UI.list('#resultscontent');
console.log(results_list);
results_list.removeAllItems();
results_list.setHeader(result.feed.title);
for (var i = 0; i < result.feed.entries.length; i++) {
results_list.append(result.feed.entries[i].title.replace(/"/g, "'"),
null,
null,
function (target, result_infos) { showArticle.apply(null, result_infos); },
[escape(result.feed.entries[i].title), escape(result.feed.entries[i].link), escape(result.feed.entries[i].content)] );
}
} else
alert('feed error');
});
}
function showArticle(title, url, desc) {
UI.pagestack.push("article");
if (typeof desc == "undefined")
desc = "(No description provided)";
$("#articleinfo").html("
");
}
google.load("feeds", "1");
ubuntu-html5-theme-0.1.2+16.04.20160203/tests/data/html/apps/rss-reader/styles.css 0000644 0000156 0000165 00000002115 12654470322 027613 0 ustar pbuser pbgroup 0000000 0000000 /*
* Copyright (C) 2013 Adnane Belmadiaf
* License granted by Canonical Limited
*
* This file is part of ubuntu-html5-ui-toolkit.
*
* This package is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3 of the
* License, or
* (at your option) any later version.
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this program. If not, see
* .
*/
#articleinfo {
padding: 10px;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
#articleinfo iframe {
max-width: 100%;
}
#articleinfo p {
margin: 7px 0;
}
#articleinfo a{
text-decoration: none;
color: #787878;
font-weight: bold;
} ubuntu-html5-theme-0.1.2+16.04.20160203/tests/data/html/apps/rss-reader/index.html 0000644 0000156 0000165 00000010155 12654470322 027556 0 ustar pbuser pbgroup 0000000 0000000
RSS Mobile Reader - Ubuntu UI Example
ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/ 0000755 0000156 0000165 00000000000 12654470531 022712 5 ustar pbuser pbgroup 0000000 0000000 ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/tools/ 0000755 0000156 0000165 00000000000 12654470530 024051 5 ustar pbuser pbgroup 0000000 0000000 ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/tools/qml/ 0000755 0000156 0000165 00000000000 12654470531 024643 5 ustar pbuser pbgroup 0000000 0000000 ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/tools/qml/message-server.js 0000644 0000156 0000165 00000002124 12654470322 030126 0 ustar pbuser pbgroup 0000000 0000000 // Copyright (C) 2014 Canonical Ltd.
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
oxide.addMessageHandler("EVALUATE-CODE", function(msg) {
var code = msg.args.code;
if (msg.args.wrap) {
code = "(function() {" + code + "})()";
}
try {
var result = eval(code);
msg.reply({result: result});
} catch(e) {
msg.error("Code threw exception: \"" + e + "\"");
}
});
ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/tools/qml/webview.qml 0000644 0000156 0000165 00000020100 12654470322 027015 0 ustar pbuser pbgroup 0000000 0000000 /*
* Copyright 2013 Canonical Ltd.
*
* This file is part of ubuntu-html5-ui-toolkit.
*
* ubuntu-html5-ui-toolkit is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* webbrowser-app is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import QtTest 1.0
import com.canonical.Oxide 1.0 as Oxide
Item {
id: root
objectName: "webviewContainer"
width: 640
height: 640
property string url
signal resultUpdated(string message)
TestResult { id: qtest_testResult }
function __gentid() {
return Math.random() + '';
}
function __wrapJsCommands(commands) {
return '(function() { ' + commands + ' })();'
}
function __createResult(result, tid) {
return JSON.stringify({result: result, tid: tid});
}
function __dumpValue(v) {
if (typeof(v) === "string") {
return "'" + v + "'";
}
return v;
}
function __setupClosedVariables(variables) {
var variableDeclStatements = '';
for (var variable in variables) {
if (variables.hasOwnProperty(variable)) {
variableDeclStatements += 'var ' + variable + ' = ' + __dumpValue(variables[variable]) + ';';
}
}
return variableDeclStatements;
}
function clickElementById(id) {
var tid = __gentid();
var statement = 'document.getElementById("' + id + '").click();';
var result = webview.evaluateCode(statement, true);
root.resultUpdated(root.__createResult(result, tid));
}
function evalInPageUnsafe(expr) {
var result = webview.evaluateCode(expr, true);
console.log('result: ' + result)
root.resultUpdated(result ? result.toString() : result)
}
function clickAnyElementBySelector(selector) {
var tid = __gentid();
var statement = 'document.querySelectorAll("' + selector + '")[0].click();';
var result = webview.evaluateCode(statement, true);
root.resultUpdated(root.__createResult(result, tid));
}
function elementWithIdHasAttribute(id,attribute,value) {
var tid = __gentid();
var hasAttributeWithIdFunc = '
function __hasAttributeWithId() {
try { return document.querySelector("#" + id).getAttribute(attribute) === value; } catch (e) {};
return false;
};';
var statement = __setupClosedVariables({'id': id, 'attribute': attribute, 'value': value});
statement += hasAttributeWithIdFunc;
statement += "; return __hasAttributeWithId(id,attribute,value); "
var result = webview.evaluateCode(statement, true);
root.resultUpdated(root.__createResult(result, tid));
}
function isNodeWithIdVisible(id) {
var tid = __gentid();
var isNodeWithIdVisibleFunc = '
function __isNodeWithIdVisible() {
try { return document.getElementById(id).style.display !== "none"; } catch (e) { return e.toString(); };
return false;
};';
var statement = __setupClosedVariables({'id': id});
statement += isNodeWithIdVisibleFunc;
statement += "; return __isNodeWithIdVisible(id); "
var result = webview.evaluateCode(statement, true);
root.resultUpdated(root.__createResult(result, tid));
}
function getAttributeForElementWithId(id,attribute) {
var tid = __gentid();
var getAttributeWithIdFunc = '
function __getAttributeWithId() {
try { var value = document.querySelector("#" + id).getAttribute(attribute); return value || ""; } catch (e) { return e.toString(); };
return "";
};';
var statement = __setupClosedVariables({'id': id, 'attribute': attribute});
statement += getAttributeWithIdFunc;
statement += "; return __getAttributeWithId(); "
var result = webview.evaluateCode(statement, true);
root.resultUpdated(root.__createResult(result, tid));
}
Oxide.WebView {
objectName: "webview"
id: webview
url: parent.url
width: parent.width
height: parent.height - 100
anchors {
top: parent.top
bottom: addressbar.top
right: parent.right
left: parent.left
}
preferences.localStorageEnabled: true
preferences.appCacheEnabled: true
function evaluateCode(code, wrap) {
var value = webview._waitForResult(
webview.rootFrame.sendMessage(
"oxide://main-world",
"EVALUATE-CODE",
{ code: code,
wrap: wrap === undefined ? false : wrap }));
return value ? value.result : undefined;
}
function _waitForResult(req, timeout) {
var result;
var error;
req.onreply = function(response) {
result = response;
error = 0;
};
req.onerror = function(error_code, msg) {
result = msg;
error = error_code;
};
webview._waitFor(function() { return error !== undefined; },
timeout);
if (error > 0) {
console.error('Error:' + error + ', result:' + result)
} else if (error === 0) {
return result;
} else {
throw new Error("Message call timed out");
}
}
function _waitFor(predicate, timeout) {
timeout = timeout || 5000000;
var end = Date.now() + timeout;
var i = Date.now();
while (i < end && !predicate()) {
qtest_testResult.wait(50);
i = Date.now();
}
return predicate();
}
context: Oxide.WebContext {
userScripts: [
Oxide.UserScript {
context: "oxide://main-world"
emulateGreasemonkey: true
url: Qt.resolvedUrl("message-server.js")
matchAllFrames: true
}
]
}
onJavaScriptConsoleMessage: {
var msg = "[JS] (%1:%2) %3".arg(sourceId).arg(lineNumber).arg(message)
if (level === Oxide.WebView.LogSeverityVerbose) {
console.log(msg)
} else if (level === Oxide.WebView.LogSeverityInfo) {
console.info(msg)
} else if (level === Oxide.WebView.LogSeverityWarning) {
console.warn(msg)
} else if ((level === Oxide.WebView.LogSeverityError) ||
(level === Oxide.WebView.LogSeverityErrorReport) ||
(level === Oxide.WebView.LogSeverityFatal)) {
console.error(msg)
}
}
}
TextInput {
id: addressbar
objectName: "addressbar"
width: parent.width - 100
height: parent.height - 100
inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhUrlCharactersOnly
focus: true
enabled: true
readOnly: false
color: "red"
anchors {
top: webview.bottom
bottom: parent.bottom
left: parent.left
}
Rectangle {
objectName: "browseButton"
id: browseButton
border.color: "black"
border.width: 5
width: 100
height: 100
anchors {
top: parent.top
bottom: parent.bottom
left: parent.right
}
MouseArea {
anchors.fill: parent
onClicked: {
root.url = addressbar.text
}
}
}
}
}
ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/ubuntu_html5_ui_toolkit/ 0000755 0000156 0000165 00000000000 12654470531 027607 5 ustar pbuser pbgroup 0000000 0000000 ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/ubuntu_html5_ui_toolkit/__init__.py 0000644 0000156 0000165 00000000532 12654470322 031716 0 ustar pbuser pbgroup 0000000 0000000 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2013 Canonical
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License version 3, as
# published by the Free Software Foundation.
"""Tests for the Ubuntu HTML5 UI SDK package """
ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/ubuntu_html5_ui_toolkit/tests/ 0000755 0000156 0000165 00000000000 12654470531 030751 5 ustar pbuser pbgroup 0000000 0000000 ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/ubuntu_html5_ui_toolkit/tests/__init__.py 0000644 0000156 0000165 00000022272 12654470322 033065 0 ustar pbuser pbgroup 0000000 0000000 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2013 Canonical
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License version 3, as
# published by the Free Software Foundation.
"""Tests for the Ubuntu HTML5 package """
import os
import json
import http.server as http
import threading
import subprocess
HTTP_SERVER_PORT = 8383
from testtools.matchers import Equals, GreaterThan
from autopilot.matchers import Eventually
from autopilot.testcase import AutopilotTestCase
from autopilot.input import Mouse, Touch, Pointer
from autopilot import platform
# from autopilot.introspection.qt import QtIntrospectionTestMixin
class RequestHandler(http.BaseHTTPRequestHandler):
BASE_PATH_FOR_SERVED_APPS = {'rss-reader': "{}/{}".format(
os.path.dirname(os.path.realpath(__file__)),
'../../../../0.1/examples/apps/rss-reader')}
def get_served_filename(self, appname, filename):
if len(filename) == 0 or filename == '/':
filename = 'autopilot.html'
return os.path.join(
self.BASE_PATH_FOR_SERVED_APPS[appname],
filename)
def serve_file(self, filename):
import mimetypes
content_type = mimetypes.guess_type(filename)[0]
f = open(filename, 'rb')
self.send_response(200)
self.send_header('Content-length', os.fstat(f.fileno())[6])
self.send_header('Content-type', content_type)
self.end_headers()
self.wfile.write(f.read())
def do_GET(self):
# FIXME: more generic & cleaner
if self.path.startswith('/rss-reader'):
filename = self.path[len('/rss-reader'):]
self.send_response(200)
self.serve_file(
self.get_served_filename(
'rss-reader',
filename))
else:
self.send_error(404)
class UbuntuHTML5HTTPServer(threading.Thread):
def __init__(self, port):
super(UbuntuHTML5HTTPServer, self).__init__()
self.server = http.BaseHTTPServer.HTTPServer(
("", port),
RequestHandler)
self.server.allow_reuse_address = True
def run(self):
self.server.serve_forever()
def shutdown(self):
self.server.shutdown()
self.server.server_close()
class UbuntuHTML5TestCaseBase(AutopilotTestCase):
BROWSER_CONTAINER_PATH = "{}/{}".format(
os.path.dirname(os.path.realpath(__file__)),
'../../tools/qml/webview.qml')
INSTALLED_BROWSER_CONTAINER_PATH = \
'/usr/share/ubuntu-html5-ui-toolkit/tests/tools/qml/webview.qml'
BROWSER_QML_APP_LAUNCHER = "/usr/lib/{}/qt5/bin/qmlscene".format(
subprocess.check_output(
["dpkg-architecture",
"-qDEB_HOST_MULTIARCH"]).strip().decode('utf-8'))
# TODO: fix version
LOCAL_HTML_EXAMPLES_PATH = os.path.abspath(
"{}/{}".format(
os.path.dirname(os.path.realpath(__file__)),
'../../../../tests'))
INSTALLED_HTML_EXAMPLES_PATH = \
'/usr/share/ubuntu-html5-ui-toolkit/tests/'
APPS_SUBFOLDER_NAME = 'apps'
BASE_PATH = ''
def get_browser_container_path(self):
if os.path.exists(self.BROWSER_CONTAINER_PATH):
return self.BROWSER_CONTAINER_PATH
return self.INSTALLED_BROWSER_CONTAINER_PATH
def create_file_url_from(self, filepath):
return 'file://' + filepath
def setup_base_path(self):
if os.path.exists(self.LOCAL_HTML_EXAMPLES_PATH):
self.BASE_PATH = self.LOCAL_HTML_EXAMPLES_PATH
else:
self.BASE_PATH = self.INSTALLED_HTML_EXAMPLES_PATH
def setUp(self):
self.setup_base_path()
if platform.model() == "Desktop":
self.pointer = Pointer(Mouse.create())
else:
self.pointer = Pointer(Touch.create())
params = [self.BROWSER_QML_APP_LAUNCHER,
self.get_browser_container_path()]
if (platform.model() != 'Desktop'):
params.append(
'--desktop_file_hint=/usr/share/" \
+ "applications/unitywebappsqmllauncher.desktop')
self.app = self.launch_test_application(
*params,
app_type='qt')
self.webviewContainer = self.get_webviewContainer()
self.watcher = self.webviewContainer.watch_signal(
'resultUpdated(QString)')
super(UbuntuHTML5TestCaseBase, self).setUp()
def tearDown(self):
super(UbuntuHTML5TestCaseBase, self).tearDown()
def pick_app_launcher(self, app_path):
# force Qt app introspection:
from autopilot.introspection.qt import QtApplicationLauncher
return QtApplicationLauncher()
def get_webviewContainer(self):
return self.app.select_single(objectName="webviewContainer")
def get_webview(self):
return self.app.select_single(objectName="webview")
def get_addressbar(self):
return self.app.select_single(objectName="addressbar")
def get_button(self):
return self.app.select_single(objectName="browseButton")
def get_title(self):
return self.get_webview().title
def assert_url_eventually_loaded(self, url):
webview = self.get_webview()
self.assertThat(
webview.loadProgress,
Eventually(Equals(100)))
self.assertThat(
webview.loading,
Eventually(Equals(False)))
self.assertThat(
webview.url,
Eventually(Equals(url)))
def click_dom_node_with_id(self, id):
webview = self.get_webviewContainer()
webview.slots.clickElementById(id)
self.assertThat(
lambda: self.watcher.num_emissions,
Eventually(Equals(1)))
def click_any_dom_node_by_selector(self, selector):
webview = self.get_webviewContainer()
webview.slots.clickAnyElementBySelector(selector)
self.assertThat(
lambda: self.watcher.num_emissions,
Eventually(Equals(1)))
def is_dom_node_visible(self, id):
webview = self.get_webviewContainer()
prev_emissions = self.watcher.num_emissions
webview.slots.isNodeWithIdVisible(id)
self.assertThat(
lambda: self.watcher.num_emissions,
Eventually(GreaterThan(prev_emissions)))
return json.loads(
webview.get_signal_emissions(
'resultUpdated(QString)')[-1][0])['result']
def eval_expression_in_page_unsafe(self, expr):
webview = self.get_webviewContainer()
prev_emissions = self.watcher.num_emissions
webview.slots.evalInPageUnsafe(expr)
self.assertThat(
lambda: self.watcher.num_emissions,
Eventually(GreaterThan(prev_emissions)))
return webview.get_signal_emissions('resultUpdated(QString)')[-1][0]
def get_dom_node_id_attribute(self, id, attribute):
webview = self.get_webviewContainer()
prev_emissions = self.watcher.num_emissions
webview.slots.getAttributeForElementWithId(id, attribute)
self.assertThat(
lambda: self.watcher.num_emissions,
Eventually(GreaterThan(prev_emissions)))
return json.loads(
webview.get_signal_emissions(
'resultUpdated(QString)')[-1][0])['result']
def get_address_bar_action_button(self):
addressbar = self.get_addressbar()
return addressbar.select_single(objectName="browseButton")
def browse_to_url(self, url):
import time
addressbar = self.get_addressbar()
self.assertThat(
addressbar.activeFocus,
Eventually(Equals(True)))
self.keyboard.type(url, 0.001)
self.pointer.click_object(self.get_webview())
# XXX: very bad, but wont fix
time.sleep(1)
button = self.get_address_bar_action_button()
self.pointer.move_to_object(button)
self.pointer.press()
# XXX: very bad, but wont fix
time.sleep(1)
self.pointer.release()
self.assert_url_eventually_loaded(url)
def browse_to_app(self, appname):
appfilepath = os.path.abspath(
self.BASE_PATH +
'/data/html/' +
self.APPS_SUBFOLDER_NAME +
'/' +
appname +
'/index.html')
APP_HTML_PATH = self.create_file_url_from(appfilepath)
self.browse_to_url(APP_HTML_PATH)
def browse_to_test_html(self, html_filename):
self.browse_to_url(
self.create_file_url_from(
os.path.abspath(
'{}/data/html/{}'.format(
self.BASE_PATH,
html_filename))))
class UbuntuThemeWithHttpServerTestCaseBase(UbuntuHTML5TestCaseBase):
def setUp(self):
self.server = UbuntuHTML5HTTPServer(HTTP_SERVER_PORT)
self.server.start()
super(UbuntuThemeWithHttpServerTestCaseBase, self).setUp()
def tearDown(self):
super(UbuntuThemeWithHttpServerTestCaseBase, self).tearDown()
self.server.shutdown()
class UbuntuThemeRemotePageTestCaseBase(UbuntuThemeWithHttpServerTestCaseBase):
def setUp(self):
super(UbuntuThemeRemotePageTestCaseBase, self).setUp()
././@LongLink 0000000 0000000 0000000 00000000151 00000000000 011212 L ustar 0000000 0000000 ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_rss_reader.py ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_rss_reade0000644 0000156 0000165 00000002604 12654470322 033702 0 ustar pbuser pbgroup 0000000 0000000 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2013 Canonical
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License version 3, as
# published by the Free Software Foundation.
from __future__ import absolute_import
from testtools.matchers import Contains, Equals
from autopilot.matchers import Eventually
from ubuntu_html5_ui_toolkit.tests import UbuntuHTML5TestCaseBase
class UbuntuThemeRSSReaderTestCase(UbuntuHTML5TestCaseBase):
def setUp(self):
super(UbuntuThemeRSSReaderTestCase, self).setUp()
self.browse_to_app('rss-reader')
def test_appDoesLoads(self):
self.assertThat(self.get_title(), Contains("RSS Mobile Reader"))
def test_initialState(self):
self.assertThat(self.is_dom_node_visible('main'), Equals(True))
self.assertThat(self.is_dom_node_visible('article'), Equals(False))
self.assertThat(self.is_dom_node_visible('results'), Equals(False))
def test_switchToFeedView(self):
self.click_any_dom_node_by_selector('#yourfeeds li a')
self.assertThat(
lambda: self.is_dom_node_visible('main'),
Eventually(Equals(False)))
self.assertThat(self.is_dom_node_visible('article'), Equals(False))
self.assertThat(self.is_dom_node_visible('results'), Equals(True))
ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_tabs.py 0000644 0000156 0000165 00000003002 12654470322 033304 0 ustar pbuser pbgroup 0000000 0000000 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2014 Canonical
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License version 3, as
# published by the Free Software Foundation.
from __future__ import absolute_import
from testtools.matchers import Equals
from autopilot.matchers import Eventually
from ubuntu_html5_ui_toolkit.tests import UbuntuHTML5TestCaseBase
class UbuntuUIToolkitTabsTestCase(UbuntuHTML5TestCaseBase):
def setUp(self):
super(UbuntuUIToolkitTabsTestCase, self).setUp()
def test_programaticTabSelectIndex(self):
self.browse_to_test_html('test-tabs-in-app.html')
self.assertThat(
lambda: self.eval_expression_in_page_unsafe(
'var UI = new UbuntuUI(); '
'UI.init(); UI.tabs.selectedTabIndex = 1; '
'return UI.tabs.selectedTabIndex;'),
Eventually(Equals('1')))
self.assertThat(
lambda: self.is_dom_node_visible('tab1'),
Eventually(Equals(False)))
self.assertThat(
lambda: self.is_dom_node_visible('tab2'),
Eventually(Equals(True)))
self.assertThat(
lambda: self.is_dom_node_visible('tab3'),
Eventually(Equals(False)))
self.assertThat(
self.eval_expression_in_page_unsafe(
'return document.getElementById("tab2").style.display;'),
Equals('block'))
././@LongLink 0000000 0000000 0000000 00000000150 00000000000 011211 L ustar 0000000 0000000 ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_pagestack.py ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_pagestack0000644 0000156 0000165 00000006731 12654470322 033702 0 ustar pbuser pbgroup 0000000 0000000 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2013 Canonical
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License version 3, as
# published by the Free Software Foundation.
from __future__ import absolute_import
from testtools.matchers import Equals
from autopilot.matchers import Eventually
from ubuntu_html5_ui_toolkit.tests import UbuntuHTML5TestCaseBase
class UbuntuThemePageStackTestCase(UbuntuHTML5TestCaseBase):
def setUp(self):
super(UbuntuThemePageStackTestCase, self).setUp()
def test_pageLoadsWithNoPageStacks(self):
self.browse_to_test_html('test-nopagestack-in-app.html')
self.assertThat(
self.eval_expression_in_page_unsafe(
'var UI = new UbuntuUI(); UI.init(); return "ok";'),
Equals('ok'))
def test_pageLoadsWithPageStacks(self):
self.browse_to_test_html('test-pagestack-in-app.html')
self.assertThat(
self.eval_expression_in_page_unsafe(
'var UI = new UbuntuUI(); UI.init(); return "ok";'),
Equals('ok'))
self.assertThat(
self.is_dom_node_visible('main'),
Equals(True))
def test_pageChangeWithPageStackPush(self):
self.browse_to_test_html('test-pagestack-in-app.html')
self.assertThat(
self.eval_expression_in_page_unsafe(
'var UI = new UbuntuUI(); UI.init(); '
'UI.pagestack.push("results"); return "ok";'),
Equals('ok'))
self.assertThat(
self.is_dom_node_visible('main'),
Equals(False))
self.assertThat(
self.is_dom_node_visible('results'),
Equals(True))
def test_pageChangeWithPageStackPopped(self):
self.browse_to_test_html('test-pagestack-in-app.html')
self.assertThat(
self.eval_expression_in_page_unsafe(
'var UI = new UbuntuUI(); UI.init(); '
'UI.pagestack.push("main"); '
'UI.pagestack.push("results"); '
'UI.pagestack.push("article"); '
'UI.pagestack.pop(); return "ok";'),
Equals('ok'))
self.assertThat(
self.is_dom_node_visible('main'),
Equals(False))
self.assertThat(
self.is_dom_node_visible('results'),
Equals(True))
self.assertThat(
self.is_dom_node_visible('article'),
Equals(False))
def test_pagePushWithProperties(self):
self.browse_to_test_html('test-pagestack-in-app.html')
expression = """
var ui = new UbuntuUI();
ui.init();
ui.pagestack.push('main');
(new Page('results')).onactivated(
function(properties) {
document.getElementById('results').innerHTML =
JSON.stringify(properties);
});
ui.pagestack.push('results', 'WORKS');
return 'ok';
"""
self.assertThat(
self.eval_expression_in_page_unsafe(expression),
Equals('ok'))
self.assertThat(
lambda: self.is_dom_node_visible('results'),
Eventually(Equals(True)))
results_html_content = \
"return document.getElementById('results').innerHTML;"
self.assertThat(
self.eval_expression_in_page_unsafe(
results_html_content),
Equals('"WORKS"'))
././@LongLink 0000000 0000000 0000000 00000000153 00000000000 011214 L ustar 0000000 0000000 ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_page_actions.py ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_page_acti0000644 0000156 0000165 00000003233 12654470322 033646 0 ustar pbuser pbgroup 0000000 0000000 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2013 Canonical
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License version 3, as
# published by the Free Software Foundation.
from __future__ import absolute_import
from testtools.matchers import Equals, NotEquals
from autopilot.matchers import Eventually
from ubuntu_html5_ui_toolkit.tests import UbuntuHTML5TestCaseBase
class UbuntuThemePageStackTestCase(UbuntuHTML5TestCaseBase):
def setUp(self):
super(UbuntuThemePageStackTestCase, self).setUp()
def test_tabWithActions(self):
self.browse_to_test_html('test-page-actions.html')
self.eval_expression_in_page_unsafe(
'var UI = new UbuntuUI(); UI.init();'),
self.assertThat(
self.eval_expression_in_page_unsafe(
'return document.querySelector\
(\'[data-role="actions"]\') != null;'),
Equals('true'))
self.assertThat(
lambda: self.eval_expression_in_page_unsafe(
'return document.getElementById\
("addfeed").parentNode.style.display;'),
Eventually(NotEquals('none')))
def test_noActions(self):
self.browse_to_test_html('test-nopagestack-in-app.html')
self.assertThat(
self.eval_expression_in_page_unsafe(
'var UI = new UbuntuUI(); UI.init(); return "ok";'),
Equals('ok'))
self.assertThat(
self.eval_expression_in_page_unsafe(
'return document.querySelector\
(\'[data-role="actions"]\') != null;'),
Equals('false'))
ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/CMakeLists.txt 0000644 0000156 0000165 00000000623 12654470322 025451 0 ustar pbuser pbgroup 0000000 0000000 execute_process(COMMAND python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
OUTPUT_VARIABLE PYTHON_PACKAGE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
install(DIRECTORY ubuntu_html5_container ubuntu_html5_ui_toolkit
DESTINATION ${PYTHON_PACKAGE_DIR}
)
install(DIRECTORY tools
DESTINATION ${CMAKE_INSTALL_DATADIR}/ubuntu-html5-ui-toolkit/tests
)
ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/ubuntu_html5_container/ 0000755 0000156 0000165 00000000000 12654470531 027407 5 ustar pbuser pbgroup 0000000 0000000 ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/ubuntu_html5_container/__init__.py 0000644 0000156 0000165 00000000534 12654470322 031520 0 ustar pbuser pbgroup 0000000 0000000 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2014 Canonical
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License version 3, as
# published by the Free Software Foundation.
"""Tests for the Ubuntu HTML5 Launcher package """
ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/ubuntu_html5_container/tests/ 0000755 0000156 0000165 00000000000 12654470531 030551 5 ustar pbuser pbgroup 0000000 0000000 ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/ubuntu_html5_container/tests/__init__.py 0000644 0000156 0000165 00000002540 12654470322 032661 0 ustar pbuser pbgroup 0000000 0000000 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2014 Canonical
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License version 3, as
# published by the Free Software Foundation.
"""Tests for the Ubuntu HTML5 Launcher package """
import os
from autopilot.testcase import AutopilotTestCase
LAUNCHER_EXEC_NAME = 'ubuntu-html5-app-launcher'
LOCAL_LAUNCHER_PATH = os.path.abspath(
"{}/{}".format(
os.path.dirname(os.path.realpath(__file__)),
'../../../../src/ubuntu-html5-app-launcher/' + LAUNCHER_EXEC_NAME))
INSTALLED_LAUNCHER_PATH = '/usr/bin/' + LAUNCHER_EXEC_NAME
class UbuntuHtml5LauncherTestCase (AutopilotTestCase):
def setUp(self):
self.app = None
super(UbuntuHtml5LauncherTestCase, self).setUp()
def tearDown(self):
super(UbuntuHtml5LauncherTestCase, self).tearDown()
def get_launcher_path(self):
if os.path.exists(LOCAL_LAUNCHER_PATH):
return LOCAL_LAUNCHER_PATH
return INSTALLED_LAUNCHER_PATH
def get_app(self):
return self.app
def launch_with_argument(self, args):
try:
self.app = self.launch_test_application(
self.get_launcher_path(),
args)
except Exception:
pass
././@LongLink 0000000 0000000 0000000 00000000147 00000000000 011217 L ustar 0000000 0000000 ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/ubuntu_html5_container/tests/test_appLaunch.py ubuntu-html5-theme-0.1.2+16.04.20160203/tests/autopilot/ubuntu_html5_container/tests/test_appLaunch.0000644 0000156 0000165 00000001364 12654470322 033526 0 ustar pbuser pbgroup 0000000 0000000 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2014 Canonical
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License version 3, as
# published by the Free Software Foundation.
from __future__ import absolute_import
from testtools.matchers import NotEquals
from ubuntu_html5_container.tests import UbuntuHtml5LauncherTestCase
class UbuntuHtml5LauncherAppLaunchTestCase(UbuntuHtml5LauncherTestCase):
def setUp(self):
super(UbuntuHtml5LauncherAppLaunchTestCase, self).setUp()
def test_launcher_succeeds_with_no_www(self):
self.launch_with_argument('')
self.assertThat(self.get_app(), NotEquals(None))
ubuntu-html5-theme-0.1.2+16.04.20160203/tests/CMakeLists.txt 0000644 0000156 0000165 00000000211 12654470322 023422 0 ustar pbuser pbgroup 0000000 0000000 add_subdirectory(autopilot)
install(DIRECTORY data
DESTINATION ${CMAKE_INSTALL_DATADIR}/ubuntu-html5-ui-toolkit/tests
)
ubuntu-html5-theme-0.1.2+16.04.20160203/src/ 0000755 0000156 0000165 00000000000 12654470531 020317 5 ustar pbuser pbgroup 0000000 0000000 ubuntu-html5-theme-0.1.2+16.04.20160203/src/plugin/ 0000755 0000156 0000165 00000000000 12654470531 021615 5 ustar pbuser pbgroup 0000000 0000000 ubuntu-html5-theme-0.1.2+16.04.20160203/src/plugin/Ubuntu/ 0000755 0000156 0000165 00000000000 12654470531 023077 5 ustar pbuser pbgroup 0000000 0000000 ubuntu-html5-theme-0.1.2+16.04.20160203/src/plugin/Ubuntu/WebApps/ 0000755 0000156 0000165 00000000000 12654470531 024440 5 ustar pbuser pbgroup 0000000 0000000 ubuntu-html5-theme-0.1.2+16.04.20160203/src/plugin/Ubuntu/WebApps/WebAppContainer.qml 0000644 0000156 0000165 00000007456 12654470322 030206 0 ustar pbuser pbgroup 0000000 0000000 /*
* Copyright 2014 Canonical Ltd.
*
* This file is part of ubuntu-html5-container.
*
* ubuntu-html5-container is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* webbrowser-app is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Components 0.1
import Ubuntu.UnityWebApps 0.1
import com.canonical.Oxide 1.0 as Oxide
import Ubuntu.Web 0.2
/*!
\qmltype WebAppContainer
\inqmlmodule Ubuntu.WebApps 0.1
\ingroup ubuntu
\brief WebAppContainer is the root element that should be used for all HTML5 applications.
*/
MainView {
id: root
objectName: "root"
anchorToKeyboard: true
automaticOrientation: true
/*!
\preliminary
The property holds the path to the filesystem location where the 'index.html'
file can be found (root of the HTML5 application).
The path is absolute or relative to the current dir.
*/
property string htmlIndexDirectory: ""
/*!
\preliminary
The properties hold whether the remote debugging interface should be enabled for the
Web View. The host ip and port for accessing the remote interface should be provided.
*/
property bool remoteInspectorEnabled: false
Page {
id: mainPage
anchors.fill: parent
/*!
\internal
*/
function _getAppStartupIndexFileUri() {
return 'file://' + root.htmlIndexDirectory + '/index.html';
}
/*!
\internal
*/
Loader {
id: webviewComponentLoader
anchors.fill: parent
onLoaded: {
webappBindingsLoader.sourceComponent = webappBindingsComponent
}
}
Component {
id: webviewComponent
WebView {
id: webview
preferences.allowUniversalAccessFromFileUrls: true
preferences.allowFileAccessFromFileUrls: true
preferences.appCacheEnabled: true
preferences.localStorageEnabled: true
function navigationRequestedDelegate(request) {
var url = request.url.toString()
if (url.indexOf("file://") !== 0) {
request.action = Oxide.NavigationRequest.ActionReject
Qt.openUrlExternally(url)
return
}
}
}
}
Component.onCompleted: {
webviewComponentLoader.sourceComponent = webviewComponent;
}
/*!
\internal
*/
function getUnityWebappsProxies() {
return UnityWebAppsUtils.makeProxiesForWebViewBindee(webviewComponentLoader.item);
}
/*!
\internal
*/
Loader {
id: webappBindingsLoader
visible: false
anchors.fill: parent
}
function userScriptInjected() {
webviewComponentLoader.item.url =
mainPage._getAppStartupIndexFileUri();
}
/*!
\internal
*/
Component {
id: webappBindingsComponent
UnityWebApps {
bindee: mainPage
injectExtraUbuntuApis: true
requiresInit: false
onUserScriptsInjected: mainPage.userScriptInjected()
}
}
}
}
ubuntu-html5-theme-0.1.2+16.04.20160203/src/plugin/Ubuntu/WebApps/qmldir 0000644 0000156 0000165 00000000076 12654470322 025654 0 ustar pbuser pbgroup 0000000 0000000 module Ubuntu.WebApps
WebAppContainer 0.1 WebAppContainer.qml
ubuntu-html5-theme-0.1.2+16.04.20160203/src/plugin/Ubuntu/WebApps/CMakeLists.txt 0000644 0000156 0000165 00000002017 12654470322 027176 0 ustar pbuser pbgroup 0000000 0000000 project(ubuntu-html5-container)
# setup install location
execute_process(
COMMAND qmake -query QT_INSTALL_QML
OUTPUT_VARIABLE QT_INSTALL_QML
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(HTML5_CONTAINER_IMPORTS_DIR "${QT_INSTALL_QML}/Ubuntu/WebApps")
# setup install for local component files
file(GLOB QML_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.qml qmldir)
install(FILES ${QML_FILES} DESTINATION ${HTML5_CONTAINER_IMPORTS_DIR})
# make sure that we have all the files in the right place if we test locally
# & have a specific build dir
if(NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
foreach(_qmlfile ${QML_FILES})
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_qmlfile}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_qmlfile}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${_qmlfile} ${CMAKE_CURRENT_BINARY_DIR}/${_qmlfile})
endforeach(_qmlfile)
add_custom_target(copy_to_build_dir DEPENDS ${QML_FILES})
endif()
ubuntu-html5-theme-0.1.2+16.04.20160203/src/plugin/Ubuntu/CMakeLists.txt 0000644 0000156 0000165 00000000032 12654470322 025630 0 ustar pbuser pbgroup 0000000 0000000 add_subdirectory(WebApps)
ubuntu-html5-theme-0.1.2+16.04.20160203/src/plugin/CMakeLists.txt 0000644 0000156 0000165 00000000031 12654470322 024345 0 ustar pbuser pbgroup 0000000 0000000 add_subdirectory(Ubuntu)
ubuntu-html5-theme-0.1.2+16.04.20160203/src/CMakeLists.txt 0000644 0000156 0000165 00000000105 12654470322 023051 0 ustar pbuser pbgroup 0000000 0000000 add_subdirectory(ubuntu-html5-app-launcher)
add_subdirectory(plugin)
ubuntu-html5-theme-0.1.2+16.04.20160203/src/ubuntu-html5-app-launcher/ 0000755 0000156 0000165 00000000000 12654470531 025245 5 ustar pbuser pbgroup 0000000 0000000 ubuntu-html5-theme-0.1.2+16.04.20160203/src/ubuntu-html5-app-launcher/main.cpp 0000644 0000156 0000165 00000015765 12654470322 026711 0 ustar pbuser pbgroup 0000000 0000000 /*
* Copyright 2013-2015 Canonical Ltd.
*
* This file is part of ubuntu-html5-ui-toolkit.
*
* ubuntu-html5-ui-toolkit is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* ubuntu-html5-ui-toolkit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "config.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace {
void loadQtTestability(const QStringList & arguments)
{
// The testability driver is only loaded
// by QApplication but not by QGuiApplication.
// However, QApplication depends on QWidget which
// would add some unneeded overhead => Let's load the testability driver on our own.
if (arguments.contains(QLatin1String("-testability"))) {
QLibrary testLib(QLatin1String("qttestability"));
if (testLib.load()) {
typedef void (*TasInitialize)(void);
TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init");
if (initFunction) {
initFunction();
} else {
qCritical("Library qttestability resolve failed!");
}
} else {
qCritical("Library qttestability load failed!");
}
}
}
} // namespace
void addPathToQmlImport(const QString & importPath)
{
QString existingImportPath (qgetenv("QML2_IMPORT_PATH"));
existingImportPath = existingImportPath.trimmed();
if ( ! existingImportPath.trimmed().isEmpty())
existingImportPath.append(":");
existingImportPath.append(importPath);
qputenv("QML2_IMPORT_PATH", existingImportPath.toLatin1());
}
void setUpQmlImportPathIfNecessary()
{
QString importPath = Webapp::Config::getContainerImportPath();
if ( !importPath.isEmpty())
{
addPathToQmlImport(importPath);
}
qDebug() << "Setting import path to: "
<< qgetenv("QML2_IMPORT_PATH").data();
}
void usage()
{
QTextStream out(stdout);
QString command = QFileInfo(QCoreApplication::applicationFilePath()).fileName();
out << "Usage: "
<< command
<< " [-h|--help] [--www=] [--inspector]" << endl;
out << "Options:" << endl;
out << " -h, --help display this help message and exit" << endl;
out << " --www=PATH relative or absolute path to the 'index.html' root file" << endl;
out << " --maximized maximize the app window at startup time" << endl;
out << " --inspector run a remote inspector on port "
<< REMOTE_INSPECTOR_PORT << endl;
}
int main(int argc, char *argv[])
{
// Enable compositing in oxide
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QGuiApplication app(argc, argv);
if (!app.arguments().count())
{
qCritical() << "Invalid inputs args";
usage();
return EXIT_FAILURE;
}
loadQtTestability(app.arguments());
const QString WWW_LOCATION_ARG_HEADER = "--www=";
const QString MAXIMIZED_ARG_HEADER = "--maximized";
const QString ARG_HEADER = "--";
const QString VALUE_HEADER = "=";
const QString INSPECTOR = "--inspector";
QString wwwfolderArg;
bool maximized = false;
QString remoteInspectorHost = "";
QString remoteInspectorPort = QString::number(REMOTE_INSPECTOR_PORT);
bool remoteInspectorEnabled = false;
QStringList arguments = app.arguments();
arguments.pop_front();
Q_FOREACH(QString argument, arguments)
{
if (argument.contains(WWW_LOCATION_ARG_HEADER))
{
wwwfolderArg = argument.split(WWW_LOCATION_ARG_HEADER)[1];
}
else
if (argument.contains(MAXIMIZED_ARG_HEADER))
{
maximized = true;
}
else
if (argument.contains(INSPECTOR))
{
remoteInspectorEnabled = true;
Q_FOREACH(QHostAddress address, QNetworkInterface::allAddresses()) {
if (!address.isLoopback() && (address.protocol() == QAbstractSocket::IPv4Protocol)) {
remoteInspectorHost = address.toString();
break;
}
}
if (argument.startsWith(INSPECTOR + "=")) {
remoteInspectorPort = argument.split(INSPECTOR + "=")[1];
}
}
else
{
qDebug() << "Ignoring argument: " << argument;
}
}
if (wwwfolderArg.isEmpty())
{
wwwfolderArg = QDir::currentPath();
qDebug() << "No (or empty) WWW folder path specified." << endl
<< "Defaulting to the current directory:" << wwwfolderArg;
}
QFileInfo wwwFolder(wwwfolderArg);
if (wwwFolder.isRelative())
{
wwwFolder.makeAbsolute();
}
if (!wwwFolder.exists() || !wwwFolder.isDir())
{
qCritical() << "WWW folder not found or not a proper directory: "
<< wwwFolder.absoluteFilePath();
return EXIT_FAILURE;
}
// set the current directory to the project/application folder
// to help use relative paths for the embedded js components as well
QDir::setCurrent(wwwFolder.absoluteFilePath());
// Ensure that application-specific data is written where it ought to.
if (qgetenv("APP_ID").data() != NULL)
{
QString appPkgName = qgetenv("APP_ID").split('_').first();
QCoreApplication::setApplicationName(appPkgName);
}
setUpQmlImportPathIfNecessary();
QQuickView view;
QQmlEngine* engine = view.engine();
if (remoteInspectorEnabled) {
qputenv("UBUNTU_WEBVIEW_DEVTOOLS_HOST", remoteInspectorHost.toUtf8());
qputenv("UBUNTU_WEBVIEW_DEVTOOLS_PORT", remoteInspectorPort.toUtf8());
}
engine->rootContext()->setContextProperty("inspector", remoteInspectorEnabled);
engine->rootContext()->setContextProperty("wwwFolder", wwwFolder.absoluteFilePath());
view.setSource(QUrl::fromLocalFile(Webapp::Config::getContainerMainQmlPath()
+ "/main.qml"));
if (view.status() != QQuickView::Ready)
{
qCritical() << "Main application component cannot be loaded.";
return EXIT_FAILURE;
}
view.setTitle(QCoreApplication::applicationName());
view.setResizeMode(QQuickView::SizeRootObjectToView);
QObject::connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit()));
if (maximized)
view.showMaximized();
else
view.show();
return app.exec();
}
ubuntu-html5-theme-0.1.2+16.04.20160203/src/ubuntu-html5-app-launcher/config.h.in 0000644 0000156 0000165 00000003076 12654470322 027274 0 ustar pbuser pbgroup 0000000 0000000 /*
* Copyright 2013 Canonical Ltd.
*
* This file is part of ubuntu-html5-ui-toolkit.
*
* ubuntu-html5-ui-toolkit is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* ubuntu-html5-ui-toolkit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef __CONFIG_H__
#define __CONFIG_H__
#include
#include
#include
#define REMOTE_INSPECTOR_PORT 9221
namespace Webapp {
namespace Config {
bool isRunningInstalled()
{
static bool installed = (QCoreApplication::applicationDirPath() == QDir("@CMAKE_INSTALL_FULL_BINDIR@").canonicalPath());
return installed;
}
QString getContainerMainQmlPath()
{
static QString mainQml =
isRunningInstalled()
? QString("@CMAKE_INSTALL_FULL_DATADIR@/ubuntu-html5-app-launcher/qml")
: QString("@CMAKE_SOURCE_DIR@/src/ubuntu-html5-app-launcher");
return mainQml;
}
QString getContainerImportPath()
{
static QString mainQml =
! isRunningInstalled()
? QString("@CMAKE_SOURCE_DIR@/src/plugin")
: QString();
return mainQml;
}
} // namespace Config
} // namespace Webapp
#endif // __CONFIG_H__
ubuntu-html5-theme-0.1.2+16.04.20160203/src/ubuntu-html5-app-launcher/main.qml 0000644 0000156 0000165 00000001626 12654470322 026707 0 ustar pbuser pbgroup 0000000 0000000 /*
* Copyright 2014 Canonical Ltd.
*
* This file is part of ubuntu-html5-ui-toolkit.
*
* ubuntu-html5-ui-toolkit is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* ubuntu-html5-ui-toolkit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Components 0.1
import Ubuntu.WebApps 0.1
WebAppContainer {
width: units.gu(100)
height: units.gu(75)
remoteInspectorEnabled: inspector
htmlIndexDirectory: wwwFolder
}
ubuntu-html5-theme-0.1.2+16.04.20160203/src/ubuntu-html5-app-launcher/CMakeLists.txt 0000644 0000156 0000165 00000001224 12654470322 030002 0 ustar pbuser pbgroup 0000000 0000000 project(ubuntu-html5-app-launcher)
configure_file(
config.h.in
${CMAKE_CURRENT_BINARY_DIR}/config.h
@ONLY)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
)
# ubuntu-html5-app binary
set(HTML5_LAUNCHER ubuntu-html5-app-launcher)
set(HTML5_LAUNCHER_SRC
main.cpp
)
add_executable(${HTML5_LAUNCHER}
${HTML5_LAUNCHER_SRC}
)
qt5_use_modules(${HTML5_LAUNCHER} Core Gui Widgets Quick)
# install qml files
file(GLOB QML_FILES *.qml)
install(FILES ${QML_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/ubuntu-html5-app-launcher/qml)
# install bin files
install(TARGETS ${HTML5_LAUNCHER}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
ubuntu-html5-theme-0.1.2+16.04.20160203/README 0000644 0000156 0000165 00000002352 12654470322 020410 0 ustar pbuser pbgroup 0000000 0000000 ======
README
======
Ubuntu HTML5 UI SDK for Html5 apps that brings a collection of HTML5 widgets
and js runtime support for HTML5 apps along with the HTML5 WebRuntime that is
meant to host those apps.
=======
HACKING
=======
Here is how to develop on this code base.
Install SASS
============
Complete the steps in globally install SASS if you currently do not have it
installed:
http://sass-lang.com/install
Running SASS
============
Once you have SASS installed. Open terminal (CTRL+Alt+T) and cd into your
branch folder. Then enter this command to begin watching your scss files:
$ sass --watch 0.1/ambiance/css/sass/default.scss:0.1/ambiance/css/appTemplate.css --style expanded
Automated UI tests
==================
The ubuntu-html5 container and the ubuntu-ui-toolkit both use autopilot (https://launchpad.net/autopilot) to test its functional elements.
To run the tests, you will need to install python3-autopilot and libautopilot-qt.
Then do the following:
$ cd tests/autopilot/
$ autopilot3 run ubuntu_html5_ui_toolkit
$ autopilot3 run ubuntu_html5_container
You can get a list of all available tests with the following commands:
$ autopilot3 list ubuntu_html5_ui_toolkit
$ autopilot3 list ubuntu_html5_container
ubuntu-html5-theme-0.1.2+16.04.20160203/ubuntu-html5-theme 0000755 0000156 0000165 00000002771 12654470322 023134 0 ustar pbuser pbgroup 0000000 0000000 #! /bin/sh
OUTDIR="$(pwd)"
WORKDIR=$(mktemp -d)
cleanup()
{
rm -rf $WORKDIR
rm -f .ubuntu-html5-theme.releases-list
}
trap cleanup EXIT INT QUIT ILL KILL SEGV TERM
list_releases() {
wget -q -O ./.ubuntu-html5-theme.releases-list https://code.launchpad.net/ubuntu-html5-theme
cat .ubuntu-html5-theme.releases-list | \
grep lp:ubuntu | \
grep ~ubuntu-html5-theme-devs | \
awk '{match($0, /~ubuntu-html5-theme-devs\/ubuntu-html5-theme\/([^\"]*)/, releases); print releases[1]}'
}
download() {
rel=$1
echo "Downloading release $rel..."
bzr branch https://code.launchpad.net/~ubuntu-html5-theme-devs/ubuntu-html5-theme/$1 $WORKDIR/$rel
if [ "$?" -ne 0 ]; then
echo "Unable to download release $rel"
exit 1
fi
}
do_install_theme() {
if [ ! -d $OUTDIR/www ]; then
echo "No 'www' folder found in the current directory"
echo "Exiting..."
exit 1
fi
if [ -d $OUTDIR/ambiance ]; then
echo "There is already an 'ambiance' folder in the project directory"
echo "Exiting..."
exit 1
fi
download $1
mv $WORKDIR/$1/0.1/ambiance $OUTDIR/www
}
do_convert_project() {
if [ ! -e $OUTDIR/www/index.html ]; then
echo "No index.html found in the 'www' folder"
echo "Exiting..."
exit 1
fi
sed -i 's:/usr/share/ubuntu-html5-ui-toolkit/0.1/::' $OUTDIR/www/index.html
}
case "$1" in
install)
do_install_theme $2
;;
convert)
do_convert_project
;;
list)
list_releases
;;
update)
echo "Not implemented..."
exit 1
;;
*)
echo "Usage: $0 {list|install |convert|update}"
exit 1
esac
ubuntu-html5-theme-0.1.2+16.04.20160203/package.json 0000644 0000156 0000165 00000000605 12654470322 022015 0 ustar pbuser pbgroup 0000000 0000000 {
"author": "Adnane Belmadiaf",
"name": "ubuntu-html5-theme",
"version": "0.0.1",
"homepage": "https://launchpad.net/ubuntu-html5-theme",
"devDependencies": {
"grunt": "~0.4.0",
"grunt-contrib-concat": "~0.1.3",
"grunt-contrib-uglify": "~0.1.1",
"grunt-contrib-cssmin": "~0.4.1",
"grunt-contrib-jshint": "~0.1.0",
"grunt-contrib-compress": "~0.3.3"
}
}
ubuntu-html5-theme-0.1.2+16.04.20160203/cmake_uninstall.cmake.in 0000644 0000156 0000165 00000002117 12654470322 024307 0 ustar pbuser pbgroup 0000000 0000000 # Source: http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
list(REVERSE files)
foreach (file ${files})
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
if (EXISTS "$ENV{DESTDIR}${file}")
execute_process(
COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}"
OUTPUT_VARIABLE rm_out
RESULT_VARIABLE rm_retval
)
if(NOT ${rm_retval} EQUAL 0)
message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
endif (NOT ${rm_retval} EQUAL 0)
else (EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
endif (EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)
ubuntu-html5-theme-0.1.2+16.04.20160203/COPYING 0000644 0000156 0000165 00000016743 12654470322 020574 0 ustar pbuser pbgroup 0000000 0000000 GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
ubuntu-html5-theme-0.1.2+16.04.20160203/Gruntfile.js 0000644 0000156 0000165 00000005267 12654470322 022035 0 ustar pbuser pbgroup 0000000 0000000 /*
* Copyright (C) 2013 Adnane Belmadiaf
* Licese granted by Canonical Limited
*
* This file is part of ubuntu-html5-ui-toolkit.
*
* This package is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3 of the
* License, or
* (at your option) any later version.
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this program. If not, see
* .
*/
/*global module:false*/
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
banner:
'/*!\n' +
' * app.js <%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd, HH:MM") %>)\n' +
' * https://launchpad.net/ubuntu-html5-theme\n' +
' * GNU LGPL v3\n' +
' */'
},
jshint: {
options: {
curly: false,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
eqnull: true,
browser: true,
expr: true,
globals: {
head: false,
module: false,
console: false
}
},
files: [ 'Gruntfile.js', 'js/app.js' ]
},
concat: {
options:{
separator: ';'
},
js: {
src: ['ambiance/js/*.js'],
dest: 'build/app.js'
},
css:{
src: ['ambiance/css/*.css'],
dest: 'build/app.css'
}
},
uglify: {
options: {
banner: '<%= meta.banner %>\n'
},
build: {
src: '<%= concat.js.dest %>',
dest: 'build/app.min.js'
}
},
cssmin: {
options: {
banner: '/*!\n' +
' * app.min.css <%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd, HH:MM") %>)\n' +
' * https://launchpad.net/ubuntu-html5-theme\n' +
' * GNU LGPL v3\n' +
' */'
},
compress: {
files: {
'build/app.min.css': [ '<%= concat.css.dest %>' ]
}
}
}
});
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
grunt.loadNpmTasks( 'grunt-contrib-uglify' );
grunt.loadNpmTasks( 'grunt-contrib-concat' );
// Default task.
grunt.registerTask( 'default', [ 'jshint', 'concat', 'cssmin', 'uglify' ] );
};
ubuntu-html5-theme-0.1.2+16.04.20160203/update-docs 0000755 0000156 0000165 00000000306 12654470322 021663 0 ustar pbuser pbgroup 0000000 0000000 #!/bin/sh
if [ ! $(which yuidoc) ]; then
echo "Please install yuidocjs: sudo apt-get install npm nodejs-legacy && sudo npm -g install yuidocjs"
exit 1
fi
cd 0.1/ambiance/js && ./yuidoc-build.sh
ubuntu-html5-theme-0.1.2+16.04.20160203/CMakeLists.txt 0000644 0000156 0000165 00000002101 12654470322 022260 0 ustar pbuser pbgroup 0000000 0000000 cmake_minimum_required(VERSION 2.8.9)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# Standard install paths
include(GNUInstallDirs)
string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lower)
# enable QML debugging
if(CMAKE_BUILD_TYPE MATCHES DEBUG OR CMAKE_BUILD_TYPE MATCHES "Debug")
add_definitions(-DQT_QML_DEBUG)
endif()
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Quick REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
# make non compiled files (QML, JS, images, etc.) visible in QtCreator
file(GLOB_RECURSE NON_COMPILED_FILES *.qml *.js *.png *.py *.pot *.po *.qdoc *.qdocconf *.css *.html)
add_custom_target(NON_COMPILED_TARGET ALL SOURCES ${NON_COMPILED_FILES})
add_subdirectory(src)
add_subdirectory(tests)
ubuntu-html5-theme-0.1.2+16.04.20160203/0.1/ 0000755 0000156 0000165 00000000000 12654470530 020025 5 ustar pbuser pbgroup 0000000 0000000 ubuntu-html5-theme-0.1.2+16.04.20160203/0.1/ambiance/ 0000755 0000156 0000165 00000000000 12654470530 021564 5 ustar pbuser pbgroup 0000000 0000000 ubuntu-html5-theme-0.1.2+16.04.20160203/0.1/ambiance/js/ 0000755 0000156 0000165 00000000000 12654470531 022201 5 ustar pbuser pbgroup 0000000 0000000 ubuntu-html5-theme-0.1.2+16.04.20160203/0.1/ambiance/js/yuidoc.json 0000644 0000156 0000165 00000000425 12654470322 024367 0 ustar pbuser pbgroup 0000000 0000000 {
"description": "Ubuntu HTML5 API: JavaScript for HTML5 Ubuntu Apps",
"majorversion": "HTML-14.04-dev",
"options": {
"themedir": "yuidoc-theme",
"outdir": "./docsbuild"
},
"name": "Ubuntu HTML5 API",
"version": "HTML-14.04-dev~bzr202"
} ubuntu-html5-theme-0.1.2+16.04.20160203/0.1/ambiance/js/fast-buttons.js 0000644 0000156 0000165 00000014737 12654470322 025202 0 ustar pbuser pbgroup 0000000 0000000 /*
* Copyright (C) 2013 Adnane Belmadiaf
* License granted by Canonical Limited
*
* This file is part of ubuntu-html5-ui-toolkit.
*
* This package is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3 of the
* License, or
* (at your option) any later version.
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this program. If not, see
* .
*/
(function () {
/**
* From: http://code.this.com/mobile/articles/fast_buttons.html
* Also see: http://stackoverflow.com/questions/6300136/trying-to-implement-googles-fast-button
*/
/** For IE8 and earlier compatibility: https://developer.mozilla.org/en/DOM/element.addEventListener */
function addListener(el, type, listener, useCapture) {
if (el.addEventListener) {
el.addEventListener(type, listener, useCapture);
return {
destroy: function () {
el.removeEventListener(type, listener, useCapture);
}
};
} else {
// see: http://stackoverflow.com/questions/5198845/javascript-this-losing-context-in-ie
var handler = function (e) {
listener.handleEvent(window.event, listener);
};
el.attachEvent('on' + type, handler);
return {
destroy: function () {
el.detachEvent('on' + type, handler);
}
};
}
}
var isTouch = "ontouchstart" in window;
/* Construct the FastButton with a reference to the element and click handler. */
this.FastButton = function (element, handler, useCapture) {
// collect functions to call to cleanup events
this.events = [];
this.touchEvents = [];
this.element = element;
this.handler = handler;
this.useCapture = useCapture;
if (isTouch)
this.events.push(addListener(element, 'touchstart', this, this.useCapture));
this.events.push(addListener(element, 'click', this, this.useCapture));
};
/* Remove event handling when no longer needed for this button */
this.FastButton.prototype.destroy = function () {
for (var i = this.events.length - 1; i >= 0; i -= 1)
this.events[i].destroy();
this.events = this.touchEvents = this.element = this.handler = this.fastButton = null;
};
/* acts as an event dispatcher */
this.FastButton.prototype.handleEvent = function (event) {
switch (event.type) {
case 'touchstart':
this.onTouchStart(event);
break;
case 'touchmove':
this.onTouchMove(event);
break;
case 'touchend':
this.onClick(event);
break;
case 'click':
this.onClick(event);
break;
}
};
/* Save a reference to the touchstart coordinate and start listening to touchmove and
touchend events. Calling stopPropagation guarantees that other behaviors don’t get a
chance to handle the same click event. This is executed at the beginning of touch. */
this.FastButton.prototype.onTouchStart = function (event) {
event.stopPropagation ? event.stopPropagation() : (event.cancelBubble = true);
this.touchEvents.push(addListener(this.element, 'touchend', this, this.useCapture));
this.touchEvents.push(addListener(document.body, 'touchmove', this, this.useCapture));
this.startX = event.touches[0].clientX;
this.startY = event.touches[0].clientY;
};
/* When /if touchmove event is invoked, check if the user has dragged past the threshold of 10px. */
this.FastButton.prototype.onTouchMove = function (event) {
if (Math.abs(event.touches[0].clientX - this.startX) > 10 || Math.abs(event.touches[0].clientY - this.startY) > 10) {
this.reset(); //if he did, then cancel the touch event
}
};
/* Invoke the actual click handler and prevent ghost clicks if this was a touchend event. */
this.FastButton.prototype.onClick = function (event) {
event.stopPropagation ? event.stopPropagation() : (event.cancelBubble = true);
this.reset();
// Use .call to call the method so that we have the correct "this": https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/call
var result = this.handler.call(this.element, event);
if (event.type == 'touchend')
clickbuster.preventGhostClick(this.startX, this.startY);
return result;
};
this.FastButton.prototype.reset = function () {
for (var i = this.touchEvents.length - 1; i >= 0; i -= 1)
this.touchEvents[i].destroy();
this.touchEvents = [];
};
this.clickbuster = function () {};
/* Call preventGhostClick to bust all click events that happen within 25px of
the provided x, y coordinates in the next 2.5s. */
this.clickbuster.preventGhostClick = function (x, y) {
clickbuster.coordinates.push(x, y);
window.setTimeout(clickbuster.pop, 2500);
};
this.clickbuster.pop = function () {
clickbuster.coordinates.splice(0, 2);
};
/* If we catch a click event inside the given radius and time threshold then we call
stopPropagation and preventDefault. Calling preventDefault will stop links
from being activated. */
this.clickbuster.onClick = function (event) {
for (var i = 0; i < clickbuster.coordinates.length; i += 2) {
var x = clickbuster.coordinates[i];
var y = clickbuster.coordinates[i + 1];
if (Math.abs(event.clientX - x) < 25 && Math.abs(event.clientY - y) < 25) {
event.stopPropagation ? event.stopPropagation() : (event.cancelBubble = true);
event.preventDefault ? event.preventDefault() : (event.returnValue = false);
}
}
};
if (isTouch) {
// Don't need to use our custom addListener function since we only bust clicks on touch devices
document.addEventListener('click', clickbuster.onClick, true);
clickbuster.coordinates = [];
}
})(this);
ubuntu-html5-theme-0.1.2+16.04.20160203/0.1/ambiance/js/fix_copyright_header.py 0000755 0000156 0000165 00000005107 12654470322 026745 0 ustar pbuser pbgroup 0000000 0000000 #!/usr/bin/python3
#
# Copyright 2015 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see