From 02f3b14035f0b7f97f24c6bb2f8e81ee1884bc0c Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Thu, 5 Sep 2013 17:44:37 -0700 Subject: Move webhelper smoke test into a new subdir The webhelper tests should be in their own directory, mirroring the source directory structure. [endlessm/eos-sdk#290] --- test/smoke-tests/webview.js | 112 ---------------------- test/smoke-tests/webview/first_page.html | 54 ----------- test/webhelper/smoke-tests/webview.js | 155 +++++++++++++++++++++++++++++++ 3 files changed, 155 insertions(+), 166 deletions(-) delete mode 100644 test/smoke-tests/webview.js delete mode 100644 test/smoke-tests/webview/first_page.html create mode 100644 test/webhelper/smoke-tests/webview.js (limited to 'test') diff --git a/test/smoke-tests/webview.js b/test/smoke-tests/webview.js deleted file mode 100644 index 98226f3..0000000 --- a/test/smoke-tests/webview.js +++ /dev/null @@ -1,112 +0,0 @@ -//Copyright 2013 Endless Mobile, Inc. - -const Lang = imports.lang; -const Endless = imports.gi.Endless; -const GLib = imports.gi.GLib; -const Gtk = imports.gi.Gtk; -const WebKit = imports.gi.WebKit; - -// WebHelper.js must be copied somewhere in GJS's imports.searchPath -const WebHelper = imports.webhelper; - -const TEST_APPLICATION_ID = 'com.endlessm.example.test-webview'; - -const TestApplication = new Lang.Class({ - Name: 'TestApplication', - Extends: WebHelper.Application, - - /* *** ACTIONS AVAILABLE FROM THE WEB VIEW *** */ - - _webActions: { - /* dict['name'] is the name of the page to move to */ - 'moveToPage': function(dict) { - print('move to page '+dict['name']); - this._pm.visible_page_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._webview = new WebKit.WebView(); - - let cwd = GLib.get_current_dir(); - let target = cwd + '/test/smoke-tests/webview/first_page.html'; - this._webview.load_uri(GLib.filename_to_uri(target, null)); - - this._webview.connect('notify::load-status', - Lang.bind(this, function (web_view, status) { - if (web_view.load_status == WebKit.LoadStatus.FINISHED) { - // now we translate to Brazilian Portuguese - this._translateHTML (web_view, 'pt_BR'); - } - })); - - this._webview.connect('navigation-policy-decision-requested', - Lang.bind(this, this._onNavigationRequested)); - - 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_page_name = 'page1'; - })) - this._page2.add(back_button); - - this._pm = new Endless.PageManager(); - this._pm.set_transition_type(Endless.PageManagerTransitionType.CROSSFADE) - this._pm.add(this._page1, { name: 'page1' }); - this._pm.add(this._page2, { name: 'page2' }); - - this._pm.visible_page = this._page1; - - this._window = new Endless.Window({ - application: this, - border_width: 16, - page_manager: this._pm - }); - - this._window.show_all(); - } -}); - -let app = new TestApplication({ application_id: TEST_APPLICATION_ID, - flags: 0 }); -app.run(ARGV); diff --git a/test/smoke-tests/webview/first_page.html b/test/smoke-tests/webview/first_page.html deleted file mode 100644 index 33a6a8f..0000000 --- a/test/smoke-tests/webview/first_page.html +++ /dev/null @@ -1,54 +0,0 @@ - - - -First page - - - - - - -

First page

- -

-Move to page 2 -

- -

-Show message from parameter in this URL -

- -
- - -
- -

- -Show message using the <input>'s ID -

- -

-Regular link to a Web site -

- -

-I want stars! -

- -

-This is text that will be translated: Hello, world! -

- - - \ No newline at end of file diff --git a/test/webhelper/smoke-tests/webview.js b/test/webhelper/smoke-tests/webview.js new file mode 100644 index 0000000..681de20 --- /dev/null +++ b/test/webhelper/smoke-tests/webview.js @@ -0,0 +1,155 @@ +//Copyright 2013 Endless Mobile, Inc. + +const Lang = imports.lang; +const Endless = imports.gi.Endless; +const GLib = imports.gi.GLib; +const Gtk = imports.gi.Gtk; +const WebKit = imports.gi.WebKit; + +// WebHelper.js must be copied somewhere in GJS's imports.searchPath +const WebHelper = imports.webhelper; + +const TEST_APPLICATION_ID = 'com.endlessm.example.test-webview'; + +const TEST_HTML = '\ + \ + \ +First page \ + \ + \ +\ + \ +

First page

\ +\ +

Move to page 2

\ +\ +

Show \ +message from parameter in this URL

\ +\ +
\ + \ + \ +
\ +\ +

\ + \ +Show message \ +using the <input>\'s ID \ +

\ +\ +

Regular link to a Web site

\ +\ +

I want \ +stars!

\ +\ +

This is text that will be translated: Hello, \ +world!

\ +\ + \ +'; + +const TestApplication = new Lang.Class({ + Name: 'TestApplication', + Extends: WebHelper.Application, + + /* *** ACTIONS AVAILABLE FROM THE WEB VIEW *** */ + + _webActions: { + /* dict['name'] is the name of the page to move to */ + 'moveToPage': function(dict) { + print('move to page '+dict['name']); + this._pm.visible_page_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._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 (web_view, status) { + if (web_view.load_status == WebKit.LoadStatus.FINISHED) { + // now we translate to Brazilian Portuguese + this._translateHTML (web_view, 'pt_BR'); + } + })); + + this._webview.connect('navigation-policy-decision-requested', + Lang.bind(this, this._onNavigationRequested)); + + 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_page_name = 'page1'; + })) + this._page2.add(back_button); + + this._pm = new Endless.PageManager(); + this._pm.set_transition_type(Endless.PageManagerTransitionType.CROSSFADE) + this._pm.add(this._page1, { name: 'page1' }); + this._pm.add(this._page2, { name: 'page2' }); + + this._pm.visible_page = this._page1; + + this._window = new Endless.Window({ + application: this, + border_width: 16, + page_manager: this._pm + }); + + this._window.show_all(); + } +}); + +let app = new TestApplication({ application_id: TEST_APPLICATION_ID, + flags: 0 }); +app.run(ARGV); -- cgit v1.2.3