| 1 |
/* |
| 2 |
* Copyright 2013-2016 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 |
|
| 17 |
import QtQuick 2.0 |
| 18 |
import QtTest 1.0 |
| 19 |
import TestUtil 0.1 |
| 20 |
import Lomiri.Launcher 0.1 |
| 21 |
|
| 22 |
Item { |
| 23 |
|
| 24 |
SignalSpy { |
| 25 |
id: signalSpy |
| 26 |
} |
| 27 |
|
| 28 |
Verifier { |
| 29 |
id: checkModelVerifier |
| 30 |
|
| 31 |
property var model: LauncherModel |
| 32 |
|
| 33 |
function test_model_data() { |
| 34 |
return [ |
| 35 |
{ tag: "LauncherModel[object]", type: "object" }, |
| 36 |
{ tag: "LauncherModel[LauncherModelInterface]", type: "lomiri::shell::launcher::LauncherModelInterface" }, |
| 37 |
]; |
| 38 |
} |
| 39 |
|
| 40 |
function test_model(data) { |
| 41 |
object = model; |
| 42 |
name = "LauncherModel" |
| 43 |
|
| 44 |
verifyData(data); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
Verifier { |
| 49 |
when: checkModelVerifier.completed |
| 50 |
|
| 51 |
Repeater { |
| 52 |
id: repeater |
| 53 |
model: LauncherModel |
| 54 |
delegate: Item { |
| 55 |
property var roles: model |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
Repeater { |
| 60 |
id: quickListRepeater |
| 61 |
model: LauncherModel.get(0).quickList |
| 62 |
delegate: Item { |
| 63 |
property var roles: model |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
Repeater { |
| 69 |
id: appDrawerRepeater |
| 70 |
model: AppDrawerModel {} |
| 71 |
delegate: Item { |
| 72 |
property var roles: model |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
function initTestCase() { |
| 77 |
if (repeater.count < 5) { |
| 78 |
print("This Test Suite requires at least 5 items in the model.") |
| 79 |
fail() |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
/* make sure all the required roles are exposed on Model */ |
| 84 |
function test_model_roles_data() { |
| 85 |
return [ |
| 86 |
{ tag: "Model.roles[appId]", role: "appId", type: "string" }, |
| 87 |
{ tag: "Model.roles[name]", role: "name", type: "string" }, |
| 88 |
{ tag: "Model.roles[icon]", role: "icon", type: "string" }, |
| 89 |
{ tag: "Model.roles[pinned]", role: "pinned", type: "boolean" }, |
| 90 |
{ tag: "Model.roles[running]", role: "running", type: "boolean" }, |
| 91 |
{ tag: "Model.roles[recent]", role: "recent", type: "boolean" }, |
| 92 |
{ tag: "Model.roles[progress]", role: "progress", type: "number" }, |
| 93 |
{ tag: "Model.roles[count]", role: "count", type: "number" }, |
| 94 |
{ tag: "Model.roles[countVisible]", role: "countVisible", type: "boolean" }, |
| 95 |
{ tag: "Model.roles[focused]", role: "focused", type: "boolean" }, |
| 96 |
{ tag: "Model.roles[alerting]", role: "alerting", type: "boolean" }, |
| 97 |
{ tag: "Model.roles[surfaceCount]", role: "surfaceCount", type: "number" }, |
| 98 |
]; |
| 99 |
} |
| 100 |
|
| 101 |
function test_model_roles(data) { |
| 102 |
name = "LauncherModel" |
| 103 |
try { |
| 104 |
object = repeater.itemAt(0).roles; |
| 105 |
} catch(err) { |
| 106 |
object = undefined; |
| 107 |
} |
| 108 |
|
| 109 |
verifyData(data); |
| 110 |
} |
| 111 |
|
| 112 |
function test_model_methods_data() { |
| 113 |
return [ |
| 114 |
{ tag: "Model.methods[get]", method: "get" }, |
| 115 |
{ tag: "Model.methods[move]", method: "move" }, |
| 116 |
{ tag: "Model.methods[pin]", method: "pin" }, |
| 117 |
{ tag: "Model.methods[requestRemove]", method: "requestRemove" }, |
| 118 |
{ tag: "Model.methods[quickListActionInvoked]", method: "quickListActionInvoked" }, |
| 119 |
{ tag: "Model.methods[setUser]", method: "setUser" }, |
| 120 |
]; |
| 121 |
} |
| 122 |
|
| 123 |
function test_model_methods(data) { |
| 124 |
name = "LauncherModel" |
| 125 |
object = LauncherModel; |
| 126 |
verifyData(data); |
| 127 |
} |
| 128 |
|
| 129 |
function test_model_properties_data() { |
| 130 |
return [ |
| 131 |
{ tag: "Model.properties[applicationManager]", property: "applicationManager", type: "lomiri::shell::application::ApplicationManagerInterface" }, |
| 132 |
{ tag: "Model.properties[onlyPinned]", property: "onlyPinned", type: "boolean" }, |
| 133 |
]; |
| 134 |
} |
| 135 |
|
| 136 |
function test_model_properties(data) { |
| 137 |
name = "LauncherModel"; |
| 138 |
object = LauncherModel; |
| 139 |
verifyData(data); |
| 140 |
} |
| 141 |
|
| 142 |
function test_item_properties_data() { |
| 143 |
return [ |
| 144 |
{ tag: "Item.properties[appId]", constant: "appId", type: "string" }, |
| 145 |
{ tag: "Item.properties[name]", constant: "name", type: "string" }, |
| 146 |
{ tag: "Item.properties[icon]", constant: "icon", type: "string" }, |
| 147 |
{ tag: "Item.properties[keywords]", constant: "keywords", type: "object" }, |
| 148 |
{ tag: "Item.properties[popularity]", constant: "popularity", type: "number" }, |
| 149 |
{ tag: "Item.properties[pinned]", property: "pinned", type: "boolean" }, |
| 150 |
{ tag: "Item.properties[recent]", property: "recent", type: "boolean" }, |
| 151 |
{ tag: "Item.properties[running]", property: "running", type: "boolean" }, |
| 152 |
{ tag: "Item.properties[progress]", property: "progress", type: "number" }, |
| 153 |
{ tag: "Item.properties[count]", property: "count", type: "number" }, |
| 154 |
{ tag: "Item.properties[countVisible]", property: "countVisible", type: "boolean" }, |
| 155 |
{ tag: "Item.properties[focused]", property: "focused", type: "boolean" }, |
| 156 |
{ tag: "Item.properties[alerting]", property: "alerting", type: "boolean" }, |
| 157 |
{ tag: "Item.properties[surfaceCount]", property: "surfaceCount", type: "number" }, |
| 158 |
{ tag: "Item.properties[quickList]", constant: "quickList", type: "object" }, |
| 159 |
]; |
| 160 |
} |
| 161 |
|
| 162 |
function test_item_properties(data) { |
| 163 |
name = "LauncherItem" |
| 164 |
try { |
| 165 |
object = LauncherModel.get(0) |
| 166 |
} catch(err) { |
| 167 |
object = undefined; |
| 168 |
print(err) |
| 169 |
} |
| 170 |
|
| 171 |
verifyData(data) |
| 172 |
} |
| 173 |
|
| 174 |
function test_quicklist_model_roles_data() { |
| 175 |
return [ |
| 176 |
{ tag: "Model.roles[label]", role: "label", type: "string" }, |
| 177 |
{ tag: "Model.roles[icon]", role: "icon", type: "string" }, |
| 178 |
{ tag: "Model.roles[clickable]", role: "clickable", type: "boolean" }, |
| 179 |
{ tag: "Model.roles[hasSeparator]", role: "hasSeparator", type: "boolean" }, |
| 180 |
{ tag: "Model.roles[isPrivate]", role: "isPrivate", type: "boolean" } |
| 181 |
]; |
| 182 |
} |
| 183 |
|
| 184 |
function test_quicklist_model_roles(data) { |
| 185 |
name = "QuickListModel" |
| 186 |
try { |
| 187 |
object = quickListRepeater.itemAt(0).roles; |
| 188 |
} catch(err) { |
| 189 |
object = undefined; |
| 190 |
} |
| 191 |
|
| 192 |
verifyData(data); |
| 193 |
} |
| 194 |
|
| 195 |
function test_appdrawer_model_roles_data() { |
| 196 |
return [ |
| 197 |
{ tag: "Model.roles[appId]", role: "appId", type: "string" }, |
| 198 |
{ tag: "Model.roles[name]", role: "name", type: "string" }, |
| 199 |
{ tag: "Model.roles[icon]", role: "icon", type: "string" }, |
| 200 |
{ tag: "Model.roles[keywords]", role: "keywords", type: "object" }, |
| 201 |
{ tag: "Model.roles[usage]", role: "usage", type: "number" }, |
| 202 |
]; |
| 203 |
} |
| 204 |
|
| 205 |
function test_appdrawer_model_roles(data) { |
| 206 |
name = "AppDrawerModel" |
| 207 |
try { |
| 208 |
object = appDrawerRepeater.itemAt(0).roles; |
| 209 |
} catch(err) { |
| 210 |
object = undefined; |
| 211 |
} |
| 212 |
|
| 213 |
verifyData(data); |
| 214 |
} |
| 215 |
} |
| 216 |
} |