~fboucault/unity-webapps-qml/crossbuild_fixes

« back to all changes in this revision

Viewing changes to tests/unit/test_qml/tst_api_launchEmbeddedUI.qml

Improve paramater passing to launchEmbedded UI Fixes: #1417776
Approved by: PS Jenkins bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2015 Canonical Ltd.
 
3
 *
 
4
 * This file is part of unity-webapps-qml.
 
5
 *
 
6
 * unity-webapps-qml is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; version 3.
 
9
 *
 
10
 * unity-webapps-qml is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
import QtQuick 2.0
 
20
import QtTest 1.0
 
21
import Ubuntu.Web 0.2
 
22
import com.canonical.Oxide 1.0 as Oxide
 
23
import Ubuntu.UnityWebApps 0.1
 
24
 
 
25
 
 
26
TestCase {
 
27
    id: testcase
 
28
 
 
29
    name: "LaunchEmbeddedUIApiTest"
 
30
 
 
31
    SignalSpy {
 
32
      id: spy
 
33
      target: webview
 
34
      signalName: "visibleChanged"
 
35
    }
 
36
 
 
37
    function setup() {
 
38
        spy.clear()
 
39
    }
 
40
 
 
41
    function test_invoke_shareRequestedCallback() {
 
42
        setup();
 
43
 
 
44
        webview.url = "tst_api_launchEmbeddedUI.html"
 
45
 
 
46
        evaluateCode("var e = new CustomEvent('launchEmbeddedUI', { bubbles: true }); document.dispatchEvent(e);")
 
47
 
 
48
//        spy.wait()
 
49
//        compare(spy.count, 1, "Should have had 1 messageReceived signal");
 
50
    }
 
51
 
 
52
    UnityWebApps {
 
53
        id: webapps
 
54
        bindee: webview
 
55
        injectExtraUbuntuApis: true
 
56
        injectExtraContentShareCapabilities: true
 
57
    }
 
58
 
 
59
    function evaluateCode(code, wrap) {
 
60
      webview.rootFrame.sendMessageNoReply(
 
61
        "oxide://test-ui/",
 
62
        "evalcode",
 
63
        { code: code,
 
64
          wrap: wrap === undefined ? false : wrap });
 
65
    }
 
66
    visible: true
 
67
 
 
68
    WebView {
 
69
        id: webview
 
70
 
 
71
        width: 200
 
72
        height: 200
 
73
 
 
74
        visible: true
 
75
 
 
76
        context: WebContext {
 
77
            userScripts: [
 
78
              Oxide.UserScript {
 
79
                context: "oxide://test-ui/"
 
80
                url: Qt.resolvedUrl("tst_api_launchEmbeddedUI.js")
 
81
                incognitoEnabled: true
 
82
                matchAllFrames: true
 
83
              }
 
84
            ]
 
85
        }
 
86
 
 
87
        function getUnityWebappsProxies() {
 
88
            return UnityWebAppsUtils.makeProxiesForWebViewBindee(webview);
 
89
        }
 
90
    }
 
91
}