diff options
author | Philip Chimento <philip@endlessm.com> | 2017-04-12 15:24:48 -0700 |
---|---|---|
committer | Philip Chimento <philip@endlessm.com> | 2017-04-12 16:14:06 -0700 |
commit | e54bec3feb08b09de64945f72885c8c37258de60 (patch) | |
tree | e86d9c5ff13eaf6b7b5498d68624a413a18b544d /test/smoke-tests | |
parent | 72694e1790f779edc8f8ac163a66af561bf14500 (diff) |
build: Remove Webhelper
Webhelper is now in its own repository:
https://github.com/endlessm/webhelper
https://phabricator.endlessm.com/T16203
Diffstat (limited to 'test/smoke-tests')
-rw-r--r-- | test/smoke-tests/webhelper/webview.js | 160 | ||||
-rw-r--r-- | test/smoke-tests/webhelper/webview2.js | 147 |
2 files changed, 0 insertions, 307 deletions
diff --git a/test/smoke-tests/webhelper/webview.js b/test/smoke-tests/webhelper/webview.js deleted file mode 100644 index a1dba65..0000000 --- a/test/smoke-tests/webhelper/webview.js +++ /dev/null @@ -1,160 +0,0 @@ -//Copyright 2013 Endless Mobile, Inc. - -const Endless = imports.gi.Endless; -const GLib = imports.gi.GLib; -const Gtk = imports.gi.Gtk; -const Lang = imports.lang; -const WebHelper = imports.webhelper; -const WebKit = imports.gi.WebKit; - -const TEST_APPLICATION_ID = 'com.endlessm.example.test-webview'; - -const TEST_HTML = '\ -<html> \ -<head> \ -<title>First page</title> \ -<style> \ -p, form { \ - width: 50%; \ - padding: 1em; \ - background: #FFFFFF; \ -} \ -body { \ - background: #EEEEEE; \ -} \ -</style> \ -</head> \ -\ -<body> \ -<h1>First page</h1> \ -\ -<p><a href="endless://moveToPage?name=page2">Move to page 2</a></p> \ -\ -<p><a \ -href="endless://showMessageFromParameter?msg=This%20is%20a%20message%20from%20the%20URL%20parameter">Show \ -message from parameter in this URL</a></p> \ -\ -<form action="endless://showMessageFromParameter"> \ -<input name="msg" value="I am in a form!"/> \ -<input type="submit" value="Show message using a form"/> \ -</form> \ -\ -<p> \ -<input id="inputformessage" value="my ID is inputformessage"/> \ -<a href="endless://showMessageFromInputField?id=inputformessage">Show message \ -using the <input>\'s ID</a> \ -</p> \ -\ -<p><a href="http://wikipedia.org">Regular link to a Web site</a></p> \ -\ -<p><a href="endless://addStars?id=starspan">I want \ -stars!</a> <span id="starspan"/></p> \ -\ -<p>This is text that will be italicized: <span name="translatable">Hello, \ -world!</span></p> \ -\ -</body> \ -</html>'; - -const TestApplication = new Lang.Class({ - Name: 'TestApplication', - Extends: WebHelper.Application, - - /* *** ACTIONS AVAILABLE FROM THE WEB VIEW *** */ - - /* dict['name'] is the name of the page to move to */ - moveToPage: function(dict) { - this._pm.visible_child_name = dict['name']; - }, - - /* dict['msg'] is the message to display */ - showMessageFromParameter: function(dict) { - let dialog = new Gtk.MessageDialog({ - buttons: Gtk.ButtonsType.CLOSE, - message_type: Gtk.MessageType.INFO, - text: dict['msg'] - }); - dialog.set_transient_for(this._window); - dialog.run(); - dialog.destroy(); - }, - - /* dict['id'] is the ID of the input field to use */ - showMessageFromInputField: function(dict) { - let input = this._getElementById(this._webview, dict['id']); - - // WebKitDOMHTMLInputElement - let msg = input.get_value(); - - let dialog = new Gtk.MessageDialog({ - buttons: Gtk.ButtonsType.CLOSE, - message_type: Gtk.MessageType.INFO, - text: msg - }); - dialog.set_transient_for(this._window); - dialog.run(); - dialog.destroy(); - }, - - /* dict['id'] is the ID of the element to use */ - addStars: function(dict) { - let e = this._getElementById(this._webview, dict['id']); - e.inner_text += '★ '; - }, - - /* *************************** */ - - vfunc_startup: function() { - this.parent(); - - this.set_translation_function(function(string) { - return string.italics(); - }); - this.define_web_actions({ - moveToPage: this.moveToPage, - showMessageFromParameter: this.showMessageFromParameter, - showMessageFromInputField: this.showMessageFromInputField, - addStars: this.addStars - }); - - this._webview = new WebKit.WebView(); - this._webview.load_string(TEST_HTML, 'text/html', 'UTF-8', 'file://'); - this._webview.connect('notify::load-status', - Lang.bind(this, function (webview) { - if (webview.load_status == WebKit.LoadStatus.FINISHED) - this.translate_html(webview); - })); - - this._webview.connect('navigation-policy-decision-requested', - Lang.bind(this, this.web_actions_handler)); - - this._page1 = new Gtk.ScrolledWindow(); - this._page1.add(this._webview); - - this._page2 = new Gtk.Grid(); - let back_button = new Gtk.Button({ label:"Go back to page 1" }); - back_button.connect('clicked', Lang.bind(this, function() { - this._pm.visible_child_name = 'page1'; - })); - this._page2.add(back_button); - - this._window = new Endless.Window({ - application: this, - border_width: 16 - }); - - this._pm = this._window.page_manager; - this._pm.set_transition_type(Gtk.StackTransitionType.CROSSFADE); - this._pm.add(this._page1, { name: 'page1' }); - this._pm.add(this._page2, { name: 'page2' }); - this._pm.visible_child = this._page1; - - this._window.show_all(); - } -}); - -let app = new TestApplication({ - application_id: TEST_APPLICATION_ID, - flags: 0 -}); -app.run(ARGV); diff --git a/test/smoke-tests/webhelper/webview2.js b/test/smoke-tests/webhelper/webview2.js deleted file mode 100644 index f50c42d..0000000 --- a/test/smoke-tests/webhelper/webview2.js +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright 2015 Endless Mobile, Inc. - -const Endless = imports.gi.Endless; -const Gettext = imports.gettext; -const Gtk = imports.gi.Gtk; -const Lang = imports.lang; -const WebHelper2 = imports.webhelper2; -const WebKit2 = imports.gi.WebKit2; - -const TEST_APPLICATION_ID = 'com.endlessm.example.test-webview2'; -const TEST_HTML = '\ -<html> \ -<head> \ -<title>First page</title> \ -<style> \ -p, form { \ - width: 50%; \ - padding: 1em; \ - background: #FFFFFF; \ -} \ -body { \ - background: #EEEEEE; \ -} \ -</style> \ -</head> \ -\ -<body> \ -<script type="text/javascript"> \ - window.ngettextButton = (function () { \ - var times = 0; \ - return function () { \ - times++; \ - var message = ngettext("You have clicked me __ time", "You have clicked me __ times", times); \ - alert(message.replace("__", times.toString())); \ - }; \ - })(); \ -</script> \ -<h1>First page</h1> \ -\ -<p><a href="webhelper://moveToPage?name=page2">Move to page 2</a></p> \ -\ -<p><a \ -href="webhelper://showMessageFromParameter?msg=This%20is%20a%20message%20from%20the%20URL%20parameter">Show \ -message from parameter in this URL</a></p> \ -\ -<form action="webhelper://showMessageFromParameter"> \ -<input name="msg" value="I am in a form!"/> \ -<input type="submit" value="Show message using a form"/> \ -</form> \ -\ -<p><a href="http://wikipedia.org">Regular link to a Web site</a></p> \ -\ -<p>This is text that will be italicized: <span name="translatable">Hello, \ -world!</span></p> \ -\ -<p> \ - <button onclick="alert(gettext(\'I came from gettext\'));"> \ - Click me to use gettext \ - </button> \ - <button onclick="ngettextButton();">Click me to use ngettext</button> \ -</p> \ -\ -</body> \ -</html>'; - -const TestApplication = new Lang.Class({ - Name: 'TestApplication', - Extends: Endless.Application, - - vfunc_dbus_register: function (connection, object_path) { - this._webhelper = new WebHelper2.WebHelper({ - well_known_name: this.application_id, - connection: connection, - }); - return this.parent(connection, object_path); - }, - - vfunc_startup: function () { - this.parent(); - - this._webhelper.set_gettext((s) => s.italics()); - this._webhelper.set_ngettext((s, p, n) => - '** ' + (n == 1 ? s : p) + ' **'); - this._webhelper.define_web_actions({ - moveToPage: this.moveToPage.bind(this), - showMessageFromParameter: this.showMessageFromParameter.bind(this), - }); - - this._webview = new WebKit2.WebView(); - this._webview.connect('load-changed', (webview, event) => { - if (event === WebKit2.LoadEvent.FINISHED) - this._webhelper.translate_html(webview, null, (obj, res) => { - this._webhelper.translate_html_finish(res); - }); - }); - this._webview.load_html(TEST_HTML, null); - - this._page2 = new Gtk.Grid(); - let back_button = new Gtk.Button({ label: 'Go back to page 1' }); - back_button.connect('clicked', () => { - this._pm.visible_child_name = 'page1'; - }); - this._page2.add(back_button); - - this._window = new Endless.Window({ - application: this, - border_width: 16, - }); - - this._pm = this._window.page_manager; - this._pm.set_transition_type(Gtk.StackTransitionType.CROSSFADE); - this._pm.add(this._webview, { name: 'page1' }); - this._pm.add(this._page2, { name: 'page2' }); - this._pm.visible_child_name = 'page1'; - - this._window.show_all(); - }, - - vfunc_dbus_unregister: function (connection, object_path) { - this.parent(connection, object_path); - this._webhelper.unregister(); - }, - - // WEB ACTIONS - - // dict['name'] is the name of the page to move to - moveToPage: function (dict) { - this._pm.visible_child_name = dict['name']; - }, - - // dict['msg'] is the message to display - showMessageFromParameter: function (dict) { - let dialog = new Gtk.MessageDialog({ - buttons: Gtk.ButtonsType.CLOSE, - message_type: Gtk.MessageType.INFO, - text: dict['msg'], - transient_for: this._window, - }); - dialog.run(); - dialog.destroy(); - }, -}); - -let app = new TestApplication({ - application_id: TEST_APPLICATION_ID, -}); -app.run(ARGV); |