diff options
author | Sergio Ahumada <sergio.ahumada@digia.com> | 2013-03-20 09:13:42 +0100 |
---|---|---|
committer | Sergio Ahumada <sergio.ahumada@digia.com> | 2013-03-20 09:14:33 +0100 |
commit | d815621963cee5571ed93fb89561c4884a685b6b (patch) | |
tree | 4c60b5f69eff56fd324e4203d006e1df677670ce /tests | |
parent | 9b25a6f39ee59fe1bb4352a5f2e4ef4a91f1f2c3 (diff) | |
parent | 471645f6dba6a21b85cb6788f0a0a07b6d5a804a (diff) |
Merge branch 'dev' into stable
This starts Qt 5.1 release cycle
Change-Id: I6178a580b4c99aded1a69032a02169cff502b71d
Diffstat (limited to 'tests')
149 files changed, 3319 insertions, 1235 deletions
diff --git a/tests/auto/headersclean/headersclean.pro b/tests/auto/headersclean/headersclean.pro index 4457fe1c38..2698d67124 100644 --- a/tests/auto/headersclean/headersclean.pro +++ b/tests/auto/headersclean/headersclean.pro @@ -1,2 +1,2 @@ -QT = qml quick qmltest qmldevtools +QT = qml quick qmltest load(qt_headersclean) diff --git a/tests/auto/qml/debugger/qv8profilerservice/qv8profilerservice.pro b/tests/auto/qml/debugger/qv8profilerservice/qv8profilerservice.pro index e4d588dc9a..dc6f4c5038 100644 --- a/tests/auto/qml/debugger/qv8profilerservice/qv8profilerservice.pro +++ b/tests/auto/qml/debugger/qv8profilerservice/qv8profilerservice.pro @@ -13,5 +13,4 @@ TESTDATA = data/* QT += qml testlib gui-private DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 - -mac:CONFIG+=insignificant_test #QTBUG-29975 +CONFIG+=insignificant_test diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-1.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-1.js index a4bf1c7de6..87cba8cd2f 100644 --- a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-1.js +++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-1.js @@ -252,44 +252,6 @@ for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_ST HEX_VALUE -= Math.pow(16,POWER)*15; } -// let us do some octal tests. numbers that start with 0 and do not provid a radix should -// default to using "0" as a radix. - -var OCT_STRING = "0"; -var OCT_VALUE = 0; - -for ( OCT_STRING = "0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { - new TestCase( SECTION, "parseInt("+OCT_STRING+")", OCT_VALUE, parseInt(OCT_STRING) ); - OCT_VALUE += Math.pow(8,POWER)*7; -} - -for ( OCT_STRING = "-0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { - new TestCase( SECTION, "parseInt("+OCT_STRING+")", OCT_VALUE, parseInt(OCT_STRING) ); - OCT_VALUE -= Math.pow(8,POWER)*7; -} - -// should get the same results as above if we provid the radix of 8 (or 010) - -for ( OCT_STRING = "0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { - new TestCase( SECTION, "parseInt("+OCT_STRING+",8)", OCT_VALUE, parseInt(OCT_STRING,8) ); - OCT_VALUE += Math.pow(8,POWER)*7; -} -for ( OCT_STRING = "-0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { - new TestCase( SECTION, "parseInt("+OCT_STRING+",010)", OCT_VALUE, parseInt(OCT_STRING,010) ); - OCT_VALUE -= Math.pow(8,POWER)*7; -} - -// we shall stop parsing digits when we get one that isn't a numeric literal of the type we think -// it should be. -for ( OCT_STRING = "0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { - new TestCase( SECTION, "parseInt("+OCT_STRING+"8,8)", OCT_VALUE, parseInt(OCT_STRING+"8",8) ); - OCT_VALUE += Math.pow(8,POWER)*7; -} -for ( OCT_STRING = "-0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { - new TestCase( SECTION, "parseInt("+OCT_STRING+"8,010)", OCT_VALUE, parseInt(OCT_STRING+"8",010) ); - OCT_VALUE -= Math.pow(8,POWER)*7; -} - new TestCase( SECTION, "parseInt( '0x' )", NaN, diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-1.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-1.js index 56bf83adcc..a89154e597 100644 --- a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-1.js +++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-1.js @@ -384,43 +384,12 @@ new TestCase( SECTION, "parseFloat(0XE)", 14, parseFloat(0XE)); new TestCase( SECTION, "parseFloat(0XF)", 15, parseFloat(0XF)); -// A StringNumericLiteral may not use octal notation - -new TestCase( SECTION, "parseFloat('00')", 0, parseFloat("00")); -new TestCase( SECTION, "parseFloat('01')", 1, parseFloat("01")); -new TestCase( SECTION, "parseFloat('02')", 2, parseFloat("02")); -new TestCase( SECTION, "parseFloat('03')", 3, parseFloat("03")); -new TestCase( SECTION, "parseFloat('04')", 4, parseFloat("04")); -new TestCase( SECTION, "parseFloat('05')", 5, parseFloat("05")); -new TestCase( SECTION, "parseFloat('06')", 6, parseFloat("06")); -new TestCase( SECTION, "parseFloat('07')", 7, parseFloat("07")); -new TestCase( SECTION, "parseFloat('010')", 10, parseFloat("010")); -new TestCase( SECTION, "parseFloat('011')", 11, parseFloat("011")); - // A StringNumericLIteral may have any number of leading 0 digits new TestCase( SECTION, "parseFloat('001')", 1, parseFloat("001")); new TestCase( SECTION, "parseFloat('0001')", 1, parseFloat("0001")); new TestCase( SECTION, "parseFloat(' 0001 ')", 1, parseFloat(" 0001 ")); -// an octal numeric literal should be treated as an octal - -new TestCase( SECTION, "parseFloat(00)", 0, parseFloat(00)); -new TestCase( SECTION, "parseFloat(01)", 1, parseFloat(01)); -new TestCase( SECTION, "parseFloat(02)", 2, parseFloat(02)); -new TestCase( SECTION, "parseFloat(03)", 3, parseFloat(03)); -new TestCase( SECTION, "parseFloat(04)", 4, parseFloat(04)); -new TestCase( SECTION, "parseFloat(05)", 5, parseFloat(05)); -new TestCase( SECTION, "parseFloat(06)", 6, parseFloat(06)); -new TestCase( SECTION, "parseFloat(07)", 7, parseFloat(07)); -new TestCase( SECTION, "parseFloat(010)", 8, parseFloat(010)); -new TestCase( SECTION, "parseFloat(011)", 9, parseFloat(011)); - -// A StringNumericLIteral may have any number of leading 0 digits - -new TestCase( SECTION, "parseFloat(001)", 1, parseFloat(001)); -new TestCase( SECTION, "parseFloat(0001)", 1, parseFloat(0001)); - // make sure it's reflexive new TestCase( SECTION, "parseFloat(Math.PI)", Math.PI, parseFloat(Math.PI)); new TestCase( SECTION, "parseFloat(Math.LN2)", Math.LN2, parseFloat(Math.LN2)); diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-2.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-2.js index 557b93f637..1167b73ee1 100644 --- a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-2.js +++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-2.js @@ -256,28 +256,6 @@ new TestCase( SECTION, "parseFloat(' 0XD')", 0, parseFl new TestCase( SECTION, "parseFloat(' 0XE')", 0, parseFloat(" 0XE")); new TestCase( SECTION, "parseFloat(' 0XF')", 0, parseFloat(" 0XF")); -// A StringNumericLiteral may not use octal notation - -new TestCase( SECTION, "parseFloat(' 00')", 0, parseFloat(" 00")); -new TestCase( SECTION, "parseFloat(' 01')", 1, parseFloat(" 01")); -new TestCase( SECTION, "parseFloat(' 02')", 2, parseFloat(" 02")); -new TestCase( SECTION, "parseFloat(' 03')", 3, parseFloat(" 03")); -new TestCase( SECTION, "parseFloat(' 04')", 4, parseFloat(" 04")); -new TestCase( SECTION, "parseFloat(' 05')", 5, parseFloat(" 05")); -new TestCase( SECTION, "parseFloat(' 06')", 6, parseFloat(" 06")); -new TestCase( SECTION, "parseFloat(' 07')", 7, parseFloat(" 07")); -new TestCase( SECTION, "parseFloat(' 010')", 10, parseFloat(" 010")); -new TestCase( SECTION, "parseFloat(' 011')", 11, parseFloat(" 011")); - -// A StringNumericLIteral may have any number of leading 0 digits - -new TestCase( SECTION, "parseFloat(' 001')", 1, parseFloat(" 001")); -new TestCase( SECTION, "parseFloat(' 0001')", 1, parseFloat(" 0001")); - -// A StringNumericLIteral may have any number of leading 0 digits - -new TestCase( SECTION, "parseFloat(001)", 1, parseFloat(001)); -new TestCase( SECTION, "parseFloat(0001)", 1, parseFloat(0001)); // make sure it' s reflexive new TestCase( SECTION, "parseFloat( ' ' +Math.PI+' ')", Math.PI, parseFloat( ' ' +Math.PI+' ')); diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.6.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.6.js index faeeb9e0b0..18f1986d7e 100644 --- a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.6.js +++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.6.js @@ -106,9 +106,6 @@ new TestCase( SECTION, "isNaN( '0xaa' )", false, isNaN( "0xaa" ) new TestCase( SECTION, "isNaN( '0x0A' )", false, isNaN( "0x0A" ) ); new TestCase( SECTION, "isNaN( '0xAA' )", false, isNaN( "0xAA" ) ); -new TestCase( SECTION, "isNaN( 077 )", false, isNaN( 077 ) ); -new TestCase( SECTION, "isNaN( '077' )", false, isNaN( "077" ) ); - new TestCase( SECTION, "isNaN( Number.NaN )", true, isNaN(Number.NaN) ); new TestCase( SECTION, "isNaN( Number.POSITIVE_INFINITY )", false, isNaN(Number.POSITIVE_INFINITY) ); diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.7.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.7.js index e3db5e7931..9eb52a8ff1 100644 --- a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.7.js +++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.7.js @@ -107,9 +107,6 @@ new TestCase( SECTION, "isFinite( '0xaa' )", true, isFinite( "0 new TestCase( SECTION, "isFinite( '0x0A' )", true, isFinite( "0x0A" ) ); new TestCase( SECTION, "isFinite( '0xAA' )", true, isFinite( "0xAA" ) ); -new TestCase( SECTION, "isFinite( 077 )", true, isFinite( 077 ) ); -new TestCase( SECTION, "isFinite( '077' )", true, isFinite( "077" ) ); - new TestCase( SECTION, "isFinite( new String('Infinity') )", false, isFinite(new String("Infinity")) ); new TestCase( SECTION, "isFinite( new String('-Infinity') )", false, isFinite(new String("-Infinity")) ); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-1.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-1.js index fb13b24e07..3eacb2990f 100644 --- a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-1.js +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-1.js @@ -85,16 +85,6 @@ new TestCase( SECTION, 0x100000000 ); new TestCase( SECTION, - "077777777777777777", - 2251799813685247, - 077777777777777777 ); - -new TestCase( SECTION, - "077777777777777776", - 2251799813685246, - 077777777777777776 ); - -new TestCase( SECTION, "0x1fffffffffffff", 9007199254740991, 0x1fffffffffffff ); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-2.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-2.js index 8fbe16cb8f..6121cd54fd 100644 --- a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-2.js +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-2.js @@ -74,20 +74,4 @@ new TestCase( SECTION, 9, 9 ); -new TestCase( SECTION, - "09", - 9, - 09 ); - -new TestCase( SECTION, - "099", - 99, - 099 ); - - -new TestCase( SECTION, - "077", - 63, - 077 ); - test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3.js index 9ccb912752..29635596e1 100644 --- a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3.js +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3.js @@ -215,24 +215,6 @@ new TestCase( SECTION, "0XE", 14, 0XE ); new TestCase( SECTION, "0XF", 15, 0XF ); -new TestCase( SECTION, "00", 0, 00 ); -new TestCase( SECTION, "01", 1, 01 ); -new TestCase( SECTION, "02", 2, 02 ); -new TestCase( SECTION, "03", 3, 03 ); -new TestCase( SECTION, "04", 4, 04 ); -new TestCase( SECTION, "05", 5, 05 ); -new TestCase( SECTION, "06", 6, 06 ); -new TestCase( SECTION, "07", 7, 07 ); - -new TestCase( SECTION, "000", 0, 000 ); -new TestCase( SECTION, "011", 9, 011 ); -new TestCase( SECTION, "022", 18, 022 ); -new TestCase( SECTION, "033", 27, 033 ); -new TestCase( SECTION, "044", 36, 044 ); -new TestCase( SECTION, "055", 45, 055 ); -new TestCase( SECTION, "066", 54, 066 ); -new TestCase( SECTION, "077", 63, 077 ); - new TestCase( SECTION, "0.00000000001", 0.00000000001, 0.00000000001 ); new TestCase( SECTION, "0.00000000001e-2", 0.0000000000001, 0.00000000001e-2 ); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.4.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.4.js index 015a385220..4b799f8df1 100644 --- a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.4.js +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.4.js @@ -76,53 +76,6 @@ new TestCase( SECTION, "\\v", String.fromCharCode(0x000B), "\v" ); // DoubleStringCharacters:DoubleStringCharacter::EscapeSequence::OctalEscapeSequence -new TestCase( SECTION, "\\00", String.fromCharCode(0x0000), "\00" ); -new TestCase( SECTION, "\\01", String.fromCharCode(0x0001), "\01" ); -new TestCase( SECTION, "\\02", String.fromCharCode(0x0002), "\02" ); -new TestCase( SECTION, "\\03", String.fromCharCode(0x0003), "\03" ); -new TestCase( SECTION, "\\04", String.fromCharCode(0x0004), "\04" ); -new TestCase( SECTION, "\\05", String.fromCharCode(0x0005), "\05" ); -new TestCase( SECTION, "\\06", String.fromCharCode(0x0006), "\06" ); -new TestCase( SECTION, "\\07", String.fromCharCode(0x0007), "\07" ); - -new TestCase( SECTION, "\\010", String.fromCharCode(0x0008), "\010" ); -new TestCase( SECTION, "\\011", String.fromCharCode(0x0009), "\011" ); -new TestCase( SECTION, "\\012", String.fromCharCode(0x000A), "\012" ); -new TestCase( SECTION, "\\013", String.fromCharCode(0x000B), "\013" ); -new TestCase( SECTION, "\\014", String.fromCharCode(0x000C), "\014" ); -new TestCase( SECTION, "\\015", String.fromCharCode(0x000D), "\015" ); -new TestCase( SECTION, "\\016", String.fromCharCode(0x000E), "\016" ); -new TestCase( SECTION, "\\017", String.fromCharCode(0x000F), "\017" ); -new TestCase( SECTION, "\\020", String.fromCharCode(0x0010), "\020" ); -new TestCase( SECTION, "\\042", String.fromCharCode(0x0022), "\042" ); - -new TestCase( SECTION, "\\0", String.fromCharCode(0x0000), "\0" ); -new TestCase( SECTION, "\\1", String.fromCharCode(0x0001), "\1" ); -new TestCase( SECTION, "\\2", String.fromCharCode(0x0002), "\2" ); -new TestCase( SECTION, "\\3", String.fromCharCode(0x0003), "\3" ); -new TestCase( SECTION, "\\4", String.fromCharCode(0x0004), "\4" ); -new TestCase( SECTION, "\\5", String.fromCharCode(0x0005), "\5" ); -new TestCase( SECTION, "\\6", String.fromCharCode(0x0006), "\6" ); -new TestCase( SECTION, "\\7", String.fromCharCode(0x0007), "\7" ); - -new TestCase( SECTION, "\\10", String.fromCharCode(0x0008), "\10" ); -new TestCase( SECTION, "\\11", String.fromCharCode(0x0009), "\11" ); -new TestCase( SECTION, "\\12", String.fromCharCode(0x000A), "\12" ); -new TestCase( SECTION, "\\13", String.fromCharCode(0x000B), "\13" ); -new TestCase( SECTION, "\\14", String.fromCharCode(0x000C), "\14" ); -new TestCase( SECTION, "\\15", String.fromCharCode(0x000D), "\15" ); -new TestCase( SECTION, "\\16", String.fromCharCode(0x000E), "\16" ); -new TestCase( SECTION, "\\17", String.fromCharCode(0x000F), "\17" ); -new TestCase( SECTION, "\\20", String.fromCharCode(0x0010), "\20" ); -new TestCase( SECTION, "\\42", String.fromCharCode(0x0022), "\42" ); - -new TestCase( SECTION, "\\000", String.fromCharCode(0), "\000" ); -new TestCase( SECTION, "\\111", String.fromCharCode(73), "\111" ); -new TestCase( SECTION, "\\222", String.fromCharCode(146), "\222" ); -new TestCase( SECTION, "\\333", String.fromCharCode(219), "\333" ); - -// following line commented out as it causes a compile time error -// new TestCase( SECTION, "\\444", "444", "\444" ); // DoubleStringCharacters:DoubleStringCharacter::EscapeSequence::HexEscapeSequence /* @@ -182,9 +135,10 @@ new TestCase( SECTION, "\\x1E1", String.fromCharCode(30)+"1", "\x1E new TestCase( SECTION, "\\x0F0", String.fromCharCode(15)+"0", "\x0F0" ); // G is out of hex range - +/* Invalid testcase: we no longer silently ignore invalid hexadecimal escape sequences. new TestCase( SECTION, "\\xG", "xG", "\xG" ); new TestCase( SECTION, "\\xCG", "xCG", "\xCG" ); +*/ // DoubleStringCharacter::EscapeSequence::CharacterEscapeSequence::\ NonEscapeCharacter new TestCase( SECTION, "\\a", "a", "\a" ); @@ -202,13 +156,10 @@ new TestCase( SECTION, "\\o", "o", "\o" ); new TestCase( SECTION, "\\p", "p", "\p" ); new TestCase( SECTION, "\\q", "q", "\q" ); new TestCase( SECTION, "\\s", "s", "\s" ); -new TestCase( SECTION, "\\u", "u", "\u" ); new TestCase( SECTION, "\\w", "w", "\w" ); -new TestCase( SECTION, "\\x", "x", "\x" ); new TestCase( SECTION, "\\y", "y", "\y" ); new TestCase( SECTION, "\\z", "z", "\z" ); -new TestCase( SECTION, "\\9", "9", "\9" ); new TestCase( SECTION, "\\A", "A", "\A" ); new TestCase( SECTION, "\\B", "B", "\B" ); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.1.js index 0412742767..abe1095d40 100644 --- a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.1.js +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.1.js @@ -194,11 +194,6 @@ new TestCase( SECTION, Math.abs( -0xfff ) ); new TestCase( SECTION, - "Math.abs( -0777 )", - 511, - Math.abs(-0777 ) ); - -new TestCase( SECTION, "Math.abs('-1e-1')", 0.1, Math.abs('-1e-1') ); diff --git a/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-3.js index dc56427395..3141906d5d 100644 --- a/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-3.js +++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-3.js @@ -296,16 +296,6 @@ new TestCase( SECTION, 0x100000000 ); new TestCase( SECTION, - "077777777777777777", - 2251799813685247, - 077777777777777777 ); - -new TestCase( SECTION, - "077777777777777776", - 2251799813685246, - 077777777777777776 ); - -new TestCase( SECTION, "0x1fffffffffffff", 9007199254740991, 0x1fffffffffffff ); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/RegExp/hex-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/hex-001.js index 3e85ac7abf..f2dccd9267 100644 --- a/tests/auto/qml/parserstress/tests/ecma_2/RegExp/hex-001.js +++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/hex-001.js @@ -55,7 +55,10 @@ startTest(); AddRegExpCases( new RegExp("\x41"), "new RegExp('\\x41')", "A", "A", 1, 0, ["A"] ); AddRegExpCases( new RegExp("\x412"),"new RegExp('\\x412')", "A2", "A2", 1, 0, ["A2"] ); + +/* Invalid testcase: we no longer silently ignore invalid hexadecimal escape sequences. AddRegExpCases( new RegExp("\x1g"), "new RegExp('\\x1g')", "x1g","x1g", 1, 0, ["x1g"] ); +*/ AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x41", "\\x41", 1, 0, ["A"] ); AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x412", "\\x412", 1, 0, ["A"] ); diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-002.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-002.js index 401ad43c11..053720d7e9 100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-002.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-002.js @@ -125,70 +125,6 @@ expectedmatch = Array(string); addThis(); -/* - * This one should produce a match. The two-character string - * 'a' + '\011' is duplicated in the pattern and test string: - */ -status = inSection(4); -pattern = /.\011/; -string = 'a\011'; -actualmatch = string.match(pattern); -expectedmatch = Array(string); -addThis(); - - -/* - * Same as above, only now, for the second character of the string, - * use the Unicode escape '\u0009' instead of the octal escape '\011' - */ -status = inSection(5); -pattern = /.\011/; -string = 'a\u0009'; -actualmatch = string.match(pattern); -expectedmatch = Array(string); -addThis(); - - -/* - * Same as above, only now for the second character of the string, - * use the hex escape '\x09' instead of the octal escape '\011' - */ -status = inSection(6); -pattern = /.\011/; -string = 'a\x09'; -actualmatch = string.match(pattern); -expectedmatch = Array(string); -addThis(); - - -/* - * Same as above, only now for the second character of the string, - * use the escape '\t' instead of the octal escape '\011' - */ -status = inSection(7); -pattern = /.\011/; -string = 'a\t'; -actualmatch = string.match(pattern); -expectedmatch = Array(string); -addThis(); - - -/* - * Return to the string from Section 1. - * - * Unlike Section 1, use the RegExp() function to create the - * regexp pattern: null character followed by the string '11'. - * - * Since this is exactly what the string is, we should get a match - - */ -status = inSection(8); -string = 'a' + String.fromCharCode(0) + '11'; -pattern = RegExp(string); -actualmatch = string.match(pattern); -expectedmatch = Array(string); -addThis(); - - //------------------------------------------------------------------------------------------------- diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-85721.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-85721.js index bca1a15e19..7b811abc31 100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-85721.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-85721.js @@ -111,11 +111,11 @@ testRegExp([status], [re], [str], [result], [expect]); //# Some things for avoiding backslashitis later on. $esc = '\\\\'; $Period = '\.'; -$space = '\040'; $tab = '\t'; +$space = '\x20'; $tab = '\t'; $OpenBR = '\\['; $CloseBR = '\\]'; $OpenParen = '\\('; $CloseParen = '\\)'; -$NonASCII = '\x80-\xff'; $ctrl = '\000-\037'; -$CRlist = '\n\015'; //# note: this should really be only \015. +$NonASCII = '\x80-\xff'; $ctrl = '\0-\x1f'; +$CRlist = '\n\x0d'; //# note: this should really be only \015. // Items 19, 20, 21 $qtext = '[^' + $esc + $NonASCII + $CRlist + '\"]'; // # for within "..." $dtext = '[^' + $esc + $NonASCII + $CRlist + $OpenBR + $CloseBR + ']'; // # for within [...] @@ -226,7 +226,7 @@ $route_addr = '>'; // # > //# Item 3: phrase........ -$phrase_ctrl = '\000-\010\012-\037'; // # like ctrl, but without tab +$phrase_ctrl = '\0-\x08\x0a-\x1f'; // # like ctrl, but without tab //# Like atom-char, but without listing space, and uses phrase_ctrl. //# Since the class is negated, this matches the same as atom-char plus space and tab diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-441477-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-441477-01.js index 1be199743d..27ddfab51d 100755 --- a/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-441477-01.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-441477-01.js @@ -37,7 +37,7 @@ var gTestfile = 'regress-441477-01.js'; //----------------------------------------------------------------------------- -var BUGNUMBER = 441477-01; +var BUGNUMBER = 441477.01; var summary = ''; var actual = 'No Exception'; var expect = 'No Exception'; diff --git a/tests/auto/qml/parserstress/tests/ecma_3/String/regress-392378.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-392378.js index 368fde1278..59564b272e 100755 --- a/tests/auto/qml/parserstress/tests/ecma_3/String/regress-392378.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-392378.js @@ -55,7 +55,7 @@ function test() expect = ["", undefined, ""] + ''; actual = "y".split(/(x)?\1y/) + ''; - reportCompare(expect, actual, summary + ': "y".split(/(x)?\1y/)'); + reportCompare(expect, actual, summary + ': "y".split(/(x)?\\1y/)'); expect = ["", undefined, ""] + ''; actual = "y".split(/(x)?y/) + ''; diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js deleted file mode 100755 index 0e3c4b0189..0000000000 --- a/tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Martin Honnen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'regress-352044-02-n.js'; -//----------------------------------------------------------------------------- -var BUGNUMBER = 352044; -var summary = 'issues with Unicode escape sequences in JavaScript source code'; -var actual = 'No Error'; -var expect = 'SyntaxError'; - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - print('This test case is expected to throw an uncaught SyntaxError'); - - try - { - var i = 1; - i \u002b= 1; - print(i); - } - catch(ex) - { - actual = ex + ''; - } - - reportCompare(expect, actual, summary); - - exitFunc ('test'); -} diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 55c3fc800a..70b718c4d8 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -2226,15 +2226,10 @@ void tst_QJSEngine::jsContinueInSwitch() void tst_QJSEngine::jsShadowReadOnlyPrototypeProperty() { - // SpiderMonkey has different behavior than JSC and V8; it disallows - // creating a property on the instance if there's a property with the - // same name in the prototype, and that property is read-only. We - // adopted that behavior in the old (4.5) QtScript back-end, but it - // just seems weird -- and non-compliant. Adopt the JSC behavior instead. QJSEngine eng; QVERIFY(eng.evaluate("o = {}; o.__proto__ = parseInt; o.length").isNumber()); - QCOMPARE(eng.evaluate("o.length = 123; o.length").toInt(), 123); - QVERIFY(eng.evaluate("o.hasOwnProperty('length')").toBool()); + QVERIFY(eng.evaluate("o.length = 123; o.length").toInt() != 123); + QVERIFY(!eng.evaluate("o.hasOwnProperty('length')").toBool()); } void tst_QJSEngine::jsReservedWords_data() diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro index b77effe3e5..584533c65b 100644 --- a/tests/auto/qml/qml.pro +++ b/tests/auto/qml/qml.pro @@ -23,8 +23,9 @@ PUBLICTESTS += \ qqmlqt \ qqmltranslation \ qqmlxmlhttprequest \ - qqmlparser \ - qquickfolderlistmodel + qtqmlmodules \ + qquickfolderlistmodel \ + qqmlapplicationengine PRIVATETESTS += \ animation \ @@ -42,11 +43,12 @@ PRIVATETESTS += \ qqmlvaluetypes \ qqmlvaluetypeproviders \ qqmlbinding \ - qquickchangeset \ + qqmlchangeset \ qqmlconnections \ - qquicklistcompositor \ - qquicklistmodel \ - qquicklistmodelworkerscript \ + qqmllistcompositor \ + qqmllistmodel \ + qqmllistmodelworkerscript \ + qqmlparser \ qquickworkerscript \ qqmlbundle \ qrcqml \ diff --git a/tests/auto/qml/qmlmin/tst_qmlmin.cpp b/tests/auto/qml/qmlmin/tst_qmlmin.cpp index a2ac6949ee..65549efddc 100644 --- a/tests/auto/qml/qmlmin/tst_qmlmin.cpp +++ b/tests/auto/qml/qmlmin/tst_qmlmin.cpp @@ -112,6 +112,7 @@ void tst_qmlmin::initTestCase() invalidFiles << "tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.js"; invalidFiles << "tests/auto/qml/qquickworkerscript/data/script_error_onLoad.js"; invalidFiles << "tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js"; + invalidFiles << "tests/auto/qml/qqmlecmascript/data/incrDecrSemicolon_error1.qml"; invalidFiles << "tests/auto/qml/qqmlecmascript/data/jsimportfail/malformedFileQualifier.js"; invalidFiles << "tests/auto/qml/qqmlecmascript/data/jsimportfail/malformedImport.js"; invalidFiles << "tests/auto/qml/qqmlecmascript/data/jsimportfail/malformedModule.js"; @@ -120,6 +121,14 @@ void tst_qmlmin::initTestCase() invalidFiles << "tests/auto/qml/qqmlecmascript/data/jsimportfail/missingFileQualifier.js"; invalidFiles << "tests/auto/qml/qqmlecmascript/data/jsimportfail/missingModuleQualifier.js"; invalidFiles << "tests/auto/qml/qqmlecmascript/data/jsimportfail/missingModuleVersion.js"; + invalidFiles << "tests/auto/qml/qqmlecmascript/data/stringParsing_error.1.qml"; + invalidFiles << "tests/auto/qml/qqmlecmascript/data/stringParsing_error.2.qml"; + invalidFiles << "tests/auto/qml/qqmlecmascript/data/stringParsing_error.3.qml"; + invalidFiles << "tests/auto/qml/qqmlecmascript/data/stringParsing_error.4.qml"; + invalidFiles << "tests/auto/qml/qqmlecmascript/data/stringParsing_error.5.qml"; + invalidFiles << "tests/auto/qml/qqmlecmascript/data/stringParsing_error.6.qml"; + invalidFiles << "tests/auto/qml/qqmlecmascript/data/numberParsing_error.1.qml"; + invalidFiles << "tests/auto/qml/qqmlecmascript/data/numberParsing_error.2.qml"; } QStringList tst_qmlmin::findFiles(const QDir &d) diff --git a/tests/auto/qml/qqmlapplicationengine/data/TestItem.qml b/tests/auto/qml/qqmlapplicationengine/data/TestItem.qml new file mode 100644 index 0000000000..e879577e10 --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/data/TestItem.qml @@ -0,0 +1,4 @@ +import QtQml 2.0 + +QtObject { +} diff --git a/tests/auto/qml/qqmlapplicationengine/data/applicationTest.qml b/tests/auto/qml/qqmlapplicationengine/data/applicationTest.qml new file mode 100644 index 0000000000..2a1b4fbf57 --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/data/applicationTest.qml @@ -0,0 +1,14 @@ +import QtQml 2.0 + +QtObject { + property string originalName + property string originalVersion + property string currentName: Qt.application.name + property string currentVersion: Qt.application.version + Component.onCompleted: { + originalName = Qt.application.name + originalVersion = Qt.application.version + Qt.application.name = "Test B" + Qt.application.version = "0.0B" + } +} diff --git a/tests/auto/qml/qqmlapplicationengine/data/basicTest.qml b/tests/auto/qml/qqmlapplicationengine/data/basicTest.qml new file mode 100644 index 0000000000..837835f6df --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/data/basicTest.qml @@ -0,0 +1,5 @@ +import QtQml 2.0 + +QtObject { + property bool success: true +} diff --git a/tests/auto/qml/qqmlapplicationengine/qqmlapplicationengine.pro b/tests/auto/qml/qqmlapplicationengine/qqmlapplicationengine.pro new file mode 100644 index 0000000000..4a2dde7c47 --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/qqmlapplicationengine.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS = tst_qqmlapplicationengine.pro \ + testapp diff --git a/tests/auto/qml/qqmlapplicationengine/testapp/main.cpp b/tests/auto/qml/qqmlapplicationengine/testapp/main.cpp new file mode 100644 index 0000000000..fe64bb35ad --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/testapp/main.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QCoreApplication> +#include <QQmlApplicationEngine> + +int main (int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + QQmlApplicationEngine e(QUrl("qrc:///main.qml")); + return app.exec(); +} diff --git a/tests/auto/qml/qqmlapplicationengine/testapp/main.qml b/tests/auto/qml/qqmlapplicationengine/testapp/main.qml new file mode 100644 index 0000000000..c75485a7f7 --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/testapp/main.qml @@ -0,0 +1,11 @@ +import QtQml 2.0 + +QtObject { + id: root + property Timer t: Timer { interval: 1; running: true; onTriggered: Qt.quit(); } + property Connections c: Connections { + target: Qt.application + onAboutToQuit: console.log("End"); + } + Component.onCompleted: console.log("Start: " + Qt.application.arguments[1]); +} diff --git a/tests/auto/qml/qqmlapplicationengine/testapp/main.qrc b/tests/auto/qml/qqmlapplicationengine/testapp/main.qrc new file mode 100644 index 0000000000..5f6483ac33 --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/testapp/main.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + </qresource> +</RCC> diff --git a/tests/auto/qml/qqmlapplicationengine/testapp/testapp.pro b/tests/auto/qml/qqmlapplicationengine/testapp/testapp.pro new file mode 100644 index 0000000000..34d2718178 --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/testapp/testapp.pro @@ -0,0 +1,11 @@ +TEMPLATE = app +TARGET = testapp +DESTDIR = ./ +CONFIG -= app_bundle +CONFIG += console + +QT += qml + +# Input +SOURCES += main.cpp +RESOURCES += main.qrc diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp new file mode 100644 index 0000000000..1c11fcbc73 --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp @@ -0,0 +1,162 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "../../shared/util.h" +#include <QQmlApplicationEngine> +#include <QSignalSpy> +#include <QProcess> +#include <QDebug> + +class tst_qqmlapplicationengine : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qqmlapplicationengine() {} + + +private slots: + void initTestCase(); + void basicLoading(); + void application(); + void applicationProperties(); +private: + QString buildDir; + QString srcDir; +}; + +void tst_qqmlapplicationengine::initTestCase() +{ + buildDir = QDir::currentPath(); + QQmlDataTest::initTestCase(); //Changes current path to src dir + srcDir = QDir::currentPath(); +} + +void tst_qqmlapplicationengine::basicLoading() +{ + int size = 0; + + QQmlApplicationEngine *test = new QQmlApplicationEngine(testFileUrl("basicTest.qml")); + QCOMPARE(test->rootObjects().size(), ++size); + QVERIFY(test->rootObjects()[size -1]); + QVERIFY(test->rootObjects()[size -1]->property("success").toBool()); + + QSignalSpy objectCreated(test, SIGNAL(objectCreated(QObject*,const QUrl&))); + test->load(testFileUrl("basicTest.qml")); + QCOMPARE(objectCreated.count(), size);//one less than rootObjects().size() because we missed the first one + QCOMPARE(test->rootObjects().size(), ++size); + QVERIFY(test->rootObjects()[size -1]); + QVERIFY(test->rootObjects()[size -1]->property("success").toBool()); + + QByteArray testQml("import QtQml 2.0; QtObject{property bool success: true; property TestItem t: TestItem{}}"); + test->loadData(testQml, testFileUrl("dynamicTest.qml")); + QCOMPARE(objectCreated.count(), size); + QCOMPARE(test->rootObjects().size(), ++size); + QVERIFY(test->rootObjects()[size -1]); + QVERIFY(test->rootObjects()[size -1]->property("success").toBool()); + + delete test; +} + +void tst_qqmlapplicationengine::application() +{ + /* This test batches together some tests about running an external application + written with QQmlApplicationEngine. The application tests the following functionality + which is easier to do by watching a separate process: + -Loads relative paths from the working directory + -quits when quit is called + -emits aboutToQuit after quit is called + -has access to application command line arguments + + Note that checking the output means that on builds with extra debugging, this might fail with a false positive. + Also the testapp is automatically built and installed in shadow builds, so it does NOT use testData + */ + QDir::setCurrent(buildDir); + QProcess *testProcess = new QProcess(this); + QTest::ignoreMessage(QtWarningMsg, "Don't know how to handle 'QProcess::ExitStatus', use qRegisterMetaType to register it."); + QSignalSpy processFinished(testProcess, SIGNAL(finished(int,QProcess::ExitStatus))); + QStringList args; + args << QLatin1String("testData"); + testProcess->start(QLatin1String("testapp/testapp"), args); + QTRY_VERIFY(processFinished.count());//Application should immediately exit + QCOMPARE(processFinished[0][0].toInt(), 0); + QByteArray test_stdout = testProcess->readAllStandardOutput(); + QByteArray test_stderr = testProcess->readAllStandardError(); + QByteArray test_stderr_target("Start: testData\nEnd\n"); +#ifdef Q_OS_WIN + test_stderr_target.replace('\n', QByteArray("\r\n")); +#endif + QCOMPARE(test_stdout, QByteArray("")); + QCOMPARE(test_stderr, test_stderr_target); + delete testProcess; + QDir::setCurrent(srcDir); +} + +void tst_qqmlapplicationengine::applicationProperties() +{ + QCoreApplication* coreApp = QCoreApplication::instance(); + QString originalName = coreApp->applicationName(); + QString originalVersion = coreApp->applicationVersion(); + QString firstName = QLatin1String("Test A"); + QString firstVersion = QLatin1String("0.0A"); + QString secondName = QLatin1String("Test B"); + QString secondVersion = QLatin1String("0.0B"); + + coreApp->setApplicationName(firstName); + coreApp->setApplicationVersion(firstVersion); + + QQmlApplicationEngine *test = new QQmlApplicationEngine(testFileUrl("applicationTest.qml")); + QObject* root = test->rootObjects().at(0); + QVERIFY(root); + QCOMPARE(root->property("originalName").toString(), firstName); + QCOMPARE(root->property("originalVersion").toString(), firstVersion); + QCOMPARE(root->property("currentName").toString(), secondName); + QCOMPARE(root->property("currentVersion").toString(), secondVersion); + QCOMPARE(coreApp->applicationName(), secondName); + QCOMPARE(coreApp->applicationVersion(), secondVersion); + + coreApp->setApplicationName(originalName); + coreApp->setApplicationVersion(originalVersion); + delete test; +} + +QTEST_MAIN(tst_qqmlapplicationengine) + +#include "tst_qqmlapplicationengine.moc" diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.pro b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.pro new file mode 100644 index 0000000000..18c38a80b6 --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.pro @@ -0,0 +1,10 @@ +CONFIG += testcase +TARGET = tst_qqmlapplicationengine +macx:CONFIG -= app_bundle + + +SOURCES += tst_qqmlapplicationengine.cpp +TESTDATA += data/* + +include (../../shared/util.pri) +QT += core-private gui-private qml-private network testlib diff --git a/tests/auto/qml/qqmlchangeset/qqmlchangeset.pro b/tests/auto/qml/qqmlchangeset/qqmlchangeset.pro new file mode 100644 index 0000000000..b65e58c0b3 --- /dev/null +++ b/tests/auto/qml/qqmlchangeset/qqmlchangeset.pro @@ -0,0 +1,10 @@ +CONFIG += testcase +TARGET = tst_qqmlhangeset +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmlchangeset.cpp + +CONFIG += parallel_test + +QT += core-private gui-private qml-private testlib +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qquickchangeset/tst_qquickchangeset.cpp b/tests/auto/qml/qqmlchangeset/tst_qqmlchangeset.cpp index 77286b04b4..0f09de26d3 100644 --- a/tests/auto/qml/qquickchangeset/tst_qquickchangeset.cpp +++ b/tests/auto/qml/qqmlchangeset/tst_qqmlchangeset.cpp @@ -39,9 +39,9 @@ ** ****************************************************************************/ #include <qtest.h> -#include <private/qquickchangeset_p.h> +#include <private/qqmlchangeset_p.h> -class tst_qquickchangeset : public QObject +class tst_qqmlchangeset : public QObject { Q_OBJECT private slots: @@ -140,7 +140,7 @@ public: bool applyChanges(QVector<int> &list, const QVector<Signal> &changes) { - QHash<QQuickChangeSet::MoveKey, int> removedValues; + QHash<QQmlChangeSet::MoveKey, int> removedValues; foreach (const Signal &signal, changes) { if (signal.isInsert()) { if (signal.index < 0 || signal.index > list.count()) { @@ -148,7 +148,7 @@ public: return false; } if (signal.moveId != -1) { - QQuickChangeSet::Insert insert(signal.index, signal.count, signal.moveId, signal.offset); + QQmlChangeSet::Insert insert(signal.index, signal.count, signal.moveId, signal.offset); for (int i = insert.start(); i < insert.end(); ++i) list.insert(i, removedValues.take(insert.moveKey(i))); } else { @@ -160,7 +160,7 @@ public: return false; } if (signal.moveId != -1) { - QQuickChangeSet::Remove remove(signal.index, signal.count, signal.moveId, signal.offset); + QQmlChangeSet::Remove remove(signal.index, signal.count, signal.moveId, signal.offset); for (int i = remove.start(); i < remove.end(); ++i) removedValues.insert(remove.moveKey(i), list.at(i)); } @@ -184,7 +184,7 @@ public: }; -bool operator ==(const tst_qquickchangeset::Signal &left, const tst_qquickchangeset::Signal &right) +bool operator ==(const tst_qqmlchangeset::Signal &left, const tst_qqmlchangeset::Signal &right) { return left.index == right.index && left.count == right.count @@ -194,13 +194,13 @@ bool operator ==(const tst_qquickchangeset::Signal &left, const tst_qquickchange } QT_BEGIN_NAMESPACE -bool operator ==(const QQuickChangeSet::Change &left, const QQuickChangeSet::Change &right) +bool operator ==(const QQmlChangeSet::Change &left, const QQmlChangeSet::Change &right) { return left.index == right.index && left.count == right.count && left.moveId == right.moveId; } QT_END_NAMESPACE -QDebug operator <<(QDebug debug, const tst_qquickchangeset::Signal &signal) +QDebug operator <<(QDebug debug, const tst_qqmlchangeset::Signal &signal) { if (signal.isInsert() && signal.moveId == -1) debug.nospace() << "Insert(" << signal.index << "," << signal.count << ")"; @@ -217,8 +217,8 @@ QDebug operator <<(QDebug debug, const tst_qquickchangeset::Signal &signal) return debug; } -Q_DECLARE_METATYPE(tst_qquickchangeset::SignalList) -Q_DECLARE_METATYPE(tst_qquickchangeset::SignalListList) +Q_DECLARE_METATYPE(tst_qqmlchangeset::SignalList) +Q_DECLARE_METATYPE(tst_qqmlchangeset::SignalListList) #if 0 # define VERIFY_EXPECTED_OUTPUT \ @@ -256,7 +256,7 @@ Q_DECLARE_METATYPE(tst_qquickchangeset::SignalListList) } #endif -void tst_qquickchangeset::sequence_data() +void tst_qqmlchangeset::sequence_data() { QTest::addColumn<SignalList>("input"); QTest::addColumn<SignalList>("output"); @@ -1163,12 +1163,12 @@ void tst_qquickchangeset::sequence_data() << Insert(24,1,5,9) << Insert(25,2) << Insert(27,2)); } -void tst_qquickchangeset::sequence() +void tst_qqmlchangeset::sequence() { QFETCH(SignalList, input); QFETCH(SignalList, output); - QQuickChangeSet set; + QQmlChangeSet set; foreach (const Signal &signal, input) { if (signal.isRemove()) @@ -1182,18 +1182,18 @@ void tst_qquickchangeset::sequence() } SignalList changes; - foreach (const QQuickChangeSet::Remove &remove, set.removes()) + foreach (const QQmlChangeSet::Remove &remove, set.removes()) changes << Remove(remove.index, remove.count, remove.moveId, remove.offset); - foreach (const QQuickChangeSet::Insert &insert, set.inserts()) + foreach (const QQmlChangeSet::Insert &insert, set.inserts()) changes << Insert(insert.index, insert.count, insert.moveId, insert.offset); - foreach (const QQuickChangeSet::Change &change, set.changes()) + foreach (const QQmlChangeSet::Change &change, set.changes()) changes << Change(change.index, change.count); VERIFY_EXPECTED_OUTPUT QCOMPARE(changes, output); } -void tst_qquickchangeset::apply_data() +void tst_qqmlchangeset::apply_data() { QTest::addColumn<SignalListList>("input"); @@ -1297,15 +1297,15 @@ void tst_qquickchangeset::apply_data() << (SignalList() << Move(38,23,1,3) << Move(38,31,0,4) << Remove(26,11) << Move(5,7,18,5) << Move(19,0,8,6))); } -void tst_qquickchangeset::apply() +void tst_qqmlchangeset::apply() { QFETCH(SignalListList, input); - QQuickChangeSet set; - QQuickChangeSet linearSet; + QQmlChangeSet set; + QQmlChangeSet linearSet; foreach (const SignalList &list, input) { - QQuickChangeSet intermediateSet; + QQmlChangeSet intermediateSet; foreach (const Signal &signal, list) { if (signal.isRemove()) { intermediateSet.remove(signal.index, signal.count); @@ -1322,15 +1322,15 @@ void tst_qquickchangeset::apply() } SignalList changes; - foreach (const QQuickChangeSet::Remove &remove, set.removes()) + foreach (const QQmlChangeSet::Remove &remove, set.removes()) changes << Remove(remove.index, remove.count, remove.moveId, remove.offset); - foreach (const QQuickChangeSet::Insert &insert, set.inserts()) + foreach (const QQmlChangeSet::Insert &insert, set.inserts()) changes << Insert(insert.index, insert.count, insert.moveId, insert.offset); SignalList linearChanges; - foreach (const QQuickChangeSet::Remove &remove, linearSet.removes()) + foreach (const QQmlChangeSet::Remove &remove, linearSet.removes()) linearChanges << Remove(remove.index, remove.count, remove.moveId, remove.offset); - foreach (const QQuickChangeSet::Insert &insert, linearSet.inserts()) + foreach (const QQmlChangeSet::Insert &insert, linearSet.inserts()) linearChanges << Insert(insert.index, insert.count, insert.moveId, insert.offset); // The output in the failing tests isn't incorrect, merely sub-optimal. @@ -1343,7 +1343,7 @@ void tst_qquickchangeset::apply() QCOMPARE(changes, linearChanges); } -void tst_qquickchangeset::removeConsecutive_data() +void tst_qqmlchangeset::removeConsecutive_data() { QTest::addColumn<SignalList>("input"); QTest::addColumn<SignalList>("output"); @@ -1359,22 +1359,22 @@ void tst_qquickchangeset::removeConsecutive_data() << (SignalList() << Remove(0,2) << Remove(0,1,0,0) << Remove(0,5)); } -void tst_qquickchangeset::removeConsecutive() +void tst_qqmlchangeset::removeConsecutive() { QFETCH(SignalList, input); QFETCH(SignalList, output); - QVector<QQuickChangeSet::Remove> removes; + QVector<QQmlChangeSet::Remove> removes; foreach (const Signal &signal, input) { QVERIFY(signal.isRemove()); - removes.append(QQuickChangeSet::Remove(signal.index, signal.count, signal.moveId, signal.offset)); + removes.append(QQmlChangeSet::Remove(signal.index, signal.count, signal.moveId, signal.offset)); } - QQuickChangeSet set; + QQmlChangeSet set; set.remove(removes); SignalList changes; - foreach (const QQuickChangeSet::Remove &remove, set.removes()) + foreach (const QQmlChangeSet::Remove &remove, set.removes()) changes << Remove(remove.index, remove.count, remove.moveId, remove.offset); QVERIFY(set.inserts().isEmpty()); QVERIFY(set.changes().isEmpty()); @@ -1383,7 +1383,7 @@ void tst_qquickchangeset::removeConsecutive() QCOMPARE(changes, output); } -void tst_qquickchangeset::insertConsecutive_data() +void tst_qqmlchangeset::insertConsecutive_data() { QTest::addColumn<SignalList>("input"); QTest::addColumn<SignalList>("output"); @@ -1399,22 +1399,22 @@ void tst_qquickchangeset::insertConsecutive_data() << (SignalList() << Insert(0,2) << Insert(2,1,0,0) << Insert(3,5)); } -void tst_qquickchangeset::insertConsecutive() +void tst_qqmlchangeset::insertConsecutive() { QFETCH(SignalList, input); QFETCH(SignalList, output); - QVector<QQuickChangeSet::Insert> inserts; + QVector<QQmlChangeSet::Insert> inserts; foreach (const Signal &signal, input) { QVERIFY(signal.isInsert()); - inserts.append(QQuickChangeSet::Insert(signal.index, signal.count, signal.moveId, signal.offset)); + inserts.append(QQmlChangeSet::Insert(signal.index, signal.count, signal.moveId, signal.offset)); } - QQuickChangeSet set; + QQmlChangeSet set; set.insert(inserts); SignalList changes; - foreach (const QQuickChangeSet::Insert &insert, set.inserts()) + foreach (const QQmlChangeSet::Insert &insert, set.inserts()) changes << Insert(insert.index, insert.count, insert.moveId, insert.offset); QVERIFY(set.removes().isEmpty()); QVERIFY(set.changes().isEmpty()); @@ -1423,9 +1423,9 @@ void tst_qquickchangeset::insertConsecutive() QCOMPARE(changes, output); } -void tst_qquickchangeset::copy() +void tst_qqmlchangeset::copy() { - QQuickChangeSet changeSet; + QQmlChangeSet changeSet; changeSet.remove(0, 12); changeSet.remove(5, 4); changeSet.insert(3, 9); @@ -1433,9 +1433,9 @@ void tst_qquickchangeset::copy() changeSet.change(24, 8); changeSet.move(3, 5, 9, 0); - QQuickChangeSet copy(changeSet); + QQmlChangeSet copy(changeSet); - QQuickChangeSet assign; + QQmlChangeSet assign; assign = changeSet; copy.move(4, 2, 5, 1); @@ -1453,27 +1453,27 @@ void tst_qquickchangeset::copy() QCOMPARE(assign.difference(), changeSet.difference()); } -void tst_qquickchangeset::debug() +void tst_qqmlchangeset::debug() { - QQuickChangeSet changeSet; + QQmlChangeSet changeSet; changeSet.remove(0, 12); changeSet.remove(5, 4); changeSet.insert(3, 9); changeSet.insert(15, 2); changeSet.change(24, 8); - QTest::ignoreMessage(QtDebugMsg, "QQuickChangeSet(Remove(0,12) Remove(5,4) Insert(3,9) Insert(15,2) Change(24,8) )"); + QTest::ignoreMessage(QtDebugMsg, "QQmlChangeSet(Remove(0,12) Remove(5,4) Insert(3,9) Insert(15,2) Change(24,8) )"); qDebug() << changeSet; changeSet.clear(); - QTest::ignoreMessage(QtDebugMsg, "QQuickChangeSet(Remove(12,4,0,0) Insert(5,4,0,0) )"); + QTest::ignoreMessage(QtDebugMsg, "QQmlChangeSet(Remove(12,4,0,0) Insert(5,4,0,0) )"); changeSet.move(12, 5, 4, 0); qDebug() << changeSet; } -void tst_qquickchangeset::random_data() +void tst_qqmlchangeset::random_data() { QTest::addColumn<int>("seed"); QTest::addColumn<int>("combinations"); @@ -1484,7 +1484,7 @@ void tst_qquickchangeset::random_data() QTest::newRow("3*5") << 32 << 3 << 5; } -void tst_qquickchangeset::random() +void tst_qqmlchangeset::random() { QFETCH(int, seed); QFETCH(int, combinations); @@ -1494,14 +1494,14 @@ void tst_qquickchangeset::random() int failures = 0; for (int i = 0; i < 20000; ++i) { - QQuickChangeSet accumulatedSet; + QQmlChangeSet accumulatedSet; SignalList input; int modelCount = 40; int moveCount = 0; for (int j = 0; j < combinations; ++j) { - QQuickChangeSet set; + QQmlChangeSet set; for (int k = 0; k < depth; ++k) { switch (-(qrand() % 3)) { case InsertOp: { @@ -1537,9 +1537,9 @@ void tst_qquickchangeset::random() } SignalList output; - foreach (const QQuickChangeSet::Remove &remove, accumulatedSet.removes()) + foreach (const QQmlChangeSet::Remove &remove, accumulatedSet.removes()) output << Remove(remove.index, remove.count, remove.moveId, remove.offset); - foreach (const QQuickChangeSet::Insert &insert, accumulatedSet.inserts()) + foreach (const QQmlChangeSet::Insert &insert, accumulatedSet.inserts()) output << Insert(insert.index, insert.count, insert.moveId, insert.offset); QVector<int> inputList; @@ -1569,6 +1569,6 @@ void tst_qquickchangeset::random() QCOMPARE(failures, 0); } -QTEST_MAIN(tst_qquickchangeset) +QTEST_MAIN(tst_qqmlchangeset) -#include "tst_qquickchangeset.moc" +#include "tst_qqmlchangeset.moc" diff --git a/tests/auto/qml/qqmlecmascript/data/getSet.qml b/tests/auto/qml/qqmlecmascript/data/getSet.qml new file mode 100644 index 0000000000..2987986b38 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/getSet.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +QtObject { + function get(x) { return 1; } + function set(x) { return 1; } + function code() { + var get = 0; + var set = 1; + var o = { + get foo() { return 2; }, + set foo(x) { 1; } + } + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/incrDecrSemicolon1.qml b/tests/auto/qml/qqmlecmascript/data/incrDecrSemicolon1.qml new file mode 100644 index 0000000000..b9a30ef8b5 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/incrDecrSemicolon1.qml @@ -0,0 +1,47 @@ +import QtQuick 2.0 + +QtObject { + + // PLEASE NOTE: the function below is whitespace and newline sensitive, + // because that is what the test is all about. + // + // So: DO NOT REFORMAT THE CODE BELOW! + + function code() { +var x=0, y=0; +var z= +x ++ +++ +y + +////////////////////////////////////////////////////////////////////////////// +if (false) { + ; +} +////////////////////////////////////////////////////////////////////////////// + +z= +x ++ ++ +y + +////////////////////////////////////////////////////////////////////////////// +if (false) { + ; +} +////////////////////////////////////////////////////////////////////////////// + +z= +x ++ ++ +y + +////////////////////////////////////////////////////////////////////////////// +if (false) { + ; +} + + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/incrDecrSemicolon2.qml b/tests/auto/qml/qqmlecmascript/data/incrDecrSemicolon2.qml new file mode 100644 index 0000000000..717cdb5715 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/incrDecrSemicolon2.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 + +QtObject { + + // PLEASE NOTE: the function below is whitespace and newline sensitive, + // because that is what the test is all about. + // + // So: DO NOT REFORMAT THE CODE BELOW! + + function code() { +var a, b, c; +a=b +++c + +if (a === b) { +} + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/incrDecrSemicolon_error1.qml b/tests/auto/qml/qqmlecmascript/data/incrDecrSemicolon_error1.qml new file mode 100644 index 0000000000..710729cbfe --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/incrDecrSemicolon_error1.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 + +QtObject { + + // PLEASE NOTE: the function below is whitespace and newline sensitive, + // because that is what the test is all about. + // + // So: DO NOT REFORMAT THE CODE BELOW! + + function code() { +var x=0, y=0; +var z= +x +++ +++ +y + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/numberParsing.1.qml b/tests/auto/qml/qqmlecmascript/data/numberParsing.1.qml new file mode 100644 index 0000000000..1b83a1be0b --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/numberParsing.1.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = 0; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/numberParsing.2.qml b/tests/auto/qml/qqmlecmascript/data/numberParsing.2.qml new file mode 100644 index 0000000000..77f13178c3 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/numberParsing.2.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = 1.01; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/numberParsing.3.qml b/tests/auto/qml/qqmlecmascript/data/numberParsing.3.qml new file mode 100644 index 0000000000..f20baf305a --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/numberParsing.3.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = 1e-10; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/numberParsing.4.qml b/tests/auto/qml/qqmlecmascript/data/numberParsing.4.qml new file mode 100644 index 0000000000..e115dbbbb1 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/numberParsing.4.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = -1.2; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/numberParsing.5.qml b/tests/auto/qml/qqmlecmascript/data/numberParsing.5.qml new file mode 100644 index 0000000000..c3db17602a --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/numberParsing.5.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = .4e-5; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/numberParsing.6.qml b/tests/auto/qml/qqmlecmascript/data/numberParsing.6.qml new file mode 100644 index 0000000000..471db8708a --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/numberParsing.6.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = 0x1; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/numberParsing.7.qml b/tests/auto/qml/qqmlecmascript/data/numberParsing.7.qml new file mode 100644 index 0000000000..f8f8e1aae8 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/numberParsing.7.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = 0Xa; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/numberParsing_error.1.qml b/tests/auto/qml/qqmlecmascript/data/numberParsing_error.1.qml new file mode 100644 index 0000000000..61233cbd5b --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/numberParsing_error.1.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = 0x; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/numberParsing_error.2.qml b/tests/auto/qml/qqmlecmascript/data/numberParsing_error.2.qml new file mode 100644 index 0000000000..45195452ca --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/numberParsing_error.2.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = 0X; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/stringParsing_error.1.qml b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.1.qml new file mode 100644 index 0000000000..71b82b956d --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.1.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = "\01"; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/stringParsing_error.2.qml b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.2.qml new file mode 100644 index 0000000000..787f1d86c7 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.2.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = "\1a"; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/stringParsing_error.3.qml b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.3.qml new file mode 100644 index 0000000000..9954617b6b --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.3.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = "\012"; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/stringParsing_error.4.qml b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.4.qml new file mode 100644 index 0000000000..5bf41f0c1a --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.4.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = "\00a"; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/stringParsing_error.5.qml b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.5.qml new file mode 100644 index 0000000000..563e01a995 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.5.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + var x = "\u000G"; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/stringParsing_error.6.qml b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.6.qml new file mode 100644 index 0000000000..8ee5b59d9e --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.6.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + "\x0G" + } +} + diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index cc49f234c1..06590f0ad6 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -266,6 +266,9 @@ private slots: void deleteLaterObjectMethodCall(); void automaticSemicolon(); void compatibilitySemicolon(); + void incrDecrSemicolon1(); + void incrDecrSemicolon2(); + void incrDecrSemicolon_error1(); void unaryExpression(); void switchStatement(); void withStatement(); @@ -285,6 +288,8 @@ private slots: void propertyOverride(); void concatenatedStringPropertyAccess(); void jsOwnedObjectsDeletedOnEngineDestroy(); + void numberParsing(); + void stringParsing(); private: static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -1792,10 +1797,7 @@ void tst_qqmlecmascript::functionErrors() object = componentTwo.create(); QVERIFY(object != 0); - QString srpname = object->property("srp_name").toString(); - - warning = url + QLatin1String(":16: TypeError: Property 'scarceResource' of object ") + srpname - + QLatin1String(" is not a function"); + warning = url + QLatin1String(":16: TypeError: Property 'scarceResource' of object [object Object] is not a function"); QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); // we expect a meaningful warning to be printed. QMetaObject::invokeMethod(object, "retrieveScarceResource"); delete object; @@ -4111,8 +4113,7 @@ void tst_qqmlecmascript::scarceResources_other() QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>()); QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. - srp_name = object->property("srp_name").toString(); - expectedWarning = varComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object ") + srp_name + QLatin1String(" is not a function"); + expectedWarning = varComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object [object Object] is not a function"); QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed. QMetaObject::invokeMethod(object, "retrieveScarceResource"); QVERIFY(!object->property("scarceResourceCopy").isValid()); // due to exception, assignment will NOT have occurred. @@ -4184,8 +4185,7 @@ void tst_qqmlecmascript::scarceResources_other() QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>()); QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. - srp_name = object->property("srp_name").toString(); - expectedWarning = variantComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object ") + srp_name + QLatin1String(" is not a function"); + expectedWarning = variantComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object [object Object] is not a function"); QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed. QMetaObject::invokeMethod(object, "retrieveScarceResource"); QVERIFY(!object->property("scarceResourceCopy").isValid()); // due to exception, assignment will NOT have occurred. @@ -6625,6 +6625,27 @@ void tst_qqmlecmascript::compatibilitySemicolon() QVERIFY(object != 0); } +void tst_qqmlecmascript::incrDecrSemicolon1() +{ + QQmlComponent component(&engine, testFileUrl("incrDecrSemicolon1.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); +} + +void tst_qqmlecmascript::incrDecrSemicolon2() +{ + QQmlComponent component(&engine, testFileUrl("incrDecrSemicolon2.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); +} + +void tst_qqmlecmascript::incrDecrSemicolon_error1() +{ + QQmlComponent component(&engine, testFileUrl("incrDecrSemicolon_error1.qml")); + QObject *object = component.create(); + QVERIFY(object == 0); +} + void tst_qqmlecmascript::unaryExpression() { QQmlComponent component(&engine, testFileUrl("unaryExpression.qml")); @@ -7343,6 +7364,34 @@ void tst_qqmlecmascript::jsOwnedObjectsDeletedOnEngineDestroy() delete object; } +void tst_qqmlecmascript::numberParsing() +{ + for (int i = 1; i < 8; ++i) { + QString file("numberParsing.%1.qml"); + file = file.arg(i); + QQmlComponent component(&engine, testFileUrl(file)); + QObject *object = component.create(); + QVERIFY(object != 0); + } + for (int i = 1; i < 3; ++i) { + QString file("numberParsing_error.%1.qml"); + file = file.arg(i); + QQmlComponent component(&engine, testFileUrl(file)); + QVERIFY(!component.errors().isEmpty()); + } +} + +void tst_qqmlecmascript::stringParsing() +{ + for (int i = 1; i < 7; ++i) { + QString file("stringParsing_error.%1.qml"); + file = file.arg(i); + QQmlComponent component(&engine, testFileUrl(file)); + QObject *object = component.create(); + QVERIFY(object == 0); + } +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp index 4e1ac22337..9177ff58f7 100644 --- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp +++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp @@ -48,6 +48,7 @@ #include <QStandardPaths> #include <QSignalSpy> #include <QDebug> +#include <QBuffer> #include <QQmlComponent> #include <QQmlNetworkAccessManagerFactory> #include <QQmlExpression> @@ -63,6 +64,7 @@ public: private slots: void rootContext(); void networkAccessManager(); + void synchronousNetworkAccessManager(); void baseUrl(); void contextForObject(); void offlineStoragePath(); @@ -127,6 +129,53 @@ void tst_qqmlengine::networkAccessManager() delete engine; } +class ImmediateReply : public QNetworkReply { + + Q_OBJECT + +public: + ImmediateReply() { + setFinished(true); + } + virtual qint64 readData(char* , qint64 ) { + return 0; + } + virtual void abort() { } +}; + +class ImmediateManager : public QNetworkAccessManager { + + Q_OBJECT + +public: + ImmediateManager(QObject *parent = 0) : QNetworkAccessManager(parent) { + } + + QNetworkReply *createRequest(Operation, const QNetworkRequest & , QIODevice * outgoingData = 0) { + Q_UNUSED(outgoingData); + return new ImmediateReply; + } +}; + +class ImmediateFactory : public QQmlNetworkAccessManagerFactory { + +public: + QNetworkAccessManager *create(QObject *) { + return new ImmediateManager; + } +}; + +void tst_qqmlengine::synchronousNetworkAccessManager() +{ + ImmediateFactory factory; + QQmlEngine engine; + engine.setNetworkAccessManagerFactory(&factory); + QQmlComponent c(&engine, QUrl("myScheme://test.qml")); + // reply is finished, so should not be in loading state. + QVERIFY(!c.isLoading()); +} + + void tst_qqmlengine::baseUrl() { QQmlEngine engine; diff --git a/tests/auto/qml/qqmlglobal/tst_qqmlglobal.cpp b/tests/auto/qml/qqmlglobal/tst_qqmlglobal.cpp index 293eccbf64..793da64734 100644 --- a/tests/auto/qml/qqmlglobal/tst_qqmlglobal.cpp +++ b/tests/auto/qml/qqmlglobal/tst_qqmlglobal.cpp @@ -54,7 +54,7 @@ private slots: void initTestCase(); void colorProviderWarning(); - void guiProviderWarning(); + void noGuiProviderWarning(); }; void tst_qqmlglobal::initTestCase() @@ -68,11 +68,9 @@ void tst_qqmlglobal::colorProviderWarning() QQml_colorProvider(); } -void tst_qqmlglobal::guiProviderWarning() +void tst_qqmlglobal::noGuiProviderWarning() { - const QLatin1String expected("Warning: QQml_guiProvider: no GUI provider has been set! "); - QTest::ignoreMessage(QtWarningMsg, expected.data()); - QQml_guiProvider(); + QVERIFY(QQml_guiProvider()); //No GUI provider, so a default non-zero application instance is returned. } QTEST_MAIN(tst_qqmlglobal) diff --git a/tests/auto/qml/qqmllanguage/data/CompositeType5.qml b/tests/auto/qml/qqmllanguage/data/CompositeType5.qml new file mode 100644 index 0000000000..564468ce90 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/CompositeType5.qml @@ -0,0 +1,2 @@ +CompositeType { +} diff --git a/tests/auto/qml/qqmllanguage/data/CompositeType6.qml b/tests/auto/qml/qqmllanguage/data/CompositeType6.qml new file mode 100644 index 0000000000..a8a2af9318 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/CompositeType6.qml @@ -0,0 +1,2 @@ +CompositeType2 { +} diff --git a/tests/auto/qml/qqmllanguage/data/assignCompositeToType.qml b/tests/auto/qml/qqmllanguage/data/assignCompositeToType.qml index 717cd84536..4034849df8 100644 --- a/tests/auto/qml/qqmllanguage/data/assignCompositeToType.qml +++ b/tests/auto/qml/qqmllanguage/data/assignCompositeToType.qml @@ -8,6 +8,10 @@ QtObject { property QtObject myProperty4 property MyQmlObject myProperty5 property MyQmlObject myProperty6 + property CompositeType myProperty7 + property CompositeType myProperty8 + property CompositeType2 myProperty9 + property CompositeType2 myPropertyA myProperty: CompositeType {} myProperty2: CompositeType2 {} @@ -15,4 +19,8 @@ QtObject { myProperty4: CompositeType4 {} myProperty5: CompositeType2 {} myProperty6: CompositeType4 {} + myProperty7: CompositeType {} + myProperty8: CompositeType5 {} + myProperty9: CompositeType2 {} + myPropertyA: CompositeType6 {} } diff --git a/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.1.errors.txt b/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.1.errors.txt new file mode 100644 index 0000000000..7a75447a62 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.1.errors.txt @@ -0,0 +1,2 @@ +3:1:Type RegisteredCompositeType2 unavailable +-1:-1:File not found diff --git a/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.1.qml b/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.1.qml new file mode 100644 index 0000000000..915a6138d9 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.1.qml @@ -0,0 +1,3 @@ +import Test 1.0 + +RegisteredCompositeType2 {} diff --git a/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.2.errors.txt b/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.2.errors.txt new file mode 100644 index 0000000000..0272619404 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.2.errors.txt @@ -0,0 +1,2 @@ +3:1:Type RegisteredCompositeType3 unavailable +1:1:Expected a qualified name id diff --git a/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.2.qml b/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.2.qml new file mode 100644 index 0000000000..43d7f3ee95 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.2.qml @@ -0,0 +1,3 @@ +import Test 1.0 + +RegisteredCompositeType3 {} diff --git a/tests/auto/qml/qqmllanguage/data/literals.qml b/tests/auto/qml/qqmllanguage/data/literals.qml index ffef050438..564b389760 100644 --- a/tests/auto/qml/qqmllanguage/data/literals.qml +++ b/tests/auto/qml/qqmllanguage/data/literals.qml @@ -2,12 +2,14 @@ import QtQuick 2.0 QtObject { property variant n1: 0xFe32 // hex - property variant n2: 015 // octal + property variant n2: 015 property variant n3: -4.2E11 // floating-point literals property variant n4: .1e9 property variant n5: 3e-12 property variant n6: 3e+12 property variant n7: 0.1e9 + property variant n8: 1152921504606846976 + property variant n9: 100000000000000000000 property variant c1: "\b" // special characters property variant c2: "\f" diff --git a/tests/auto/qml/qqmllanguage/data/registeredCompositeType.qml b/tests/auto/qml/qqmllanguage/data/registeredCompositeType.qml new file mode 100644 index 0000000000..f633a14fa7 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/registeredCompositeType.qml @@ -0,0 +1,3 @@ +import Test 1.0 + +RegisteredCompositeType {} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 0f9e328bd9..3121d10265 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -139,6 +139,7 @@ private slots: void registrationOrder(); void readonly(); void receivers(); + void registeredCompositeType(); void basicRemote_data(); void basicRemote(); @@ -467,6 +468,9 @@ void tst_qqmllanguage::errors_data() QTest::newRow("invalidTypeName.4") << "invalidTypeName.4.qml" << "invalidTypeName.4.errors.txt" << false; QTest::newRow("Major version isolation") << "majorVersionIsolation.qml" << "majorVersionIsolation.errors.txt" << false; + + QTest::newRow("badCompositeRegistration.1") << "badCompositeRegistration.1.qml" << "badCompositeRegistration.1.errors.txt" << false; + QTest::newRow("badCompositeRegistration.2") << "badCompositeRegistration.2.qml" << "badCompositeRegistration.2.errors.txt" << false; } @@ -2771,6 +2775,10 @@ void tst_qqmllanguage::initTestCase() QQmlMetaType::registerCustomStringConverter(qMetaTypeId<MyCustomVariantType>(), myCustomVariantTypeConverter); registerTypes(); + // Registered here because it uses testFileUrl + qmlRegisterType(testFileUrl("CompositeType.qml"), "Test", 1, 0, "RegisteredCompositeType"); + qmlRegisterType(testFileUrl("CompositeType.DoesNotExist.qml"), "Test", 1, 0, "RegisteredCompositeType2"); + qmlRegisterType(testFileUrl("invalidRoot.1.qml"), "Test", 1, 0, "RegisteredCompositeType3"); // Registering the TestType class in other modules should have no adverse effects qmlRegisterType<TestType>("org.qtproject.TestPre", 1, 0, "Test"); @@ -2915,6 +2923,17 @@ void tst_qqmllanguage::receivers() delete o; } +void tst_qqmllanguage::registeredCompositeType() +{ + QQmlComponent component(&engine, testFileUrl("registeredCompositeType.qml")); + + VERIFY_ERRORS(0); + QObject *o = component.create(); + QVERIFY(o != 0); + + delete o; +} + // QTBUG-18268 void tst_qqmllanguage::remoteLoadCrash() { @@ -3053,6 +3072,8 @@ void tst_qqmllanguage::literals_data() QTest::newRow("fp3") << "n5" << QVariant(3e-12); QTest::newRow("fp4") << "n6" << QVariant(3e+12); QTest::newRow("fp5") << "n7" << QVariant(0.1e9); + QTest::newRow("large-int1") << "n8" << QVariant((double) 1152921504606846976); + QTest::newRow("large-int2") << "n9" << QVariant(100000000000000000000.); QTest::newRow("special1") << "c1" << QVariant(QString("\b")); QTest::newRow("special2") << "c2" << QVariant(QString("\f")); @@ -3064,8 +3085,8 @@ void tst_qqmllanguage::literals_data() QTest::newRow("special8") << "c8" << QVariant(QString("\"")); QTest::newRow("special9") << "c9" << QVariant(QString("\\")); // We don't handle octal escape sequences - QTest::newRow("special11") << "c10" << QVariant(QString(1, QChar(0xa9))); - QTest::newRow("special12") << "c11" << QVariant(QString(1, QChar(0x00A9))); + QTest::newRow("special10") << "c10" << QVariant(QString(1, QChar(0xa9))); + QTest::newRow("special11") << "c11" << QVariant(QString(1, QChar(0x00A9))); } void tst_qqmllanguage::literals() diff --git a/tests/auto/qml/qquickchangeset/qquickchangeset.pro b/tests/auto/qml/qqmllistcompositor/qqmllistcompositor.pro index fd8c87baa4..e6c9dc3a29 100644 --- a/tests/auto/qml/qquickchangeset/qquickchangeset.pro +++ b/tests/auto/qml/qqmllistcompositor/qqmllistcompositor.pro @@ -1,8 +1,8 @@ CONFIG += testcase -TARGET = tst_qquickchangeset +TARGET = tst_qqmllistcompositor macx:CONFIG -= app_bundle -SOURCES += tst_qquickchangeset.cpp +SOURCES += tst_qqmllistcompositor.cpp CONFIG += parallel_test diff --git a/tests/auto/qml/qquicklistcompositor/tst_qquicklistcompositor.cpp b/tests/auto/qml/qqmllistcompositor/tst_qqmllistcompositor.cpp index 5be501c94e..d5e85f478d 100644 --- a/tests/auto/qml/qquicklistcompositor/tst_qquicklistcompositor.cpp +++ b/tests/auto/qml/qqmllistcompositor/tst_qqmllistcompositor.cpp @@ -39,11 +39,11 @@ ** ****************************************************************************/ #include <qtest.h> -#include <private/qquicklistcompositor_p.h> +#include <private/qqmllistcompositor_p.h> template<typename T, int N> int lengthOf(const T (&)[N]) { return N; } -typedef QQuickListCompositor C; +typedef QQmlListCompositor C; struct Range { @@ -70,9 +70,9 @@ template <typename T> struct Array typedef Array<int> IndexArray; typedef Array<const void *> ListArray; -typedef QVector<QQuickListCompositor::Remove> RemoveList; -typedef QVector<QQuickListCompositor::Insert> InsertList; -typedef QVector<QQuickListCompositor::Change> ChangeList; +typedef QVector<QQmlListCompositor::Remove> RemoveList; +typedef QVector<QQmlListCompositor::Insert> InsertList; +typedef QVector<QQmlListCompositor::Change> ChangeList; typedef QVector<Range> RangeList; @@ -102,7 +102,7 @@ QT_END_NAMESPACE static const C::Group Visible = C::Group(2); static const C::Group Selection = C::Group(3); -class tst_qquicklistcompositor : public QObject +class tst_qqmllistcompositor : public QObject { Q_OBJECT @@ -174,7 +174,7 @@ private slots: void groupDebug(); }; -void tst_qquicklistcompositor::find_data() +void tst_qqmllistcompositor::find_data() { QTest::addColumn<RangeList>("ranges"); QTest::addColumn<C::Group>("startGroup"); @@ -201,7 +201,7 @@ void tst_qquicklistcompositor::find_data() << uint(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag) << 0; } -void tst_qquicklistcompositor::find() +void tst_qqmllistcompositor::find() { QFETCH(RangeList, ranges); QFETCH(C::Group, startGroup); @@ -215,7 +215,7 @@ void tst_qquicklistcompositor::find() QFETCH(uint, rangeFlags); QFETCH(int, rangeIndex); - QQuickListCompositor compositor; + QQmlListCompositor compositor; compositor.setGroupCount(4); compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); @@ -224,7 +224,7 @@ void tst_qquicklistcompositor::find() compositor.find(startGroup, startIndex); - QQuickListCompositor::iterator it = compositor.find(group, index); + QQmlListCompositor::iterator it = compositor.find(group, index); QCOMPARE(it.index[C::Cache], cacheIndex); QCOMPARE(it.index[C::Default], defaultIndex); QCOMPARE(it.index[Visible], visibleIndex); @@ -233,7 +233,7 @@ void tst_qquicklistcompositor::find() QCOMPARE(it->index, rangeIndex); } -void tst_qquicklistcompositor::findInsertPosition_data() +void tst_qqmllistcompositor::findInsertPosition_data() { QTest::addColumn<RangeList>("ranges"); QTest::addColumn<C::Group>("group"); @@ -265,7 +265,7 @@ void tst_qquicklistcompositor::findInsertPosition_data() << uint(0) << 0; } -void tst_qquicklistcompositor::findInsertPosition() +void tst_qqmllistcompositor::findInsertPosition() { QFETCH(RangeList, ranges); QFETCH(C::Group, group); @@ -277,14 +277,14 @@ void tst_qquicklistcompositor::findInsertPosition() QFETCH(uint, rangeFlags); QFETCH(int, rangeIndex); - QQuickListCompositor compositor; + QQmlListCompositor compositor; compositor.setGroupCount(4); compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); foreach (const Range &range, ranges) compositor.append(range.list, range.index, range.count, range.flags); - QQuickListCompositor::insert_iterator it = compositor.findInsertPosition(group, index); + QQmlListCompositor::insert_iterator it = compositor.findInsertPosition(group, index); QCOMPARE(it.index[C::Cache], cacheIndex); QCOMPARE(it.index[C::Default], defaultIndex); @@ -294,9 +294,9 @@ void tst_qquicklistcompositor::findInsertPosition() QCOMPARE(it->index, rangeIndex); } -void tst_qquicklistcompositor::insert() +void tst_qqmllistcompositor::insert() { - QQuickListCompositor compositor; + QQmlListCompositor compositor; compositor.setGroupCount(4); compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); @@ -383,7 +383,7 @@ void tst_qquicklistcompositor::insert() } } -void tst_qquicklistcompositor::clearFlags_data() +void tst_qqmllistcompositor::clearFlags_data() { QTest::addColumn<RangeList>("ranges"); QTest::addColumn<C::Group>("group"); @@ -518,7 +518,7 @@ void tst_qquicklistcompositor::clearFlags_data() } } -void tst_qquicklistcompositor::clearFlags() +void tst_qqmllistcompositor::clearFlags() { QFETCH(RangeList, ranges); QFETCH(C::Group, group); @@ -535,7 +535,7 @@ void tst_qquicklistcompositor::clearFlags() QFETCH(IndexArray, selectionIndexes); QFETCH(ListArray, selectionLists); - QQuickListCompositor compositor; + QQmlListCompositor compositor; compositor.setGroupCount(4); compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); @@ -577,7 +577,7 @@ void tst_qquicklistcompositor::clearFlags() } } -void tst_qquicklistcompositor::setFlags_data() +void tst_qqmllistcompositor::setFlags_data() { QTest::addColumn<RangeList>("ranges"); QTest::addColumn<C::Group>("group"); @@ -700,7 +700,7 @@ void tst_qquicklistcompositor::setFlags_data() } } -void tst_qquicklistcompositor::setFlags() +void tst_qqmllistcompositor::setFlags() { QFETCH(RangeList, ranges); QFETCH(C::Group, group); @@ -717,7 +717,7 @@ void tst_qquicklistcompositor::setFlags() QFETCH(IndexArray, selectionIndexes); QFETCH(ListArray, selectionLists); - QQuickListCompositor compositor; + QQmlListCompositor compositor; compositor.setGroupCount(4); compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); @@ -759,7 +759,7 @@ void tst_qquicklistcompositor::setFlags() } } -void tst_qquicklistcompositor::move_data() +void tst_qqmllistcompositor::move_data() { QTest::addColumn<RangeList>("ranges"); QTest::addColumn<C::Group>("fromGroup"); @@ -985,7 +985,7 @@ void tst_qquicklistcompositor::move_data() } } -void tst_qquicklistcompositor::move() +void tst_qqmllistcompositor::move() { QFETCH(RangeList, ranges); QFETCH(C::Group, fromGroup); @@ -1004,7 +1004,7 @@ void tst_qquicklistcompositor::move() QFETCH(IndexArray, selectionIndexes); QFETCH(ListArray, selectionLists); - QQuickListCompositor compositor; + QQmlListCompositor compositor; compositor.setGroupCount(4); compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); @@ -1048,11 +1048,11 @@ void tst_qquicklistcompositor::move() } } -void tst_qquicklistcompositor::moveFromEnd() +void tst_qqmllistcompositor::moveFromEnd() { int listA; void *a = &listA; - QQuickListCompositor compositor; + QQmlListCompositor compositor; compositor.append(a, 0, 1, C::AppendFlag | C::PrependFlag | C::DefaultFlag); // Moving an item anchors it to that position. @@ -1074,9 +1074,9 @@ void tst_qquicklistcompositor::moveFromEnd() QCOMPARE(it.modelIndex(), 0); } -void tst_qquicklistcompositor::clear() +void tst_qqmllistcompositor::clear() { - QQuickListCompositor compositor; + QQmlListCompositor compositor; compositor.setGroupCount(4); compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); @@ -1097,7 +1097,7 @@ void tst_qquicklistcompositor::clear() QCOMPARE(compositor.count(C::Cache), 0); } -void tst_qquicklistcompositor::listItemsInserted_data() +void tst_qqmllistcompositor::listItemsInserted_data() { QTest::addColumn<RangeList>("ranges"); QTest::addColumn<void *>("list"); @@ -1226,7 +1226,7 @@ void tst_qquicklistcompositor::listItemsInserted_data() } } -void tst_qquicklistcompositor::listItemsInserted() +void tst_qqmllistcompositor::listItemsInserted() { QFETCH(RangeList, ranges); QFETCH(void *, list); @@ -1238,7 +1238,7 @@ void tst_qquicklistcompositor::listItemsInserted() QFETCH(IndexArray, visibleIndexes); QFETCH(IndexArray, selectionIndexes); - QQuickListCompositor compositor; + QQmlListCompositor compositor; compositor.setGroupCount(4); compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); @@ -1276,7 +1276,7 @@ void tst_qquicklistcompositor::listItemsInserted() } } -void tst_qquicklistcompositor::listItemsRemoved_data() +void tst_qqmllistcompositor::listItemsRemoved_data() { QTest::addColumn<RangeList>("ranges"); QTest::addColumn<void *>("list"); @@ -1362,7 +1362,7 @@ void tst_qquicklistcompositor::listItemsRemoved_data() } } -void tst_qquicklistcompositor::listItemsRemoved() +void tst_qqmllistcompositor::listItemsRemoved() { QFETCH(RangeList, ranges); QFETCH(void *, list); @@ -1374,7 +1374,7 @@ void tst_qquicklistcompositor::listItemsRemoved() QFETCH(IndexArray, visibleIndexes); QFETCH(IndexArray, selectionIndexes); - QQuickListCompositor compositor; + QQmlListCompositor compositor; compositor.setGroupCount(4); compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); @@ -1412,7 +1412,7 @@ void tst_qquicklistcompositor::listItemsRemoved() } } -void tst_qquicklistcompositor::listItemsMoved_data() +void tst_qqmllistcompositor::listItemsMoved_data() { QTest::addColumn<RangeList>("ranges"); QTest::addColumn<void *>("list"); @@ -1554,7 +1554,7 @@ void tst_qquicklistcompositor::listItemsMoved_data() } } -void tst_qquicklistcompositor::listItemsMoved() +void tst_qqmllistcompositor::listItemsMoved() { QFETCH(RangeList, ranges); QFETCH(void *, list); @@ -1568,7 +1568,7 @@ void tst_qquicklistcompositor::listItemsMoved() QFETCH(IndexArray, visibleIndexes); QFETCH(IndexArray, selectionIndexes); - QQuickListCompositor compositor; + QQmlListCompositor compositor; compositor.setGroupCount(4); compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); @@ -1608,7 +1608,7 @@ void tst_qquicklistcompositor::listItemsMoved() } } -void tst_qquicklistcompositor::listItemsChanged_data() +void tst_qqmllistcompositor::listItemsChanged_data() { QTest::addColumn<RangeList>("ranges"); QTest::addColumn<void *>("list"); @@ -1640,7 +1640,7 @@ void tst_qquicklistcompositor::listItemsChanged_data() << Change(0, 0, 3, 6, 2, C::DefaultFlag | C::CacheFlag)); } -void tst_qquicklistcompositor::listItemsChanged() +void tst_qqmllistcompositor::listItemsChanged() { QFETCH(RangeList, ranges); QFETCH(void *, list); @@ -1648,7 +1648,7 @@ void tst_qquicklistcompositor::listItemsChanged() QFETCH(int, count); QFETCH(ChangeList, expectedChanges); - QQuickListCompositor compositor; + QQmlListCompositor compositor; compositor.setGroupCount(4); compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); @@ -1661,12 +1661,12 @@ void tst_qquicklistcompositor::listItemsChanged() QCOMPARE(changes, expectedChanges); } -void tst_qquicklistcompositor::compositorDebug() +void tst_qqmllistcompositor::compositorDebug() { void *a = (void *)0xa0; void *b = (void *)0xb0; - QQuickListCompositor compositor; + QQmlListCompositor compositor; compositor.setGroupCount(4); compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); compositor.append(a, 0, 2, C::PrependFlag | C::DefaultFlag); @@ -1676,7 +1676,7 @@ void tst_qquicklistcompositor::compositorDebug() compositor.append(a, 2, 3, C::DefaultFlag); QTest::ignoreMessage(QtDebugMsg, - "QQuickListCompositor(00110\n" + "QQmlListCompositor(00110\n" " 0 0 0 0 Range(0xa0 0 2 00P000000000D0\n" " 0 0 2 0 Range(0xa0 2 3 00P00000000000\n" " 0 0 2 0 Range(0xa0 5 2 0AP000000000D0\n" @@ -1687,7 +1687,7 @@ void tst_qquicklistcompositor::compositorDebug() compositor.setFlags(C::Default, 5, 2, SelectionFlag); QTest::ignoreMessage(QtDebugMsg, - "QQuickListCompositor(20110\n" + "QQmlListCompositor(20110\n" " 0 0 0 0 Range(0xa0 0 2 00P000000000D0\n" " 0 0 2 0 Range(0xa0 2 3 00P00000000000\n" " 0 0 2 0 Range(0xa0 5 2 0AP000000000D0\n" @@ -1698,12 +1698,12 @@ void tst_qquicklistcompositor::compositorDebug() qDebug() << compositor; } -void tst_qquicklistcompositor::changeDebug() +void tst_qqmllistcompositor::changeDebug() { void *a = (void *)0xa0; void *b = (void *)0xb0; - QQuickListCompositor compositor; + QQmlListCompositor compositor; compositor.setGroupCount(4); compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); compositor.append(a, 0, 2, C::PrependFlag | C::DefaultFlag); @@ -1716,14 +1716,14 @@ void tst_qquicklistcompositor::changeDebug() QTest::ignoreMessage(QtDebugMsg, "Change(-1 2 000000010D0 2 0 7 0)"); - qDebug() << QQuickListCompositor::Change(compositor.find(C::Default, 7), 2, SelectionFlag | C::DefaultFlag); + qDebug() << QQmlListCompositor::Change(compositor.find(C::Default, 7), 2, SelectionFlag | C::DefaultFlag); QTest::ignoreMessage(QtDebugMsg, "Remove(9 4 000000000D0 10 0)"); - qDebug() << QQuickListCompositor::Remove(compositor.find(C::Default, 10), 4, C::DefaultFlag, 9); + qDebug() << QQmlListCompositor::Remove(compositor.find(C::Default, 10), 4, C::DefaultFlag, 9); QTest::ignoreMessage(QtDebugMsg, "Insert(9 4 000000000D0 3 0)"); - qDebug() << QQuickListCompositor::Insert(compositor.find(C::Default, 3), 4, C::DefaultFlag, 9); + qDebug() << QQmlListCompositor::Insert(compositor.find(C::Default, 3), 4, C::DefaultFlag, 9); } -void tst_qquicklistcompositor::groupDebug() +void tst_qqmllistcompositor::groupDebug() { QTest::ignoreMessage(QtDebugMsg, "Default "); qDebug() << C::Default; @@ -1733,8 +1733,8 @@ void tst_qquicklistcompositor::groupDebug() qDebug() << Selection; } -QTEST_MAIN(tst_qquicklistcompositor) +QTEST_MAIN(tst_qqmllistcompositor) -#include "tst_qquicklistcompositor.moc" +#include "tst_qqmllistcompositor.moc" diff --git a/tests/auto/qml/qquicklistmodel/data/enumerate.qml b/tests/auto/qml/qqmllistmodel/data/enumerate.qml index f73d66b318..f73d66b318 100644 --- a/tests/auto/qml/qquicklistmodel/data/enumerate.qml +++ b/tests/auto/qml/qqmllistmodel/data/enumerate.qml diff --git a/tests/auto/qml/qquicklistmodel/data/multipleroles.qml b/tests/auto/qml/qqmllistmodel/data/multipleroles.qml index 4a331e2b3e..4a331e2b3e 100644 --- a/tests/auto/qml/qquicklistmodel/data/multipleroles.qml +++ b/tests/auto/qml/qqmllistmodel/data/multipleroles.qml diff --git a/tests/auto/qml/qquicklistmodel/data/setmodelcachelist.qml b/tests/auto/qml/qqmllistmodel/data/setmodelcachelist.qml index 58bf1ccd04..58bf1ccd04 100644 --- a/tests/auto/qml/qquicklistmodel/data/setmodelcachelist.qml +++ b/tests/auto/qml/qqmllistmodel/data/setmodelcachelist.qml diff --git a/tests/auto/qml/qquicklistmodel/data/signalhandlers.qml b/tests/auto/qml/qqmllistmodel/data/signalhandlers.qml index 750d99c5a3..750d99c5a3 100644 --- a/tests/auto/qml/qquicklistmodel/data/signalhandlers.qml +++ b/tests/auto/qml/qqmllistmodel/data/signalhandlers.qml diff --git a/tests/auto/qml/qquicklistmodel/qquicklistmodel.pro b/tests/auto/qml/qqmllistmodel/qqmllistmodel.pro index e2b88ccec6..ef044f1663 100644 --- a/tests/auto/qml/qquicklistmodel/qquicklistmodel.pro +++ b/tests/auto/qml/qqmllistmodel/qqmllistmodel.pro @@ -1,8 +1,8 @@ CONFIG += testcase -TARGET = tst_qquicklistmodel +TARGET = tst_qqmllistmodel macx:CONFIG -= app_bundle -SOURCES += tst_qquicklistmodel.cpp +SOURCES += tst_qqmllistmodel.cpp include (../../shared/util.pri) diff --git a/tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp index 8deaae9902..eec312ec4f 100644 --- a/tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp +++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp @@ -43,7 +43,7 @@ #include <QtQuick/private/qquicktext_p.h> #include <QtQuick/private/qquickanimation_p.h> #include <QtQml/private/qqmlengine_p.h> -#include <QtQml/private/qquicklistmodel_p.h> +#include <QtQml/private/qqmllistmodel_p.h> #include <QtQml/private/qqmlexpression_p.h> #include <QQmlComponent> @@ -82,17 +82,17 @@ static bool isValidErrorMessage(const QString &msg, bool dynamicRoleTest) return valid; } -class tst_qquicklistmodel : public QQmlDataTest +class tst_qqmllistmodel : public QQmlDataTest { Q_OBJECT public: - tst_qquicklistmodel() + tst_qqmllistmodel() { qRegisterMetaType<QVector<int> >(); } private: - int roleFromName(const QQuickListModel *model, const QString &roleName); + int roleFromName(const QQmlListModel *model, const QString &roleName); static bool compareVariantList(const QVariantList &testList, QVariant object); @@ -132,11 +132,11 @@ private slots: void datetime_data(); }; -bool tst_qquicklistmodel::compareVariantList(const QVariantList &testList, QVariant object) +bool tst_qqmllistmodel::compareVariantList(const QVariantList &testList, QVariant object) { bool allOk = true; - QQuickListModel *model = qobject_cast<QQuickListModel *>(object.value<QObject *>()); + QQmlListModel *model = qobject_cast<QQmlListModel *>(object.value<QObject *>()); if (model == 0) return false; @@ -178,12 +178,12 @@ bool tst_qquicklistmodel::compareVariantList(const QVariantList &testList, QVari return allOk; } -int tst_qquicklistmodel::roleFromName(const QQuickListModel *model, const QString &roleName) +int tst_qqmllistmodel::roleFromName(const QQmlListModel *model, const QString &roleName) { return model->roleNames().key(roleName.toUtf8(), -1); } -void tst_qquicklistmodel::static_types_data() +void tst_qqmllistmodel::static_types_data() { QTest::addColumn<QString>("qml"); QTest::addColumn<QVariant>("value"); @@ -240,7 +240,7 @@ void tst_qquicklistmodel::static_types_data() << QString("<Unknown File>: Can't assign to existing role 'foo' of different type [List -> Number]"); } -void tst_qquicklistmodel::static_types() +void tst_qqmllistmodel::static_types() { QFETCH(QString, qml); QFETCH(QVariant, value); @@ -272,7 +272,7 @@ void tst_qquicklistmodel::static_types() delete obj; } -void tst_qquicklistmodel::static_i18n_data() +void tst_qqmllistmodel::static_i18n_data() { QTest::addColumn<QString>("qml"); QTest::addColumn<QVariant>("value"); @@ -309,7 +309,7 @@ void tst_qquicklistmodel::static_i18n_data() << QString("ListElement: improperly specified QT_TRID_NOOP"); } -void tst_qquicklistmodel::static_i18n() +void tst_qqmllistmodel::static_i18n() { QFETCH(QString, qml); QFETCH(QVariant, value); @@ -341,7 +341,7 @@ void tst_qquicklistmodel::static_i18n() delete obj; } -void tst_qquicklistmodel::static_nestedElements() +void tst_qqmllistmodel::static_nestedElements() { QFETCH(int, elementCount); @@ -379,7 +379,7 @@ void tst_qquicklistmodel::static_nestedElements() delete obj; } -void tst_qquicklistmodel::static_nestedElements_data() +void tst_qqmllistmodel::static_nestedElements_data() { QTest::addColumn<int>("elementCount"); @@ -389,7 +389,7 @@ void tst_qquicklistmodel::static_nestedElements_data() QTest::newRow("many items") << 5; } -void tst_qquicklistmodel::dynamic_data() +void tst_qqmllistmodel::dynamic_data() { QTest::addColumn<QString>("script"); QTest::addColumn<int>("result"); @@ -530,7 +530,7 @@ void tst_qquicklistmodel::dynamic_data() } } -void tst_qquicklistmodel::dynamic() +void tst_qqmllistmodel::dynamic() { QFETCH(QString, script); QFETCH(int, result); @@ -539,7 +539,7 @@ void tst_qquicklistmodel::dynamic() QQuickItem dummyItem0, dummyItem1; QQmlEngine engine; - QQuickListModel model; + QQmlListModel model; model.setDynamicRoles(dynamicRoles); QQmlEngine::setContextForObject(&model,engine.rootContext()); engine.rootContext()->setContextObject(&model); @@ -561,7 +561,7 @@ void tst_qquicklistmodel::dynamic() QVERIFY(spyCount.count() > 0); } -void tst_qquicklistmodel::enumerate() +void tst_qqmllistmodel::enumerate() { QQmlEngine eng; QQmlComponent component(&eng, testFileUrl("enumerate.qml")); @@ -602,7 +602,7 @@ void tst_qquicklistmodel::enumerate() delete item; } -void tst_qquicklistmodel::error_data() +void tst_qqmllistmodel::error_data() { QTest::addColumn<QString>("qml"); QTest::addColumn<QString>("error"); @@ -652,7 +652,7 @@ void tst_qquicklistmodel::error_data() << "Foo.ListElement - Foo is not a namespace"; } -void tst_qquicklistmodel::error() +void tst_qqmllistmodel::error() { QFETCH(QString, qml); QFETCH(QString, error); @@ -671,7 +671,7 @@ void tst_qquicklistmodel::error() } } -void tst_qquicklistmodel::syncError() +void tst_qqmllistmodel::syncError() { QString qml = "import QtQuick 2.0\nListModel { id: lm; Component.onCompleted: lm.sync() }"; QString error = "file:dummy.qml:2:1: QML ListModel: List sync() can only be called from a WorkerScript"; @@ -689,7 +689,7 @@ void tst_qquicklistmodel::syncError() /* Test model changes from set() are available to the view */ -void tst_qquicklistmodel::set_data() +void tst_qqmllistmodel::set_data() { QTest::addColumn<bool>("dynamicRoles"); @@ -697,12 +697,12 @@ void tst_qquicklistmodel::set_data() QTest::newRow("dynamicRoles") << true; } -void tst_qquicklistmodel::set() +void tst_qqmllistmodel::set() { QFETCH(bool, dynamicRoles); QQmlEngine engine; - QQuickListModel model; + QQmlListModel model; model.setDynamicRoles(dynamicRoles); QQmlEngine::setContextForObject(&model,engine.rootContext()); engine.rootContext()->setContextProperty("model", &model); @@ -727,7 +727,7 @@ void tst_qquicklistmodel::set() /* Test model changes on values returned by get() are available to the view */ -void tst_qquicklistmodel::get() +void tst_qqmllistmodel::get() { QFETCH(QString, expression); QFETCH(int, index); @@ -740,7 +740,7 @@ void tst_qquicklistmodel::get() component.setData( "import QtQuick 2.0\n" "ListModel {}\n", QUrl()); - QQuickListModel *model = qobject_cast<QQuickListModel*>(component.create()); + QQmlListModel *model = qobject_cast<QQmlListModel*>(component.create()); model->setDynamicRoles(dynamicRoles); engine.rootContext()->setContextProperty("model", model); @@ -775,7 +775,7 @@ void tst_qquicklistmodel::get() delete model; } -void tst_qquicklistmodel::get_data() +void tst_qqmllistmodel::get_data() { QTest::addColumn<QString>("expression"); QTest::addColumn<int>("index"); @@ -802,7 +802,7 @@ void tst_qquicklistmodel::get_data() /* Test that the tests run in get() also work for nested list data */ -void tst_qquicklistmodel::get_nested() +void tst_qqmllistmodel::get_nested() { QFETCH(QString, expression); QFETCH(int, index); @@ -818,10 +818,10 @@ void tst_qquicklistmodel::get_nested() component.setData( "import QtQuick 2.0\n" "ListModel {}", QUrl()); - QQuickListModel *model = qobject_cast<QQuickListModel*>(component.create()); + QQmlListModel *model = qobject_cast<QQmlListModel*>(component.create()); model->setDynamicRoles(dynamicRoles); QVERIFY(component.errorString().isEmpty()); - QQuickListModel *childModel; + QQmlListModel *childModel; engine.rootContext()->setContextProperty("model", model); RUNEXPR("model.append({ listRoleA: [\n" @@ -872,7 +872,7 @@ void tst_qquicklistmodel::get_nested() int outerListRole = roleFromName(model, outerListRoleName); QVERIFY(outerListRole >= 0); - childModel = qobject_cast<QQuickListModel*>(model->data(outerListIndex, outerListRole).value<QObject*>()); + childModel = qobject_cast<QQmlListModel*>(model->data(outerListIndex, outerListRole).value<QObject*>()); QVERIFY(childModel); QString extendedExpression = QString("get(%1).%2.%3").arg(outerListIndex).arg(outerListRoleName).arg(expression); @@ -900,20 +900,20 @@ void tst_qquicklistmodel::get_nested() delete model; } -void tst_qquicklistmodel::get_nested_data() +void tst_qqmllistmodel::get_nested_data() { get_data(); } //QTBUG-13754 -void tst_qquicklistmodel::crash_model_with_multiple_roles() +void tst_qqmllistmodel::crash_model_with_multiple_roles() { QQmlEngine eng; QQmlComponent component(&eng, testFileUrl("multipleroles.qml")); QObject *rootItem = component.create(); QVERIFY(component.errorString().isEmpty()); QVERIFY(rootItem != 0); - QQuickListModel *model = rootItem->findChild<QQuickListModel*>("listModel"); + QQmlListModel *model = rootItem->findChild<QQmlListModel*>("listModel"); QVERIFY(model != 0); // used to cause a crash @@ -923,7 +923,7 @@ void tst_qquicklistmodel::crash_model_with_multiple_roles() } //QTBUG-15190 -void tst_qquicklistmodel::set_model_cache() +void tst_qqmllistmodel::set_model_cache() { QQmlEngine eng; QQmlComponent component(&eng, testFileUrl("setmodelcachelist.qml")); @@ -935,7 +935,7 @@ void tst_qquicklistmodel::set_model_cache() delete model; } -void tst_qquicklistmodel::property_changes() +void tst_qqmllistmodel::property_changes() { QFETCH(QString, script_setup); QFETCH(QString, script_change); @@ -946,7 +946,7 @@ void tst_qquicklistmodel::property_changes() QFETCH(bool, dynamicRoles); QQmlEngine engine; - QQuickListModel model; + QQmlListModel model; model.setDynamicRoles(dynamicRoles); QQmlEngine::setContextForObject(&model, engine.rootContext()); engine.rootContext()->setContextObject(&model); @@ -973,7 +973,7 @@ void tst_qquicklistmodel::property_changes() expr.setExpression(script_change); expr.evaluate(); - QVERIFY2(!expr.hasError(), QTest::toString(expr.error())); + QVERIFY2(!expr.hasError(), QTest::toString(expr.error().toString())); // test the object returned by get() emits the correct signals QCOMPARE(connectionsObject->property("gotSignal").toBool(), itemsChanged); @@ -993,7 +993,7 @@ void tst_qquicklistmodel::property_changes() delete connectionsObject; } -void tst_qquicklistmodel::property_changes_data() +void tst_qqmllistmodel::property_changes_data() { QTest::addColumn<QString>("script_setup"); QTest::addColumn<QString>("script_change"); @@ -1066,7 +1066,7 @@ void tst_qquicklistmodel::property_changes_data() } } -void tst_qquicklistmodel::clear_data() +void tst_qqmllistmodel::clear_data() { QTest::addColumn<bool>("dynamicRoles"); @@ -1074,12 +1074,12 @@ void tst_qquicklistmodel::clear_data() QTest::newRow("dynamicRoles") << true; } -void tst_qquicklistmodel::clear() +void tst_qqmllistmodel::clear() { QFETCH(bool, dynamicRoles); QQmlEngine engine; - QQuickListModel model; + QQmlListModel model; model.setDynamicRoles(dynamicRoles); QQmlEngine::setContextForObject(&model, engine.rootContext()); engine.rootContext()->setContextProperty("model", &model); @@ -1111,7 +1111,7 @@ void tst_qquicklistmodel::clear() QCOMPARE(roleNames[2], QByteArray("propertyC")); } -void tst_qquicklistmodel::signal_handlers_data() +void tst_qqmllistmodel::signal_handlers_data() { QTest::addColumn<bool>("dynamicRoles"); @@ -1119,14 +1119,14 @@ void tst_qquicklistmodel::signal_handlers_data() QTest::newRow("dynamicRoles") << true; } -void tst_qquicklistmodel::signal_handlers() +void tst_qqmllistmodel::signal_handlers() { QFETCH(bool, dynamicRoles); QQmlEngine eng; QQmlComponent component(&eng, testFileUrl("signalhandlers.qml")); QObject *model = component.create(); - QQuickListModel *lm = qobject_cast<QQuickListModel *>(model); + QQmlListModel *lm = qobject_cast<QQmlListModel *>(model); QVERIFY(lm != 0); lm->setDynamicRoles(dynamicRoles); QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString())); @@ -1136,7 +1136,7 @@ void tst_qquicklistmodel::signal_handlers() delete model; } -void tst_qquicklistmodel::role_mode_data() +void tst_qqmllistmodel::role_mode_data() { QTest::addColumn<QString>("script"); QTest::addColumn<int>("result"); @@ -1150,14 +1150,14 @@ void tst_qquicklistmodel::role_mode_data() QTest::newRow("enableDynamic2") << "{dynamicRoles=true;append({'a':1});dynamicRoles=false;dynamicRoles}" << 1 << "<Unknown File>: QML ListModel: unable to enable static roles as this model is not empty!"; } -void tst_qquicklistmodel::role_mode() +void tst_qqmllistmodel::role_mode() { QFETCH(QString, script); QFETCH(int, result); QFETCH(QString, warning); QQmlEngine engine; - QQuickListModel model; + QQmlListModel model; QQmlEngine::setContextForObject(&model,engine.rootContext()); engine.rootContext()->setContextObject(&model); QQmlExpression e(engine.rootContext(), &model, script); @@ -1171,10 +1171,10 @@ void tst_qquicklistmodel::role_mode() QCOMPARE(actual,result); } -void tst_qquicklistmodel::string_to_list_crash() +void tst_qqmllistmodel::string_to_list_crash() { QQmlEngine engine; - QQuickListModel model; + QQmlListModel model; QQmlEngine::setContextForObject(&model,engine.rootContext()); engine.rootContext()->setContextObject(&model); QString script = QLatin1String("{append({'a':'data'});get(0).a = [{'x':123}]}"); @@ -1184,7 +1184,7 @@ void tst_qquicklistmodel::string_to_list_crash() e.evaluate(); } -void tst_qquicklistmodel::empty_element_warning_data() +void tst_qqmllistmodel::empty_element_warning_data() { QTest::addColumn<QString>("qml"); QTest::addColumn<bool>("warning"); @@ -1198,7 +1198,7 @@ void tst_qquicklistmodel::empty_element_warning_data() QTest::newRow("role3") << "import QtQuick 2.0\nListModel { ListElement {} ListElement {a:1} ListElement {b:2} }" << false; } -void tst_qquicklistmodel::empty_element_warning() +void tst_qqmllistmodel::empty_element_warning() { QFETCH(QString, qml); QFETCH(bool, warning); @@ -1219,7 +1219,7 @@ void tst_qquicklistmodel::empty_element_warning() delete obj; } -void tst_qquicklistmodel::datetime_data() +void tst_qqmllistmodel::datetime_data() { QTest::addColumn<QString>("qml"); QTest::addColumn<QDateTime>("expected"); @@ -1234,13 +1234,13 @@ void tst_qquicklistmodel::datetime_data() QTest::newRow("dt3") << "{append({'date':dt0});get(0).date=undefined;get(0).date}" << dt; } -void tst_qquicklistmodel::datetime() +void tst_qqmllistmodel::datetime() { QFETCH(QString, qml); QFETCH(QDateTime, expected); QQmlEngine engine; - QQuickListModel model; + QQmlListModel model; QQmlEngine::setContextForObject(&model,engine.rootContext()); QDateTime dt0(QDate(1900, 1, 2), QTime( 8, 14)); QDateTime dt1(QDate(2000, 11, 22), QTime(10, 45)); @@ -1253,6 +1253,6 @@ void tst_qquicklistmodel::datetime() QVERIFY(expected == dtResult); } -QTEST_MAIN(tst_qquicklistmodel) +QTEST_MAIN(tst_qqmllistmodel) -#include "tst_qquicklistmodel.moc" +#include "tst_qqmllistmodel.moc" diff --git a/tests/auto/qml/qquicklistmodelworkerscript/data/model.qml b/tests/auto/qml/qqmllistmodelworkerscript/data/model.qml index 5973ea8adf..5973ea8adf 100644 --- a/tests/auto/qml/qquicklistmodelworkerscript/data/model.qml +++ b/tests/auto/qml/qqmllistmodelworkerscript/data/model.qml diff --git a/tests/auto/qml/qquicklistmodelworkerscript/data/script.js b/tests/auto/qml/qqmllistmodelworkerscript/data/script.js index 66a4acb8a8..66a4acb8a8 100644 --- a/tests/auto/qml/qquicklistmodelworkerscript/data/script.js +++ b/tests/auto/qml/qqmllistmodelworkerscript/data/script.js diff --git a/tests/auto/qml/qquicklistmodelworkerscript/data/workerremoveelement.js b/tests/auto/qml/qqmllistmodelworkerscript/data/workerremoveelement.js index cb9dfa66aa..cb9dfa66aa 100644 --- a/tests/auto/qml/qquicklistmodelworkerscript/data/workerremoveelement.js +++ b/tests/auto/qml/qqmllistmodelworkerscript/data/workerremoveelement.js diff --git a/tests/auto/qml/qquicklistmodelworkerscript/data/workerremoveelement.qml b/tests/auto/qml/qqmllistmodelworkerscript/data/workerremoveelement.qml index e2361acf6b..e2361acf6b 100644 --- a/tests/auto/qml/qquicklistmodelworkerscript/data/workerremoveelement.qml +++ b/tests/auto/qml/qqmllistmodelworkerscript/data/workerremoveelement.qml diff --git a/tests/auto/qml/qquicklistmodelworkerscript/data/workerremovelist.js b/tests/auto/qml/qqmllistmodelworkerscript/data/workerremovelist.js index f63dd68839..f63dd68839 100644 --- a/tests/auto/qml/qquicklistmodelworkerscript/data/workerremovelist.js +++ b/tests/auto/qml/qqmllistmodelworkerscript/data/workerremovelist.js diff --git a/tests/auto/qml/qquicklistmodelworkerscript/data/workerremovelist.qml b/tests/auto/qml/qqmllistmodelworkerscript/data/workerremovelist.qml index bdb5e024d8..bdb5e024d8 100644 --- a/tests/auto/qml/qquicklistmodelworkerscript/data/workerremovelist.qml +++ b/tests/auto/qml/qqmllistmodelworkerscript/data/workerremovelist.qml diff --git a/tests/auto/qml/qquicklistmodelworkerscript/data/workersync.js b/tests/auto/qml/qqmllistmodelworkerscript/data/workersync.js index 9b8d8fa7f3..9b8d8fa7f3 100644 --- a/tests/auto/qml/qquicklistmodelworkerscript/data/workersync.js +++ b/tests/auto/qml/qqmllistmodelworkerscript/data/workersync.js diff --git a/tests/auto/qml/qquicklistmodelworkerscript/data/workersync.qml b/tests/auto/qml/qqmllistmodelworkerscript/data/workersync.qml index c21cd43e7e..c21cd43e7e 100644 --- a/tests/auto/qml/qquicklistmodelworkerscript/data/workersync.qml +++ b/tests/auto/qml/qqmllistmodelworkerscript/data/workersync.qml diff --git a/tests/auto/qml/qquicklistmodelworkerscript/qquicklistmodelworkerscript.pro b/tests/auto/qml/qqmllistmodelworkerscript/qqmllistmodelworkerscript.pro index 07875722f1..14f0604a9b 100644 --- a/tests/auto/qml/qquicklistmodelworkerscript/qquicklistmodelworkerscript.pro +++ b/tests/auto/qml/qqmllistmodelworkerscript/qqmllistmodelworkerscript.pro @@ -1,8 +1,8 @@ CONFIG += testcase -TARGET = tst_qquicklistmodelworkerscript +TARGET = tst_qqmllistmodelworkerscript macx:CONFIG -= app_bundle -SOURCES += tst_qquicklistmodelworkerscript.cpp +SOURCES += tst_qqmllistmodelworkerscript.cpp include (../../shared/util.pri) diff --git a/tests/auto/qml/qquicklistmodelworkerscript/tst_qquicklistmodelworkerscript.cpp b/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp index 8d5f34c010..a0edfb6891 100644 --- a/tests/auto/qml/qquicklistmodelworkerscript/tst_qquicklistmodelworkerscript.cpp +++ b/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp @@ -42,7 +42,7 @@ #include <QtQuick/private/qquickitem_p.h> #include <QtQuick/private/qquicktext_p.h> #include <QtQml/private/qqmlengine_p.h> -#include <QtQml/private/qquicklistmodel_p.h> +#include <QtQml/private/qqmllistmodel_p.h> #include <QtQml/private/qqmlexpression_p.h> #include <QQmlComponent> @@ -81,18 +81,18 @@ static bool isValidErrorMessage(const QString &msg, bool dynamicRoleTest) return valid; } -class tst_qquicklistmodelworkerscript : public QQmlDataTest +class tst_qqmllistmodelworkerscript : public QQmlDataTest { Q_OBJECT public: - tst_qquicklistmodelworkerscript() + tst_qqmllistmodelworkerscript() { qRegisterMetaType<QVector<int> >(); } private: - int roleFromName(const QQuickListModel *model, const QString &roleName); - QQuickItem *createWorkerTest(QQmlEngine *eng, QQmlComponent *component, QQuickListModel *model); + int roleFromName(const QQmlListModel *model, const QString &roleName); + QQuickItem *createWorkerTest(QQmlEngine *eng, QQmlComponent *component, QQmlListModel *model); void waitForWorker(QQuickItem *item); static bool compareVariantList(const QVariantList &testList, QVariant object); @@ -119,11 +119,11 @@ private slots: void dynamic_role(); }; -bool tst_qquicklistmodelworkerscript::compareVariantList(const QVariantList &testList, QVariant object) +bool tst_qqmllistmodelworkerscript::compareVariantList(const QVariantList &testList, QVariant object) { bool allOk = true; - QQuickListModel *model = qobject_cast<QQuickListModel *>(object.value<QObject *>()); + QQmlListModel *model = qobject_cast<QQmlListModel *>(object.value<QObject *>()); if (model == 0) return false; @@ -165,12 +165,12 @@ bool tst_qquicklistmodelworkerscript::compareVariantList(const QVariantList &tes return allOk; } -int tst_qquicklistmodelworkerscript::roleFromName(const QQuickListModel *model, const QString &roleName) +int tst_qqmllistmodelworkerscript::roleFromName(const QQmlListModel *model, const QString &roleName) { return model->roleNames().key(roleName.toUtf8(), -1); } -QQuickItem *tst_qquicklistmodelworkerscript::createWorkerTest(QQmlEngine *eng, QQmlComponent *component, QQuickListModel *model) +QQuickItem *tst_qqmllistmodelworkerscript::createWorkerTest(QQmlEngine *eng, QQmlComponent *component, QQmlListModel *model) { QQuickItem *item = qobject_cast<QQuickItem*>(component->create()); QQmlEngine::setContextForObject(model, eng->rootContext()); @@ -179,7 +179,7 @@ QQuickItem *tst_qquicklistmodelworkerscript::createWorkerTest(QQmlEngine *eng, Q return item; } -void tst_qquicklistmodelworkerscript::waitForWorker(QQuickItem *item) +void tst_qqmllistmodelworkerscript::waitForWorker(QQuickItem *item) { QQmlProperty prop(item, "done"); QVERIFY(prop.isValid()); @@ -198,7 +198,7 @@ void tst_qquicklistmodelworkerscript::waitForWorker(QQuickItem *item) QVERIFY(prop.read().toBool()); } -void tst_qquicklistmodelworkerscript::dynamic_data() +void tst_qqmllistmodelworkerscript::dynamic_data() { QTest::addColumn<QString>("script"); QTest::addColumn<int>("result"); @@ -339,12 +339,12 @@ void tst_qquicklistmodelworkerscript::dynamic_data() } } -void tst_qquicklistmodelworkerscript::dynamic_worker_data() +void tst_qqmllistmodelworkerscript::dynamic_worker_data() { dynamic_data(); } -void tst_qquicklistmodelworkerscript::dynamic_worker() +void tst_qqmllistmodelworkerscript::dynamic_worker() { QFETCH(QString, script); QFETCH(int, result); @@ -357,7 +357,7 @@ void tst_qquicklistmodelworkerscript::dynamic_worker() // This is same as dynamic() except it applies the test to a ListModel called // from a WorkerScript. - QQuickListModel model; + QQmlListModel model; model.setDynamicRoles(dynamicRoles); QQmlEngine eng; QQmlComponent component(&eng, testFileUrl("model.qml")); @@ -389,12 +389,12 @@ void tst_qquicklistmodelworkerscript::dynamic_worker() qApp->processEvents(); } -void tst_qquicklistmodelworkerscript::dynamic_worker_sync_data() +void tst_qqmllistmodelworkerscript::dynamic_worker_sync_data() { dynamic_data(); } -void tst_qquicklistmodelworkerscript::dynamic_worker_sync() +void tst_qqmllistmodelworkerscript::dynamic_worker_sync() { QFETCH(QString, script); QFETCH(int, result); @@ -408,7 +408,7 @@ void tst_qquicklistmodelworkerscript::dynamic_worker_sync() // from the worker script, calls sync(), and tests the changes are reflected in the // list in the main thread - QQuickListModel model; + QQmlListModel model; model.setDynamicRoles(dynamicRoles); QQmlEngine eng; QQmlComponent component(&eng, testFileUrl("model.qml")); @@ -439,7 +439,7 @@ void tst_qquicklistmodelworkerscript::dynamic_worker_sync() qApp->processEvents(); } -void tst_qquicklistmodelworkerscript::get_data() +void tst_qqmllistmodelworkerscript::get_data() { QTest::addColumn<QString>("expression"); QTest::addColumn<int>("index"); @@ -463,7 +463,7 @@ void tst_qquicklistmodelworkerscript::get_data() } } -void tst_qquicklistmodelworkerscript::get_worker() +void tst_qqmllistmodelworkerscript::get_worker() { QFETCH(QString, expression); QFETCH(int, index); @@ -471,7 +471,7 @@ void tst_qquicklistmodelworkerscript::get_worker() QFETCH(QVariant, roleValue); QFETCH(bool, dynamicRoles); - QQuickListModel model; + QQmlListModel model; model.setDynamicRoles(dynamicRoles); QQmlEngine eng; QQmlComponent component(&eng, testFileUrl("model.qml")); @@ -513,12 +513,12 @@ void tst_qquicklistmodelworkerscript::get_worker() delete item; } -void tst_qquicklistmodelworkerscript::get_worker_data() +void tst_qqmllistmodelworkerscript::get_worker_data() { get_data(); } -void tst_qquicklistmodelworkerscript::property_changes_data() +void tst_qqmllistmodelworkerscript::property_changes_data() { QTest::addColumn<QString>("script_setup"); QTest::addColumn<QString>("script_change"); @@ -591,7 +591,7 @@ void tst_qquicklistmodelworkerscript::property_changes_data() } } -void tst_qquicklistmodelworkerscript::property_changes_worker() +void tst_qqmllistmodelworkerscript::property_changes_worker() { QFETCH(QString, script_setup); QFETCH(QString, script_change); @@ -600,7 +600,7 @@ void tst_qquicklistmodelworkerscript::property_changes_worker() QFETCH(bool, itemsChanged); QFETCH(bool, dynamicRoles); - QQuickListModel model; + QQmlListModel model; model.setDynamicRoles(dynamicRoles); QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("model.qml")); @@ -631,12 +631,12 @@ void tst_qquicklistmodelworkerscript::property_changes_worker() qApp->processEvents(); } -void tst_qquicklistmodelworkerscript::property_changes_worker_data() +void tst_qqmllistmodelworkerscript::property_changes_worker_data() { property_changes_data(); } -void tst_qquicklistmodelworkerscript::worker_sync_data() +void tst_qqmllistmodelworkerscript::worker_sync_data() { QTest::addColumn<bool>("dynamicRoles"); @@ -644,11 +644,11 @@ void tst_qquicklistmodelworkerscript::worker_sync_data() QTest::newRow("dynamicRoles") << true; } -void tst_qquicklistmodelworkerscript::worker_sync() +void tst_qqmllistmodelworkerscript::worker_sync() { QFETCH(bool, dynamicRoles); - QQuickListModel model; + QQmlListModel model; model.setDynamicRoles(dynamicRoles); QQmlEngine eng; QQmlComponent component(&eng, testFileUrl("workersync.qml")); @@ -661,7 +661,7 @@ void tst_qquicklistmodelworkerscript::worker_sync() QVERIFY(model.count() == 2); QVariant childData = model.data(0, 0); - QQuickListModel *childModel = qobject_cast<QQuickListModel *>(childData.value<QObject *>()); + QQmlListModel *childModel = qobject_cast<QQmlListModel *>(childData.value<QObject *>()); QVERIFY(childModel); QVERIFY(childModel->count() == 1); @@ -704,16 +704,16 @@ void tst_qquicklistmodelworkerscript::worker_sync() qApp->processEvents(); } -void tst_qquicklistmodelworkerscript::worker_remove_element_data() +void tst_qqmllistmodelworkerscript::worker_remove_element_data() { worker_sync_data(); } -void tst_qquicklistmodelworkerscript::worker_remove_element() +void tst_qqmllistmodelworkerscript::worker_remove_element() { QFETCH(bool, dynamicRoles); - QQuickListModel model; + QQmlListModel model; model.setDynamicRoles(dynamicRoles); QQmlEngine eng; QQmlComponent component(&eng, testFileUrl("workerremoveelement.qml")); @@ -746,7 +746,7 @@ void tst_qquicklistmodelworkerscript::worker_remove_element() { //don't crash if model was deleted earlier - QQuickListModel* model = new QQuickListModel; + QQmlListModel* model = new QQmlListModel; model->setDynamicRoles(dynamicRoles); QQmlEngine eng; QQmlComponent component(&eng, testFileUrl("workerremoveelement.qml")); @@ -767,16 +767,16 @@ void tst_qquicklistmodelworkerscript::worker_remove_element() } } -void tst_qquicklistmodelworkerscript::worker_remove_list_data() +void tst_qqmllistmodelworkerscript::worker_remove_list_data() { worker_sync_data(); } -void tst_qquicklistmodelworkerscript::worker_remove_list() +void tst_qqmllistmodelworkerscript::worker_remove_list() { QFETCH(bool, dynamicRoles); - QQuickListModel model; + QQmlListModel model; model.setDynamicRoles(dynamicRoles); QQmlEngine eng; QQmlComponent component(&eng, testFileUrl("workerremovelist.qml")); @@ -808,7 +808,7 @@ void tst_qquicklistmodelworkerscript::worker_remove_list() qApp->processEvents(); } -void tst_qquicklistmodelworkerscript::dynamic_role_data() +void tst_qqmllistmodelworkerscript::dynamic_role_data() { QTest::addColumn<QString>("preamble"); QTest::addColumn<QString>("script"); @@ -817,13 +817,13 @@ void tst_qquicklistmodelworkerscript::dynamic_role_data() QTest::newRow("sync1") << "{append({'a':[{'b':1},{'b':2}]})}" << "{get(0).a = 'string';count}" << 1; } -void tst_qquicklistmodelworkerscript::dynamic_role() +void tst_qqmllistmodelworkerscript::dynamic_role() { QFETCH(QString, preamble); QFETCH(QString, script); QFETCH(int, result); - QQuickListModel model; + QQmlListModel model; model.setDynamicRoles(true); QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("model.qml")); @@ -854,6 +854,6 @@ void tst_qquicklistmodelworkerscript::dynamic_role() qApp->processEvents(); } -QTEST_MAIN(tst_qquicklistmodelworkerscript) +QTEST_MAIN(tst_qqmllistmodelworkerscript) -#include "tst_qquicklistmodelworkerscript.moc" +#include "tst_qqmllistmodelworkerscript.moc" diff --git a/tests/auto/qml/qqmlmetatype/data/CompositeType.qml b/tests/auto/qml/qqmlmetatype/data/CompositeType.qml new file mode 100644 index 0000000000..bc2abca42b --- /dev/null +++ b/tests/auto/qml/qqmlmetatype/data/CompositeType.qml @@ -0,0 +1,5 @@ +import QtQml 2.0 + +QtObject { + property int foo +} diff --git a/tests/auto/qml/qqmlmetatype/data/ImplicitType.qml b/tests/auto/qml/qqmlmetatype/data/ImplicitType.qml new file mode 100644 index 0000000000..ca2bcef5bf --- /dev/null +++ b/tests/auto/qml/qqmlmetatype/data/ImplicitType.qml @@ -0,0 +1,5 @@ +import QtQml 2.0 + +QtObject { + property int bar +} diff --git a/tests/auto/qml/qqmlmetatype/data/testImplicitComposite.qml b/tests/auto/qml/qqmlmetatype/data/testImplicitComposite.qml new file mode 100644 index 0000000000..f838c6995f --- /dev/null +++ b/tests/auto/qml/qqmlmetatype/data/testImplicitComposite.qml @@ -0,0 +1,3 @@ +import "." + +ImplicitType{} diff --git a/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro b/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro index b24f006bad..a9a6a32a2b 100644 --- a/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro +++ b/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro @@ -3,6 +3,9 @@ TARGET = tst_qqmlmetatype SOURCES += tst_qqmlmetatype.cpp macx:CONFIG -= app_bundle +TESTDATA = data/* +include (../../shared/util.pri) + CONFIG += parallel_test QT += core-private gui-private qml-private testlib v8-private DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp index d5dd364e25..90023222d3 100644 --- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp +++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp @@ -41,12 +41,16 @@ #include <qtest.h> #include <qqml.h> +#include <qqmlprivate.h> +#include <qqmlengine.h> +#include <qqmlcomponent.h> #include <private/qqmlmetatype_p.h> #include <private/qqmlpropertyvalueinterceptor_p.h> #include <private/qhashedstring_p.h> +#include "../../shared/util.h" -class tst_qqmlmetatype : public QObject +class tst_qqmlmetatype : public QQmlDataTest { Q_OBJECT public: @@ -60,6 +64,8 @@ private slots: void qmlPropertyValueInterceptorCast(); void qmlType(); void invalidQmlTypeName(); + void registrationType(); + void compositeType(); void isList(); @@ -77,6 +83,13 @@ public: }; QML_DECLARE_TYPE(TestType); +QObject *testTypeProvider(QQmlEngine *engine, QJSEngine *scriptEngine) +{ + Q_UNUSED(engine); + Q_UNUSED(scriptEngine); + return new TestType(); +} + class ParserStatusTestType : public QObject, public QQmlParserStatus { Q_OBJECT @@ -108,10 +121,15 @@ QML_DECLARE_TYPE(ValueInterceptorTestType); void tst_qqmlmetatype::initTestCase() { + QQmlDataTest::initTestCase(); qmlRegisterType<TestType>("Test", 1, 0, "TestType"); + qmlRegisterSingletonType<TestType>("Test", 1, 0, "TestTypeSingleton", testTypeProvider); qmlRegisterType<ParserStatusTestType>("Test", 1, 0, "ParserStatusTestType"); qmlRegisterType<ValueSourceTestType>("Test", 1, 0, "ValueSourceTestType"); qmlRegisterType<ValueInterceptorTestType>("Test", 1, 0, "ValueInterceptorTestType"); + + QUrl testTypeUrl(testFileUrl("CompositeType.qml")); + qmlRegisterType(testTypeUrl, "Test", 1, 0, "TestTypeComposite"); } void tst_qqmlmetatype::qmlParserStatusCast() @@ -228,6 +246,44 @@ void tst_qqmlmetatype::defaultObject() QCOMPARE(QString(QQmlMetaType::defaultProperty(&t).name()), QString("foo")); } +void tst_qqmlmetatype::registrationType() +{ + QQmlType *type = QQmlMetaType::qmlType(QString("TestType"), QString("Test"), 1, 0); + QVERIFY(type); + QVERIFY(!type->isInterface()); + QVERIFY(!type->isSingleton()); + QVERIFY(!type->isComposite()); + + type = QQmlMetaType::qmlType(QString("TestTypeSingleton"), QString("Test"), 1, 0); + QVERIFY(type); + QVERIFY(!type->isInterface()); + QVERIFY(type->isSingleton()); + QVERIFY(!type->isComposite()); + + type = QQmlMetaType::qmlType(QString("TestTypeComposite"), QString("Test"), 1, 0); + QVERIFY(type); + QVERIFY(!type->isInterface()); + QVERIFY(!type->isSingleton()); + QVERIFY(type->isComposite()); +} + +void tst_qqmlmetatype::compositeType() +{ + QQmlEngine engine; + + //Loading the test file also loads all composite types it imports + QQmlComponent c(&engine, testFileUrl("testImplicitComposite.qml")); + QObject* obj = c.create(); + QVERIFY(obj); + + QQmlType *type = QQmlMetaType::qmlType(QString("ImplicitType"), QString(""), 1, 0); + QVERIFY(type); + QVERIFY(type->module() == QLatin1String("")); + QVERIFY(type->elementName() == QLatin1String("ImplicitType")); + QCOMPARE(type->qmlTypeName(), QLatin1String("ImplicitType")); + QCOMPARE(type->sourceUrl(), testFileUrl("ImplicitType.qml")); +} + QTEST_MAIN(tst_qqmlmetatype) #include "tst_qqmlmetatype.moc" diff --git a/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType/qmldir deleted file mode 100644 index 0a8b5d46eb..0000000000 --- a/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin plugin diff --git a/tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp b/tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp index ae37b6a4fb..fa3b190826 100644 --- a/tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp +++ b/tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp @@ -161,7 +161,7 @@ public: private slots: void initTestCase() Q_DECL_OVERRIDE; void cleanupTestCase(); - void connectNotify(); + void testConnectNotify(); void removeV4Binding(); void removeV4Binding2(); @@ -215,7 +215,7 @@ void tst_qqmlnotifier::cleanupTestCase() exportedObject = 0; } -void tst_qqmlnotifier::connectNotify() +void tst_qqmlnotifier::testConnectNotify() { createObjects(); diff --git a/tests/auto/qml/qqmlparser/qqmlparser.pro b/tests/auto/qml/qqmlparser/qqmlparser.pro index f181a876e8..c666b71d6c 100644 --- a/tests/auto/qml/qqmlparser/qqmlparser.pro +++ b/tests/auto/qml/qqmlparser/qqmlparser.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qqmlparser -QT += qmldevtools-private testlib gui-private +QT += qml-private testlib macx:CONFIG -= app_bundle SOURCES += tst_qqmlparser.cpp diff --git a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp index ec55709d35..3d08ec3e16 100644 --- a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp +++ b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp @@ -75,15 +75,9 @@ using namespace QQmlJS; class Check: public AST::Visitor { - Engine *engine; QList<AST::Node *> nodeStack; public: - Check(Engine *engine) - : engine(engine) - { - } - void operator()(AST::Node *node) { AST::Node::accept(node, this); @@ -206,7 +200,7 @@ void tst_qqmlparser::qmlParser() else parser.parseProgram(); - check::Check chk(&engine); + check::Check chk; chk(parser.rootNode()); } #endif diff --git a/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp index 46e0c9e436..a2bf06c2ba 100644 --- a/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp +++ b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp @@ -145,7 +145,7 @@ void tst_QQuickWorkerScript::messaging_data() void tst_QQuickWorkerScript::messaging_sendQObjectList() { - // Not allowed to send QObjects other than QQuickListModelWorkerAgent + // Not allowed to send QObjects other than QQmlListModelWorkerAgent // instances. If objects are sent in a list, they will be sent as 'undefined' // js values. diff --git a/tests/auto/qml/qtqmlmodules/data/base.qml b/tests/auto/qml/qtqmlmodules/data/base.qml new file mode 100644 index 0000000000..942b270572 --- /dev/null +++ b/tests/auto/qml/qtqmlmodules/data/base.qml @@ -0,0 +1,14 @@ +import QtQml 2.0 + +QtObject { + property bool success: { + prop1 != undefined && + prop2 != undefined && + prop3 != undefined && + prop4 != undefined + } + property Component prop1: Component { QtObject {}} + property Timer prop2: Timer {} + property Connections prop3: Connections{} + property Binding prop4: Binding{} +} diff --git a/tests/auto/qml/qtqmlmodules/data/models.qml b/tests/auto/qml/qtqmlmodules/data/models.qml new file mode 100644 index 0000000000..d253565932 --- /dev/null +++ b/tests/auto/qml/qtqmlmodules/data/models.qml @@ -0,0 +1,15 @@ +import QtQml 2.0 +import QtQml.Models 2.1 + +QtObject { + property bool success: { + prop1 != undefined && + prop2 != undefined && + prop3 != undefined && + prop4 != undefined + } + property DelegateModelGroup prop1: DelegateModelGroup{} + property DelegateModel prop2: DelegateModel{} + property ObjectModel prop3: ObjectModel{} + property ListModel prop4: ListModel{ListElement{dummy: true}} +} diff --git a/tests/auto/qml/qtqmlmodules/data/unavailable.qml b/tests/auto/qml/qtqmlmodules/data/unavailable.qml new file mode 100644 index 0000000000..5841e3f677 --- /dev/null +++ b/tests/auto/qml/qtqmlmodules/data/unavailable.qml @@ -0,0 +1,35 @@ +import QtQml 2.0 + +QtObject { + id: root + property bool success: false; + Component.onCompleted: { + var strings = [ + "QtObject{}", + "Binding{}", + "Connections{}", + "Timer{}", + "Component{QtObject{}}", + "ListModel{ListElement{}}", + "ObjectModel{QtObject{}}", + "import QtQml 2.0 Item{}", + "import QtQml 2.0 ListModel{}", + "import QtQml 2.0 ObjectModel{}" + ]; + var idx; + for (idx in strings) { + var errored = false; + var item; + try { + item = Qt.createQmlObject(strings[idx], root); + } catch (err) { + errored = true; + } + if (!errored) { + console.log("It worked? ", item); + return; + } + } + root.success = true; + } +} diff --git a/tests/auto/qml/qtqmlmodules/qtqmlmodules.pro b/tests/auto/qml/qtqmlmodules/qtqmlmodules.pro new file mode 100644 index 0000000000..36ece8d7e0 --- /dev/null +++ b/tests/auto/qml/qtqmlmodules/qtqmlmodules.pro @@ -0,0 +1,12 @@ +CONFIG += testcase +TARGET = tst_qtqmlmodules +SOURCES += tst_qtqmlmodules.cpp + +include (../../shared/util.pri) + +macx:CONFIG -= app_bundle + +TESTDATA = data/* + +QT += core-private v8-private qml-private testlib gui gui-private +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qtqmlmodules/tst_qtqmlmodules.cpp b/tests/auto/qml/qtqmlmodules/tst_qtqmlmodules.cpp new file mode 100644 index 0000000000..1e98c53694 --- /dev/null +++ b/tests/auto/qml/qtqmlmodules/tst_qtqmlmodules.cpp @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research in Motion. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qtest.h> +#include <QDebug> +#include <QQmlEngine> +#include <QQmlComponent> +#include "../../shared/util.h" + +class tst_qtqmlmodules : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qtqmlmodules() {} + +private slots: + void baseTypes(); + void modelsTypes(); + void unavailableTypes(); +}; + +void tst_qtqmlmodules::baseTypes() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("base.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QVERIFY(object->property("success").toBool()); + + delete object; +} + +void tst_qtqmlmodules::modelsTypes() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("models.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QVERIFY(object->property("success").toBool()); + + delete object; +} + +void tst_qtqmlmodules::unavailableTypes() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("unavailable.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QVERIFY(object->property("success").toBool()); + + delete object; +} + +QTEST_MAIN(tst_qtqmlmodules) + +#include "tst_qtqmlmodules.moc" diff --git a/tests/auto/qml/v4/data/equals.qml b/tests/auto/qml/v4/data/equals.qml index c32603cc7e..2862bb7ac9 100644 --- a/tests/auto/qml/v4/data/equals.qml +++ b/tests/auto/qml/v4/data/equals.qml @@ -44,5 +44,8 @@ QtObject { property bool test32: true != zero property bool test33: true == 1 property bool test34: true != 1 + + property bool test35: "a\ +b" === "ab" } diff --git a/tests/auto/qmldevtools/compile/compile.pro b/tests/auto/qmldevtools/compile/compile.pro index ffe0778763..1c65daf909 100644 --- a/tests/auto/qmldevtools/compile/compile.pro +++ b/tests/auto/qmldevtools/compile/compile.pro @@ -1,9 +1,12 @@ -CONFIG += testcase +option(host_build) TARGET = tst_compile -QT = core qmldevtools-private testlib +force_bootstrap: \ + QT = bootstrap-private +else: \ + QT = core +QT += qmldevtools-private macx:CONFIG -= app_bundle SOURCES += tst_compile.cpp -CONFIG += parallel_test DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qmldevtools/compile/tst_compile.cpp b/tests/auto/qmldevtools/compile/tst_compile.cpp index ad63922763..6b13d1b4bb 100644 --- a/tests/auto/qmldevtools/compile/tst_compile.cpp +++ b/tests/auto/qmldevtools/compile/tst_compile.cpp @@ -38,7 +38,6 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include <qtest.h> #include <private/qqmljsengine_p.h> #include <private/qqmljslexer_p.h> @@ -46,17 +45,9 @@ #include <private/qqmljsastvisitor_p.h> #include <private/qqmljsast_p.h> -class tst_compile : public QObject +int main() { - Q_OBJECT -public: - tst_compile() { } - -private slots: // Nothing - this test just makes sure that the QmlDevTools headers // are present, and that we can link against the library. -}; - -QTEST_MAIN(tst_compile) - -#include "tst_compile.moc" + return 0; +} diff --git a/tests/auto/quick/dialogs/data/RectWithFileDialog.qml b/tests/auto/quick/dialogs/data/RectWithFileDialog.qml new file mode 100644 index 0000000000..ca7ecc948a --- /dev/null +++ b/tests/auto/quick/dialogs/data/RectWithFileDialog.qml @@ -0,0 +1,33 @@ +import QtQuick 2.0 +import QtQuick.Dialogs 1.0 + +Rectangle { + width: 1024 + height: 320 + property alias fileDialog: fileDialog + property alias label: label + property alias mouseArea: mouseArea + + FileDialog { + id: fileDialog + title: "Choose some files" + selectMultiple: true + nameFilters: [ "QML files (*.qml)", "All files (*)" ] + selectedNameFilter: "QML files (*.qml)" + onAccepted: label.text = fileDialog.filePaths + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: fileDialog.visible = !fileDialog.visible + } + + Text { + id: label + text: "Click to open a file dialog" + wrapMode: Text.Wrap + anchors.fill: parent + anchors.margins: 10 + } +} diff --git a/tests/auto/quick/dialogs/dialogs.pro b/tests/auto/quick/dialogs/dialogs.pro new file mode 100644 index 0000000000..d28c623a1f --- /dev/null +++ b/tests/auto/quick/dialogs/dialogs.pro @@ -0,0 +1,17 @@ +CONFIG += testcase +TARGET = tst_dialogs +SOURCES += tst_dialogs.cpp + +include (../../shared/util.pri) + +macx:CONFIG -= app_bundle + +CONFIG += parallel_test +QT += core-private gui-private qml-private quick-private v8-private testlib + +TESTDATA = data/* + +OTHER_FILES += \ + data/FileDialog.qml \ + +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/dialogs/tst_dialogs.cpp b/tests/auto/quick/dialogs/tst_dialogs.cpp new file mode 100644 index 0000000000..9f0dc8ec18 --- /dev/null +++ b/tests/auto/quick/dialogs/tst_dialogs.cpp @@ -0,0 +1,156 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qtest.h> +#include "../../shared/util.h" +#include <QtQuick/QQuickItem> +#include <QtQuick/QQuickView> +#include <QSignalSpy> + +class tst_dialogs : public QQmlDataTest +{ + Q_OBJECT +public: + +private slots: + void initTestCase() + { + QQmlDataTest::initTestCase(); + } + + // FileDialog + void fileDialogDefaultModality(); + void fileDialogNonModal(); + void fileDialogNameFilters(); + +private: +}; + +void tst_dialogs::fileDialogDefaultModality() +{ + QQuickView *window = new QQuickView; + QScopedPointer<QQuickWindow> cleanup(window); + + window->setSource(testFileUrl("RectWithFileDialog.qml")); + window->setGeometry(240,240,1024,320); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + // Click to show + QObject *dlg = qvariant_cast<QObject *>(window->rootObject()->property("fileDialog")); + QSignalSpy spyVisibilityChanged(dlg, SIGNAL(visibilityChanged())); + QTest::mouseClick(window, Qt::LeftButton, 0, QPoint(1000, 100)); // show + QTRY_VERIFY(spyVisibilityChanged.count() > 0); + int visibilityChangedCount = spyVisibilityChanged.count(); + // Can't hide by clicking the main window, because dialog is modal. + QTest::mouseClick(window, Qt::LeftButton, 0, QPoint(1000, 100)); +#ifdef Q_OS_MAC + /* + On the Mac, if you send an event directly to a window, the modal dialog + doesn't block the event, so the window will process it normally. This + is a different code path compared to having a user click the mouse and + generate a native event; in that case the OS does the filtering itself, + and Qt will not even see the event. But simulating real events in the + test framework is generally unstable. So there isn't a good way to test + modality on the mac. + */ + QSKIP("Modality test doesn't work on Mac OS"); +#endif + // So we expect no change in visibility. + QCOMPARE(spyVisibilityChanged.count(), visibilityChangedCount); + + QCOMPARE(dlg->property("visible").toBool(), true); + QMetaObject::invokeMethod(dlg, "close"); + QTRY_VERIFY(spyVisibilityChanged.count() > visibilityChangedCount); + visibilityChangedCount = spyVisibilityChanged.count(); + QCOMPARE(dlg->property("visible").toBool(), false); + QMetaObject::invokeMethod(dlg, "open"); + QTRY_VERIFY(spyVisibilityChanged.count() > visibilityChangedCount); + QCOMPARE(dlg->property("visible").toBool(), true); + QCOMPARE(dlg->property("modality").toInt(), (int)Qt::WindowModal); +} + +void tst_dialogs::fileDialogNonModal() +{ + QQuickView *window = new QQuickView; + QScopedPointer<QQuickWindow> cleanup(window); + + window->setSource(testFileUrl("RectWithFileDialog.qml")); + window->setGeometry(240,240,1024,320); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + // Click to toggle visibility + QObject *dlg = qvariant_cast<QObject *>(window->rootObject()->property("fileDialog")); + dlg->setProperty("modality", QVariant((int)Qt::NonModal)); + QSignalSpy spyVisibilityChanged(dlg, SIGNAL(visibilityChanged())); + QTest::mouseClick(window, Qt::LeftButton, 0, QPoint(1000, 100)); // show + int visibilityChangedCount = spyVisibilityChanged.count(); + QTRY_VERIFY(visibilityChangedCount > 0); + QCOMPARE(dlg->property("visible").toBool(), true); + QTest::mouseClick(window, Qt::LeftButton, 0, QPoint(1000, 100)); // hide + QTRY_VERIFY(spyVisibilityChanged.count() > visibilityChangedCount); + QCOMPARE(dlg->property("visible").toBool(), false); + QCOMPARE(dlg->property("modality").toInt(), (int)Qt::NonModal); +} + +void tst_dialogs::fileDialogNameFilters() +{ + QQuickView *window = new QQuickView; + QScopedPointer<QQuickWindow> cleanup(window); + + window->setSource(testFileUrl("RectWithFileDialog.qml")); + window->setGeometry(240,240,1024,320); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QObject *dlg = qvariant_cast<QObject *>(window->rootObject()->property("fileDialog")); + QStringList filters; + filters << "QML files (*.qml)"; + filters << "Image files (*.jpg, *.png, *.gif)"; + filters << "All files (*)"; + dlg->setProperty("nameFilters", QVariant(filters)); + QCOMPARE(dlg->property("selectedNameFilter").toString(), filters.first()); +} + +QTEST_MAIN(tst_dialogs) + +#include "tst_dialogs.moc" diff --git a/tests/auto/quick/examples/tst_examples.cpp b/tests/auto/quick/examples/tst_examples.cpp index 7055fb6e03..9c5fb88af2 100644 --- a/tests/auto/quick/examples/tst_examples.cpp +++ b/tests/auto/quick/examples/tst_examples.cpp @@ -82,11 +82,9 @@ private: QStringList findQmlFiles(const QDir &); QQmlEngine engine; - - QQuickWindow *window; }; -tst_examples::tst_examples() : window(0) +tst_examples::tst_examples() { // Add files to exclude here excludedFiles << "examples/quick/canvas/tiger/tiger.qml"; // QTBUG-26528 @@ -94,7 +92,7 @@ tst_examples::tst_examples() : window(0) // Add directories you want excluded here (don't add examples/, because they install to examples/qtdeclarative/) excludedDirs << "shared"; //Not an example - excludedDirs << "qtquick/text/fonts"; // QTBUG-21415 + excludedDirs << "quick/text/fonts"; // QTBUG-29004 excludedDirs << "snippets/qml/path"; //No root QQuickItem excludedDirs << "tutorials/gettingStartedQml"; //C++ example, but no cpp files in root dir @@ -120,7 +118,6 @@ tst_examples::tst_examples() : window(0) tst_examples::~tst_examples() { - delete window; } void tst_examples::init() @@ -260,6 +257,9 @@ void tst_examples::sgexamples_data() void tst_examples::sgexamples() { QFETCH(QString, file); + QQuickWindow window; + window.setPersistentOpenGLContext(true); + window.setPersistentSceneGraph(true); QQmlComponent component(&engine, QUrl::fromLocalFile(file)); if (component.status() == QQmlComponent::Error) @@ -272,13 +272,11 @@ void tst_examples::sgexamples() component.completeCreate(); QVERIFY(root); - if (!window) { - window = new QQuickWindow(); - window->resize(240, 320); - window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - } - root->setParentItem(window->contentItem()); + window.resize(240, 320); + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + root->setParentItem(window.contentItem()); component.completeCreate(); qApp->processEvents(); @@ -303,6 +301,8 @@ void tst_examples::sgsnippets_data() void tst_examples::sgsnippets() { + QQuickWindow window; + QFETCH(QString, file); QQmlComponent component(&engine, QUrl::fromLocalFile(file)); @@ -316,13 +316,11 @@ void tst_examples::sgsnippets() component.completeCreate(); QVERIFY(root); - if (!window) { - window = new QQuickWindow(); - window->resize(240, 320); - window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - } - root->setParentItem(window->contentItem()); + window.resize(240, 320); + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + root->setParentItem(window.contentItem()); component.completeCreate(); qApp->processEvents(); diff --git a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp index 46141a946e..d0bb075f4e 100644 --- a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp +++ b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp @@ -55,8 +55,6 @@ #include "../../shared/util.h" -typedef QSharedPointer<QAccessibleInterface> QAI; - #define EXPECT(cond) \ do { \ if (!errorAt && !(cond)) { \ @@ -82,14 +80,11 @@ static int verifyHierarchy(QAccessibleInterface *iface) // navigate Ancestor... QAccessibleInterface *parent = if2->parent(); EXPECT(iface->object() == parent->object()); - delete parent; // verify children... if (!errorAt) errorAt = verifyHierarchy(if2); - delete if2; } - delete middleChild; --treelevel; return errorAt; @@ -149,7 +144,6 @@ void tst_QQuickAccessible::commonTests() QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(view); QVERIFY(iface); - delete iface; delete view; } @@ -274,7 +268,7 @@ void tst_QQuickAccessible::quickAttachedProperties() void tst_QQuickAccessible::basicPropertiesTest() { - QAI app = QAI(QAccessible::queryAccessibleInterface(qApp)); + QAccessibleInterface *app = QAccessible::queryAccessibleInterface(qApp); QCOMPARE(app->childCount(), 0); QQuickView *window = new QQuickView(); @@ -282,19 +276,19 @@ void tst_QQuickAccessible::basicPropertiesTest() window->show(); QCOMPARE(app->childCount(), 1); - QAI iface = QAI(QAccessible::queryAccessibleInterface(window)); - QVERIFY(iface.data()); + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(window); + QVERIFY(iface); QCOMPARE(iface->childCount(), 1); - QAI item = QAI(iface->child(0)); - QVERIFY(item.data()); + QAccessibleInterface *item = iface->child(0); + QVERIFY(item); QCOMPARE(item->childCount(), 2); QCOMPARE(item->rect().size(), QSize(400, 400)); QCOMPARE(item->role(), QAccessible::Pane); - QCOMPARE(iface->indexOfChild(item.data()), 0); + QCOMPARE(iface->indexOfChild(item), 0); - QAI text = QAI(item->child(0)); - QVERIFY(text.data()); + QAccessibleInterface *text = item->child(0); + QVERIFY(text); QCOMPARE(text->childCount(), 0); QCOMPARE(text->text(QAccessible::Name), QLatin1String("Hello Accessibility")); @@ -302,10 +296,10 @@ void tst_QQuickAccessible::basicPropertiesTest() QCOMPARE(text->rect().x(), item->rect().x() + 100); QCOMPARE(text->rect().y(), item->rect().y() + 20); QCOMPARE(text->role(), QAccessible::StaticText); - QCOMPARE(item->indexOfChild(text.data()), 0); + QCOMPARE(item->indexOfChild(text), 0); - QAI text2 = QAI(item->child(1)); - QVERIFY(text2.data()); + QAccessibleInterface *text2 = item->child(1); + QVERIFY(text2); QCOMPARE(text2->childCount(), 0); QCOMPARE(text2->text(QAccessible::Name), QLatin1String("The Hello 2 accessible text")); @@ -313,22 +307,22 @@ void tst_QQuickAccessible::basicPropertiesTest() QCOMPARE(text2->rect().x(), item->rect().x() + 100); QCOMPARE(text2->rect().y(), item->rect().y() + 40); QCOMPARE(text2->role(), QAccessible::StaticText); - QCOMPARE(item->indexOfChild(text2.data()), 1); + QCOMPARE(item->indexOfChild(text2), 1); - QCOMPARE(iface->indexOfChild(text2.data()), -1); - QCOMPARE(text2->indexOfChild(item.data()), -1); + QCOMPARE(iface->indexOfChild(text2), -1); + QCOMPARE(text2->indexOfChild(item), -1); delete window; } -QAI topLevelChildAt(QAccessibleInterface *iface, int x, int y) +QAccessibleInterface *topLevelChildAt(QAccessibleInterface *iface, int x, int y) { - QAI child = QAI(iface->childAt(x, y)); + QAccessibleInterface *child = iface->childAt(x, y); if (!child) - return QAI(); + return 0; - QAI childOfChild; - while (childOfChild = QAI(child->childAt(x, y))) { + QAccessibleInterface *childOfChild; + while (childOfChild = child->childAt(x, y)) { child = childOfChild; } return child; @@ -340,45 +334,45 @@ void tst_QQuickAccessible::hitTest() window->setSource(testFileUrl("hittest.qml")); window->show(); - QAI windowIface = QAI(QAccessible::queryAccessibleInterface(window)); - QVERIFY(windowIface.data()); - QAI rootItem = QAI(windowIface->child(0)); + QAccessibleInterface *windowIface = QAccessible::queryAccessibleInterface(window); + QVERIFY(windowIface); + QAccessibleInterface *rootItem = windowIface->child(0); QRect rootRect = rootItem->rect(); // check the root item from app - QAI appIface = QAI(QAccessible::queryAccessibleInterface(qApp)); + QAccessibleInterface *appIface = QAccessible::queryAccessibleInterface(qApp); QVERIFY(appIface); - QAI itemHit(appIface->childAt(rootRect.x() + 200, rootRect.y() + 50)); + QAccessibleInterface *itemHit(appIface->childAt(rootRect.x() + 200, rootRect.y() + 50)); QVERIFY(itemHit); QCOMPARE(rootRect, itemHit->rect()); // hit rect1 - QAI rect1(rootItem->child(0)); + QAccessibleInterface *rect1(rootItem->child(0)); QRect rect1Rect = rect1->rect(); - QAI rootItemIface = QAI(rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10)); + QAccessibleInterface *rootItemIface = rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10); QVERIFY(rootItemIface); QCOMPARE(rect1Rect, rootItemIface->rect()); QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect1")); // should also work from top level (app) - QAI app(QAccessible::queryAccessibleInterface(qApp)); - QAI itemHit2(topLevelChildAt(app.data(), rect1Rect.x() + 10, rect1Rect.y() + 10)); + QAccessibleInterface *app(QAccessible::queryAccessibleInterface(qApp)); + QAccessibleInterface *itemHit2(topLevelChildAt(app, rect1Rect.x() + 10, rect1Rect.y() + 10)); QVERIFY(itemHit2); QCOMPARE(itemHit2->rect(), rect1Rect); QCOMPARE(itemHit2->text(QAccessible::Name), QLatin1String("rect1")); // hit rect201 - QAI rect2(rootItem->child(1)); + QAccessibleInterface *rect2(rootItem->child(1)); QVERIFY(rect2); // FIXME: This is seems broken on mac // QCOMPARE(rect2->rect().translated(rootItem->rect().x(), rootItem->rect().y()), QRect(0, 50, 100, 100)); - QAI rect20(rect2->child(0)); + QAccessibleInterface *rect20(rect2->child(0)); QVERIFY(rect20); - QAI rect201(rect20->child(1)); + QAccessibleInterface *rect201(rect20->child(1)); QVERIFY(rect201); QRect rect201Rect = rect201->rect(); - rootItemIface = QAI(windowIface->childAt(rect201Rect.x() + 20, rect201Rect.y() + 20)); + rootItemIface = windowIface->childAt(rect201Rect.x() + 20, rect201Rect.y() + 20); QVERIFY(rootItemIface); QCOMPARE(rootItemIface->rect(), rect201Rect); QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect201")); @@ -392,29 +386,29 @@ void tst_QQuickAccessible::checkableTest() window->setSource(testFileUrl("checkbuttons.qml")); window->show(); - QAI iface = QAI(QAccessible::queryAccessibleInterface(window)); - QVERIFY(iface.data()); - QAI root = QAI(iface->child(0)); + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(window); + QVERIFY(iface); + QAccessibleInterface *root = iface->child(0); - QAI button1 = QAI(root->child(0)); + QAccessibleInterface *button1 = root->child(0); QCOMPARE(button1->role(), QAccessible::Button); QVERIFY(!(button1->state().checked)); QVERIFY(!(button1->state().checkable)); - QAI button2 = QAI(root->child(1)); + QAccessibleInterface *button2 = root->child(1); QVERIFY(!(button2->state().checked)); QVERIFY(button2->state().checkable); - QAI button3 = QAI(root->child(2)); + QAccessibleInterface *button3 = root->child(2); QVERIFY(button3->state().checked); QVERIFY(button3->state().checkable); - QAI checkBox1 = QAI(root->child(3)); + QAccessibleInterface *checkBox1 = root->child(3); QCOMPARE(checkBox1->role(), QAccessible::CheckBox); QVERIFY((checkBox1->state().checked)); QVERIFY(checkBox1->state().checkable); - QAI checkBox2 = QAI(root->child(4)); + QAccessibleInterface *checkBox2 = root->child(4); QVERIFY(!(checkBox2->state().checked)); QVERIFY(checkBox2->state().checkable); } diff --git a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp index aad1327e6f..201287b2a8 100644 --- a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp +++ b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp @@ -152,9 +152,8 @@ void tst_qquickanimatedimage::mirror_running() QQuickView window; window.setSource(testFileUrl("hearts.qml")); - window.requestActivate(); window.show(); - QTest::qWaitForWindowActive(&window); + QTest::qWaitForWindowExposed(&window); QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(window.rootObject()); QVERIFY(anim); diff --git a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp index 7847268d94..34a1614ac5 100644 --- a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp +++ b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp @@ -93,8 +93,7 @@ void tst_qquickanimatedsprite::test_frameChangedSignal() window->setSource(testFileUrl("frameChange.qml")); window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QTest::qWaitForWindowExposed(window)); QVERIFY(window->rootObject()); QQuickAnimatedSprite* sprite = window->rootObject()->findChild<QQuickAnimatedSprite*>("sprite"); diff --git a/tests/auto/quick/qquickanimations/qquickanimations.pro b/tests/auto/quick/qquickanimations/qquickanimations.pro index f3cf4832e5..747a2afdff 100644 --- a/tests/auto/quick/qquickanimations/qquickanimations.pro +++ b/tests/auto/quick/qquickanimations/qquickanimations.pro @@ -1,4 +1,5 @@ CONFIG += testcase +mac:CONFIG+=insignificant_test # QTBUG-29062 TARGET = tst_qquickanimations SOURCES += tst_qquickanimations.cpp diff --git a/tests/auto/quick/qquickcanvasitem/data/CanvasComponent.qml b/tests/auto/quick/qquickcanvasitem/data/CanvasComponent.qml index b9e8d75f5a..000888a36f 100644 --- a/tests/auto/quick/qquickcanvasitem/data/CanvasComponent.qml +++ b/tests/auto/quick/qquickcanvasitem/data/CanvasComponent.qml @@ -5,6 +5,7 @@ Component { id:canvas Canvas { id:c + antialiasing: false; width:100;height:100 onPaint :{} //this line is needed for some tests (make sure onPaint handler always called property alias paintCount:spyPaint.count @@ -27,4 +28,4 @@ Component { SignalSpy {id: spyImageLoaded;target:c;signalName: "imageLoaded"} SignalSpy {id: spyAvailableChanged;target:c;signalName: "availableChanged"} } -}
\ No newline at end of file +} diff --git a/tests/auto/quick/qquickflickable/qquickflickable.pro b/tests/auto/quick/qquickflickable/qquickflickable.pro index 95c703befe..67d5fc12f0 100644 --- a/tests/auto/quick/qquickflickable/qquickflickable.pro +++ b/tests/auto/quick/qquickflickable/qquickflickable.pro @@ -11,3 +11,4 @@ TESTDATA = data/* QT += core-private gui-private v8-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 +CONFIG+=insignificant_test diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index c4f871fc11..3575dfa012 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -210,10 +210,10 @@ void tst_qquickflickable::boundsBehavior() void tst_qquickflickable::rebound() { - QQuickView *window = new QQuickView; + QScopedPointer<QQuickView> window(new QQuickView); window->setSource(testFileUrl("rebound.qml")); window->show(); - window->requestActivate(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); QVERIFY(window->rootObject() != 0); QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject()); @@ -229,7 +229,7 @@ void tst_qquickflickable::rebound() QSignalSpy hMoveSpy(flickable, SIGNAL(movingHorizontallyChanged())); // flick and test the transition is run - flick(window, QPoint(20,20), QPoint(120,120), 200); + flick(window.data(), QPoint(20,20), QPoint(120,120), 200); QTRY_COMPARE(window->rootObject()->property("transitionsStarted").toInt(), 2); QCOMPARE(hMoveSpy.count(), 1); @@ -259,14 +259,13 @@ void tst_qquickflickable::rebound() #ifdef Q_OS_MAC QSKIP("QTBUG-26696 - sometimes fails on Mac"); - delete window; return; #endif // flick and trigger the transition multiple times // (moving signals are emitted as soon as the first transition starts) - flick(window, QPoint(20,20), QPoint(120,120), 200); // both x and y will bounce back - flick(window, QPoint(20,120), QPoint(120,20), 200); // only x will bounce back + flick(window.data(), QPoint(20,20), QPoint(120,120), 200); // both x and y will bounce back + flick(window.data(), QPoint(20,120), QPoint(120,20), 200); // only x will bounce back QVERIFY(flickable->isMoving()); QVERIFY(window->rootObject()->property("transitionsStarted").toInt() >= 1); @@ -295,7 +294,7 @@ void tst_qquickflickable::rebound() // (i.e. moving but transition->running = false) window->rootObject()->setProperty("transitionEnabled", false); - flick(window, QPoint(20,20), QPoint(120,120), 200); + flick(window.data(), QPoint(20,20), QPoint(120,120), 200); QCOMPARE(window->rootObject()->property("transitionsStarted").toInt(), 0); QCOMPARE(hMoveSpy.count(), 1); QCOMPARE(vMoveSpy.count(), 1); @@ -308,8 +307,6 @@ void tst_qquickflickable::rebound() QCOMPARE(movementStartedSpy.count(), 1); QCOMPARE(movementEndedSpy.count(), 1); QCOMPARE(window->rootObject()->property("transitionsStarted").toInt(), 0); - - delete window; } void tst_qquickflickable::maximumFlickVelocity() @@ -355,7 +352,7 @@ void tst_qquickflickable::pressDelay() QScopedPointer<QQuickView> window(new QQuickView); window->setSource(testFileUrl("pressDelay.qml")); window->show(); - window->requestActivate(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); QVERIFY(window->rootObject() != 0); QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject()); @@ -394,7 +391,7 @@ void tst_qquickflickable::nestedPressDelay() QScopedPointer<QQuickView> window(new QQuickView); window->setSource(testFileUrl("nestedPressDelay.qml")); window->show(); - window->requestActivate(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); QVERIFY(window->rootObject() != 0); QQuickFlickable *outer = qobject_cast<QQuickFlickable*>(window->rootObject()); @@ -503,7 +500,8 @@ void tst_qquickflickable::returnToBounds() { QFETCH(bool, setRebound); - QQuickView *window = new QQuickView; + QScopedPointer<QQuickView> window(new QQuickView); + window->rootContext()->setContextProperty("setRebound", setRebound); window->setSource(testFileUrl("resize.qml")); QVERIFY(window->rootObject() != 0); @@ -534,8 +532,6 @@ void tst_qquickflickable::returnToBounds() QVERIFY(!rebound->running()); QCOMPARE(reboundSpy.count(), setRebound ? 2 : 0); - - delete window; } void tst_qquickflickable::returnToBounds_data() @@ -548,10 +544,10 @@ void tst_qquickflickable::returnToBounds_data() void tst_qquickflickable::wheel() { - QQuickView *window = new QQuickView; + QScopedPointer<QQuickView> window(new QQuickView); window->setSource(testFileUrl("wheel.qml")); window->show(); - window->requestActivate(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); QVERIFY(window->rootObject() != 0); QQuickFlickable *flick = window->rootObject()->findChild<QQuickFlickable*>("flick"); @@ -561,7 +557,7 @@ void tst_qquickflickable::wheel() QPoint pos(200, 200); QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(), QPoint(0,-120), -120, Qt::Vertical, Qt::NoButton, Qt::NoModifier); event.setAccepted(false); - QGuiApplication::sendEvent(window, &event); + QGuiApplication::sendEvent(window.data(), &event); } QTRY_VERIFY(flick->contentY() > 0); @@ -575,13 +571,11 @@ void tst_qquickflickable::wheel() QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(), QPoint(-120,0), -120, Qt::Horizontal, Qt::NoButton, Qt::NoModifier); event.setAccepted(false); - QGuiApplication::sendEvent(window, &event); + QGuiApplication::sendEvent(window.data(), &event); } QTRY_VERIFY(flick->contentX() > 0); QVERIFY(flick->contentY() == 0); - - delete window; } void tst_qquickflickable::movingAndFlicking_data() @@ -616,11 +610,10 @@ void tst_qquickflickable::movingAndFlicking() const QPoint flickFrom(50, 200); // centre - QQuickView *window = new QQuickView; + QScopedPointer<QQuickView> window(new QQuickView); window->setSource(testFileUrl("flickable03.qml")); window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); QVERIFY(window->rootObject() != 0); QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject()); @@ -639,7 +632,7 @@ void tst_qquickflickable::movingAndFlicking() QSignalSpy flickEndSpy(flickable, SIGNAL(flickEnded())); // do a flick that keeps the view within the bounds - flick(window, flickFrom, flickToWithoutSnapBack, 200); + flick(window.data(), flickFrom, flickToWithoutSnapBack, 200); QTRY_VERIFY(flickable->isMoving()); QCOMPARE(flickable->isMovingHorizontally(), horizontalEnabled); @@ -698,7 +691,7 @@ void tst_qquickflickable::movingAndFlicking() flickable->setContentX(0); flickable->setContentY(0); QTRY_VERIFY(!flickable->isMoving()); - flick(window, flickFrom, flickToWithSnapBack, 200); + flick(window.data(), flickFrom, flickToWithSnapBack, 10); QTRY_VERIFY(flickable->isMoving()); QCOMPARE(flickable->isMovingHorizontally(), horizontalEnabled); @@ -742,8 +735,6 @@ void tst_qquickflickable::movingAndFlicking() QCOMPARE(flickable->contentX(), 0.0); QCOMPARE(flickable->contentY(), 0.0); - - delete window; } @@ -779,11 +770,10 @@ void tst_qquickflickable::movingAndDragging() const QPoint moveFrom(50, 200); // centre - QQuickView *window = new QQuickView; + QScopedPointer<QQuickView> window(new QQuickView); window->setSource(testFileUrl("flickable03.qml")); window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowExposed(window)); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); QVERIFY(window->rootObject() != 0); QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject()); @@ -802,10 +792,10 @@ void tst_qquickflickable::movingAndDragging() QSignalSpy moveEndSpy(flickable, SIGNAL(movementEnded())); // start the drag - QTest::mousePress(window, Qt::LeftButton, 0, moveFrom); - QTest::mouseMove(window, moveFrom + moveByWithoutSnapBack); - QTest::mouseMove(window, moveFrom + moveByWithoutSnapBack*2); - QTest::mouseMove(window, moveFrom + moveByWithoutSnapBack*3); + QTest::mousePress(window.data(), Qt::LeftButton, 0, moveFrom); + QTest::mouseMove(window.data(), moveFrom + moveByWithoutSnapBack); + QTest::mouseMove(window.data(), moveFrom + moveByWithoutSnapBack*2); + QTest::mouseMove(window.data(), moveFrom + moveByWithoutSnapBack*3); QTRY_VERIFY(flickable->isMoving()); QCOMPARE(flickable->isMovingHorizontally(), horizontalEnabled); @@ -829,7 +819,7 @@ void tst_qquickflickable::movingAndDragging() QCOMPARE(moveStartSpy.count(), 1); QCOMPARE(dragStartSpy.count(), 1); - QTest::mouseRelease(window, Qt::LeftButton, 0, moveFrom + moveByWithoutSnapBack*3); + QTest::mouseRelease(window.data(), Qt::LeftButton, 0, moveFrom + moveByWithoutSnapBack*3); QVERIFY(!flickable->isDragging()); QVERIFY(!flickable->isDraggingHorizontally()); @@ -878,10 +868,10 @@ void tst_qquickflickable::movingAndDragging() flickable->setContentX(0); flickable->setContentY(0); QTRY_VERIFY(!flickable->isMoving()); - QTest::mousePress(window, Qt::LeftButton, 0, moveFrom); - QTest::mouseMove(window, moveFrom + moveByWithSnapBack); - QTest::mouseMove(window, moveFrom + moveByWithSnapBack*2); - QTest::mouseMove(window, moveFrom + moveByWithSnapBack*3); + QTest::mousePress(window.data(), Qt::LeftButton, 0, moveFrom); + QTest::mouseMove(window.data(), moveFrom + moveByWithSnapBack); + QTest::mouseMove(window.data(), moveFrom + moveByWithSnapBack*2); + QTest::mouseMove(window.data(), moveFrom + moveByWithSnapBack*3); QVERIFY(flickable->isMoving()); QCOMPARE(flickable->isMovingHorizontally(), horizontalEnabled); @@ -902,7 +892,7 @@ void tst_qquickflickable::movingAndDragging() QCOMPARE(dragStartSpy.count(), 1); QCOMPARE(dragEndSpy.count(), 0); - QTest::mouseRelease(window, Qt::LeftButton, 0, moveFrom + moveByWithSnapBack*3); + QTest::mouseRelease(window.data(), Qt::LeftButton, 0, moveFrom + moveByWithSnapBack*3); // should now start snapping back to bounds (moving but not dragging) QVERIFY(flickable->isMoving()); @@ -945,17 +935,14 @@ void tst_qquickflickable::movingAndDragging() QCOMPARE(flickable->contentX(), 0.0); QCOMPARE(flickable->contentY(), 0.0); - - delete window; } void tst_qquickflickable::flickOnRelease() { - QQuickView *window = new QQuickView; + QScopedPointer<QQuickView> window(new QQuickView); window->setSource(testFileUrl("flickable03.qml")); window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowExposed(window)); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); QVERIFY(window->rootObject() != 0); QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject()); @@ -968,9 +955,9 @@ void tst_qquickflickable::flickOnRelease() // underlying drivers will hopefully provide a pre-calculated velocity // (based on more data than what the UI gets), thus making this use case // working even with small movements. - QTest::mousePress(window, Qt::LeftButton, 0, QPoint(50, 300)); - QTest::mouseMove(window, QPoint(50, 10), 10); - QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50, 10), 10); + QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(50, 300)); + QTest::mouseMove(window.data(), QPoint(50, 10), 10); + QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(50, 10), 10); QCOMPARE(vFlickSpy.count(), 1); @@ -982,17 +969,14 @@ void tst_qquickflickable::flickOnRelease() #endif // Stop on a full pixel after user interaction QCOMPARE(flickable->contentY(), (qreal)qRound(flickable->contentY())); - - delete window; } void tst_qquickflickable::pressWhileFlicking() { - QQuickView *window = new QQuickView; + QScopedPointer<QQuickView> window(new QQuickView); window->setSource(testFileUrl("flickable03.qml")); window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowExposed(window)); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); QVERIFY(window->rootObject() != 0); QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject()); @@ -1007,7 +991,7 @@ void tst_qquickflickable::pressWhileFlicking() // flick then press while it is still moving // flicking == false, moving == true; - flick(window, QPoint(20,190), QPoint(20, 50), 200); + flick(window.data(), QPoint(20,190), QPoint(20, 50), 200); QVERIFY(flickable->verticalVelocity() > 0.0); QTRY_VERIFY(flickable->isFlicking()); QVERIFY(flickable->isFlickingVertically()); @@ -1022,77 +1006,72 @@ void tst_qquickflickable::pressWhileFlicking() QCOMPARE(hFlickSpy.count(), 0); QCOMPARE(flickSpy.count(), 1); - QTest::mousePress(window, Qt::LeftButton, 0, QPoint(20, 50)); + QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(20, 50)); QTRY_VERIFY(!flickable->isFlicking()); QVERIFY(!flickable->isFlickingVertically()); QVERIFY(flickable->isMoving()); QVERIFY(flickable->isMovingVertically()); - QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(20,50)); + QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(20,50)); QVERIFY(!flickable->isFlicking()); QVERIFY(!flickable->isFlickingVertically()); QTRY_VERIFY(!flickable->isMoving()); QVERIFY(!flickable->isMovingVertically()); // Stop on a full pixel after user interaction QCOMPARE(flickable->contentX(), (qreal)qRound(flickable->contentX())); - - delete window; } void tst_qquickflickable::disabled() { - QQuickView *window = new QQuickView; + QScopedPointer<QQuickView> window(new QQuickView); window->setSource(testFileUrl("disabled.qml")); window->show(); - window->requestActivate(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); QVERIFY(window->rootObject() != 0); QQuickFlickable *flick = window->rootObject()->findChild<QQuickFlickable*>("flickable"); QVERIFY(flick != 0); - QTest::mousePress(window, Qt::LeftButton, 0, QPoint(50, 90)); + QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(50, 90)); - QTest::mouseMove(window, QPoint(50, 80)); - QTest::mouseMove(window, QPoint(50, 70)); - QTest::mouseMove(window, QPoint(50, 60)); + QTest::mouseMove(window.data(), QPoint(50, 80)); + QTest::mouseMove(window.data(), QPoint(50, 70)); + QTest::mouseMove(window.data(), QPoint(50, 60)); QVERIFY(flick->isMoving() == false); - QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50, 60)); + QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(50, 60)); // verify that mouse clicks on other elements still work (QTBUG-20584) - QTest::mousePress(window, Qt::LeftButton, 0, QPoint(50, 10)); - QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50, 10)); + QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(50, 10)); + QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(50, 10)); QTRY_VERIFY(window->rootObject()->property("clicked").toBool() == true); - - delete window; } void tst_qquickflickable::flickVelocity() { - QQuickView *window = new QQuickView; + QScopedPointer<QQuickView> window(new QQuickView); window->setSource(testFileUrl("flickable03.qml")); window->show(); - window->requestActivate(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); QVERIFY(window->rootObject() != 0); QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject()); QVERIFY(flickable != 0); // flick up - flick(window, QPoint(20,190), QPoint(20, 50), 200); + flick(window.data(), QPoint(20,190), QPoint(20, 50), 200); QVERIFY(flickable->verticalVelocity() > 0.0); QTRY_VERIFY(flickable->verticalVelocity() == 0.0); // flick down - flick(window, QPoint(20,10), QPoint(20, 140), 200); - QVERIFY(flickable->verticalVelocity() < 0.0); + flick(window.data(), QPoint(20,10), QPoint(20, 140), 200); + QTRY_VERIFY(flickable->verticalVelocity() < 0.0); QTRY_VERIFY(flickable->verticalVelocity() == 0.0); #ifdef Q_OS_MAC QSKIP("boost doesn't work on OS X"); - delete window; return; #endif @@ -1100,17 +1079,15 @@ void tst_qquickflickable::flickVelocity() QQuickFlickablePrivate *fp = QQuickFlickablePrivate::get(flickable); bool boosted = false; for (int i = 0; i < 6; ++i) { - flick(window, QPoint(20,390), QPoint(20, 50), 100); + flick(window.data(), QPoint(20,390), QPoint(20, 50), 100); boosted |= fp->flickBoost > 1.0; } QVERIFY(boosted); // Flick in opposite direction -> boost cancelled. - flick(window, QPoint(20,10), QPoint(20, 340), 200); + flick(window.data(), QPoint(20,10), QPoint(20, 340), 200); QTRY_VERIFY(flickable->verticalVelocity() < 0.0); QVERIFY(fp->flickBoost == 1.0); - - delete window; } void tst_qquickflickable::margins() @@ -1174,20 +1151,20 @@ void tst_qquickflickable::margins() void tst_qquickflickable::cancelOnMouseGrab() { - QQuickView *window = new QQuickView; + QScopedPointer<QQuickView> window(new QQuickView); window->setSource(testFileUrl("cancel.qml")); window->show(); - window->requestActivate(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); QVERIFY(window->rootObject() != 0); QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject()); QVERIFY(flickable != 0); - QTest::mousePress(window, Qt::LeftButton, 0, QPoint(10, 10)); + QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(10, 10)); // drag out of bounds - QTest::mouseMove(window, QPoint(50, 50)); - QTest::mouseMove(window, QPoint(100, 100)); - QTest::mouseMove(window, QPoint(150, 150)); + QTest::mouseMove(window.data(), QPoint(50, 50)); + QTest::mouseMove(window.data(), QPoint(100, 100)); + QTest::mouseMove(window.data(), QPoint(150, 150)); QVERIFY(flickable->contentX() != 0); QVERIFY(flickable->contentY() != 0); @@ -1203,56 +1180,52 @@ void tst_qquickflickable::cancelOnMouseGrab() QTRY_VERIFY(!flickable->isMoving()); QTRY_VERIFY(!flickable->isDragging()); - QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50, 10)); + QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(50, 10)); - delete window; } void tst_qquickflickable::clickAndDragWhenTransformed() { - QQuickView *view = new QQuickView; + QScopedPointer<QQuickView> view(new QQuickView); view->setSource(testFileUrl("transformedFlickable.qml")); view->show(); - view->requestActivate(); - QVERIFY(QTest::qWaitForWindowExposed(view)); + QVERIFY(QTest::qWaitForWindowExposed(view.data())); QVERIFY(view->rootObject() != 0); QQuickFlickable *flickable = view->rootObject()->findChild<QQuickFlickable*>("flickable"); QVERIFY(flickable != 0); // click outside child rect - QTest::mousePress(view, Qt::LeftButton, 0, QPoint(190, 190)); + QTest::mousePress(view.data(), Qt::LeftButton, 0, QPoint(190, 190)); QTest::qWait(10); QCOMPARE(flickable->property("itemPressed").toBool(), false); - QTest::mouseRelease(view, Qt::LeftButton, 0, QPoint(190, 190)); + QTest::mouseRelease(view.data(), Qt::LeftButton, 0, QPoint(190, 190)); // click inside child rect - QTest::mousePress(view, Qt::LeftButton, 0, QPoint(200, 200)); + QTest::mousePress(view.data(), Qt::LeftButton, 0, QPoint(200, 200)); QTest::qWait(10); QCOMPARE(flickable->property("itemPressed").toBool(), true); - QTest::mouseRelease(view, Qt::LeftButton, 0, QPoint(200, 200)); + QTest::mouseRelease(view.data(), Qt::LeftButton, 0, QPoint(200, 200)); const int threshold = qApp->styleHints()->startDragDistance(); // drag outside bounds - QTest::mousePress(view, Qt::LeftButton, 0, QPoint(160, 160)); + QTest::mousePress(view.data(), Qt::LeftButton, 0, QPoint(160, 160)); QTest::qWait(10); - QTest::mouseMove(view, QPoint(160 + threshold * 2, 160)); - QTest::mouseMove(view, QPoint(160 + threshold * 3, 160)); + QTest::mouseMove(view.data(), QPoint(160 + threshold * 2, 160)); + QTest::mouseMove(view.data(), QPoint(160 + threshold * 3, 160)); QCOMPARE(flickable->isDragging(), false); QCOMPARE(flickable->property("itemPressed").toBool(), false); - QTest::mouseRelease(view, Qt::LeftButton, 0, QPoint(180, 160)); + QTest::mouseRelease(view.data(), Qt::LeftButton, 0, QPoint(180, 160)); // drag inside bounds - QTest::mousePress(view, Qt::LeftButton, 0, QPoint(200, 140)); + QTest::mousePress(view.data(), Qt::LeftButton, 0, QPoint(200, 140)); QTest::qWait(10); - QTest::mouseMove(view, QPoint(200 + threshold * 2, 140)); - QTest::mouseMove(view, QPoint(200 + threshold * 3, 140)); + QTest::mouseMove(view.data(), QPoint(200 + threshold * 2, 140)); + QTest::mouseMove(view.data(), QPoint(200 + threshold * 3, 140)); QCOMPARE(flickable->isDragging(), true); QCOMPARE(flickable->property("itemPressed").toBool(), false); - QTest::mouseRelease(view, Qt::LeftButton, 0, QPoint(220, 140)); - - delete view; + QTest::mouseRelease(view.data(), Qt::LeftButton, 0, QPoint(220, 140)); } void tst_qquickflickable::flickTwiceUsingTouches() @@ -1266,8 +1239,6 @@ void tst_qquickflickable::flickTwiceUsingTouches() QQuickView *window = new QQuickView; window->setSource(testFileUrl("longList.qml")); window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); QVERIFY(window->rootObject() != 0); QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject()); diff --git a/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp b/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp index 19059c55df..b350abe953 100644 --- a/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp +++ b/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp @@ -525,7 +525,6 @@ void tst_qquickfocusscope::canvasFocus() QSignalSpy scope2ActiveFocusSpy(scope2, SIGNAL(activeFocusChanged(bool))); QSignalSpy item2ActiveFocusSpy(item2, SIGNAL(activeFocusChanged(bool))); - QEXPECT_FAIL("", "QTBUG-22415", Abort); QCOMPARE(rootItem->hasFocus(), false); QCOMPARE(rootItem->hasActiveFocus(), false); QCOMPARE(scope1->hasFocus(), true); diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp index 3c30f9e887..0c9788ab8e 100644 --- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp @@ -51,8 +51,7 @@ #include <QtQuick/private/qquickitem_p.h> #include <QtQuick/private/qquickgridview_p.h> #include <QtQuick/private/qquicktext_p.h> -#include <QtQuick/private/qquickvisualitemmodel_p.h> -#include <QtQml/private/qquicklistmodel_p.h> +#include <QtQml/private/qqmllistmodel_p.h> #include "../../shared/util.h" #include "../shared/viewtestutil.h" #include "../shared/visualtestutil.h" @@ -2435,7 +2434,7 @@ void tst_QQuickGridView::modelChanges() QQuickGridView *gridView = window->rootObject()->findChild<QQuickGridView*>("gridView"); QTRY_VERIFY(gridView); - QQuickListModel *alternateModel = window->rootObject()->findChild<QQuickListModel*>("alternateModel"); + QQmlListModel *alternateModel = window->rootObject()->findChild<QQmlListModel*>("alternateModel"); QTRY_VERIFY(alternateModel); QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel); QSignalSpy modelSpy(gridView, SIGNAL(modelChanged())); @@ -2871,7 +2870,8 @@ void tst_QQuickGridView::enforceRange_rightToLeft() ctxt->setContextProperty("testTopToBottom", QVariant(true)); window->setSource(testFileUrl("gridview-enforcerange.qml")); - qApp->processEvents(); + window->show(); + QTRY_VERIFY(window->isExposed()); QVERIFY(window->rootObject() != 0); QQuickGridView *gridview = findItem<QQuickGridView>(window->rootObject(), "grid"); diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp index 531bf1202e..0804c7b900 100644 --- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp +++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp @@ -315,8 +315,7 @@ void tst_qquickimage::mirror() obj->setFillMode(fillMode); obj->setProperty("mirror", true); window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QTest::qWaitForWindowExposed(window)); QImage screenshot = window->grabWindow(); screenshots[fillMode] = screenshot; @@ -500,8 +499,7 @@ void tst_qquickimage::tiling_QTBUG_6716() QQuickView view(testFileUrl(source)); view.show(); - view.requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QQuickImage *tiling = findItem<QQuickImage>(view.rootObject(), "tiling"); diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp index e237174eb1..a7343f686f 100644 --- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -175,6 +175,8 @@ private: }; void ensureFocus(QWindow *w) { + if (w->width() <=0 || w->height() <= 0) + w->setGeometry(100, 100, 400, 300); w->show(); w->requestActivate(); QTest::qWaitForWindowActive(w); @@ -270,10 +272,6 @@ void tst_qquickitem::simpleFocus() QQuickWindow window; ensureFocus(&window); -#ifdef Q_OS_MAC - QSKIP("QTBUG-24094: fails on Mac OS X 10.7"); -#endif - QTRY_VERIFY(QGuiApplication::focusWindow() == &window); QQuickItem *l1c1 = new TestItem(window.contentItem()); @@ -732,7 +730,7 @@ void tst_qquickitem::focusSubItemInNonFocusScope() QQuickView *view = new QQuickView; view->setSource(testFileUrl("focusSubItemInNonFocusScope.qml")); view->show(); - qApp->processEvents(); + QTest::qWaitForWindowActive(view); QQuickItem *dummyItem = view->rootObject()->findChild<QQuickItem *>("dummyItem"); QVERIFY(dummyItem); diff --git a/tests/auto/quick/qquickitem2/data/activeFocusOnTab.qml b/tests/auto/quick/qquickitem2/data/activeFocusOnTab.qml new file mode 100644 index 0000000000..e064b41efe --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/activeFocusOnTab.qml @@ -0,0 +1,136 @@ +import QtQuick 2.0 + +Item { + id: main + objectName: "main" + width: 800 + height: 600 + focus: true + Component.onCompleted: button12.focus = true + Item { + id: sub1 + objectName: "sub1" + width: 230 + height: 600 + anchors.top: parent.top + anchors.left: parent.left + Item { + id: button11 + objectName: "button11" + width: 100 + height: 50 + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + + anchors.top: parent.top + anchors.topMargin: 100 + } + Item { + id: button12 + objectName: "button12" + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + width: 100 + height: 50 + + anchors.top: button11.bottom + anchors.bottomMargin: 100 + } + Item { + id: button13 + objectName: "button13" + enabled: false + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + width: 100 + height: 50 + + anchors.top: button12.bottom + anchors.bottomMargin: 100 + } + Item { + id: button14 + objectName: "button14" + visible: false + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + width: 100 + height: 50 + + anchors.top: button12.bottom + anchors.bottomMargin: 100 + } + } + Item { + id: sub2 + objectName: "sub2" + activeFocusOnTab: true + width: 230 + height: 600 + anchors.top: parent.top + anchors.left: sub1.right + Item { + id: button21 + objectName: "button21" + width: 100 + height: 50 + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + + anchors.top: parent.top + anchors.topMargin: 100 + } + Item { + id: button22 + objectName: "button22" + width: 100 + height: 50 + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + + anchors.top: button21.bottom + anchors.bottomMargin: 100 + } + } + Item { + id: sub3 + objectName: "sub3" + width: 230 + height: 600 + anchors.top: parent.top + anchors.left: sub2.right + TextEdit { + id: edit + objectName: "edit" + width: 230 + height: 400 + readOnly: false + activeFocusOnTab: true + wrapMode: TextEdit.Wrap + textFormat: TextEdit.RichText + + text: "aaa\n" + +"bbb\n" + +"ccc\n" + +"ddd\n" + } + } +} diff --git a/tests/auto/quick/qquickitem2/data/activeFocusOnTab3.qml b/tests/auto/quick/qquickitem2/data/activeFocusOnTab3.qml new file mode 100644 index 0000000000..00fb82d59e --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/activeFocusOnTab3.qml @@ -0,0 +1,250 @@ +import QtQuick 2.0 + +Item { + id: main + objectName: "main" + width: 400 + height: 700 + focus: true + Component.onCompleted: button1.focus = true + Item { + id: sub1 + objectName: "sub1" + activeFocusOnTab: false + width: 100 + height: 50 + anchors.top: parent.top + Item { + id: button1 + objectName: "button1" + width: 100 + height: 50 + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + } + } + Row { + id: row_repeater + objectName: "row_repeater" + activeFocusOnTab: false + anchors.top: sub1.bottom + Repeater { + activeFocusOnTab: false + model: 3 + Rectangle { + activeFocusOnTab: true + width: 100; height: 40 + border.width: 1 + color: activeFocus ? "red" : "yellow" + } + } + } + Item { + id: sub2 + objectName: "sub2" + activeFocusOnTab: false + anchors.top: row_repeater.bottom + width: 100 + height: 50 + Item { + id: button2 + objectName: "button2" + width: 100 + height: 50 + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + } + } + Row { + id: row + objectName: "row" + activeFocusOnTab: false + anchors.top: sub2.bottom + Rectangle { activeFocusOnTab: true; color: activeFocus ? "red" : "yellow"; width: 50; height: 50 } + Rectangle { activeFocusOnTab: true; color: activeFocus ? "red" : "green"; width: 20; height: 50 } + Rectangle { activeFocusOnTab: true; color: activeFocus ? "red" : "blue"; width: 50; height: 20 } + } + Item { + id: sub3 + objectName: "sub3" + activeFocusOnTab: false + anchors.top: row.bottom + width: 100 + height: 50 + Item { + id: button3 + objectName: "button3" + width: 100 + height: 50 + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + } + } + Flow { + id: flow + objectName: "flow" + activeFocusOnTab: false + anchors.top: sub3.bottom + width: parent.width + anchors.margins: 4 + spacing: 10 + Rectangle { activeFocusOnTab: true; color: activeFocus ? "red" : "yellow"; width: 50; height: 50 } + Rectangle { activeFocusOnTab: true; color: activeFocus ? "red" : "green"; width: 20; height: 50 } + Rectangle { activeFocusOnTab: true; color: activeFocus ? "red" : "blue"; width: 50; height: 20 } + } + Item { + id: sub4 + objectName: "sub4" + activeFocusOnTab: false + anchors.top: flow.bottom + width: 100 + height: 50 + Item { + id: button4 + objectName: "button4" + width: 100 + height: 50 + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + } + } + FocusScope { + id: focusscope + objectName: "focusscope" + activeFocusOnTab: false + anchors.top: sub4.bottom + height: 40 + Row { + id: row_focusscope + objectName: "row_focusscope" + activeFocusOnTab: false + anchors.fill: parent + Repeater { + activeFocusOnTab: false + model: 3 + Rectangle { + activeFocusOnTab: true + width: 100; height: 40 + border.width: 1 + color: activeFocus ? "red" : "yellow" + } + } + } + } + Item { + id: sub5 + objectName: "sub5" + activeFocusOnTab: false + anchors.top: focusscope.bottom + width: 100 + height: 50 + Item { + id: button5 + objectName: "button5" + width: 100 + height: 50 + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + } + } + FocusScope { + id: focusscope2 + objectName: "focusscope2" + activeFocusOnTab: true + anchors.top: sub5.bottom + height: 40 + Row { + id: row_focusscope2 + objectName: "row_focusscope2" + activeFocusOnTab: false + anchors.fill: parent + Repeater { + activeFocusOnTab: false + model: 3 + Rectangle { + activeFocusOnTab: true + focus: true + width: 100; height: 40 + border.width: 1 + color: activeFocus ? "red" : "yellow" + } + } + } + } + Item { + id: sub6 + objectName: "sub6" + activeFocusOnTab: false + anchors.top: focusscope2.bottom + width: 100 + height: 50 + Item { + id: button6 + objectName: "button6" + width: 100 + height: 50 + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + } + } + FocusScope { + id: focusscope3 + objectName: "focusscope3" + activeFocusOnTab: true + anchors.top: sub6.bottom + height: 40 + Row { + id: row_focusscope3 + objectName: "row_focusscope3" + activeFocusOnTab: false + anchors.fill: parent + Repeater { + activeFocusOnTab: false + model: 3 + Rectangle { + activeFocusOnTab: true + width: 100; height: 40 + border.width: 1 + color: activeFocus ? "red" : "yellow" + } + } + } + } + Item { + id: sub7 + objectName: "sub7" + activeFocusOnTab: false + anchors.top: focusscope3.bottom + width: 100 + height: 50 + Item { + id: button7 + objectName: "button7" + width: 100 + height: 50 + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + } + } +} diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp index c82372c287..668b5e2945 100644 --- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp @@ -64,6 +64,10 @@ private slots: void initTestCase(); void cleanup(); + void activeFocusOnTab(); + void activeFocusOnTab2(); + void activeFocusOnTab3(); + void keys(); void keysProcessingOrder(); void keysim(); @@ -273,6 +277,331 @@ void tst_QQuickItem::cleanup() inputMethodPrivate->testContext = 0; } +void tst_QQuickItem::activeFocusOnTab() +{ + QQuickView *window = new QQuickView(0); + window->setBaseSize(QSize(800,600)); + + window->setSource(testFileUrl("activeFocusOnTab.qml")); + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QGuiApplication::focusWindow() == window); + + // original: button12 + QQuickItem *item = findItem<QQuickItem>(window->rootObject(), "button12"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // Tab: button12->sub2 + QKeyEvent key(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem<QQuickItem>(window->rootObject(), "sub2"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // Tab: sub2->button21 + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem<QQuickItem>(window->rootObject(), "button21"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // Tab: button21->button22 + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem<QQuickItem>(window->rootObject(), "button22"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // Tab: button22->edit + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem<QQuickItem>(window->rootObject(), "edit"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // BackTab: edit->button22 + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem<QQuickItem>(window->rootObject(), "button22"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // BackTab: button22->button21 + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem<QQuickItem>(window->rootObject(), "button21"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // BackTab: button21->sub2 + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem<QQuickItem>(window->rootObject(), "sub2"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // BackTab: sub2->button12 + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem<QQuickItem>(window->rootObject(), "button12"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // BackTab: button12->button11 + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem<QQuickItem>(window->rootObject(), "button11"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // BackTab: button11->edit + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem<QQuickItem>(window->rootObject(), "edit"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + delete window; +} + +void tst_QQuickItem::activeFocusOnTab2() +{ + QQuickView *window = new QQuickView(0); + window->setBaseSize(QSize(800,600)); + + window->setSource(testFileUrl("activeFocusOnTab.qml")); + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QGuiApplication::focusWindow() == window); + + // original: button12 + QQuickItem *item = findItem<QQuickItem>(window->rootObject(), "button12"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // BackTab: button12->button11 + QKeyEvent key(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem<QQuickItem>(window->rootObject(), "button11"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // BackTab: button11->edit + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem<QQuickItem>(window->rootObject(), "edit"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + delete window; +} + +void tst_QQuickItem::activeFocusOnTab3() +{ + QQuickView *window = new QQuickView(0); + window->setBaseSize(QSize(800,600)); + + window->setSource(testFileUrl("activeFocusOnTab3.qml")); + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QGuiApplication::focusWindow() == window); + + // original: button1 + QQuickItem *item = findItem<QQuickItem>(window->rootObject(), "button1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // 4 Tabs: button1->button2, through a repeater + QKeyEvent key(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);; + for (int i = 0; i < 4; ++i) { + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + } + + item = findItem<QQuickItem>(window->rootObject(), "button2"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // 4 Tabs: button2->button3, through a row + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);; + for (int i = 0; i < 4; ++i) { + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + } + + item = findItem<QQuickItem>(window->rootObject(), "button3"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // 4 Tabs: button3->button4, through a flow + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);; + for (int i = 0; i < 4; ++i) { + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + } + + item = findItem<QQuickItem>(window->rootObject(), "button4"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // 4 Tabs: button4->button5, through a focusscope + // parent is activeFocusOnTab:false, one of children is focus:true + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);; + for (int i = 0; i < 4; ++i) { + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + } + + item = findItem<QQuickItem>(window->rootObject(), "button5"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // 4 Tabs: button5->button6, through a focusscope + // parent is activeFocusOnTab:true, one of children is focus:true + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);; + for (int i = 0; i < 4; ++i) { + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + } + + item = findItem<QQuickItem>(window->rootObject(), "button6"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // 5 Tabs: button6->button7, through a focusscope + // parent is activeFocusOnTab:true, none of children is focus:true + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);; + for (int i = 0; i < 5; ++i) { + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + } + + item = findItem<QQuickItem>(window->rootObject(), "button7"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // 4 BackTabs: button7->button6, through a focusscope + // parent is activeFocusOnTab:true, one of children got focus:true in previous code + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); + for (int i = 0; i < 4; ++i) { + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + } + + item = findItem<QQuickItem>(window->rootObject(), "button6"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // 4 Tabs: button6->button7, through a focusscope + // parent is activeFocusOnTab:true, one of children got focus:true in previous code + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);; + for (int i = 0; i < 4; ++i) { + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + } + + item = findItem<QQuickItem>(window->rootObject(), "button7"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // 4 BackTabs: button7->button6, through a focusscope + // parent is activeFocusOnTab:true, one of children got focus:true in previous code + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); + for (int i = 0; i < 4; ++i) { + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + } + + item = findItem<QQuickItem>(window->rootObject(), "button6"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // 4 BackTabs: button6->button5, through a focusscope(parent is activeFocusOnTab: false) + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); + for (int i = 0; i < 4; ++i) { + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + } + + item = findItem<QQuickItem>(window->rootObject(), "button5"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // 4 BackTabs: button5->button4, through a focusscope(parent is activeFocusOnTab: false) + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); + for (int i = 0; i < 4; ++i) { + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + } + + item = findItem<QQuickItem>(window->rootObject(), "button4"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // 4 BackTabs: button4->button3, through a flow + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); + for (int i = 0; i < 4; ++i) { + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + } + + item = findItem<QQuickItem>(window->rootObject(), "button3"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // 4 BackTabs: button3->button2, through a row + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); + for (int i = 0; i < 4; ++i) { + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + } + + item = findItem<QQuickItem>(window->rootObject(), "button2"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // 4 BackTabs: button2->button1, through a repeater + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); + for (int i = 0; i < 4; ++i) { + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + } + + item = findItem<QQuickItem>(window->rootObject(), "button1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + delete window; +} + void tst_QQuickItem::keys() { QQuickView *window = new QQuickView(0); diff --git a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp index 9387264eb0..4f103bd1fa 100644 --- a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp +++ b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp @@ -266,7 +266,7 @@ void tst_QQuickItemLayer::layerVisibility() view.show(); - QTest::qWaitForWindowActive(&view); + QTest::qWaitForWindowExposed(&view); QImage fb = view.grabWindow(); uint pixel = fb.pixel(0, 0); diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 3b4a41e203..f8c7de6635 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -48,8 +48,8 @@ #include <QtQml/qqmlincubator.h> #include <QtQuick/private/qquicklistview_p.h> #include <QtQuick/private/qquicktext_p.h> -#include <QtQuick/private/qquickvisualitemmodel_p.h> -#include <QtQml/private/qquicklistmodel_p.h> +#include <QtQml/private/qqmlobjectmodel_p.h> +#include <QtQml/private/qqmllistmodel_p.h> #include "../../shared/util.h" #include "../shared/viewtestutil.h" #include "../shared/visualtestutil.h" @@ -2769,7 +2769,7 @@ void tst_QQuickListView::itemList() QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != 0); - QQuickVisualItemModel *model = window->rootObject()->findChild<QQuickVisualItemModel*>("itemModel"); + QQmlObjectModel *model = window->rootObject()->findChild<QQmlObjectModel*>("itemModel"); QTRY_VERIFY(model != 0); QTRY_VERIFY(model->count() == 3); @@ -2810,7 +2810,7 @@ void tst_QQuickListView::itemListFlicker() QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != 0); - QQuickVisualItemModel *model = window->rootObject()->findChild<QQuickVisualItemModel*>("itemModel"); + QQmlObjectModel *model = window->rootObject()->findChild<QQmlObjectModel*>("itemModel"); QTRY_VERIFY(model != 0); QTRY_VERIFY(model->count() == 3); @@ -3259,7 +3259,7 @@ void tst_QQuickListView::modelChanges() QQuickListView *listView = window->rootObject()->findChild<QQuickListView*>("listView"); QTRY_VERIFY(listView); - QQuickListModel *alternateModel = window->rootObject()->findChild<QQuickListModel*>("alternateModel"); + QQmlListModel *alternateModel = window->rootObject()->findChild<QQmlListModel*>("alternateModel"); QTRY_VERIFY(alternateModel); QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel); QSignalSpy modelSpy(listView, SIGNAL(modelChanged())); @@ -4607,7 +4607,7 @@ void tst_QQuickListView::rightToLeft() QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - QQuickVisualItemModel *model = window->rootObject()->findChild<QQuickVisualItemModel*>("itemModel"); + QQmlObjectModel *model = window->rootObject()->findChild<QQmlObjectModel*>("itemModel"); QTRY_VERIFY(model != 0); QTRY_VERIFY(model->count() == 3); diff --git a/tests/auto/quick/qquickloader/data/QTBUG_30183.qml b/tests/auto/quick/qquickloader/data/QTBUG_30183.qml new file mode 100644 index 0000000000..1f626d969f --- /dev/null +++ b/tests/auto/quick/qquickloader/data/QTBUG_30183.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Loader { + width: implicitWidth + height: implicitHeight + + sourceComponent: Rectangle { + color: "green" + implicitWidth: 240 + implicitHeight: 120 + } +} diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp index d01e8aae52..50ded4d95a 100644 --- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp +++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp @@ -126,6 +126,7 @@ private slots: void parented(); void sizeBound(); + void QTBUG_30183(); private: QQmlEngine engine; @@ -1126,6 +1127,22 @@ void tst_QQuickLoader::sizeBound() delete root; } +void tst_QQuickLoader::QTBUG_30183() +{ + QQmlComponent component(&engine, testFileUrl("/QTBUG_30183.qml")); + QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create()); + QVERIFY(loader != 0); + QCOMPARE(loader->width(), 240.0); + QCOMPARE(loader->height(), 120.0); + + // the loaded item must follow the size + QQuickItem *rect = qobject_cast<QQuickItem*>(loader->item()); + QVERIFY(rect); + QCOMPARE(rect->width(), 240.0); + QCOMPARE(rect->height(), 120.0); + + delete loader; +} QTEST_MAIN(tst_QQuickLoader) diff --git a/tests/auto/quick/qquickmousearea/data/pressedCanceled.qml b/tests/auto/quick/qquickmousearea/data/pressedCanceled.qml index 231436d0f2..14630b8962 100644 --- a/tests/auto/quick/qquickmousearea/data/pressedCanceled.qml +++ b/tests/auto/quick/qquickmousearea/data/pressedCanceled.qml @@ -1,4 +1,5 @@ import QtQuick 2.0 +import QtQuick.Window 2.0 Rectangle { id: root @@ -7,6 +8,12 @@ Rectangle { property bool pressed:mouse.pressed property bool canceled: false property bool released: false + property alias secondWindow: secondWindow + + Window { + id: secondWindow + x: root.x + root.width + } MouseArea { id: mouse @@ -15,4 +22,4 @@ Rectangle { onCanceled: {root.canceled = true} onReleased: {root.released = true; root.canceled = false} } -}
\ No newline at end of file +} diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index 055facc9e1..fa33f3f626 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -132,7 +132,7 @@ void tst_QQuickMouseArea::dragProperties() window->setSource(testFileUrl("dragproperties.qml")); window->show(); - window->requestActivate(); + QTest::qWaitForWindowExposed(window); QVERIFY(window->rootObject() != 0); QQuickMouseArea *mouseRegion = window->rootObject()->findChild<QQuickMouseArea*>("mouseregion"); @@ -218,7 +218,7 @@ void tst_QQuickMouseArea::resetDrag() window->rootContext()->setContextProperty("haveTarget", QVariant(true)); window->setSource(testFileUrl("dragreset.qml")); window->show(); - window->requestActivate(); + QTest::qWaitForWindowExposed(window); QVERIFY(window->rootObject() != 0); QQuickMouseArea *mouseRegion = window->rootObject()->findChild<QQuickMouseArea*>("mouseregion"); @@ -250,7 +250,7 @@ void tst_QQuickMouseArea::dragging() window->setSource(testFileUrl("dragging.qml")); window->show(); - window->requestActivate(); + QTest::qWaitForWindowExposed(window); QVERIFY(QTest::qWaitForWindowExposed(window)); QVERIFY(window->rootObject() != 0); @@ -305,8 +305,7 @@ void tst_QQuickMouseArea::invalidDrag() window->setSource(testFileUrl("dragging.qml")); window->show(); - window->requestActivate(); - QTest::qWait(20); + QTest::qWaitForWindowExposed(window); QVERIFY(window->rootObject() != 0); QQuickMouseArea *mouseRegion = window->rootObject()->findChild<QQuickMouseArea*>("mouseregion"); @@ -357,8 +356,7 @@ void tst_QQuickMouseArea::setDragOnPressed() window->setSource(testFileUrl("setDragOnPressed.qml")); window->show(); - window->requestActivate(); - QTest::qWait(20); + QTest::qWaitForWindowExposed(window); QVERIFY(window->rootObject() != 0); QQuickMouseArea *mouseArea = qobject_cast<QQuickMouseArea *>(window->rootObject()); @@ -412,7 +410,7 @@ void tst_QQuickMouseArea::updateMouseAreaPosOnClick() QQuickView *window = createView(); window->setSource(testFileUrl("updateMousePosOnClick.qml")); window->show(); - window->requestActivate(); + QTest::qWaitForWindowExposed(window); QVERIFY(window->rootObject() != 0); QQuickMouseArea *mouseRegion = window->rootObject()->findChild<QQuickMouseArea*>("mouseregion"); @@ -441,7 +439,7 @@ void tst_QQuickMouseArea::updateMouseAreaPosOnResize() QQuickView *window = createView(); window->setSource(testFileUrl("updateMousePosOnResize.qml")); window->show(); - window->requestActivate(); + QTest::qWaitForWindowExposed(window); QVERIFY(window->rootObject() != 0); QQuickMouseArea *mouseRegion = window->rootObject()->findChild<QQuickMouseArea*>("mouseregion"); @@ -478,7 +476,7 @@ void tst_QQuickMouseArea::noOnClickedWithPressAndHold() QQuickView *window = createView(); window->setSource(testFileUrl("clickandhold.qml")); window->show(); - window->requestActivate(); + QTest::qWaitForWindowExposed(window); QVERIFY(window->rootObject() != 0); QQuickMouseArea *mouseArea = qobject_cast<QQuickMouseArea*>(window->rootObject()->children().first()); QVERIFY(mouseArea); @@ -511,7 +509,7 @@ void tst_QQuickMouseArea::noOnClickedWithPressAndHold() QQuickView *window = createView(); window->setSource(testFileUrl("noclickandhold.qml")); window->show(); - window->requestActivate(); + QTest::qWaitForWindowExposed(window); QVERIFY(window->rootObject() != 0); QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); @@ -535,7 +533,7 @@ void tst_QQuickMouseArea::onMousePressRejected() QQuickView *window = createView(); window->setSource(testFileUrl("rejectEvent.qml")); window->show(); - window->requestActivate(); + QTest::qWaitForWindowExposed(window); QVERIFY(window->rootObject() != 0); QVERIFY(window->rootObject()->property("enabled").toBool()); @@ -572,7 +570,7 @@ void tst_QQuickMouseArea::pressedCanceledOnWindowDeactivate() QQuickView *window = createView(); window->setSource(testFileUrl("pressedCanceled.qml")); window->show(); - window->requestActivate(); + QTest::qWaitForWindowExposed(window); QVERIFY(window->rootObject() != 0); QVERIFY(!window->rootObject()->property("pressed").toBool()); QVERIFY(!window->rootObject()->property("canceled").toBool()); @@ -585,16 +583,14 @@ void tst_QQuickMouseArea::pressedCanceledOnWindowDeactivate() QVERIFY(!window->rootObject()->property("canceled").toBool()); QVERIFY(!window->rootObject()->property("released").toBool()); - QTest::qWait(200); + QWindow *secondWindow = qvariant_cast<QWindow*>(window->rootObject()->property("secondWindow")); + secondWindow->setProperty("visible", true); + QTest::qWaitForWindowActive(secondWindow); - QEvent windowDeactivateEvent(QEvent::WindowDeactivate); - QGuiApplication::sendEvent(window, &windowDeactivateEvent); QVERIFY(!window->rootObject()->property("pressed").toBool()); QVERIFY(window->rootObject()->property("canceled").toBool()); QVERIFY(!window->rootObject()->property("released").toBool()); - QTest::qWait(200); - //press again QGuiApplication::sendEvent(window, &pressEvent); QVERIFY(window->rootObject()->property("pressed").toBool()); @@ -621,7 +617,7 @@ void tst_QQuickMouseArea::doubleClick() QQuickView *window = createView(); window->setSource(testFileUrl("doubleclick.qml")); window->show(); - window->requestActivate(); + QTest::qWaitForWindowExposed(window); QVERIFY(window->rootObject() != 0); QQuickMouseArea *mouseArea = window->rootObject()->findChild<QQuickMouseArea *>("mousearea"); @@ -659,7 +655,7 @@ void tst_QQuickMouseArea::clickTwice() QQuickView *window = createView(); window->setSource(testFileUrl("clicktwice.qml")); window->show(); - window->requestActivate(); + QTest::qWaitForWindowExposed(window); QVERIFY(window->rootObject() != 0); QQuickMouseArea *mouseArea = window->rootObject()->findChild<QQuickMouseArea *>("mousearea"); @@ -696,7 +692,7 @@ void tst_QQuickMouseArea::invalidClick() QQuickView *window = createView(); window->setSource(testFileUrl("doubleclick.qml")); window->show(); - window->requestActivate(); + QTest::qWaitForWindowExposed(window); QVERIFY(window->rootObject() != 0); QQuickMouseArea *mouseArea = window->rootObject()->findChild<QQuickMouseArea *>("mousearea"); @@ -730,7 +726,7 @@ void tst_QQuickMouseArea::pressedOrdering() QQuickView *window = createView(); window->setSource(testFileUrl("pressedOrdering.qml")); window->show(); - window->requestActivate(); + QTest::qWaitForWindowExposed(window); QVERIFY(window->rootObject() != 0); QCOMPARE(window->rootObject()->property("value").toString(), QLatin1String("base")); @@ -758,7 +754,7 @@ void tst_QQuickMouseArea::preventStealing() window->setSource(testFileUrl("preventstealing.qml")); window->show(); - window->requestActivate(); + QTest::qWaitForWindowExposed(window); QVERIFY(window->rootObject() != 0); QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject()); @@ -822,7 +818,7 @@ void tst_QQuickMouseArea::clickThrough() QQuickView *window = createView(); window->setSource(testFileUrl("clickThrough.qml")); window->show(); - window->requestActivate(); + QTest::qWaitForWindowExposed(window); QVERIFY(window->rootObject() != 0); QTest::mousePress(window, Qt::LeftButton, 0, QPoint(100,100)); @@ -857,7 +853,7 @@ void tst_QQuickMouseArea::clickThrough() window = createView(); window->setSource(testFileUrl("clickThrough2.qml")); window->show(); - window->requestActivate(); + QTest::qWaitForWindowExposed(window); QVERIFY(window->rootObject() != 0); QTest::mousePress(window, Qt::LeftButton, 0, QPoint(100,100)); @@ -1016,8 +1012,7 @@ void tst_QQuickMouseArea::disableAfterPress() QQuickView *window = createView(); window->setSource(testFileUrl("dragging.qml")); window->show(); - window->requestActivate(); - QTest::qWait(20); + QTest::qWaitForWindowExposed(window); QVERIFY(window->rootObject() != 0); QQuickMouseArea *mouseArea = window->rootObject()->findChild<QQuickMouseArea*>("mouseregion"); @@ -1166,7 +1161,7 @@ void tst_QQuickMouseArea::transformedMouseArea() QQuickView *window = createView(); window->setSource(testFileUrl("transformedMouseArea.qml")); window->show(); - window->requestActivate(); + QTest::qWaitForWindowExposed(window); QVERIFY(window->rootObject() != 0); QQuickMouseArea *mouseArea = window->rootObject()->findChild<QQuickMouseArea *>("mouseArea"); @@ -1284,7 +1279,7 @@ void tst_QQuickMouseArea::pressedMultipleButtons() QQuickView *view = createView(); view->setSource(testFileUrl("simple.qml")); view->show(); - view->requestActivate(); + QTest::qWaitForWindowExposed(view); QVERIFY(view->rootObject() != 0); QQuickMouseArea *mouseArea = view->rootObject()->findChild<QQuickMouseArea *>("mousearea"); @@ -1321,7 +1316,7 @@ void tst_QQuickMouseArea::changeAxis() view->setSource(testFileUrl("changeAxis.qml")); view->show(); - view->requestActivate(); + QTest::qWaitForWindowExposed(view); QTRY_VERIFY(view->rootObject() != 0); QQuickMouseArea *mouseRegion = view->rootObject()->findChild<QQuickMouseArea*>("mouseregion"); @@ -1413,7 +1408,7 @@ void tst_QQuickMouseArea::moveAndReleaseWithoutPress() window->setSource(testFileUrl("moveAndReleaseWithoutPress.qml")); window->show(); - window->requestActivate(); + QTest::qWaitForWindowExposed(window); QVERIFY(QTest::qWaitForWindowExposed(window)); QObject *root = window->rootObject(); diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp index 73c2cf68dd..663d02d921 100644 --- a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp +++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp @@ -851,8 +851,7 @@ QQuickView *tst_QQuickMultiPointTouchArea::createAndShowView(const QString &file QQuickView *window = new QQuickView(0); window->setSource(testFileUrl(file)); window->show(); - window->requestActivate(); - QTest::qWaitForWindowActive(window); + QTest::qWaitForWindowExposed(window); return window; } diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index 8821203902..e805a6b074 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -50,7 +50,7 @@ #include <QtQuick/private/qquickpath_p.h> #include <QtQuick/private/qquicktext_p.h> #include <QtQuick/private/qquickrectangle_p.h> -#include <QtQml/private/qquicklistmodel_p.h> +#include <QtQml/private/qqmllistmodel_p.h> #include <QtQml/private/qqmlvaluetype_p.h> #include <QtGui/qstandarditemmodel.h> #include <QStringListModel> @@ -199,7 +199,7 @@ void tst_QQuickPathView::initValues() void tst_QQuickPathView::items() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); QaimModel model; model.addItem("Fred", "12345"); @@ -238,8 +238,6 @@ void tst_QQuickPathView::items() offset.setX(pathview->highlightItem()->width()/2); offset.setY(pathview->highlightItem()->height()/2); QCOMPARE(pathview->highlightItem()->position() + offset, start); - - delete window; } void tst_QQuickPathView::pathview2() @@ -312,34 +310,34 @@ void tst_QQuickPathView::insertModel_data() // We have 8 items, with currentIndex == 4 QTest::newRow("insert after current") - << int(QQuickPathView::StrictlyEnforceRange) << 6 << 1 << 5. << 4; + << int(QQuickPathView::StrictlyEnforceRange) << 6 << 1 << qreal(5.) << 4; QTest::newRow("insert before current") - << int(QQuickPathView::StrictlyEnforceRange) << 2 << 1 << 4. << 5; + << int(QQuickPathView::StrictlyEnforceRange) << 2 << 1 << qreal(4.)<< 5; QTest::newRow("insert multiple after current") - << int(QQuickPathView::StrictlyEnforceRange) << 5 << 2 << 6. << 4; + << int(QQuickPathView::StrictlyEnforceRange) << 5 << 2 << qreal(6.) << 4; QTest::newRow("insert multiple before current") - << int(QQuickPathView::StrictlyEnforceRange) << 1 << 2 << 4. << 6; + << int(QQuickPathView::StrictlyEnforceRange) << 1 << 2 << qreal(4.) << 6; QTest::newRow("insert at end") - << int(QQuickPathView::StrictlyEnforceRange) << 8 << 1 << 5. << 4; + << int(QQuickPathView::StrictlyEnforceRange) << 8 << 1 << qreal(5.) << 4; QTest::newRow("insert at beginning") - << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 4. << 5; + << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << qreal(4.) << 5; QTest::newRow("insert at current") - << int(QQuickPathView::StrictlyEnforceRange) << 4 << 1 << 4. << 5; + << int(QQuickPathView::StrictlyEnforceRange) << 4 << 1 << qreal(4.) << 5; QTest::newRow("no range - insert after current") - << int(QQuickPathView::NoHighlightRange) << 6 << 1 << 5. << 4; + << int(QQuickPathView::NoHighlightRange) << 6 << 1 << qreal(5.) << 4; QTest::newRow("no range - insert before current") - << int(QQuickPathView::NoHighlightRange) << 2 << 1 << 4. << 5; + << int(QQuickPathView::NoHighlightRange) << 2 << 1 << qreal(4.) << 5; QTest::newRow("no range - insert multiple after current") - << int(QQuickPathView::NoHighlightRange) << 5 << 2 << 6. << 4; + << int(QQuickPathView::NoHighlightRange) << 5 << 2 << qreal(6.) << 4; QTest::newRow("no range - insert multiple before current") - << int(QQuickPathView::NoHighlightRange) << 1 << 2 << 4. << 6; + << int(QQuickPathView::NoHighlightRange) << 1 << 2 << qreal(4.) << 6; QTest::newRow("no range - insert at end") - << int(QQuickPathView::NoHighlightRange) << 8 << 1 << 5. << 4; + << int(QQuickPathView::NoHighlightRange) << 8 << 1 << qreal(5.) << 4; QTest::newRow("no range - insert at beginning") - << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 4. << 5; + << int(QQuickPathView::NoHighlightRange) << 0 << 1 << qreal(4.) << 5; QTest::newRow("no range - insert at current") - << int(QQuickPathView::NoHighlightRange) << 4 << 1 << 4. << 5; + << int(QQuickPathView::NoHighlightRange) << 4 << 1 << qreal(4.) << 5; } void tst_QQuickPathView::insertModel() @@ -350,7 +348,7 @@ void tst_QQuickPathView::insertModel() QFETCH(qreal, offset); QFETCH(int, currentIndex); - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->show(); QaimModel model; @@ -388,8 +386,6 @@ void tst_QQuickPathView::insertModel() QTRY_COMPARE(pathview->offset(), offset); QCOMPARE(pathview->currentIndex(), currentIndex); - - delete window; } void tst_QQuickPathView::removeModel_data() @@ -402,38 +398,38 @@ void tst_QQuickPathView::removeModel_data() // We have 8 items, with currentIndex == 4 QTest::newRow("remove after current") - << int(QQuickPathView::StrictlyEnforceRange) << 6 << 1 << 3. << 4; + << int(QQuickPathView::StrictlyEnforceRange) << 6 << 1 << qreal(3.) << 4; QTest::newRow("remove before current") - << int(QQuickPathView::StrictlyEnforceRange) << 2 << 1 << 4. << 3; + << int(QQuickPathView::StrictlyEnforceRange) << 2 << 1 << qreal(4.) << 3; QTest::newRow("remove multiple after current") - << int(QQuickPathView::StrictlyEnforceRange) << 5 << 2 << 2. << 4; + << int(QQuickPathView::StrictlyEnforceRange) << 5 << 2 << qreal(2.) << 4; QTest::newRow("remove multiple before current") - << int(QQuickPathView::StrictlyEnforceRange) << 1 << 2 << 4. << 2; + << int(QQuickPathView::StrictlyEnforceRange) << 1 << 2 << qreal(4.) << 2; QTest::newRow("remove last") - << int(QQuickPathView::StrictlyEnforceRange) << 7 << 1 << 3. << 4; + << int(QQuickPathView::StrictlyEnforceRange) << 7 << 1 << qreal(3.) << 4; QTest::newRow("remove first") - << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 4. << 3; + << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << qreal(4.) << 3; QTest::newRow("remove current") - << int(QQuickPathView::StrictlyEnforceRange) << 4 << 1 << 3. << 4; + << int(QQuickPathView::StrictlyEnforceRange) << 4 << 1 << qreal(3.) << 4; QTest::newRow("remove all") - << int(QQuickPathView::StrictlyEnforceRange) << 0 << 8 << 0. << 0; + << int(QQuickPathView::StrictlyEnforceRange) << 0 << 8 << qreal(0.) << 0; QTest::newRow("no range - remove after current") - << int(QQuickPathView::NoHighlightRange) << 6 << 1 << 3. << 4; + << int(QQuickPathView::NoHighlightRange) << 6 << 1 << qreal(3.) << 4; QTest::newRow("no range - remove before current") - << int(QQuickPathView::NoHighlightRange) << 2 << 1 << 4. << 3; + << int(QQuickPathView::NoHighlightRange) << 2 << 1 << qreal(4.) << 3; QTest::newRow("no range - remove multiple after current") - << int(QQuickPathView::NoHighlightRange) << 5 << 2 << 2. << 4; + << int(QQuickPathView::NoHighlightRange) << 5 << 2 << qreal(2.) << 4; QTest::newRow("no range - remove multiple before current") - << int(QQuickPathView::NoHighlightRange) << 1 << 2 << 4. << 2; + << int(QQuickPathView::NoHighlightRange) << 1 << 2 << qreal(4.) << 2; QTest::newRow("no range - remove last") - << int(QQuickPathView::NoHighlightRange) << 7 << 1 << 3. << 4; + << int(QQuickPathView::NoHighlightRange) << 7 << 1 << qreal(3.) << 4; QTest::newRow("no range - remove first") - << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 4. << 3; + << int(QQuickPathView::NoHighlightRange) << 0 << 1 << qreal(4.) << 3; QTest::newRow("no range - remove current offset") - << int(QQuickPathView::NoHighlightRange) << 4 << 1 << 4. << 4; + << int(QQuickPathView::NoHighlightRange) << 4 << 1 << qreal(4.) << 4; QTest::newRow("no range - remove all") - << int(QQuickPathView::NoHighlightRange) << 0 << 8 << 0. << 0; + << int(QQuickPathView::NoHighlightRange) << 0 << 8 << qreal(0.) << 0; } void tst_QQuickPathView::removeModel() @@ -444,7 +440,8 @@ void tst_QQuickPathView::removeModel() QFETCH(qreal, offset); QFETCH(int, currentIndex); - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); + window->show(); QaimModel model; @@ -478,8 +475,6 @@ void tst_QQuickPathView::removeModel() QTRY_COMPARE(pathview->offset(), offset); QCOMPARE(pathview->currentIndex(), currentIndex); - - delete window; } @@ -494,40 +489,40 @@ void tst_QQuickPathView::moveModel_data() // We have 8 items, with currentIndex == 4 QTest::newRow("move after current") - << int(QQuickPathView::StrictlyEnforceRange) << 5 << 6 << 1 << 4. << 4; + << int(QQuickPathView::StrictlyEnforceRange) << 5 << 6 << 1 << qreal(4.) << 4; QTest::newRow("move before current") - << int(QQuickPathView::StrictlyEnforceRange) << 2 << 3 << 1 << 4. << 4; + << int(QQuickPathView::StrictlyEnforceRange) << 2 << 3 << 1 << qreal(4.) << 4; QTest::newRow("move before current to after") - << int(QQuickPathView::StrictlyEnforceRange) << 2 << 6 << 1 << 5. << 3; + << int(QQuickPathView::StrictlyEnforceRange) << 2 << 6 << 1 << qreal(5.) << 3; QTest::newRow("move multiple after current") - << int(QQuickPathView::StrictlyEnforceRange) << 5 << 6 << 2 << 4. << 4; + << int(QQuickPathView::StrictlyEnforceRange) << 5 << 6 << 2 << qreal(4.) << 4; QTest::newRow("move multiple before current") - << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 2 << 4. << 4; + << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 2 << qreal(4.) << 4; QTest::newRow("move before current to end") - << int(QQuickPathView::StrictlyEnforceRange) << 2 << 7 << 1 << 5. << 3; + << int(QQuickPathView::StrictlyEnforceRange) << 2 << 7 << 1 << qreal(5.) << 3; QTest::newRow("move last to beginning") - << int(QQuickPathView::StrictlyEnforceRange) << 7 << 0 << 1 << 3. << 5; + << int(QQuickPathView::StrictlyEnforceRange) << 7 << 0 << 1 << qreal(3.) << 5; QTest::newRow("move current") - << int(QQuickPathView::StrictlyEnforceRange) << 4 << 6 << 1 << 2. << 6; + << int(QQuickPathView::StrictlyEnforceRange) << 4 << 6 << 1 << qreal(2.) << 6; QTest::newRow("no range - move after current") - << int(QQuickPathView::NoHighlightRange) << 5 << 6 << 1 << 4. << 4; + << int(QQuickPathView::NoHighlightRange) << 5 << 6 << 1 << qreal(4.) << 4; QTest::newRow("no range - move before current") - << int(QQuickPathView::NoHighlightRange) << 2 << 3 << 1 << 4. << 4; + << int(QQuickPathView::NoHighlightRange) << 2 << 3 << 1 << qreal(4.) << 4; QTest::newRow("no range - move before current to after") - << int(QQuickPathView::NoHighlightRange) << 2 << 6 << 1 << 5. << 3; + << int(QQuickPathView::NoHighlightRange) << 2 << 6 << 1 << qreal(5.) << 3; QTest::newRow("no range - move multiple after current") - << int(QQuickPathView::NoHighlightRange) << 5 << 6 << 2 << 4. << 4; + << int(QQuickPathView::NoHighlightRange) << 5 << 6 << 2 << qreal(4.) << 4; QTest::newRow("no range - move multiple before current") - << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 2 << 4. << 4; + << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 2 << qreal(4.) << 4; QTest::newRow("no range - move before current to end") - << int(QQuickPathView::NoHighlightRange) << 2 << 7 << 1 << 5. << 3; + << int(QQuickPathView::NoHighlightRange) << 2 << 7 << 1 << qreal(5.) << 3; QTest::newRow("no range - move last to beginning") - << int(QQuickPathView::NoHighlightRange) << 7 << 0 << 1 << 3. << 5; + << int(QQuickPathView::NoHighlightRange) << 7 << 0 << 1 << qreal(3.) << 5; QTest::newRow("no range - move current") - << int(QQuickPathView::NoHighlightRange) << 4 << 6 << 1 << 4. << 6; + << int(QQuickPathView::NoHighlightRange) << 4 << 6 << 1 << qreal(4.) << 6; QTest::newRow("no range - move multiple incl. current") - << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 5 << 4. << 5; + << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 5 << qreal(4.) << 5; } void tst_QQuickPathView::moveModel() @@ -539,7 +534,7 @@ void tst_QQuickPathView::moveModel() QFETCH(qreal, offset); QFETCH(int, currentIndex); - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->show(); QaimModel model; @@ -573,8 +568,6 @@ void tst_QQuickPathView::moveModel() QTRY_COMPARE(pathview->offset(), offset); QCOMPARE(pathview->currentIndex(), currentIndex); - - delete window; } void tst_QQuickPathView::consecutiveModelChanges_data() @@ -640,7 +633,7 @@ void tst_QQuickPathView::consecutiveModelChanges() QFETCH(qreal, offset); QFETCH(int, currentIndex); - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->show(); QaimModel model; @@ -704,7 +697,6 @@ void tst_QQuickPathView::consecutiveModelChanges() QCOMPARE(pathview->currentIndex(), currentIndex); - delete window; } void tst_QQuickPathView::path() @@ -756,7 +748,7 @@ void tst_QQuickPathView::path() void tst_QQuickPathView::dataModel() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->show(); QQmlContext *ctxt = window->rootContext(); @@ -865,13 +857,12 @@ void tst_QQuickPathView::dataModel() model.removeItem(model.count()-1); QCOMPARE(pathview->currentIndex(), model.count()-1); - delete window; delete testObject; } void tst_QQuickPathView::pathMoved() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->show(); QaimModel model; @@ -926,7 +917,6 @@ void tst_QQuickPathView::pathMoved() window->rootObject()->setProperty("delegateScale", 1.2); QTRY_COMPARE(firstItem->position() + offset, start); - delete window; } void tst_QQuickPathView::offset_data() @@ -960,7 +950,7 @@ void tst_QQuickPathView::offset() void tst_QQuickPathView::setCurrentIndex() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->show(); QaimModel model; @@ -1103,12 +1093,11 @@ void tst_QQuickPathView::setCurrentIndex() QCOMPARE(pathview->currentItem(), firstItem); QCOMPARE(firstItem->property("onPath"), QVariant(true)); - delete window; } void tst_QQuickPathView::resetModel() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); QStringList strings; strings << "one" << "two" << "three"; @@ -1143,12 +1132,11 @@ void tst_QQuickPathView::resetModel() QCOMPARE(display->text(), strings.at(i)); } - delete window; } void tst_QQuickPathView::propertyChanges() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); QVERIFY(window); window->setSource(testFileUrl("propertychanges.qml")); @@ -1185,12 +1173,11 @@ void tst_QQuickPathView::propertyChanges() pathView->setMaximumFlickVelocity(1000); QCOMPARE(maximumFlickVelocitySpy.count(), 1); - delete window; } void tst_QQuickPathView::pathChanges() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); QVERIFY(window); window->setSource(testFileUrl("propertychanges.qml")); @@ -1247,12 +1234,11 @@ void tst_QQuickPathView::pathChanges() pathAttribute->setName("scale"); QCOMPARE(nameSpy.count(),1); - delete window; } void tst_QQuickPathView::componentChanges() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); QVERIFY(window); window->setSource(testFileUrl("propertychanges.qml")); @@ -1270,12 +1256,11 @@ void tst_QQuickPathView::componentChanges() pathView->setDelegate(&delegateComponent); QCOMPARE(delegateSpy.count(),1); - delete window; } void tst_QQuickPathView::modelChanges() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); QVERIFY(window); window->setSource(testFileUrl("propertychanges.qml")); @@ -1284,7 +1269,7 @@ void tst_QQuickPathView::modelChanges() pathView->setCurrentIndex(3); QTRY_COMPARE(pathView->offset(), 6.0); - QQuickListModel *alternateModel = window->rootObject()->findChild<QQuickListModel*>("alternateModel"); + QQmlListModel *alternateModel = window->rootObject()->findChild<QQmlListModel*>("alternateModel"); QVERIFY(alternateModel); QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel); QSignalSpy modelSpy(pathView, SIGNAL(modelChanged())); @@ -1305,12 +1290,11 @@ void tst_QQuickPathView::modelChanges() QCOMPARE(pathView->currentIndex(), 0); QCOMPARE(currentIndexSpy.count(), 1); - delete window; } void tst_QQuickPathView::pathUpdateOnStartChanged() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); QVERIFY(window); window->setSource(testFileUrl("pathUpdateOnStartChanged.qml")); @@ -1327,17 +1311,16 @@ void tst_QQuickPathView::pathUpdateOnStartChanged() QCOMPARE(item->x(), path->startX() - item->width() / 2.0); QCOMPARE(item->y(), path->startY() - item->height() / 2.0); - delete window; } void tst_QQuickPathView::package() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); QVERIFY(window); window->setSource(testFileUrl("pathview_package.qml")); window->show(); window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QTest::qWaitForWindowActive(window.data())); QQuickPathView *pathView = window->rootObject()->findChild<QQuickPathView*>("photoPathView"); QVERIFY(pathView); @@ -1350,13 +1333,12 @@ void tst_QQuickPathView::package() QVERIFY(item); QVERIFY(item->scale() != 1.0); - delete window; } //QTBUG-13017 void tst_QQuickPathView::emptyModel() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); QStringListModel model; @@ -1371,7 +1353,6 @@ void tst_QQuickPathView::emptyModel() QCOMPARE(pathview->offset(), qreal(0.0)); - delete window; } void tst_QQuickPathView::emptyPath() @@ -1411,7 +1392,7 @@ void tst_QQuickPathView::closed() // QTBUG-14239 void tst_QQuickPathView::pathUpdate() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); QVERIFY(window); window->setSource(testFileUrl("pathUpdate.qml")); @@ -1422,7 +1403,6 @@ void tst_QQuickPathView::pathUpdate() QVERIFY(item); QCOMPARE(item->x(), 150.0); - delete window; } void tst_QQuickPathView::visualDataModel() @@ -1463,12 +1443,12 @@ void tst_QQuickPathView::undefinedPath() void tst_QQuickPathView::mouseDrag() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("dragpath.qml")); window->show(); window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - QCOMPARE(window, qGuiApp->focusWindow()); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + QCOMPARE(window.data(), qGuiApp->focusWindow()); QQuickPathView *pathview = qobject_cast<QQuickPathView*>(window->rootObject()); QVERIFY(pathview != 0); @@ -1482,12 +1462,12 @@ void tst_QQuickPathView::mouseDrag() int current = pathview->currentIndex(); - QTest::mousePress(window, Qt::LeftButton, 0, QPoint(10,100)); + QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(10,100)); QTest::qWait(100); { QMouseEvent mv(QEvent::MouseMove, QPoint(30,100), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QGuiApplication::sendEvent(window, &mv); + QGuiApplication::sendEvent(window.data(), &mv); } // first move beyond threshold does not trigger drag QVERIFY(!pathview->isMoving()); @@ -1501,7 +1481,7 @@ void tst_QQuickPathView::mouseDrag() { QMouseEvent mv(QEvent::MouseMove, QPoint(90,100), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QGuiApplication::sendEvent(window, &mv); + QGuiApplication::sendEvent(window.data(), &mv); } // next move beyond threshold does trigger drag QVERIFY(pathview->isMoving()); @@ -1515,7 +1495,7 @@ void tst_QQuickPathView::mouseDrag() QVERIFY(pathview->currentIndex() != current); - QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(40,100)); + QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(40,100)); QVERIFY(!pathview->isDragging()); QCOMPARE(draggingSpy.count(), 2); QCOMPARE(dragStartedSpy.count(), 1); @@ -1524,12 +1504,11 @@ void tst_QQuickPathView::mouseDrag() QTRY_COMPARE(moveEndedSpy.count(), 1); QCOMPARE(moveStartedSpy.count(), 1); - delete window; } void tst_QQuickPathView::treeModel() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->show(); QStandardItemModel model; @@ -1552,18 +1531,17 @@ void tst_QQuickPathView::treeModel() QTRY_VERIFY(item = findItem<QQuickText>(pathview, "wrapper", 0)); QTRY_COMPARE(item->text(), QLatin1String("Row 2 Child Item")); - delete window; } void tst_QQuickPathView::changePreferredHighlight() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->setGeometry(0,0,400,200); window->setSource(testFileUrl("dragpath.qml")); window->show(); window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - QCOMPARE(window, qGuiApp->focusWindow()); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + QCOMPARE(window.data(), qGuiApp->focusWindow()); QQuickPathView *pathview = qobject_cast<QQuickPathView*>(window->rootObject()); QVERIFY(pathview != 0); @@ -1587,7 +1565,6 @@ void tst_QQuickPathView::changePreferredHighlight() QTRY_COMPARE(firstItem->position() + offset, start); QCOMPARE(pathview->currentIndex(), 0); - delete window; } void tst_QQuickPathView::creationContext() @@ -1608,7 +1585,7 @@ void tst_QQuickPathView::creationContext() // QTBUG-21320 void tst_QQuickPathView::currentOffsetOnInsertion() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->show(); QaimModel model; @@ -1681,12 +1658,11 @@ void tst_QQuickPathView::currentOffsetOnInsertion() // verify that current item (item 1) is still at offset 0.5 QCOMPARE(item->position() + offset, start); - delete window; } void tst_QQuickPathView::asynchronous() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->show(); QQmlIncubationController controller; window->engine()->setIncubationController(&controller); @@ -1737,7 +1713,6 @@ void tst_QQuickPathView::asynchronous() QCOMPARE(curItem->position() + offset, itemPos); } - delete window; } void tst_QQuickPathView::missingPercent() @@ -1752,12 +1727,12 @@ void tst_QQuickPathView::missingPercent() void tst_QQuickPathView::cancelDrag() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("dragpath.qml")); window->show(); window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - QCOMPARE(window, qGuiApp->focusWindow()); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + QCOMPARE(window.data(), qGuiApp->focusWindow()); QQuickPathView *pathview = qobject_cast<QQuickPathView*>(window->rootObject()); QVERIFY(pathview != 0); @@ -1767,10 +1742,10 @@ void tst_QQuickPathView::cancelDrag() QSignalSpy dragEndedSpy(pathview, SIGNAL(dragEnded())); // drag between snap points - QTest::mousePress(window, Qt::LeftButton, 0, QPoint(10,100)); + QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(10,100)); QTest::qWait(100); - QTest::mouseMove(window, QPoint(30, 100)); - QTest::mouseMove(window, QPoint(85, 100)); + QTest::mouseMove(window.data(), QPoint(30, 100)); + QTest::mouseMove(window.data(), QPoint(85, 100)); QTRY_VERIFY(pathview->offset() != qFloor(pathview->offset())); QTRY_VERIFY(pathview->isMoving()); @@ -1791,25 +1766,24 @@ void tst_QQuickPathView::cancelDrag() QCOMPARE(dragStartedSpy.count(), 1); QCOMPARE(dragEndedSpy.count(), 1); - QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(40,100)); + QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(40,100)); - delete window; } void tst_QQuickPathView::maximumFlickVelocity() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("dragpath.qml")); window->show(); window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - QCOMPARE(window, qGuiApp->focusWindow()); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + QCOMPARE(window.data(), qGuiApp->focusWindow()); QQuickPathView *pathview = qobject_cast<QQuickPathView*>(window->rootObject()); QVERIFY(pathview != 0); pathview->setMaximumFlickVelocity(700); - flick(window, QPoint(200,10), QPoint(10,10), 180); + flick(window.data(), QPoint(200,10), QPoint(10,10), 180); QVERIFY(pathview->isMoving()); QVERIFY(pathview->isFlicking()); QTRY_VERIFY_WITH_TIMEOUT(!pathview->isMoving(), 50000); @@ -1818,7 +1792,7 @@ void tst_QQuickPathView::maximumFlickVelocity() pathview->setOffset(0.); pathview->setMaximumFlickVelocity(300); - flick(window, QPoint(200,10), QPoint(10,10), 180); + flick(window.data(), QPoint(200,10), QPoint(10,10), 180); QVERIFY(pathview->isMoving()); QVERIFY(pathview->isFlicking()); QTRY_VERIFY_WITH_TIMEOUT(!pathview->isMoving(), 50000); @@ -1827,7 +1801,7 @@ void tst_QQuickPathView::maximumFlickVelocity() pathview->setOffset(0.); pathview->setMaximumFlickVelocity(500); - flick(window, QPoint(200,10), QPoint(10,10), 180); + flick(window.data(), QPoint(200,10), QPoint(10,10), 180); QVERIFY(pathview->isMoving()); QVERIFY(pathview->isFlicking()); QTRY_VERIFY_WITH_TIMEOUT(!pathview->isMoving(), 50000); @@ -1838,14 +1812,13 @@ void tst_QQuickPathView::maximumFlickVelocity() QVERIFY(dist3 > dist2); QVERIFY(dist2 < dist1); - delete window; } void tst_QQuickPathView::snapToItem() { QFETCH(bool, enforceRange); - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("panels.qml")); QQuickPathView *pathview = window->rootObject()->findChild<QQuickPathView*>("view"); QVERIFY(pathview != 0); @@ -1857,7 +1830,7 @@ void tst_QQuickPathView::snapToItem() QSignalSpy snapModeSpy(pathview, SIGNAL(snapModeChanged())); - flick(window, QPoint(200,10), QPoint(10,10), 180); + flick(window.data(), QPoint(200,10), QPoint(10,10), 180); QVERIFY(pathview->isMoving()); QTRY_VERIFY(!pathview->isMoving()); @@ -1869,7 +1842,6 @@ void tst_QQuickPathView::snapToItem() else QVERIFY(pathview->currentIndex() == currentIndex); - delete window; } void tst_QQuickPathView::snapToItem_data() @@ -1884,12 +1856,12 @@ void tst_QQuickPathView::snapOneItem() { QFETCH(bool, enforceRange); - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("panels.qml")); window->show(); window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - QCOMPARE(window, qGuiApp->focusWindow()); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + QCOMPARE(window.data(), qGuiApp->focusWindow()); QQuickPathView *pathview = window->rootObject()->findChild<QQuickPathView*>("view"); QVERIFY(pathview != 0); @@ -1905,7 +1877,7 @@ void tst_QQuickPathView::snapOneItem() int currentIndex = pathview->currentIndex(); double startOffset = pathview->offset(); - flick(window, QPoint(200,10), QPoint(10,10), 180); + flick(window.data(), QPoint(200,10), QPoint(10,10), 180); QVERIFY(pathview->isMoving()); QTRY_VERIFY(!pathview->isMoving()); @@ -1918,7 +1890,6 @@ void tst_QQuickPathView::snapOneItem() else QVERIFY(pathview->currentIndex() == currentIndex); - delete window; } void tst_QQuickPathView::snapOneItem_data() @@ -1938,12 +1909,12 @@ void tst_QQuickPathView::positionViewAtIndex() QFETCH(QQuickPathView::PositionMode, mode); QFETCH(qreal, offset); - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("pathview3.qml")); window->show(); window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - QCOMPARE(window, qGuiApp->focusWindow()); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + QCOMPARE(window.data(), qGuiApp->focusWindow()); QQuickPathView *pathview = qobject_cast<QQuickPathView*>(window->rootObject()); QVERIFY(pathview != 0); @@ -1959,7 +1930,6 @@ void tst_QQuickPathView::positionViewAtIndex() QCOMPARE(pathview->offset(), offset); - delete window; } void tst_QQuickPathView::positionViewAtIndex_data() @@ -2002,12 +1972,12 @@ void tst_QQuickPathView::indexAt_itemAt() QFETCH(qreal, y); QFETCH(int, index); - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("pathview3.qml")); window->show(); window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - QCOMPARE(window, qGuiApp->focusWindow()); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + QCOMPARE(window.data(), qGuiApp->focusWindow()); QQuickPathView *pathview = qobject_cast<QQuickPathView*>(window->rootObject()); QVERIFY(pathview != 0); @@ -2020,7 +1990,6 @@ void tst_QQuickPathView::indexAt_itemAt() QCOMPARE(pathview->indexAt(x,y), index); QVERIFY(pathview->itemAt(x,y) == item); - delete window; } void tst_QQuickPathView::indexAt_itemAt_data() @@ -2029,16 +1998,16 @@ void tst_QQuickPathView::indexAt_itemAt_data() QTest::addColumn<qreal>("y"); QTest::addColumn<int>("index"); - QTest::newRow("Item 0 - 585, 95") << 585. << 95. << 0; - QTest::newRow("Item 0 - 660, 165") << 660. << 165. << 0; - QTest::newRow("No Item a - 580, 95") << 580. << 95. << -1; - QTest::newRow("No Item b - 585, 85") << 585. << 85. << -1; - QTest::newRow("Item 7 - 360, 200") << 360. << 200. << 7; + QTest::newRow("Item 0 - 585, 95") << qreal(585.) << qreal(95.) << 0; + QTest::newRow("Item 0 - 660, 165") << qreal(660.) << qreal(165.) << 0; + QTest::newRow("No Item a - 580, 95") << qreal(580.) << qreal(95.) << -1; + QTest::newRow("No Item b - 585, 85") << qreal(585.) << qreal(85.) << -1; + QTest::newRow("Item 7 - 360, 200") << qreal(360.) << qreal(200.) << 7; } void tst_QQuickPathView::cacheItemCount() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("pathview3.qml")); window->show(); @@ -2112,7 +2081,6 @@ void tst_QQuickPathView::cacheItemCount() controller.incubateWhile(&b); } - delete window; } QTEST_MAIN(tst_QQuickPathView) diff --git a/tests/auto/quick/qquickpincharea/qquickpincharea.pro b/tests/auto/quick/qquickpincharea/qquickpincharea.pro index df3b14d8c0..970ce48851 100644 --- a/tests/auto/quick/qquickpincharea/qquickpincharea.pro +++ b/tests/auto/quick/qquickpincharea/qquickpincharea.pro @@ -1,4 +1,5 @@ CONFIG += testcase +CONFIG += parallel_test TARGET = tst_qquickpincharea macx:CONFIG -= app_bundle diff --git a/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp b/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp index ba1db0e7cf..18595133d0 100644 --- a/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp +++ b/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp @@ -84,10 +84,9 @@ void tst_QQuickPinchArea::cleanupTestCase() } void tst_QQuickPinchArea::pinchProperties() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("pinchproperties.qml")); window->show(); - window->requestActivate(); QVERIFY(window->rootObject() != 0); QQuickPinchArea *pinchArea = window->rootObject()->findChild<QQuickPinchArea*>("pincharea"); @@ -195,8 +194,6 @@ void tst_QQuickPinchArea::pinchProperties() QCOMPARE(rotMinSpy.count(),1); QCOMPARE(rotMaxSpy.count(),1); - - delete window; } QTouchEvent::TouchPoint makeTouchPoint(int id, QPoint p, QQuickView *v, QQuickItem *i) @@ -211,10 +208,10 @@ QTouchEvent::TouchPoint makeTouchPoint(int id, QPoint p, QQuickView *v, QQuickIt void tst_QQuickPinchArea::scale() { QQuickView *window = createView(); + QScopedPointer<QQuickView> scope(window); window->setSource(testFileUrl("pinchproperties.qml")); window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QTest::qWaitForWindowExposed(window)); QVERIFY(window->rootObject() != 0); qApp->processEvents(); @@ -267,17 +264,15 @@ void tst_QQuickPinchArea::scale() pinchSequence.release(0, p1, window).release(1, p2, window).commit(); } QVERIFY(!root->property("pinchActive").toBool()); - - delete window; } void tst_QQuickPinchArea::pan() { QQuickView *window = createView(); + QScopedPointer<QQuickView> scope(window); window->setSource(testFileUrl("pinchproperties.qml")); window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QTest::qWaitForWindowExposed(window)); QVERIFY(window->rootObject() != 0); qApp->processEvents(); @@ -327,18 +322,16 @@ void tst_QQuickPinchArea::pan() QTest::touchEvent(window, device).release(0, p1, window).release(1, p2, window); QVERIFY(!root->property("pinchActive").toBool()); - - delete window; } // test pinch, release one point, touch again to continue pinch void tst_QQuickPinchArea::retouch() { QQuickView *window = createView(); + QScopedPointer<QQuickView> scope(window); window->setSource(testFileUrl("pinchproperties.qml")); window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QTest::qWaitForWindowExposed(window)); QVERIFY(window->rootObject() != 0); qApp->processEvents(); @@ -413,8 +406,6 @@ void tst_QQuickPinchArea::retouch() QCOMPARE(startedSpy.count(), 2); QCOMPARE(finishedSpy.count(), 1); } - - delete window; } void tst_QQuickPinchArea::transformedPinchArea_data() @@ -449,10 +440,10 @@ void tst_QQuickPinchArea::transformedPinchArea() QFETCH(bool, shouldPinch); QQuickView *view = createView(); + QScopedPointer<QQuickView> scope(view); view->setSource(testFileUrl("transformedPinchArea.qml")); view->show(); - view->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(view)); + QVERIFY(QTest::qWaitForWindowExposed(view)); QVERIFY(view->rootObject() != 0); qApp->processEvents(); @@ -475,8 +466,6 @@ void tst_QQuickPinchArea::transformedPinchArea() pinchSequence.release(0, p1, view).release(1, p2, view).commit(); QCOMPARE(pinchArea->property("pinching").toBool(), false); } - - delete view; } QQuickView *tst_QQuickPinchArea::createView() diff --git a/tests/auto/quick/qquickpositioners/data/gridtest.qml b/tests/auto/quick/qquickpositioners/data/gridtest.qml index 50bec1377b..fbe0b22b15 100644 --- a/tests/auto/quick/qquickpositioners/data/gridtest.qml +++ b/tests/auto/quick/qquickpositioners/data/gridtest.qml @@ -1,11 +1,15 @@ -import QtQuick 2.0 +import QtQuick 2.1 Item { width: 640 height: 480 property bool testRightToLeft: false + property int testHAlignment: Grid.AlignLeft; + property int testVAlignment: Grid.AlignTop; Grid { layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight + horizontalItemAlignment: testHAlignment + verticalItemAlignment: testVAlignment objectName: "grid" columns: 3 Rectangle { diff --git a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp index 98999e540a..1f472a3f46 100644 --- a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp +++ b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp @@ -78,6 +78,8 @@ private slots: void test_grid_animated(); void test_grid_animated_rightToLeft(); void test_grid_zero_columns(); + void test_grid_H_alignment(); + void test_grid_V_alignment(); void test_propertychanges(); void test_repeater(); void test_flow(); @@ -288,7 +290,7 @@ tst_qquickpositioners::tst_qquickpositioners() void tst_qquickpositioners::test_horizontal() { - QQuickView *window = createView(testFile("horizontal.qml")); + QScopedPointer<QQuickView> window(createView(testFile("horizontal.qml"))); window->rootObject()->setProperty("testRightToLeft", false); @@ -311,13 +313,11 @@ void tst_qquickpositioners::test_horizontal() QQuickItem *row = window->rootObject()->findChild<QQuickItem*>("row"); QCOMPARE(row->width(), 110.0); QCOMPARE(row->height(), 50.0); - - delete window; } void tst_qquickpositioners::test_horizontal_rtl() { - QQuickView *window = createView(testFile("horizontal.qml")); + QScopedPointer<QQuickView> window(createView(testFile("horizontal.qml"))); window->rootObject()->setProperty("testRightToLeft", true); @@ -350,12 +350,11 @@ void tst_qquickpositioners::test_horizontal_rtl() QCOMPARE(three->x(), 90.0); QCOMPARE(three->y(), 0.0); - delete window; } void tst_qquickpositioners::test_horizontal_spacing() { - QQuickView *window = createView(testFile("horizontal-spacing.qml")); + QScopedPointer<QQuickView> window(createView(testFile("horizontal-spacing.qml"))); window->rootObject()->setProperty("testRightToLeft", false); @@ -379,12 +378,11 @@ void tst_qquickpositioners::test_horizontal_spacing() QCOMPARE(row->width(), 130.0); QCOMPARE(row->height(), 50.0); - delete window; } void tst_qquickpositioners::test_horizontal_spacing_rightToLeft() { - QQuickView *window = createView(testFile("horizontal-spacing.qml")); + QScopedPointer<QQuickView> window(createView(testFile("horizontal-spacing.qml"))); window->rootObject()->setProperty("testRightToLeft", true); @@ -408,12 +406,11 @@ void tst_qquickpositioners::test_horizontal_spacing_rightToLeft() QCOMPARE(row->width(), 130.0); QCOMPARE(row->height(), 50.0); - delete window; } void tst_qquickpositioners::test_horizontal_animated() { - QQuickView *window = createView(testFile("horizontal-animated.qml"), false); + QScopedPointer<QQuickView> window(createView(testFile("horizontal-animated.qml"), false)); window->rootObject()->setProperty("testRightToLeft", false); @@ -431,7 +428,7 @@ void tst_qquickpositioners::test_horizontal_animated() QCOMPARE(two->x(), -100.0); QCOMPARE(three->x(), -100.0); - QVERIFY(QTest::qWaitForWindowExposed(window)); //It may not relayout until the next frame, so it needs to be drawn + QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn QQuickItem *row = window->rootObject()->findChild<QQuickItem*>("row"); QVERIFY(row); @@ -462,12 +459,11 @@ void tst_qquickpositioners::test_horizontal_animated() QTRY_COMPARE(two->x(), 50.0); QTRY_COMPARE(three->x(), 100.0); - delete window; } void tst_qquickpositioners::test_horizontal_animated_rightToLeft() { - QQuickView *window = createView(testFile("horizontal-animated.qml"), false); + QScopedPointer<QQuickView> window(createView(testFile("horizontal-animated.qml"), false)); window->rootObject()->setProperty("testRightToLeft", true); @@ -485,7 +481,7 @@ void tst_qquickpositioners::test_horizontal_animated_rightToLeft() QCOMPARE(two->x(), -100.0); QCOMPARE(three->x(), -100.0); - QVERIFY(QTest::qWaitForWindowExposed(window)); //It may not relayout until the next frame, so it needs to be drawn + QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn QQuickItem *row = window->rootObject()->findChild<QQuickItem*>("row"); QVERIFY(row); @@ -518,12 +514,11 @@ void tst_qquickpositioners::test_horizontal_animated_rightToLeft() QTRY_COMPARE(one->x(), 100.0); QTRY_COMPARE(two->x(), 50.0); - delete window; } void tst_qquickpositioners::test_horizontal_animated_disabled() { - QQuickView *window = createView(testFile("horizontal-animated-disabled.qml")); + QScopedPointer<QQuickView> window(createView(testFile("horizontal-animated-disabled.qml"))); QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one"); QVERIFY(one != 0); @@ -556,7 +551,6 @@ void tst_qquickpositioners::test_horizontal_animated_disabled() QTRY_COMPARE(two->x(), 50.0); QTRY_COMPARE(three->x(), 100.0); - delete window; } void tst_qquickpositioners::populateTransitions(const QString &positionerObjectName) @@ -576,7 +570,8 @@ void tst_qquickpositioners::populateTransitions(const QString &positionerObjectN QaimModel model_targetItems_transitionFrom; QaimModel model_displacedItems_transitionVia; - QQuickView *window = QQuickViewTestUtil::createView(); + QScopedPointer<QQuickView> window(QQuickViewTestUtil::createView()); + QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("usePopulateTransition", usePopulateTransition); ctxt->setContextProperty("enableAddTransition", true); @@ -592,6 +587,7 @@ void tst_qquickpositioners::populateTransitions(const QString &positionerObjectN QQuickItem *positioner = window->rootObject()->findChild<QQuickItem*>(positionerObjectName); QVERIFY(positioner); window->show(); + QTest::qWaitForWindowExposed(window.data()); qApp->processEvents(); if (!dynamicallyPopulate && usePopulateTransition) { @@ -627,8 +623,6 @@ void tst_qquickpositioners::populateTransitions(const QString &positionerObjectN model.insertItem(0, "new item", ""); QTRY_COMPARE(window->rootObject()->property("addTransitionsDone").toInt(), 1); QTRY_COMPARE(window->rootObject()->property("populateTransitionsDone").toInt(), 0); - - delete window; } void tst_qquickpositioners::populateTransitions_data() @@ -657,7 +651,7 @@ void tst_qquickpositioners::addTransitions(const QString &positionerObjectName) QaimModel model_targetItems_transitionFrom; QaimModel model_displacedItems_transitionVia; - QQuickView *window = QQuickViewTestUtil::createView(); + QScopedPointer<QQuickView> window(QQuickViewTestUtil::createView()); QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("usePopulateTransition", QVariant(false)); ctxt->setContextProperty("enableAddTransition", QVariant(true)); @@ -667,6 +661,7 @@ void tst_qquickpositioners::addTransitions(const QString &positionerObjectName) ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia); window->setSource(testFileUrl("transitions.qml")); window->show(); + QTest::qWaitForWindowExposed(window.data()); qApp->processEvents(); QQuickItem *positioner = window->rootObject()->findChild<QQuickItem*>(positionerObjectName); @@ -733,8 +728,6 @@ void tst_qquickpositioners::addTransitions(const QString &positionerObjectName) } checkItemPositions(positioner, &model, window->rootObject()->property("incrementalSize").toInt()); - - delete window; } void tst_qquickpositioners::addTransitions_data() @@ -770,7 +763,7 @@ void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName) QaimModel model_targetItems_transitionFrom; QaimModel model_displacedItems_transitionVia; - QQuickView *window = QQuickViewTestUtil::createView(); + QScopedPointer<QQuickView> window(QQuickViewTestUtil::createView()); QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("usePopulateTransition", QVariant(false)); ctxt->setContextProperty("enableAddTransition", QVariant(false)); @@ -780,6 +773,7 @@ void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName) ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia); window->setSource(testFileUrl("transitions.qml")); window->show(); + QTest::qWaitForWindowExposed(window.data()); qApp->processEvents(); QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); @@ -842,8 +836,6 @@ void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName) } checkItemPositions(positioner, &model, window->rootObject()->property("incrementalSize").toInt()); - - delete window; } void tst_qquickpositioners::moveTransitions_data() @@ -929,7 +921,7 @@ void tst_qquickpositioners::checkItemPositions(QQuickItem *positioner, QaimModel void tst_qquickpositioners::test_vertical() { - QQuickView *window = createView(testFile("vertical.qml")); + QScopedPointer<QQuickView> window(createView(testFile("vertical.qml"))); QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one"); QVERIFY(one != 0); @@ -952,12 +944,11 @@ void tst_qquickpositioners::test_vertical() QCOMPARE(column->height(), 80.0); QCOMPARE(column->width(), 50.0); - delete window; } void tst_qquickpositioners::test_vertical_spacing() { - QQuickView *window = createView(testFile("vertical-spacing.qml")); + QScopedPointer<QQuickView> window(createView(testFile("vertical-spacing.qml"))); QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one"); QVERIFY(one != 0); @@ -979,12 +970,11 @@ void tst_qquickpositioners::test_vertical_spacing() QCOMPARE(column->height(), 100.0); QCOMPARE(column->width(), 50.0); - delete window; } void tst_qquickpositioners::test_vertical_animated() { - QQuickView *window = createView(testFile("vertical-animated.qml"), false); + QScopedPointer<QQuickView> window(createView(testFile("vertical-animated.qml"), false)); //Note that they animate in QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one"); @@ -999,7 +989,7 @@ void tst_qquickpositioners::test_vertical_animated() QVERIFY(three != 0); QCOMPARE(three->y(), -100.0); - QVERIFY(QTest::qWaitForWindowExposed(window)); //It may not relayout until the next frame, so it needs to be drawn + QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn QQuickItem *column = window->rootObject()->findChild<QQuickItem*>("column"); QVERIFY(column); @@ -1029,12 +1019,11 @@ void tst_qquickpositioners::test_vertical_animated() QTRY_COMPARE(two->y(), 50.0); QTRY_COMPARE(three->y(), 100.0); - delete window; } void tst_qquickpositioners::test_grid() { - QQuickView *window = createView(testFile("gridtest.qml")); + QScopedPointer<QQuickView> window(createView(testFile("gridtest.qml"))); QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one"); QVERIFY(one != 0); @@ -1063,12 +1052,11 @@ void tst_qquickpositioners::test_grid() QCOMPARE(grid->width(), 100.0); QCOMPARE(grid->height(), 100.0); - delete window; } void tst_qquickpositioners::test_grid_topToBottom() { - QQuickView *window = createView(testFile("grid-toptobottom.qml")); + QScopedPointer<QQuickView> window(createView(testFile("grid-toptobottom.qml"))); QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one"); QVERIFY(one != 0); @@ -1097,12 +1085,11 @@ void tst_qquickpositioners::test_grid_topToBottom() QCOMPARE(grid->width(), 100.0); QCOMPARE(grid->height(), 120.0); - delete window; } void tst_qquickpositioners::test_grid_rightToLeft() { - QQuickView *window = createView(testFile("gridtest.qml")); + QScopedPointer<QQuickView> window(createView(testFile("gridtest.qml"))); window->rootObject()->setProperty("testRightToLeft", true); @@ -1146,12 +1133,11 @@ void tst_qquickpositioners::test_grid_rightToLeft() QCOMPARE(five->x(), 140.0); QCOMPARE(five->y(), 50.0); - delete window; } void tst_qquickpositioners::test_grid_spacing() { - QQuickView *window = createView(testFile("grid-spacing.qml")); + QScopedPointer<QQuickView> window(createView(testFile("grid-spacing.qml"))); QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one"); QVERIFY(one != 0); @@ -1179,12 +1165,11 @@ void tst_qquickpositioners::test_grid_spacing() QCOMPARE(grid->width(), 128.0); QCOMPARE(grid->height(), 104.0); - delete window; } void tst_qquickpositioners::test_grid_row_column_spacing() { - QQuickView *window = createView(testFile("grid-row-column-spacing.qml")); + QScopedPointer<QQuickView> window(createView(testFile("grid-row-column-spacing.qml"))); QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one"); QVERIFY(one != 0); @@ -1212,12 +1197,11 @@ void tst_qquickpositioners::test_grid_row_column_spacing() QCOMPARE(grid->width(), 142.0); QCOMPARE(grid->height(), 107.0); - delete window; } void tst_qquickpositioners::test_grid_animated() { - QQuickView *window = createView(testFile("grid-animated.qml"), false); + QScopedPointer<QQuickView> window(createView(testFile("grid-animated.qml"), false)); window->rootObject()->setProperty("testRightToLeft", false); @@ -1247,7 +1231,7 @@ void tst_qquickpositioners::test_grid_animated() QCOMPARE(five->x(), -100.0); QCOMPARE(five->y(), -100.0); - QVERIFY(QTest::qWaitForWindowExposed(window)); //It may not relayout until the next frame, so it needs to be drawn + QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn QQuickItem *grid = window->rootObject()->findChild<QQuickItem*>("grid"); QVERIFY(grid); @@ -1297,12 +1281,11 @@ void tst_qquickpositioners::test_grid_animated() QTRY_COMPARE(five->x(), 50.0); QTRY_COMPARE(five->y(), 50.0); - delete window; } void tst_qquickpositioners::test_grid_animated_rightToLeft() { - QQuickView *window = createView(testFile("grid-animated.qml"), false); + QScopedPointer<QQuickView> window(createView(testFile("grid-animated.qml"), false)); window->rootObject()->setProperty("testRightToLeft", true); @@ -1332,7 +1315,7 @@ void tst_qquickpositioners::test_grid_animated_rightToLeft() QCOMPARE(five->x(), -100.0); QCOMPARE(five->y(), -100.0); - QVERIFY(QTest::qWaitForWindowExposed(window)); //It may not relayout until the next frame, so it needs to be drawn + QVERIFY(QTest::qWaitForWindowExposed(window.data())); //It may not relayout until the next frame, so it needs to be drawn QQuickItem *grid = window->rootObject()->findChild<QQuickItem*>("grid"); QVERIFY(grid); @@ -1382,12 +1365,11 @@ void tst_qquickpositioners::test_grid_animated_rightToLeft() QTRY_COMPARE(five->x(), 50.0); QTRY_COMPARE(five->y(), 50.0); - delete window; } void tst_qquickpositioners::test_grid_zero_columns() { - QQuickView *window = createView(testFile("gridzerocolumns.qml")); + QScopedPointer<QQuickView> window(createView(testFile("gridzerocolumns.qml"))); QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one"); QVERIFY(one != 0); @@ -1415,12 +1397,133 @@ void tst_qquickpositioners::test_grid_zero_columns() QCOMPARE(grid->width(), 170.0); QCOMPARE(grid->height(), 60.0); - delete window; +} + +void tst_qquickpositioners::test_grid_H_alignment() +{ + QScopedPointer<QQuickView> window(createView(testFile("gridtest.qml"))); + + window->rootObject()->setProperty("testHAlignment", QQuickGrid::AlignHCenter); + + QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one"); + QVERIFY(one != 0); + QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>("two"); + QVERIFY(two != 0); + QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>("three"); + QVERIFY(three != 0); + QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>("four"); + QVERIFY(four != 0); + QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>("five"); + QVERIFY(five != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 50.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 70.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 0.0); + QCOMPARE(four->y(), 50.0); + QCOMPARE(five->x(), 55.0); + QCOMPARE(five->y(), 50.0); + + QQuickItem *grid = window->rootObject()->findChild<QQuickItem*>("grid"); + QCOMPARE(grid->width(), 100.0); + QCOMPARE(grid->height(), 100.0); + + window->rootObject()->setProperty("testHAlignment", QQuickGrid::AlignRight); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 50.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 70.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 0.0); + QCOMPARE(four->y(), 50.0); + QCOMPARE(five->x(), 60.0); + QCOMPARE(five->y(), 50.0); + QCOMPARE(grid->width(), 100.0); + QCOMPARE(grid->height(), 100.0); + + window->rootObject()->setProperty("testRightToLeft", true); + + QCOMPARE(one->x(), 50.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 30.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 0.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 50.0); + QCOMPARE(four->y(), 50.0); + QCOMPARE(five->x(), 30.0); + QCOMPARE(five->y(), 50.0); + QCOMPARE(grid->width(), 100.0); + QCOMPARE(grid->height(), 100.0); + + window->rootObject()->setProperty("testHAlignment", QQuickGrid::AlignHCenter); + + QCOMPARE(one->x(), 50.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 30.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 0.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 50.0); + QCOMPARE(four->y(), 50.0); + QCOMPARE(five->x(), 35.0); + QCOMPARE(five->y(), 50.0); + QCOMPARE(grid->width(), 100.0); + QCOMPARE(grid->height(), 100.0); + +} + +void tst_qquickpositioners::test_grid_V_alignment() +{ + QScopedPointer<QQuickView> window(createView(testFile("gridtest.qml"))); + + window->rootObject()->setProperty("testVAlignment", QQuickGrid::AlignVCenter); + + QQuickRectangle *one = window->rootObject()->findChild<QQuickRectangle*>("one"); + QVERIFY(one != 0); + QQuickRectangle *two = window->rootObject()->findChild<QQuickRectangle*>("two"); + QVERIFY(two != 0); + QQuickRectangle *three = window->rootObject()->findChild<QQuickRectangle*>("three"); + QVERIFY(three != 0); + QQuickRectangle *four = window->rootObject()->findChild<QQuickRectangle*>("four"); + QVERIFY(four != 0); + QQuickRectangle *five = window->rootObject()->findChild<QQuickRectangle*>("five"); + QVERIFY(five != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 50.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 70.0); + QCOMPARE(three->y(), 15.0); + QCOMPARE(four->x(), 0.0); + QCOMPARE(four->y(), 50.0); + QCOMPARE(five->x(), 50.0); + QCOMPARE(five->y(), 70.0); + + window->rootObject()->setProperty("testVAlignment", QQuickGrid::AlignBottom); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 50.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 70.0); + QCOMPARE(three->y(), 30.0); + QCOMPARE(four->x(), 0.0); + QCOMPARE(four->y(), 50.0); + QCOMPARE(five->x(), 50.0); + QCOMPARE(five->y(), 90.0); + } void tst_qquickpositioners::test_propertychanges() { - QQuickView *window = createView(testFile("propertychangestest.qml")); + QScopedPointer<QQuickView> window(createView(testFile("propertychangestest.qml"))); QQuickGrid *grid = qobject_cast<QQuickGrid*>(window->rootObject()); QVERIFY(grid != 0); @@ -1474,12 +1577,11 @@ void tst_qquickpositioners::test_propertychanges() QCOMPARE(columnsSpy.count(),2); QCOMPARE(rowsSpy.count(),2); - delete window; } void tst_qquickpositioners::test_repeater() { - QQuickView *window = createView(testFile("repeatertest.qml")); + QScopedPointer<QQuickView> window(createView(testFile("repeatertest.qml"))); QQuickRectangle *one = findItem<QQuickRectangle>(window->contentItem(), "one"); QVERIFY(one != 0); @@ -1497,12 +1599,11 @@ void tst_qquickpositioners::test_repeater() QCOMPARE(three->x(), 100.0); QCOMPARE(three->y(), 0.0); - delete window; } void tst_qquickpositioners::test_flow() { - QQuickView *window = createView(testFile("flowtest.qml")); + QScopedPointer<QQuickView> window(createView(testFile("flowtest.qml"))); window->rootObject()->setProperty("testRightToLeft", false); @@ -1533,12 +1634,11 @@ void tst_qquickpositioners::test_flow() QCOMPARE(flow->width(), 90.0); QCOMPARE(flow->height(), 120.0); - delete window; } void tst_qquickpositioners::test_flow_rightToLeft() { - QQuickView *window = createView(testFile("flowtest.qml")); + QScopedPointer<QQuickView> window(createView(testFile("flowtest.qml"))); window->rootObject()->setProperty("testRightToLeft", true); @@ -1569,12 +1669,11 @@ void tst_qquickpositioners::test_flow_rightToLeft() QCOMPARE(flow->width(), 90.0); QCOMPARE(flow->height(), 120.0); - delete window; } void tst_qquickpositioners::test_flow_topToBottom() { - QQuickView *window = createView(testFile("flowtest-toptobottom.qml")); + QScopedPointer<QQuickView> window(createView(testFile("flowtest-toptobottom.qml"))); window->rootObject()->setProperty("testRightToLeft", false); @@ -1622,12 +1721,11 @@ void tst_qquickpositioners::test_flow_topToBottom() QCOMPARE(five->x(), 40.0); QCOMPARE(five->y(), 50.0); - delete window; } void tst_qquickpositioners::test_flow_resize() { - QQuickView *window = createView(testFile("flowtest.qml")); + QScopedPointer<QQuickView> window(createView(testFile("flowtest.qml"))); QQuickItem *root = qobject_cast<QQuickItem*>(window->rootObject()); QVERIFY(root); @@ -1656,12 +1754,11 @@ void tst_qquickpositioners::test_flow_resize() QTRY_COMPARE(five->x(), 50.0); QTRY_COMPARE(five->y(), 50.0); - delete window; } void tst_qquickpositioners::test_flow_resize_rightToLeft() { - QQuickView *window = createView(testFile("flowtest.qml")); + QScopedPointer<QQuickView> window(createView(testFile("flowtest.qml"))); QQuickItem *root = qobject_cast<QQuickItem*>(window->rootObject()); QVERIFY(root); @@ -1690,12 +1787,11 @@ void tst_qquickpositioners::test_flow_resize_rightToLeft() QCOMPARE(five->x(), 65.0); QCOMPARE(five->y(), 50.0); - delete window; } void tst_qquickpositioners::test_flow_implicit_resize() { - QQuickView *window = createView(testFile("flow-testimplicitsize.qml")); + QScopedPointer<QQuickView> window(createView(testFile("flow-testimplicitsize.qml"))); QVERIFY(window->rootObject() != 0); QQuickFlow *flow = window->rootObject()->findChild<QQuickFlow*>("flow"); @@ -1719,7 +1815,6 @@ void tst_qquickpositioners::test_flow_implicit_resize() QCOMPARE(flow->width(), 220.0); QCOMPARE(flow->height(), 50.0); - delete window; } void tst_qquickpositioners::test_conflictinganchors() @@ -1836,10 +1931,10 @@ void tst_qquickpositioners::test_mirroring() objectNames << "one" << "two" << "three" << "four" << "five"; foreach (const QString qmlFile, qmlFiles) { - QQuickView *windowA = createView(testFile(qmlFile)); + QScopedPointer<QQuickView> windowA(createView(testFile(qmlFile))); QQuickItem *rootA = qobject_cast<QQuickItem*>(windowA->rootObject()); - QQuickView *windowB = createView(testFile(qmlFile)); + QScopedPointer<QQuickView> windowB(createView(testFile(qmlFile))); QQuickItem *rootB = qobject_cast<QQuickItem*>(windowB->rootObject()); rootA->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft @@ -1881,15 +1976,13 @@ void tst_qquickpositioners::test_mirroring() QQuickItem *itemB = rootB->findChild<QQuickItem*>(objectName); QTRY_COMPARE(itemA->x(), itemB->x()); } - delete windowA; - delete windowB; } } void tst_qquickpositioners::test_allInvisible() { //QTBUG-19361 - QQuickView *window = createView(testFile("allInvisible.qml")); + QScopedPointer<QQuickView> window(createView(testFile("allInvisible.qml"))); QQuickItem *root = qobject_cast<QQuickItem*>(window->rootObject()); QVERIFY(root); @@ -1908,7 +2001,7 @@ void tst_qquickpositioners::test_attachedproperties() { QFETCH(QString, filename); - QQuickView *window = createView(filename); + QScopedPointer<QQuickView> window(createView(filename)); QVERIFY(window->rootObject() != 0); QQuickRectangle *greenRect = window->rootObject()->findChild<QQuickRectangle *>("greenRect"); @@ -1940,7 +2033,6 @@ void tst_qquickpositioners::test_attachedproperties() isLast = yellowRect->property("isLastItem").toBool(); QVERIFY(isLast == true); - delete window; } void tst_qquickpositioners::test_attachedproperties_data() @@ -1955,7 +2047,7 @@ void tst_qquickpositioners::test_attachedproperties_data() void tst_qquickpositioners::test_attachedproperties_dynamic() { - QQuickView *window = createView(testFile("attachedproperties-dynamic.qml")); + QScopedPointer<QQuickView> window(createView(testFile("attachedproperties-dynamic.qml"))); QVERIFY(window->rootObject() != 0); QQuickRow *row = window->rootObject()->findChild<QQuickRow *>("pos"); @@ -2006,7 +2098,6 @@ void tst_qquickpositioners::test_attachedproperties_dynamic() QTRY_VERIFY(rect1->property("firstItem").toBool() == false); QTRY_VERIFY(rect1->property("lastItem").toBool() == true); - delete window; } QQuickView *tst_qquickpositioners::createView(const QString &filename, bool wait) diff --git a/tests/auto/quick/qquickstates/tst_qquickstates.cpp b/tests/auto/quick/qquickstates/tst_qquickstates.cpp index 726d3a6e75..e165b559f7 100644 --- a/tests/auto/quick/qquickstates/tst_qquickstates.cpp +++ b/tests/auto/quick/qquickstates/tst_qquickstates.cpp @@ -1009,9 +1009,8 @@ void tst_qquickstates::anchorRewindBug() view->setSource(testFileUrl("anchorRewindBug.qml")); view->show(); - view->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(view)); + QVERIFY(QTest::qWaitForWindowExposed(view)); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(view->rootObject()); QVERIFY(rect != 0); diff --git a/tests/auto/quick/qquicktextdocument/data/text.qml b/tests/auto/quick/qquicktextdocument/data/text.qml new file mode 100644 index 0000000000..43a8c6bb82 --- /dev/null +++ b/tests/auto/quick/qquicktextdocument/data/text.qml @@ -0,0 +1,6 @@ +import QtQuick 2.1 + +TextEdit { + text: "" +} + diff --git a/tests/auto/qml/qquicklistcompositor/qquicklistcompositor.pro b/tests/auto/quick/qquicktextdocument/qquicktextdocument.pro index 9d1d2bd237..e6bfdbd099 100644 --- a/tests/auto/qml/qquicklistcompositor/qquicklistcompositor.pro +++ b/tests/auto/quick/qquicktextdocument/qquicktextdocument.pro @@ -1,10 +1,15 @@ CONFIG += testcase -TARGET = tst_qquicklistcompositor +TARGET = tst_qquicktextdocument macx:CONFIG -= app_bundle -SOURCES += tst_qquicklistcompositor.cpp +SOURCES += tst_qquicktextdocument.cpp + +include (../../shared/util.pri) + +TESTDATA = data/* CONFIG += parallel_test QT += core-private gui-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + diff --git a/tests/auto/quick/qquicktextdocument/tst_qquicktextdocument.cpp b/tests/auto/quick/qquicktextdocument/tst_qquicktextdocument.cpp new file mode 100644 index 0000000000..717496cf0e --- /dev/null +++ b/tests/auto/quick/qquicktextdocument/tst_qquicktextdocument.cpp @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qtest.h> +#include <QtTest/QtTest> +#include <QtQuick/QQuickTextDocument> +#include <QtQuick/QQuickItem> +#include <QtQuick/private/qquicktextedit_p.h> +#include <QtGui/QTextDocument> +#include <QtGui/QTextDocumentWriter> +#include <QtQml/QQmlEngine> +#include <QtQml/QQmlComponent> +#include "../../shared/util.h" + +class tst_qquicktextdocument : public QQmlDataTest +{ + Q_OBJECT +private slots: + void textDocumentWriter(); +}; + +QString text = QStringLiteral("foo bar"); + +void tst_qquicktextdocument::textDocumentWriter() +{ + QQmlEngine e; + QQmlComponent c(&e, testFileUrl("text.qml")); + QObject* o = c.create(); + QVERIFY(o); + QQuickTextEdit *edit = qobject_cast<QQuickTextEdit*>(o); + QVERIFY(edit); + + QQuickTextDocument* quickDocument = qobject_cast<QQuickTextDocument*>(edit->property("textDocument").value<QObject*>()); + QVERIFY(quickDocument->textDocument() != 0); + + QBuffer output; + output.open(QBuffer::ReadWrite); + QVERIFY(output.buffer().isEmpty()); + + edit->setProperty("text", QVariant(text)); + QTextDocumentWriter writer(&output, "plaintext"); + QVERIFY(writer.write(quickDocument->textDocument())); + QCOMPARE(output.buffer(), text.toLatin1()); + delete o; +} + +QTEST_MAIN(tst_qquicktextdocument) + +#include "tst_qquicktextdocument.moc" diff --git a/tests/auto/quick/qquicktextedit/data/focusOutSelection.qml b/tests/auto/quick/qquicktextedit/data/focusOutSelection.qml new file mode 100644 index 0000000000..91a6ac900d --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/focusOutSelection.qml @@ -0,0 +1,35 @@ +import QtQuick 2.0 + +Rectangle { + id: focusoutwindow + + width: 100 + height: 150 + + property alias text1: text1 + property alias text2: text2 + + TextEdit { + x: 20 + y: 30 + id: text1 + text: "text 1" + height: 20 + width: 50 + selectByMouse: true + activeFocusOnPress: true + objectName: "text1" + } + + TextEdit { + x: 20 + y: 80 + id: text2 + text: "text 2" + height: 20 + width: 50 + selectByMouse: true + activeFocusOnPress: true + objectName: "text2" + } +} diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index c0fd1e94a5..bce1f9e4a2 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -117,6 +117,7 @@ private slots: void color(); void textMargin(); void persistentSelection(); + void selectionOnFocusOut(); void focusOnPress(); void selection(); void isRightToLeft_data(); @@ -133,6 +134,9 @@ private slots: void dragMouseSelection(); void mouseSelectionMode_accessors(); void selectByMouse(); + void selectByKeyboard(); + void keyboardSelection_data(); + void keyboardSelection(); void renderType(); void inputMethodHints(); @@ -1163,6 +1167,48 @@ void tst_qquicktextedit::persistentSelection() } +void tst_qquicktextedit::selectionOnFocusOut() +{ + QQuickView window(testFileUrl("focusOutSelection.qml")); + window.show(); + window.requestActivate(); + QTest::qWaitForWindowActive(&window); + + QPoint p1(25, 35); + QPoint p2(25, 85); + + QQuickTextEdit *edit1 = window.rootObject()->findChild<QQuickTextEdit*>("text1"); + QQuickTextEdit *edit2 = window.rootObject()->findChild<QQuickTextEdit*>("text2"); + + QTest::mouseClick(&window, Qt::LeftButton, 0, p1); + QVERIFY(edit1->hasActiveFocus()); + QVERIFY(!edit2->hasActiveFocus()); + + edit1->selectAll(); + QCOMPARE(edit1->selectedText(), QLatin1String("text 1")); + + QTest::mouseClick(&window, Qt::LeftButton, 0, p2); + + QCOMPARE(edit1->selectedText(), QLatin1String("")); + QVERIFY(!edit1->hasActiveFocus()); + QVERIFY(edit2->hasActiveFocus()); + + edit2->selectAll(); + QCOMPARE(edit2->selectedText(), QLatin1String("text 2")); + + + edit2->setFocus(false, Qt::ActiveWindowFocusReason); + QVERIFY(!edit2->hasActiveFocus()); + QCOMPARE(edit2->selectedText(), QLatin1String("text 2")); + + edit2->setFocus(true); + QVERIFY(edit2->hasActiveFocus()); + + edit2->setFocus(false, Qt::PopupFocusReason); + QVERIFY(!edit2->hasActiveFocus()); + QCOMPARE(edit2->selectedText(), QLatin1String("text 2")); +} + void tst_qquicktextedit::focusOnPress() { QString componentStr = @@ -2020,6 +2066,127 @@ void tst_qquicktextedit::selectByMouse() QCOMPARE(spy.at(1).at(0).toBool(), false); } +void tst_qquicktextedit::selectByKeyboard() +{ + QQmlComponent oldComponent(&engine); + oldComponent.setData("import QtQuick 2.0\n TextEdit { selectByKeyboard: true }", QUrl()); + QVERIFY(!oldComponent.create()); + + QQmlComponent component(&engine); + component.setData("import QtQuick 2.1\n TextEdit { }", QUrl()); + QScopedPointer<QObject> object(component.create()); + QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(object.data()); + QVERIFY(edit); + + QSignalSpy spy(edit, SIGNAL(selectByKeyboardChanged(bool))); + + QCOMPARE(edit->isReadOnly(), false); + QCOMPARE(edit->selectByKeyboard(), true); + + edit->setReadOnly(true); + QCOMPARE(edit->selectByKeyboard(), false); + QCOMPARE(spy.count(), 1); + QCOMPARE(spy.at(0).at(0).toBool(), false); + + edit->setSelectByKeyboard(true); + QCOMPARE(edit->selectByKeyboard(), true); + QCOMPARE(spy.count(), 2); + QCOMPARE(spy.at(1).at(0).toBool(), true); + + edit->setReadOnly(false); + QCOMPARE(edit->selectByKeyboard(), true); + QCOMPARE(spy.count(), 2); + + edit->setSelectByKeyboard(false); + QCOMPARE(edit->selectByKeyboard(), false); + QCOMPARE(spy.count(), 3); + QCOMPARE(spy.at(2).at(0).toBool(), false); +} + +Q_DECLARE_METATYPE(QKeySequence::StandardKey) + +void tst_qquicktextedit::keyboardSelection_data() +{ + QTest::addColumn<QString>("text"); + QTest::addColumn<bool>("readOnly"); + QTest::addColumn<bool>("selectByKeyboard"); + QTest::addColumn<int>("cursorPosition"); + QTest::addColumn<QKeySequence::StandardKey>("standardKey"); + QTest::addColumn<QString>("selectedText"); + + QTest::newRow("editable - select first char") + << QStringLiteral("editable - select first char") << false << true << 0 << QKeySequence::SelectNextChar << QStringLiteral("e"); + QTest::newRow("editable - select first word") + << QStringLiteral("editable - select first char") << false << true << 0 << QKeySequence::SelectNextWord << QStringLiteral("editable "); + + QTest::newRow("editable - cannot select first char") + << QStringLiteral("editable - cannot select first char") << false << false << 0 << QKeySequence::SelectNextChar << QStringLiteral(""); + QTest::newRow("editable - cannot select first word") + << QStringLiteral("editable - cannot select first word") << false << false << 0 << QKeySequence::SelectNextWord << QStringLiteral(""); + + QTest::newRow("editable - select last char") + << QStringLiteral("editable - select last char") << false << true << 27 << QKeySequence::SelectPreviousChar << QStringLiteral("r"); + QTest::newRow("editable - select last word") + << QStringLiteral("editable - select last word") << false << true << 27 << QKeySequence::SelectPreviousWord << QStringLiteral("word"); + + QTest::newRow("editable - cannot select last char") + << QStringLiteral("editable - cannot select last char") << false << false << 35 << QKeySequence::SelectPreviousChar << QStringLiteral(""); + QTest::newRow("editable - cannot select last word") + << QStringLiteral("editable - cannot select last word") << false << false << 35 << QKeySequence::SelectPreviousWord << QStringLiteral(""); + + QTest::newRow("read-only - cannot select first char") + << QStringLiteral("read-only - cannot select first char") << true << false << 0 << QKeySequence::SelectNextChar << QStringLiteral(""); + QTest::newRow("read-only - cannot select first word") + << QStringLiteral("read-only - cannot select first word") << true << false << 0 << QKeySequence::SelectNextWord << QStringLiteral(""); + + QTest::newRow("read-only - cannot select last char") + << QStringLiteral("read-only - cannot select last char") << true << false << 35 << QKeySequence::SelectPreviousChar << QStringLiteral(""); + QTest::newRow("read-only - cannot select last word") + << QStringLiteral("read-only - cannot select last word") << true << false << 35 << QKeySequence::SelectPreviousWord << QStringLiteral(""); + + QTest::newRow("read-only - select first char") + << QStringLiteral("read-only - select first char") << true << true << 0 << QKeySequence::SelectNextChar << QStringLiteral("r"); + QTest::newRow("read-only - select first word") + << QStringLiteral("read-only - select first word") << true << true << 0 << QKeySequence::SelectNextWord << QStringLiteral("read"); + + QTest::newRow("read-only - select last char") + << QStringLiteral("read-only - select last char") << true << true << 28 << QKeySequence::SelectPreviousChar << QStringLiteral("r"); + QTest::newRow("read-only - select last word") + << QStringLiteral("read-only - select last word") << true << true << 28 << QKeySequence::SelectPreviousWord << QStringLiteral("word"); +} + +void tst_qquicktextedit::keyboardSelection() +{ + QFETCH(QString, text); + QFETCH(bool, readOnly); + QFETCH(bool, selectByKeyboard); + QFETCH(int, cursorPosition); + QFETCH(QKeySequence::StandardKey, standardKey); + QFETCH(QString, selectedText); + + QQmlComponent component(&engine); + component.setData("import QtQuick 2.1\n TextEdit { focus: true }", QUrl()); + QScopedPointer<QObject> object(component.create()); + QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(object.data()); + QVERIFY(edit); + + edit->setText(text); + edit->setSelectByKeyboard(selectByKeyboard); + edit->setReadOnly(readOnly); + edit->setCursorPosition(cursorPosition); + + QQuickWindow window; + edit->setParentItem(window.contentItem()); + window.show(); + window.requestActivate(); + QTest::qWaitForWindowActive(&window); + QVERIFY(edit->hasActiveFocus()); + + simulateKeys(&window, standardKey); + + QCOMPARE(edit->selectedText(), selectedText); +} + void tst_qquicktextedit::renderType() { QQmlComponent component(&engine); @@ -2225,6 +2392,7 @@ void tst_qquicktextedit::cursorDelegate() QQuickView view(source); view.show(); view.requestActivate(); + QTest::qWaitForWindowActive(&view); QQuickTextEdit *textEditObject = view.rootObject()->findChild<QQuickTextEdit*>("textEditObject"); QVERIFY(textEditObject != 0); // Delegate creation is deferred until focus in or cursor visibility is forced. @@ -2340,6 +2508,7 @@ void tst_qquicktextedit::remoteCursorDelegate() view.setSource(testFileUrl("cursorTestRemote.qml")); view.show(); view.requestActivate(); + QTest::qWaitForWindowActive(&view); QQuickTextEdit *textEditObject = view.rootObject()->findChild<QQuickTextEdit*>("textEditObject"); QVERIFY(textEditObject != 0); diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index 339aa5854d..d1ed6dd05a 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -167,6 +167,7 @@ private slots: void openInputPanel(); void setHAlignClearCache(); void focusOutClearSelection(); + void focusOutNotClearSelection(); void echoMode(); void passwordEchoDelay(); @@ -2665,6 +2666,7 @@ void tst_qquicktextinput::cursorDelegate() QQuickView view(source); view.show(); view.requestActivate(); + QTest::qWaitForWindowActive(&view); QQuickTextInput *textInputObject = view.rootObject()->findChild<QQuickTextInput*>("textInputObject"); QVERIFY(textInputObject != 0); // Delegate is created on demand, and so won't be available immediately. Focus in or @@ -2773,6 +2775,7 @@ void tst_qquicktextinput::cursorDelegate() void tst_qquicktextinput::remoteCursorDelegate() { + QSKIP("This test is unstable"); TestHTTPServer server(SERVER_PORT); server.serveDirectory(dataDirectory(), TestHTTPServer::Delay); @@ -2784,6 +2787,7 @@ void tst_qquicktextinput::remoteCursorDelegate() view.setSource(testFileUrl("cursorTestRemote.qml")); view.show(); view.requestActivate(); + QTest::qWaitForWindowActive(&view); QQuickTextInput *textInputObject = view.rootObject()->findChild<QQuickTextInput*>("textInputObject"); QVERIFY(textInputObject != 0); @@ -2806,6 +2810,7 @@ void tst_qquicktextinput::remoteCursorDelegate() void tst_qquicktextinput::cursorVisible() { + QSKIP("This test is unstable"); QQuickTextInput input; input.componentComplete(); QSignalSpy spy(&input, SIGNAL(cursorVisibleChanged(bool))); @@ -3494,6 +3499,49 @@ void tst_qquicktextinput::focusOutClearSelection() QTRY_COMPARE(input.selectedText(), QLatin1String("")); } +void tst_qquicktextinput::focusOutNotClearSelection() +{ + QQuickView view; + QQuickTextInput input; + input.setText(QLatin1String("Hello world")); + input.setFocus(true); + input.setParentItem(view.contentItem()); + input.componentComplete(); + view.show(); + view.requestActivate(); + QTest::qWaitForWindowActive(&view); + + QVERIFY(input.hasActiveFocus()); + input.select(2,5); + QTRY_COMPARE(input.selectedText(), QLatin1String("llo")); + + // The selection should not be cleared when the focus + // out event has one of the following reason: + // Qt::ActiveWindowFocusReason + // Qt::PopupFocusReason + + input.setFocus(false, Qt::ActiveWindowFocusReason); + QGuiApplication::processEvents(); + QTRY_COMPARE(input.selectedText(), QLatin1String("llo")); + QTRY_COMPARE(input.hasActiveFocus(), false); + + input.setFocus(true); + QTRY_COMPARE(input.hasActiveFocus(), true); + + input.setFocus(false, Qt::PopupFocusReason); + QGuiApplication::processEvents(); + QTRY_COMPARE(input.selectedText(), QLatin1String("llo")); + QTRY_COMPARE(input.hasActiveFocus(), false); + + input.setFocus(true); + QTRY_COMPARE(input.hasActiveFocus(), true); + + input.setFocus(false, Qt::OtherFocusReason); + QGuiApplication::processEvents(); + QTRY_COMPARE(input.selectedText(), QLatin1String("")); + QTRY_COMPARE(input.hasActiveFocus(), false); +} + void tst_qquicktextinput::geometrySignals() { QQmlComponent component(&engine, testFileUrl("geometrySignals.qml")); diff --git a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp index 74c557871f..d16bf81d88 100644 --- a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp +++ b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp @@ -52,9 +52,9 @@ #include <QtQuick/qquickview.h> #include <private/qquicklistview_p.h> #include <QtQuick/private/qquicktext_p.h> -#include <QtQuick/private/qquickvisualdatamodel_p.h> +#include <QtQml/private/qqmldelegatemodel_p.h> #include <private/qqmlvaluetype_p.h> -#include <private/qquickchangeset_p.h> +#include <private/qqmlchangeset_p.h> #include <private/qqmlengine_p.h> #include <math.h> #include <QtGui/qstandarditemmodel.h> @@ -360,21 +360,21 @@ public: int indexCreated; public Q_SLOTS: - void initItem(int index, QQuickItem *item) + void initItem(int index, QObject *item) { - itemInitialized = item; + itemInitialized = qobject_cast<QQuickItem*>(item); indexInitialized = index; } - void createdItem(int index, QQuickItem *item) + void createdItem(int index, QObject *item) { - itemCreated = item; + itemCreated = qobject_cast<QQuickItem*>(item); indexCreated = index; } - void destroyingItem(QQuickItem *item) + void destroyingItem(QObject *item) { - itemDestroyed = item; + itemDestroyed = qobject_cast<QQuickItem*>(item); } }; @@ -452,9 +452,9 @@ private: template <int N> void get_verify( const SingleRoleModel &model, - QQuickVisualDataModel *visualModel, - QQuickVisualDataGroup *visibleItems, - QQuickVisualDataGroup *selectedItems, + QQmlDelegateModel *visualModel, + QQmlDelegateModelGroup *visibleItems, + QQmlDelegateModelGroup *selectedItems, const int (&mIndex)[N], const int (&iIndex)[N], const int (&vIndex)[N], @@ -467,7 +467,7 @@ private: QQmlEngine engine; }; -Q_DECLARE_METATYPE(QQuickChangeSet) +Q_DECLARE_METATYPE(QQmlChangeSet) template <typename T> static T evaluate(QObject *scope, const QString &expression) { @@ -489,7 +489,7 @@ template <> void evaluate<void>(QObject *scope, const QString &expression) void tst_qquickvisualdatamodel::initTestCase() { QQmlDataTest::initTestCase(); - qRegisterMetaType<QQuickChangeSet>(); + qRegisterMetaType<QQmlChangeSet>(); qmlRegisterType<SingleRoleModel>("tst_qquickvisualdatamodel", 1, 0, "SingleRoleModel"); qmlRegisterType<DataObject>("tst_qquickvisualdatamodel", 1, 0, "DataObject"); @@ -517,7 +517,7 @@ void tst_qquickvisualdatamodel::rootIndex() engine.rootContext()->setContextProperty("myModel", &model); - QQuickVisualDataModel *obj = qobject_cast<QQuickVisualDataModel*>(c.create()); + QQmlDelegateModel *obj = qobject_cast<QQmlDelegateModel*>(c.create()); QVERIFY(obj != 0); QMetaObject::invokeMethod(obj, "setRoot"); @@ -611,7 +611,7 @@ void tst_qquickvisualdatamodel::childChanged() QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != 0); - QQuickVisualDataModel *vdm = listview->findChild<QQuickVisualDataModel*>("visualModel"); + QQmlDelegateModel *vdm = listview->findChild<QQmlDelegateModel*>("visualModel"); vdm->setRootIndex(QVariant::fromValue(model.indexFromItem(model.item(1,0)))); QCOMPARE(listview->count(), 1); @@ -922,7 +922,7 @@ void tst_qquickvisualdatamodel::noDelegate() QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject()); QVERIFY(listview != 0); - QQuickVisualDataModel *vdm = listview->findChild<QQuickVisualDataModel*>("visualModel"); + QQmlDelegateModel *vdm = listview->findChild<QQmlDelegateModel*>("visualModel"); QVERIFY(vdm != 0); QCOMPARE(vdm->count(), 3); @@ -1052,15 +1052,15 @@ void tst_qquickvisualdatamodel::qaimRowsMoved() SingleRoleModel model(list); engine.rootContext()->setContextProperty("myModel", &model); - QQuickVisualDataModel *obj = qobject_cast<QQuickVisualDataModel*>(c.create()); + QQmlDelegateModel *obj = qobject_cast<QQmlDelegateModel*>(c.create()); QVERIFY(obj != 0); - QSignalSpy spy(obj, SIGNAL(modelUpdated(QQuickChangeSet,bool))); + QSignalSpy spy(obj, SIGNAL(modelUpdated(QQmlChangeSet,bool))); model.emitMove(sourceFirst, sourceLast, destinationChild); QCOMPARE(spy.count(), 1); QCOMPARE(spy[0].count(), 2); - QQuickChangeSet changeSet = spy[0][0].value<QQuickChangeSet>(); + QQmlChangeSet changeSet = spy[0][0].value<QQmlChangeSet>(); QCOMPARE(changeSet.removes().count(), 1); QCOMPARE(changeSet.removes().at(0).index, expectFrom); QCOMPARE(changeSet.removes().at(0).count, expectCount); @@ -1115,11 +1115,11 @@ void tst_qquickvisualdatamodel::subtreeRowsMoved() QQmlComponent component(&engine, testFileUrl("visualdatamodel.qml")); QScopedPointer<QObject> object(component.create()); - QQuickVisualDataModel *vdm = qobject_cast<QQuickVisualDataModel*>(object.data()); + QQmlDelegateModel *vdm = qobject_cast<QQmlDelegateModel*>(object.data()); QVERIFY(vdm); - QSignalSpy spy(vdm, SIGNAL(modelUpdated(QQuickChangeSet,bool))); - QQuickChangeSet changeSet; + QSignalSpy spy(vdm, SIGNAL(modelUpdated(QQmlChangeSet,bool))); + QQmlChangeSet changeSet; QCOMPARE(vdm->count(), 4); @@ -1127,7 +1127,7 @@ void tst_qquickvisualdatamodel::subtreeRowsMoved() model.move(QModelIndex(), 1, model.index(0, 0), 3, 2); QCOMPARE(vdm->count(), 2); QCOMPARE(spy.count(), 1); - changeSet = spy.last().at(0).value<QQuickChangeSet>(); + changeSet = spy.last().at(0).value<QQmlChangeSet>(); QCOMPARE(changeSet.removes().count(), 1); QCOMPARE(changeSet.removes().at(0).index, 1); QCOMPARE(changeSet.removes().at(0).count, 2); @@ -1137,7 +1137,7 @@ void tst_qquickvisualdatamodel::subtreeRowsMoved() model.move(model.index(0, 0), 4, QModelIndex(), 2, 1); QCOMPARE(vdm->count(), 3); QCOMPARE(spy.count(), 2); - changeSet = spy.last().at(0).value<QQuickChangeSet>(); + changeSet = spy.last().at(0).value<QQmlChangeSet>(); QCOMPARE(changeSet.removes().count(), 0); QCOMPARE(changeSet.inserts().count(), 1); QCOMPARE(changeSet.inserts().at(0).index, 2); @@ -1147,11 +1147,11 @@ void tst_qquickvisualdatamodel::subtreeRowsMoved() QCOMPARE(vdm->rootIndex().value<QModelIndex>(), model.index(2, 0)); QCOMPARE(vdm->count(), 3); QCOMPARE(spy.count(), 4); - changeSet = spy.at(2).at(0).value<QQuickChangeSet>(); + changeSet = spy.at(2).at(0).value<QQmlChangeSet>(); QCOMPARE(changeSet.removes().count(), 1); QCOMPARE(changeSet.removes().at(0).index, 0); QCOMPARE(changeSet.removes().at(0).count, 3); - changeSet = spy.last().at(0).value<QQuickChangeSet>(); + changeSet = spy.last().at(0).value<QQmlChangeSet>(); QCOMPARE(changeSet.inserts().count(), 1); QCOMPARE(changeSet.inserts().at(0).index, 0); QCOMPARE(changeSet.inserts().at(0).count, 3); @@ -1182,7 +1182,7 @@ void tst_qquickvisualdatamodel::subtreeRowsMoved() QCOMPARE(vdm->rootIndex().value<QModelIndex>(), QModelIndex()); QCOMPARE(vdm->count(), 0); QCOMPARE(spy.count(), 5); - changeSet = spy.last().at(0).value<QQuickChangeSet>(); + changeSet = spy.last().at(0).value<QQmlChangeSet>(); QCOMPARE(changeSet.removes().count(), 1); QCOMPARE(changeSet.removes().at(0).index, 0); QCOMPARE(changeSet.removes().at(0).count, 3); @@ -1192,7 +1192,7 @@ void tst_qquickvisualdatamodel::subtreeRowsMoved() QCOMPARE(vdm->rootIndex().value<QModelIndex>(), QModelIndex()); QCOMPARE(vdm->count(), 2); QCOMPARE(spy.count(), 6); - changeSet = spy.last().at(0).value<QQuickChangeSet>(); + changeSet = spy.last().at(0).value<QQmlChangeSet>(); QCOMPARE(changeSet.removes().count(), 0); QCOMPARE(changeSet.inserts().count(), 1); QCOMPARE(changeSet.inserts().at(0).index, 0); @@ -1211,17 +1211,17 @@ void tst_qquickvisualdatamodel::watchedRoles() QQmlComponent component(&engine, testFileUrl("visualdatamodel.qml")); QScopedPointer<QObject> object(component.create()); - QQuickVisualDataModel *vdm = qobject_cast<QQuickVisualDataModel*>(object.data()); + QQmlDelegateModel *vdm = qobject_cast<QQmlDelegateModel*>(object.data()); QVERIFY(vdm); // VisualDataModel doesn't initialize model data until the first item is requested. - QQuickItem *item = vdm->item(0); + QQuickItem *item = qobject_cast<QQuickItem*>(vdm->object(0)); QVERIFY(item); vdm->release(item); QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // Ensure released items are deleted before test exits. - QSignalSpy spy(vdm, SIGNAL(modelUpdated(QQuickChangeSet,bool))); - QQuickChangeSet changeSet; + QSignalSpy spy(vdm, SIGNAL(modelUpdated(QQmlChangeSet,bool))); + QQmlChangeSet changeSet; QCOMPARE(vdm->count(), 30); @@ -1238,13 +1238,13 @@ void tst_qquickvisualdatamodel::watchedRoles() emit model.dataChanged(model.index(0), model.index(4)); QCOMPARE(spy.count(), 1); - changeSet = spy.last().at(0).value<QQuickChangeSet>(); + changeSet = spy.last().at(0).value<QQmlChangeSet>(); QCOMPARE(changeSet.changes().at(0).index, 0); QCOMPARE(changeSet.changes().at(0).count, 5); emit model.dataChanged(model.index(1), model.index(6), QVector<int>() << QaimModel::Name); QCOMPARE(spy.count(), 2); - changeSet = spy.last().at(0).value<QQuickChangeSet>(); + changeSet = spy.last().at(0).value<QQmlChangeSet>(); QCOMPARE(changeSet.changes().at(0).index, 1); QCOMPARE(changeSet.changes().at(0).count, 6); @@ -1255,7 +1255,7 @@ void tst_qquickvisualdatamodel::watchedRoles() emit model.dataChanged(model.index(0), model.index(4)); QCOMPARE(spy.count(), 3); - changeSet = spy.last().at(0).value<QQuickChangeSet>(); + changeSet = spy.last().at(0).value<QQmlChangeSet>(); QCOMPARE(changeSet.changes().at(0).index, 0); QCOMPARE(changeSet.changes().at(0).count, 5); @@ -1264,7 +1264,7 @@ void tst_qquickvisualdatamodel::watchedRoles() emit model.dataChanged(model.index(8), model.index(8), QVector<int>() << QaimModel::Number); QCOMPARE(spy.count(), 4); - changeSet = spy.last().at(0).value<QQuickChangeSet>(); + changeSet = spy.last().at(0).value<QQmlChangeSet>(); QCOMPARE(changeSet.changes().at(0).index, 8); QCOMPARE(changeSet.changes().at(0).count, 1); @@ -1272,19 +1272,19 @@ void tst_qquickvisualdatamodel::watchedRoles() emit model.dataChanged(model.index(0), model.index(4)); QCOMPARE(spy.count(), 5); - changeSet = spy.last().at(0).value<QQuickChangeSet>(); + changeSet = spy.last().at(0).value<QQmlChangeSet>(); QCOMPARE(changeSet.changes().at(0).index, 0); QCOMPARE(changeSet.changes().at(0).count, 5); emit model.dataChanged(model.index(1), model.index(6), QVector<int>() << QaimModel::Name); QCOMPARE(spy.count(), 6); - changeSet = spy.last().at(0).value<QQuickChangeSet>(); + changeSet = spy.last().at(0).value<QQmlChangeSet>(); QCOMPARE(changeSet.changes().at(0).index, 1); QCOMPARE(changeSet.changes().at(0).count, 6); emit model.dataChanged(model.index(8), model.index(8), QVector<int>() << QaimModel::Number); QCOMPARE(spy.count(), 7); - changeSet = spy.last().at(0).value<QQuickChangeSet>(); + changeSet = spy.last().at(0).value<QQmlChangeSet>(); QCOMPARE(changeSet.changes().at(0).index, 8); QCOMPARE(changeSet.changes().at(0).count, 1); } @@ -1301,29 +1301,29 @@ void tst_qquickvisualdatamodel::hasModelChildren() QQmlComponent component(&engine, testFileUrl("visualdatamodel.qml")); QScopedPointer<QObject> object(component.create()); - QQuickVisualDataModel *vdm = qobject_cast<QQuickVisualDataModel*>(object.data()); + QQmlDelegateModel *vdm = qobject_cast<QQmlDelegateModel*>(object.data()); QVERIFY(vdm); QCOMPARE(vdm->count(), 4); QQuickItem *item = 0; - item = vdm->item(0); + item = qobject_cast<QQuickItem*>(vdm->object(0)); QVERIFY(item); QCOMPARE(item->property("modelChildren").toBool(), true); vdm->release(item); - item = vdm->item(1); + item = qobject_cast<QQuickItem*>(vdm->object(1)); QVERIFY(item); QCOMPARE(item->property("modelChildren").toBool(), false); vdm->release(item); - item = vdm->item(2); + item = qobject_cast<QQuickItem*>(vdm->object(2)); QVERIFY(item); QCOMPARE(item->property("modelChildren").toBool(), true); vdm->release(item); - item = vdm->item(3); + item = qobject_cast<QQuickItem*>(vdm->object(3)); QVERIFY(item); QCOMPARE(item->property("modelChildren").toBool(), false); vdm->release(item); @@ -1351,14 +1351,14 @@ void tst_qquickvisualdatamodel::setValue() QQmlComponent component(&engine, testFileUrl("visualdatamodel.qml")); QScopedPointer<QObject> object(component.create()); - QQuickVisualDataModel *vdm = qobject_cast<QQuickVisualDataModel*>(object.data()); + QQmlDelegateModel *vdm = qobject_cast<QQmlDelegateModel*>(object.data()); QVERIFY(vdm); QCOMPARE(vdm->count(), 3); QQuickItem *item = 0; - item = vdm->item(0); + item = qobject_cast<QQuickItem*>(vdm->object(0)); QVERIFY(item); QCOMPARE(evaluate<QString>(item, "display"), QString("Row 1 Item")); evaluate<void>(item, "display = 'Changed Item 1'"); @@ -1412,7 +1412,7 @@ void tst_qquickvisualdatamodel::remove() QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != 0); - QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model())); + QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel *>(qvariant_cast<QObject *>(listview->model())); QVERIFY(visualModel); { @@ -1521,7 +1521,7 @@ void tst_qquickvisualdatamodel::move() QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != 0); - QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model())); + QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel *>(qvariant_cast<QObject *>(listview->model())); QVERIFY(visualModel); { @@ -1710,13 +1710,13 @@ void tst_qquickvisualdatamodel::groups() QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != 0); - QQuickVisualDataModel *visualModel = listview->findChild<QQuickVisualDataModel *>("visualModel"); + QQmlDelegateModel *visualModel = listview->findChild<QQmlDelegateModel *>("visualModel"); QVERIFY(visualModel); - QQuickVisualDataGroup *visibleItems = listview->findChild<QQuickVisualDataGroup *>("visibleItems"); + QQmlDelegateModelGroup *visibleItems = listview->findChild<QQmlDelegateModelGroup *>("visibleItems"); QVERIFY(visibleItems); - QQuickVisualDataGroup *selectedItems = listview->findChild<QQuickVisualDataGroup *>("selectedItems"); + QQmlDelegateModelGroup *selectedItems = listview->findChild<QQmlDelegateModelGroup *>("selectedItems"); QVERIFY(selectedItems); const bool f = false; @@ -1939,9 +1939,9 @@ void tst_qquickvisualdatamodel::groups() template <int N> void tst_qquickvisualdatamodel::get_verify( const SingleRoleModel &model, - QQuickVisualDataModel *visualModel, - QQuickVisualDataGroup *visibleItems, - QQuickVisualDataGroup *selectedItems, + QQmlDelegateModel *visualModel, + QQmlDelegateModelGroup *visibleItems, + QQmlDelegateModelGroup *selectedItems, const int (&mIndex)[N], const int (&iIndex)[N], const int (&vIndex)[N], @@ -2030,13 +2030,13 @@ void tst_qquickvisualdatamodel::get() QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != 0); - QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model())); + QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel *>(qvariant_cast<QObject *>(listview->model())); QVERIFY(visualModel); - QQuickVisualDataGroup *visibleItems = visualModel->findChild<QQuickVisualDataGroup *>("visibleItems"); + QQmlDelegateModelGroup *visibleItems = visualModel->findChild<QQmlDelegateModelGroup *>("visibleItems"); QVERIFY(visibleItems); - QQuickVisualDataGroup *selectedItems = visualModel->findChild<QQuickVisualDataGroup *>("selectedItems"); + QQmlDelegateModelGroup *selectedItems = visualModel->findChild<QQmlDelegateModelGroup *>("selectedItems"); QVERIFY(selectedItems); QV8Engine *v8Engine = QQmlEnginePrivate::getV8Engine(ctxt->engine()); @@ -2154,7 +2154,7 @@ void tst_qquickvisualdatamodel::get() void tst_qquickvisualdatamodel::invalidGroups() { QUrl source = testFileUrl("groups-invalid.qml"); - QTest::ignoreMessage(QtWarningMsg, (source.toString() + ":12:9: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("Group names must start with a lower case letter")).toUtf8()); + QTest::ignoreMessage(QtWarningMsg, (source.toString() + ":12:9: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("Group names must start with a lower case letter")).toUtf8()); QQmlComponent component(&engine, source); QScopedPointer<QObject> object(component.create()); @@ -2326,7 +2326,7 @@ void tst_qquickvisualdatamodel::create() QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != 0); - QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model())); + QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel *>(qvariant_cast<QObject *>(listview->model())); QVERIFY(visualModel); QCOMPARE(listview->count(), 20); @@ -2440,7 +2440,7 @@ void tst_qquickvisualdatamodel::incompleteModel() QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); - QQuickVisualDataModel *model = qobject_cast<QQuickVisualDataModel *>(object.data()); + QQmlDelegateModel *model = qobject_cast<QQmlDelegateModel *>(object.data()); QVERIFY(model); QSignalSpy itemsSpy(model->items(), SIGNAL(countChanged())); @@ -3665,67 +3665,67 @@ void tst_qquickvisualdatamodel::warnings_data() QTest::newRow("insert < 0") << testFileUrl("listmodelproperties.qml") << QString("items.insert(-2, {\"number\": \"eight\"})") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("insert: index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("insert: index out of range")) << 4; QTest::newRow("insert > length") << testFileUrl("listmodelproperties.qml") << QString("items.insert(8, {\"number\": \"eight\"})") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("insert: index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("insert: index out of range")) << 4; QTest::newRow("create < 0") << testFileUrl("listmodelproperties.qml") << QString("items.create(-2, {\"number\": \"eight\"})") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("create: index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("create: index out of range")) << 4; QTest::newRow("create > length") << testFileUrl("listmodelproperties.qml") << QString("items.create(8, {\"number\": \"eight\"})") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("create: index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("create: index out of range")) << 4; QTest::newRow("resolve from < 0") << testFileUrl("listmodelproperties.qml") << QString("items.resolve(-2, 3)") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("resolve: from index out of range")) << 4; QTest::newRow("resolve from > length") << testFileUrl("listmodelproperties.qml") << QString("items.resolve(8, 3)") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("resolve: from index out of range")) << 4; QTest::newRow("resolve to < 0") << testFileUrl("listmodelproperties.qml") << QString("items.resolve(3, -2)") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("resolve: to index out of range")) << 4; QTest::newRow("resolve to > length") << testFileUrl("listmodelproperties.qml") << QString("items.resolve(3, 8)") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("resolve: to index out of range")) << 4; QTest::newRow("resolve from invalid index") << testFileUrl("listmodelproperties.qml") << QString("items.resolve(\"two\", 3)") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index invalid")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("resolve: from index invalid")) << 4; QTest::newRow("resolve to invalid index") << testFileUrl("listmodelproperties.qml") << QString("items.resolve(3, \"two\")") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index invalid")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("resolve: to index invalid")) << 4; QTest::newRow("resolve already resolved item") << testFileUrl("listmodelproperties.qml") << QString("items.resolve(3, 2)") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from is not an unresolved item")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("resolve: from is not an unresolved item")) << 4; QTest::newRow("resolve already resolved item") @@ -3733,193 +3733,193 @@ void tst_qquickvisualdatamodel::warnings_data() << QString("{ items.insert(0, {\"number\": \"eight\"});" "items.insert(1, {\"number\": \"seven\"});" "items.resolve(0, 1)}") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to is not a model item")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("resolve: to is not a model item")) << 6; QTest::newRow("remove index < 0") << testFileUrl("listmodelproperties.qml") << QString("items.remove(-2, 1)") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("remove: index out of range")) << 4; QTest::newRow("remove index == length") << testFileUrl("listmodelproperties.qml") << QString("items.remove(4, 1)") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("remove: index out of range")) << 4; QTest::newRow("remove index > length") << testFileUrl("listmodelproperties.qml") << QString("items.remove(9, 1)") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("remove: index out of range")) << 4; QTest::newRow("remove invalid index") << testFileUrl("listmodelproperties.qml") << QString("items.remove(\"nine\", 1)") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid index")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("remove: invalid index")) << 4; QTest::newRow("remove count < 0") << testFileUrl("listmodelproperties.qml") << QString("items.remove(1, -2)") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid count")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("remove: invalid count")) << 4; QTest::newRow("remove index + count > length") << testFileUrl("listmodelproperties.qml") << QString("items.remove(2, 4, \"selected\")") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid count")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("remove: invalid count")) << 4; QTest::newRow("addGroups index < 0") << testFileUrl("listmodelproperties.qml") << QString("items.addGroups(-2, 1, \"selected\")") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("addGroups: index out of range")) << 4; QTest::newRow("addGroups index == length") << testFileUrl("listmodelproperties.qml") << QString("items.addGroups(4, 1, \"selected\")") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("addGroups: index out of range")) << 4; QTest::newRow("addGroups index > length") << testFileUrl("listmodelproperties.qml") << QString("items.addGroups(9, 1, \"selected\")") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("addGroups: index out of range")) << 4; QTest::newRow("addGroups count < 0") << testFileUrl("listmodelproperties.qml") << QString("items.addGroups(1, -2, \"selected\")") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: invalid count")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("addGroups: invalid count")) << 4; QTest::newRow("addGroups index + count > length") << testFileUrl("listmodelproperties.qml") << QString("items.addGroups(2, 4, \"selected\")") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: invalid count")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("addGroups: invalid count")) << 4; QTest::newRow("removeGroups index < 0") << testFileUrl("listmodelproperties.qml") << QString("items.removeGroups(-2, 1, \"selected\")") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("removeGroups: index out of range")) << 4; QTest::newRow("removeGroups index == length") << testFileUrl("listmodelproperties.qml") << QString("items.removeGroups(4, 1, \"selected\")") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("removeGroups: index out of range")) << 4; QTest::newRow("removeGroups index > length") << testFileUrl("listmodelproperties.qml") << QString("items.removeGroups(9, 1, \"selected\")") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("removeGroups: index out of range")) << 4; QTest::newRow("removeGroups count < 0") << testFileUrl("listmodelproperties.qml") << QString("items.removeGroups(1, -2, \"selected\")") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: invalid count")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("removeGroups: invalid count")) << 4; QTest::newRow("removeGroups index + count > length") << testFileUrl("listmodelproperties.qml") << QString("items.removeGroups(2, 4, \"selected\")") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: invalid count")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("removeGroups: invalid count")) << 4; QTest::newRow("setGroups index < 0") << testFileUrl("listmodelproperties.qml") << QString("items.setGroups(-2, 1, \"selected\")") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("setGroups: index out of range")) << 4; QTest::newRow("setGroups index == length") << testFileUrl("listmodelproperties.qml") << QString("items.setGroups(4, 1, \"selected\")") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("setGroups: index out of range")) << 4; QTest::newRow("setGroups index > length") << testFileUrl("listmodelproperties.qml") << QString("items.setGroups(9, 1, \"selected\")") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("setGroups: index out of range")) << 4; QTest::newRow("setGroups count < 0") << testFileUrl("listmodelproperties.qml") << QString("items.setGroups(1, -2, \"selected\")") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: invalid count")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("setGroups: invalid count")) << 4; QTest::newRow("setGroups index + count > length") << testFileUrl("listmodelproperties.qml") << QString("items.setGroups(2, 4, \"selected\")") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: invalid count")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("setGroups: invalid count")) << 4; QTest::newRow("move from < 0") << testFileUrl("listmodelproperties.qml") << QString("items.move(-2, 1, 1)") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("move: from index out of range")) << 4; QTest::newRow("move from == length") << testFileUrl("listmodelproperties.qml") << QString("items.move(4, 1, 1)") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("move: from index out of range")) << 4; QTest::newRow("move from > length") << testFileUrl("listmodelproperties.qml") << QString("items.move(9, 1, 1)") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("move: from index out of range")) << 4; QTest::newRow("move invalid from") << testFileUrl("listmodelproperties.qml") << QString("items.move(\"nine\", 1, 1)") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid from index")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("move: invalid from index")) << 4; QTest::newRow("move to < 0") << testFileUrl("listmodelproperties.qml") << QString("items.move(1, -2, 1)") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("move: to index out of range")) << 4; QTest::newRow("move to == length") << testFileUrl("listmodelproperties.qml") << QString("items.move(1, 4, 1)") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("move: to index out of range")) << 4; QTest::newRow("move to > length") << testFileUrl("listmodelproperties.qml") << QString("items.move(1, 9, 1)") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("move: to index out of range")) << 4; QTest::newRow("move invalid to") << testFileUrl("listmodelproperties.qml") << QString("items.move(1, \"nine\", 1)") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid to index")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("move: invalid to index")) << 4; QTest::newRow("move count < 0") << testFileUrl("listmodelproperties.qml") << QString("items.move(1, 1, -2)") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid count")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("move: invalid count")) << 4; QTest::newRow("move from + count > length") << testFileUrl("listmodelproperties.qml") << QString("items.move(2, 1, 4)") - << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range")) + << ("<Unknown File>: QML VisualDataGroup: " + QQmlDelegateModelGroup::tr("move: from index out of range")) << 4; } @@ -3961,19 +3961,19 @@ void tst_qquickvisualdatamodel::invalidAttachment() QCOMPARE(component.errors().count(), 0); QVariant property = object->property("invalidVdm"); - QCOMPARE(property.userType(), qMetaTypeId<QQuickVisualDataModel *>()); - QVERIFY(!property.value<QQuickVisualDataModel *>()); + QCOMPARE(property.userType(), qMetaTypeId<QQmlDelegateModel *>()); + QVERIFY(!property.value<QQmlDelegateModel *>()); QQuickItem *item = findItem<QQuickItem>(static_cast<QQuickItem *>(object.data()), "delegate"); QVERIFY(item); property = item->property("validVdm"); - QCOMPARE(property.userType(), qMetaTypeId<QQuickVisualDataModel *>()); - QVERIFY(property.value<QQuickVisualDataModel *>()); + QCOMPARE(property.userType(), qMetaTypeId<QQmlDelegateModel *>()); + QVERIFY(property.value<QQmlDelegateModel *>()); property = item->property("invalidVdm"); - QCOMPARE(property.userType(), qMetaTypeId<QQuickVisualDataModel *>()); - QVERIFY(!property.value<QQuickVisualDataModel *>()); + QCOMPARE(property.userType(), qMetaTypeId<QQmlDelegateModel *>()); + QVERIFY(!property.value<QQmlDelegateModel *>()); } void tst_qquickvisualdatamodel::asynchronousInsert_data() @@ -4005,15 +4005,15 @@ void tst_qquickvisualdatamodel::asynchronousInsert() engine.rootContext()->setContextProperty("myModel", &model); - QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel*>(c.create()); + QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel*>(c.create()); QVERIFY(visualModel); ItemRequester requester; - connect(visualModel, SIGNAL(initItem(int,QQuickItem*)), &requester, SLOT(initItem(int,QQuickItem*))); - connect(visualModel, SIGNAL(createdItem(int,QQuickItem*)), &requester, SLOT(createdItem(int,QQuickItem*))); - connect(visualModel, SIGNAL(destroyingItem(QQuickItem*)), &requester, SLOT(destroyingItem(QQuickItem*))); + connect(visualModel, SIGNAL(initItem(int,QObject*)), &requester, SLOT(initItem(int,QObject*))); + connect(visualModel, SIGNAL(createdItem(int,QObject*)), &requester, SLOT(createdItem(int,QObject*))); + connect(visualModel, SIGNAL(destroyingItem(QObject*)), &requester, SLOT(destroyingItem(QObject*))); - QQuickItem *item = visualModel->item(requestIndex, true); + QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, true)); QVERIFY(!item); QVERIFY(!requester.itemInitialized); @@ -4025,7 +4025,7 @@ void tst_qquickvisualdatamodel::asynchronousInsert() newItems.append(qMakePair(QLatin1String("New item") + QString::number(i), QString(QLatin1String("")))); model.insertItems(insertIndex, newItems); - item = visualModel->item(completeIndex, false); + item = qobject_cast<QQuickItem*>(visualModel->object(completeIndex, false)); QVERIFY(item); QCOMPARE(requester.itemInitialized, item); @@ -4070,15 +4070,15 @@ void tst_qquickvisualdatamodel::asynchronousRemove() engine.rootContext()->setContextProperty("myModel", &model); - QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel*>(c.create()); + QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel*>(c.create()); QVERIFY(visualModel); ItemRequester requester; - connect(visualModel, SIGNAL(initItem(int,QQuickItem*)), &requester, SLOT(initItem(int,QQuickItem*))); - connect(visualModel, SIGNAL(createdItem(int,QQuickItem*)), &requester, SLOT(createdItem(int,QQuickItem*))); - connect(visualModel, SIGNAL(destroyingItem(QQuickItem*)), &requester, SLOT(destroyingItem(QQuickItem*))); + connect(visualModel, SIGNAL(initItem(int,QObject*)), &requester, SLOT(initItem(int,QObject*))); + connect(visualModel, SIGNAL(createdItem(int,QObject*)), &requester, SLOT(createdItem(int,QObject*))); + connect(visualModel, SIGNAL(destroyingItem(QObject*)), &requester, SLOT(destroyingItem(QObject*))); - QQuickItem *item = visualModel->item(requestIndex, true); + QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, true)); QVERIFY(!item); QVERIFY(!requester.itemInitialized); @@ -4098,7 +4098,7 @@ void tst_qquickvisualdatamodel::asynchronousRemove() QCOMPARE(requester.itemCreated, requester.itemInitialized); QCOMPARE(requester.itemDestroyed, requester.itemInitialized); } else { - item = visualModel->item(completeIndex, false); + item = qobject_cast<QQuickItem*>(visualModel->object(completeIndex, false)); QVERIFY(item); QCOMPARE(requester.itemInitialized, item); @@ -4148,15 +4148,15 @@ void tst_qquickvisualdatamodel::asynchronousMove() engine.rootContext()->setContextProperty("myModel", &model); - QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel*>(c.create()); + QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel*>(c.create()); QVERIFY(visualModel); ItemRequester requester; - connect(visualModel, SIGNAL(initItem(int,QQuickItem*)), &requester, SLOT(initItem(int,QQuickItem*))); - connect(visualModel, SIGNAL(createdItem(int,QQuickItem*)), &requester, SLOT(createdItem(int,QQuickItem*))); - connect(visualModel, SIGNAL(destroyingItem(QQuickItem*)), &requester, SLOT(destroyingItem(QQuickItem*))); + connect(visualModel, SIGNAL(initItem(int,QObject*)), &requester, SLOT(initItem(int,QObject*))); + connect(visualModel, SIGNAL(createdItem(int,QObject*)), &requester, SLOT(createdItem(int,QObject*))); + connect(visualModel, SIGNAL(destroyingItem(QObject*)), &requester, SLOT(destroyingItem(QObject*))); - QQuickItem *item = visualModel->item(requestIndex, true); + QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, true)); QVERIFY(!item); QVERIFY(!requester.itemInitialized); @@ -4165,7 +4165,7 @@ void tst_qquickvisualdatamodel::asynchronousMove() model.moveItems(from, to, count); - item = visualModel->item(completeIndex, false); + item = qobject_cast<QQuickItem*>(visualModel->object(completeIndex, false)); QVERIFY(item); @@ -4196,10 +4196,10 @@ void tst_qquickvisualdatamodel::asynchronousCancel() engine.rootContext()->setContextProperty("myModel", &model); - QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel*>(c.create()); + QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel*>(c.create()); QVERIFY(visualModel); - QQuickItem *item = visualModel->item(requestIndex, true); + QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, true)); QVERIFY(!item); QCOMPARE(controller.incubatingObjectCount(), 1); @@ -4221,10 +4221,10 @@ void tst_qquickvisualdatamodel::invalidContext() QQmlComponent c(&engine, testFileUrl("visualdatamodel.qml")); - QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel*>(c.create(context.data())); + QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel*>(c.create(context.data())); QVERIFY(visualModel); - QQuickItem *item = visualModel->item(4, false); + QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(4, false)); QVERIFY(item); visualModel->release(item); @@ -4232,7 +4232,7 @@ void tst_qquickvisualdatamodel::invalidContext() model.insertItem(4, "new item", ""); - item = visualModel->item(4, false); + item = qobject_cast<QQuickItem*>(visualModel->object(4, false)); QVERIFY(!item); } diff --git a/tests/auto/quick/qquickwindow/data/focus.qml b/tests/auto/quick/qquickwindow/data/focus.qml index 901f2fcf2e..899b999cdc 100644 --- a/tests/auto/quick/qquickwindow/data/focus.qml +++ b/tests/auto/quick/qquickwindow/data/focus.qml @@ -2,6 +2,10 @@ import QtQuick 2.0 import QtQuick.Window 2.0 as Window Window.Window { + + width: 400 + height: 300 + Item { objectName: "item1" } diff --git a/tests/auto/quick/qquickwindow/data/ownershipRootItem.qml b/tests/auto/quick/qquickwindow/data/ownershipRootItem.qml index 955304e317..03400ba673 100644 --- a/tests/auto/quick/qquickwindow/data/ownershipRootItem.qml +++ b/tests/auto/quick/qquickwindow/data/ownershipRootItem.qml @@ -10,6 +10,6 @@ Window.Window { RootItemAccessor { id:accessor objectName:"accessor" - Component.onCompleted:accessor.rootItem(); + Component.onCompleted:accessor.contentItem(); } } diff --git a/tests/auto/quick/qquickwindow/data/showHideAnimate.qml b/tests/auto/quick/qquickwindow/data/showHideAnimate.qml new file mode 100644 index 0000000000..e83910c5a5 --- /dev/null +++ b/tests/auto/quick/qquickwindow/data/showHideAnimate.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + NumberAnimation on opacity { from: 0; to: 1; duration: 100; loops: Animation.Infinite } +} diff --git a/tests/auto/quick/qquickwindow/qquickwindow.pro b/tests/auto/quick/qquickwindow/qquickwindow.pro index 9ae63a9ef1..b1fc5cd4f2 100644 --- a/tests/auto/quick/qquickwindow/qquickwindow.pro +++ b/tests/auto/quick/qquickwindow/qquickwindow.pro @@ -6,13 +6,13 @@ include (../../shared/util.pri) macx:CONFIG -= app_bundle -CONFIG += parallel_test QT += core-private gui-private qml-private quick-private v8-private testlib TESTDATA = data/* OTHER_FILES += \ data/AnimationsWhileHidden.qml \ - data/Headless.qml + data/Headless.qml \ + data/showHideAnimate.qml DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 3e3a35f8d1..2d3c8f7ca7 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -284,8 +284,11 @@ private slots: void constantUpdates(); + void constantUpdatesOnWindow_data(); + void constantUpdatesOnWindow(); void mouseFiltering(); void headless(); + void noUpdateWhenNothingChanges(); void touchEvent_basic(); void touchEvent_propagation(); @@ -312,6 +315,13 @@ private slots: void ownershipRootItem(); + void hideThenDelete_data(); + void hideThenDelete(); + + void showHideAnimate(); + + void testExpose(); + #ifndef QT_NO_CURSOR void cursor(); #endif @@ -331,6 +341,56 @@ void tst_qquickwindow::constantUpdates() QTRY_VERIFY(item.iterations > 60); } +void tst_qquickwindow::constantUpdatesOnWindow_data() +{ + QTest::addColumn<bool>("blockedGui"); + QTest::addColumn<QByteArray>("signal"); + + QQuickWindow window; + window.setGeometry(100, 100, 300, 200); + window.show(); + QTest::qWaitForWindowExposed(&window); + bool threaded = window.openglContext()->thread() != QGuiApplication::instance()->thread(); + + if (threaded) { + QTest::newRow("blocked, beforeSync") << true << QByteArray(SIGNAL(beforeSynchronizing())); + QTest::newRow("blocked, beforeRender") << true << QByteArray(SIGNAL(beforeRendering())); + QTest::newRow("blocked, afterRender") << true << QByteArray(SIGNAL(afterRendering())); + QTest::newRow("blocked, swapped") << true << QByteArray(SIGNAL(frameSwapped())); + } + QTest::newRow("unblocked, beforeSync") << false << QByteArray(SIGNAL(beforeSynchronizing())); + QTest::newRow("unblocked, beforeRender") << false << QByteArray(SIGNAL(beforeRendering())); + QTest::newRow("unblocked, afterRender") << false << QByteArray(SIGNAL(afterRendering())); + QTest::newRow("unblocked, swapped") << false << QByteArray(SIGNAL(frameSwapped())); +} + +void tst_qquickwindow::constantUpdatesOnWindow() +{ + QSKIP("This test fails frequently on the present overworked CI mac machines"); + QFETCH(bool, blockedGui); + QFETCH(QByteArray, signal); + + QQuickWindow window; + window.setGeometry(100, 100, 300, 200); + + connect(&window, signal.constData(), &window, SLOT(update()), Qt::DirectConnection); + window.show(); + QTRY_VERIFY(window.isExposed()); + + QSignalSpy catcher(&window, SIGNAL(frameSwapped())); + if (blockedGui) + QTest::qSleep(1000); + else { + window.update(); + QTest::qWait(1000); + } + window.hide(); + + // We should expect 60, but under loaded conditions we could be skipping + // frames, so don't expect too much. + QVERIFY(catcher.size() > 10); +} + void tst_qquickwindow::touchEvent_basic() { TestTouchItem::clearMousePressCounter(); @@ -945,6 +1005,8 @@ void tst_qquickwindow::headless() QScopedPointer<QObject> cleanup(created); QQuickWindow* window = qobject_cast<QQuickWindow*>(created); + window->setPersistentOpenGLContext(false); + window->setPersistentSceneGraph(false); QVERIFY(window); window->show(); @@ -984,6 +1046,28 @@ void tst_qquickwindow::headless() QCOMPARE(originalContent, newContent); } +void tst_qquickwindow::noUpdateWhenNothingChanges() +{ + QQuickWindow window; + window.setGeometry(100, 100, 300, 200); + + QQuickRectangle rect(window.contentItem()); + + window.show(); + QTRY_VERIFY(window.isExposed()); + + if (window.openglContext()->thread() == QGuiApplication::instance()->thread()) { + QSKIP("Only threaded renderloop implements this feature"); + return; + } + + QSignalSpy spy(&window, SIGNAL(frameSwapped())); + rect.update(); + QTest::qWait(500); + + QCOMPARE(spy.size(), 0); +} + void tst_qquickwindow::focusObject() { QQmlEngine engine; @@ -997,6 +1081,11 @@ void tst_qquickwindow::focusObject() QQuickWindow *window = qobject_cast<QQuickWindow*>(created); QVERIFY(window); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + QQuickItem *item1 = window->findChild<QQuickItem*>("item1"); QVERIFY(item1); item1->setFocus(true); @@ -1207,6 +1296,110 @@ void tst_qquickwindow::cursor() } #endif +void tst_qquickwindow::hideThenDelete_data() +{ + QTest::addColumn<bool>("persistentSG"); + QTest::addColumn<bool>("persistentGL"); + + QTest::newRow("persistent:SG=false,GL=false") << false << false; + QTest::newRow("persistent:SG=true,GL=false") << true << false; + QTest::newRow("persistent:SG=false,GL=true") << false << true; + QTest::newRow("persistent:SG=true,GL=true") << true << true; +} + +void tst_qquickwindow::hideThenDelete() +{ + if (QGuiApplication::platformName() == QStringLiteral("xcb")) { + QSKIP("For some obscure reason this test fails in CI only"); + return; + } + + QFETCH(bool, persistentSG); + QFETCH(bool, persistentGL); + + QSignalSpy *openglDestroyed = 0; + QSignalSpy *sgInvalidated = 0; + + { + QQuickWindow window; + window.setColor(Qt::red); + + window.setPersistentSceneGraph(persistentSG); + window.setPersistentOpenGLContext(persistentGL); + + window.resize(400, 300); + window.show(); + + QTest::qWaitForWindowExposed(&window); + + openglDestroyed = new QSignalSpy(window.openglContext(), SIGNAL(aboutToBeDestroyed())); + sgInvalidated = new QSignalSpy(&window, SIGNAL(sceneGraphInvalidated())); + + window.hide(); + + QTRY_VERIFY(!window.isExposed()); + + if (!persistentSG) { + QVERIFY(sgInvalidated->size() > 0); + if (!persistentGL) + QVERIFY(openglDestroyed->size() > 0); + else + QVERIFY(openglDestroyed->size() == 0); + } else { + QVERIFY(sgInvalidated->size() == 0); + QVERIFY(openglDestroyed->size() == 0); + } + } + + QVERIFY(sgInvalidated->size() > 0); + QVERIFY(openglDestroyed->size() > 0); +} + +void tst_qquickwindow::showHideAnimate() +{ + // This test tries to mimick a bug triggered in the qquickanimatedimage test + // A window is shown, then removed again before it is exposed. This left + // traces in the render loop which prevent other animations from running + // later on. + { + QQuickWindow window; + window.resize(400, 300); + window.show(); + } + + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("showHideAnimate.qml")); + QQuickItem* created = qobject_cast<QQuickItem *>(component.create()); + + QVERIFY(created); + + QTRY_VERIFY(created->opacity() > 0.5); + QTRY_VERIFY(created->opacity() < 0.5); +} + +void tst_qquickwindow::testExpose() +{ + QQuickWindow window; + window.setGeometry(100, 100, 300, 200); + + window.show(); + QTRY_VERIFY(window.isExposed()); + + QSignalSpy swapSpy(&window, SIGNAL(frameSwapped())); + + // exhaust pending exposes, as some platforms send us plenty + // while showing the first time + QTest::qWait(1000); + while (swapSpy.size() != 0) { + swapSpy.clear(); + QTest::qWait(100); + } + + QWindowSystemInterface::handleExposeEvent(&window, QRegion(10, 10, 20, 20)); + QTRY_COMPARE(swapSpy.size(), 1); +} + QTEST_MAIN(tst_qquickwindow) #include "tst_qquickwindow.moc" diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro index c4a4173e0f..6cb091b04a 100644 --- a/tests/auto/quick/quick.pro +++ b/tests/auto/quick/quick.pro @@ -31,7 +31,7 @@ PRIVATETESTS += \ !qtHaveModule(xmlpatterns): PRIVATETESTS -= qquickxmllistmodel QUICKTESTS = \ - qquickaccessible \ +# qquickaccessible \ qquickanchors \ qquickanimatedimage \ qquickanimatedsprite \ @@ -61,6 +61,7 @@ QUICKTESTS = \ qquickshadereffect \ qquickspritesequence \ qquicktext \ + qquicktextdocument \ qquicktextedit \ qquicktextinput \ qquickvisualdatamodel \ @@ -68,6 +69,7 @@ QUICKTESTS = \ qquickcanvasitem \ qquickscreen \ touchmouse \ + dialogs \ SUBDIRS += $$PUBLICTESTS diff --git a/tests/auto/quick/rendernode/rendernode.pro b/tests/auto/quick/rendernode/rendernode.pro index 425faef0a6..1e2c50a6d1 100644 --- a/tests/auto/quick/rendernode/rendernode.pro +++ b/tests/auto/quick/rendernode/rendernode.pro @@ -15,3 +15,4 @@ OTHER_FILES += \ data/RenderOrder.qml \ data/MessUpState.qml \ DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 +CONFIG+=insignificant_test diff --git a/tests/auto/quick/touchmouse/tst_touchmouse.cpp b/tests/auto/quick/touchmouse/tst_touchmouse.cpp index caad2539be..15a4f0cc27 100644 --- a/tests/auto/quick/touchmouse/tst_touchmouse.cpp +++ b/tests/auto/quick/touchmouse/tst_touchmouse.cpp @@ -148,7 +148,7 @@ private slots: void initTestCase(); void simpleTouchEvent(); - void eventFilter(); + void testEventFilter(); void mouse(); void touchOverMouse(); void mouseOverTouch(); @@ -303,7 +303,7 @@ void tst_TouchMouse::simpleTouchEvent() delete window; } -void tst_TouchMouse::eventFilter() +void tst_TouchMouse::testEventFilter() { // // install event filter on item and see that it can grab events // QQuickView *window = createView(); @@ -824,8 +824,7 @@ void tst_TouchMouse::mouseOnFlickableOnPinch() QQuickView *window = createView(); window->setSource(testFileUrl("mouseonflickableonpinch.qml")); window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QTest::qWaitForWindowExposed(window)); QVERIFY(window->rootObject() != 0); QRect windowRect = QRect(window->position(), window->size()); QCursor::setPos(windowRect.center()); diff --git a/tests/testapplications/text/textedit.qml b/tests/testapplications/text/textedit.qml index 789a52894e..e0d7dbdde4 100644 --- a/tests/testapplications/text/textedit.qml +++ b/tests/testapplications/text/textedit.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 2.0 +import QtQuick 2.1 Rectangle { height: 360; width: 640 @@ -75,6 +75,7 @@ Rectangle { wrapMode: { wrapvalue.model.get(wrapvalue.currentIndex).value } smooth: { smoothvalue.model.get(smoothvalue.currentIndex).value } selectByMouse: { mousevalue.model.get(mousevalue.currentIndex).value } + selectByKeyboard: { keyboardvalue.model.get(keyboardvalue.currentIndex).value } onLinkActivated: { bordercolor.border.color = "red" } Rectangle { id: bordercolor; color: "transparent"; border.color: "green"; anchors.fill: parent } } @@ -228,6 +229,10 @@ Rectangle { controlname: "Mouse" model: ListModel { ListElement { name: "Off"; value: false } ListElement { name: "On"; value: true } } } ControlView { + id: keyboardvalue + controlname: "Keyboard" + model: ListModel { ListElement { name: "Off"; value: false } ListElement { name: "On"; value: true } } } + ControlView { id: halignvalue controlname: "HAlign" model: ListModel { ListElement { name: "Left"; value: Text.AlignLeft } ListElement { name: "Right"; value: Text.AlignRight } |