| 1 |
/* |
| 2 |
* Copyright 2013,2015 Canonical Ltd. |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU Lesser General Public License as published by |
| 6 |
* the Free Software Foundation; version 3. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
* |
| 16 |
* Authors: |
| 17 |
* Michael Zanetti <[email protected]> |
| 18 |
*/ |
| 19 |
|
| 20 |
import QtQuick 2.0 |
| 21 |
import QtTest 1.0 |
| 22 |
import TestUtil 0.1 |
| 23 |
import Lomiri.Application 0.1 |
| 24 |
|
| 25 |
Item { |
| 26 |
|
| 27 |
SignalSpy { |
| 28 |
id: signalSpy |
| 29 |
} |
| 30 |
|
| 31 |
Verifier { |
| 32 |
id: checkModelVerifier |
| 33 |
|
| 34 |
property var model: ApplicationManager |
| 35 |
|
| 36 |
function test_model_data() { |
| 37 |
return [ |
| 38 |
{ tag: "ApplicationManager[object]", type: "object" }, |
| 39 |
{ tag: "ApplicationManager[ApplicationManagerInterface]", type: "lomiri::shell::application::ApplicationManagerInterface" }, |
| 40 |
]; |
| 41 |
} |
| 42 |
|
| 43 |
function test_model(data) { |
| 44 |
object = model; |
| 45 |
name = "ApplicationManager" |
| 46 |
|
| 47 |
verifyData(data); |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
Verifier { |
| 52 |
when: checkModelVerifier.completed |
| 53 |
|
| 54 |
Repeater { |
| 55 |
id: repeater |
| 56 |
model: ApplicationManager |
| 57 |
delegate: Item { |
| 58 |
property var roles: model |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
/* make sure all the required roles are exposed on ApplicationManager */ |
| 63 |
function test_model_roles_enum_data() { |
| 64 |
return [ |
| 65 |
{ enum: "RoleAppId" }, |
| 66 |
{ enum: "RoleName" }, |
| 67 |
{ enum: "RoleComment" }, |
| 68 |
{ enum: "RoleIcon" }, |
| 69 |
{ enum: "RoleState" }, |
| 70 |
{ enum: "RoleFocused" }, |
| 71 |
{ enum: "RoleIsTouchApp" }, |
| 72 |
{ enum: "RoleExemptFromLifecycle" }, |
| 73 |
]; |
| 74 |
} |
| 75 |
|
| 76 |
function test_model_roles_enum(data) { |
| 77 |
name = "ApplicationManager" |
| 78 |
object = ApplicationManager |
| 79 |
|
| 80 |
verifyData(data); |
| 81 |
} |
| 82 |
|
| 83 |
function test_model_roles_data() { |
| 84 |
return [ |
| 85 |
{ tag: "ApplicationManager.roles[appId]", role: "appId", type: "string" }, |
| 86 |
{ tag: "ApplicationManager.roles[name]", role: "name", type: "string" }, |
| 87 |
{ tag: "ApplicationManager.roles[comment]", role: "comment", type: "string" }, |
| 88 |
{ tag: "ApplicationManager.roles[icon]", role: "icon", type: "object" }, |
| 89 |
{ tag: "ApplicationManager.roles[state]", role: "state", type: "number" }, |
| 90 |
{ tag: "ApplicationManager.roles[focused]", role: "focused", type: "boolean" }, |
| 91 |
{ tag: "ApplicationManager.roles[isTouchApp]", role: "isTouchApp", type: "boolean" }, |
| 92 |
{ tag: "ApplicationManager.roles[exemptFromLifecycle]", role: "exemptFromLifecycle", type: "boolean" }, |
| 93 |
]; |
| 94 |
} |
| 95 |
|
| 96 |
function test_model_roles(data) { |
| 97 |
name = "ApplicationManager" |
| 98 |
try { |
| 99 |
object = repeater.itemAt(0).roles; |
| 100 |
} catch(err) { |
| 101 |
object = undefined; |
| 102 |
} |
| 103 |
|
| 104 |
verifyData(data); |
| 105 |
} |
| 106 |
|
| 107 |
function test_model_methods_data() { |
| 108 |
return [ |
| 109 |
{ tag: "ApplicationManager.methods[get]", method: "get" }, |
| 110 |
{ tag: "ApplicationManager.methods[findApplication]", method: "findApplication" }, |
| 111 |
{ tag: "ApplicationManager.methods[requestFocusApplication]", method: "requestFocusApplication" }, |
| 112 |
{ tag: "ApplicationManager.methods[focusApplication]", method: "focusApplication" }, |
| 113 |
{ tag: "ApplicationManager.methods[unfocusCurrentApplication]", method: "unfocusCurrentApplication" }, |
| 114 |
{ tag: "ApplicationManager.methods[startApplication]", method: "startApplication" }, |
| 115 |
{ tag: "ApplicationManager.methods[stopApplication]", method: "stopApplication" }, |
| 116 |
]; |
| 117 |
} |
| 118 |
|
| 119 |
function test_model_methods(data) { |
| 120 |
name = "ApplicationManager"; |
| 121 |
object = ApplicationManager; |
| 122 |
verifyData(data); |
| 123 |
} |
| 124 |
|
| 125 |
function test_model_properties_data() { |
| 126 |
return [ |
| 127 |
{ tag: "ApplicationManager.count", property: "count", type: "number" }, |
| 128 |
{ tag: "ApplicationManager.focusedApplicationId", property: "focusedApplicationId", type: "string" }, |
| 129 |
]; |
| 130 |
} |
| 131 |
|
| 132 |
function test_model_properties(data) { |
| 133 |
name = "ApplicationManager"; |
| 134 |
object = ApplicationManager; |
| 135 |
verifyData(data); |
| 136 |
} |
| 137 |
|
| 138 |
function test_item_properties_data() { |
| 139 |
return [ |
| 140 |
{ tag: "ApplicationInfo.properties[appId]", constant: "appId", type: "string" }, |
| 141 |
{ tag: "ApplicationInfo.properties[name]", property: "name", type: "string" }, |
| 142 |
{ tag: "ApplicationInfo.properties[comment]", property: "comment", type: "string" }, |
| 143 |
{ tag: "ApplicationInfo.properties[icon]", property: "icon", type: "object" }, |
| 144 |
{ tag: "ApplicationInfo.properties[state]", property: "state", type: "number" }, |
| 145 |
{ tag: "ApplicationInfo.properties[requestedState]", property: "requestedState", type: "number" }, |
| 146 |
{ tag: "ApplicationInfo.properties[focused]", property: "focused", type: "boolean" }, |
| 147 |
{ tag: "ApplicationInfo.properties[isTouchApp]", constant: "isTouchApp", type: "boolean" }, |
| 148 |
{ tag: "ApplicationInfo.properties[exemptFromLifecycle]", constant: "exemptFromLifecycle", type: "boolean" }, |
| 149 |
{ tag: "ApplicationInfo.properties[splashTitle]", constant: "splashTitle", type: "string" }, |
| 150 |
{ tag: "ApplicationInfo.properties[splashImage]", constant: "splashImage", type: "url" }, |
| 151 |
{ tag: "ApplicationInfo.properties[splashShowHeader]", constant: "splashShowHeader", type: "boolean"}, |
| 152 |
{ tag: "ApplicationInfo.properties[splashColor]", constant: "splashColor", type: "color"}, |
| 153 |
{ tag: "ApplicationInfo.properties[splashColorHeader]", constant: "splashColorHeader", type: "color"}, |
| 154 |
{ tag: "ApplicationInfo.properties[splashColorFooter]", constant: "splashColorFooter", type: "color"}, |
| 155 |
{ tag: "ApplicationInfo.properties[supportedOrientations]", constant: "supportedOrientations", type: "number"}, |
| 156 |
{ tag: "ApplicationInfo.properties[rotatesWindowContents]", constant: "rotatesWindowContents", type: "boolean"}, |
| 157 |
]; |
| 158 |
} |
| 159 |
|
| 160 |
function test_item_properties(data) { |
| 161 |
name = "ApplicationInfo" |
| 162 |
try { |
| 163 |
object = ApplicationManager.get(0) |
| 164 |
} catch(err) { |
| 165 |
object = undefined; |
| 166 |
print(err) |
| 167 |
} |
| 168 |
|
| 169 |
verifyData(data) |
| 170 |
} |
| 171 |
} |
| 172 |
} |