| 1 |
/* |
| 2 |
* Copyright 2012 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 Lomiri.Components 1.1 |
| 20 |
|
| 21 |
TestCase { |
| 22 |
name: "LabelAPI" |
| 23 |
|
| 24 |
function cleanup() { |
| 25 |
textCustom.fontSize = "medium"; |
| 26 |
textCustom.font.weight = Font.Light; |
| 27 |
} |
| 28 |
|
| 29 |
function test_0_defaults() { |
| 30 |
compare(textCustom.font.family, "Ubuntu", "Default font family"); |
| 31 |
compare(textCustom.font.weight, Font.Light, "Default font weight"); |
| 32 |
compare(textCustom.fontSize,"medium","fontSize is 'medium' by default") |
| 33 |
} |
| 34 |
|
| 35 |
function test_fontSize_data() { |
| 36 |
return [ |
| 37 |
{tag: "xx-small"}, |
| 38 |
{tag: "x-small"}, |
| 39 |
{tag: "small"}, |
| 40 |
{tag: "medium"}, |
| 41 |
{tag: "large"}, |
| 42 |
{tag: "x-large"}, |
| 43 |
]; |
| 44 |
} |
| 45 |
function test_fontSize(data) { |
| 46 |
textCustom.fontSize = data.tag; |
| 47 |
compare(textCustom.fontSize, data.tag, "Can set/get " + data.tag) |
| 48 |
} |
| 49 |
|
| 50 |
function test_fontWeight_data() { |
| 51 |
return [ |
| 52 |
{tag: "Light", weight: Font.Light}, |
| 53 |
{tag: "Normal", weight: Font.Normal}, |
| 54 |
{tag: "DemiBold", weight: Font.DemiBold}, |
| 55 |
{tag: "Bold", weight: Font.Bold}, |
| 56 |
{tag: "Black", weight: Font.Black}, |
| 57 |
]; |
| 58 |
} |
| 59 |
function test_fontWeight(data) { |
| 60 |
textCustom.font.weight = data.weight |
| 61 |
compare(textCustom.font.weight, data.weight, "can set/get " + data.weight); |
| 62 |
} |
| 63 |
|
| 64 |
function test_boldWeightConflict() { |
| 65 |
compare(lightLabel.font.weight, Font.Light, "font.weight is not overriden by font.bold") |
| 66 |
} |
| 67 |
|
| 68 |
function test_weightPrecedence() { |
| 69 |
compare(lightLabel2.font.weight, Font.Light, "font.weight takes precedence over font.bold") |
| 70 |
} |
| 71 |
|
| 72 |
Label { |
| 73 |
id: textCustom |
| 74 |
} |
| 75 |
|
| 76 |
Label { |
| 77 |
id: lightLabel |
| 78 |
font.weight: Font.Light |
| 79 |
} |
| 80 |
|
| 81 |
Label { |
| 82 |
id: lightLabel2 |
| 83 |
font.weight: Font.Light |
| 84 |
font.bold: true |
| 85 |
} |
| 86 |
} |