diff options
Diffstat (limited to 'tests/auto/other')
-rw-r--r-- | tests/auto/other/atwrapper/atWrapperAutotest.cpp | 2 | ||||
-rw-r--r-- | tests/auto/other/collections/tst_collections.cpp | 1628 | ||||
-rw-r--r-- | tests/auto/other/d3dcompiler/d3dcompiler.pro | 5 | ||||
-rw-r--r-- | tests/auto/other/d3dcompiler/tst_d3dcompiler.cpp | 372 | ||||
-rw-r--r-- | tests/auto/other/languagechange/tst_languagechange.cpp | 8 | ||||
-rw-r--r-- | tests/auto/other/other.pro | 3 | ||||
-rw-r--r-- | tests/auto/other/qaccessibility/qaccessibility.pro | 5 | ||||
-rw-r--r-- | tests/auto/other/qaccessibility/tst_qaccessibility.cpp | 4 | ||||
-rw-r--r-- | tests/auto/other/qcomplextext/tst_qcomplextext.cpp | 58 | ||||
-rw-r--r-- | tests/auto/other/qfocusevent/tst_qfocusevent.cpp | 4 | ||||
-rw-r--r-- | tests/auto/other/qvariant_common/tst_qvariant_common.h | 2 |
11 files changed, 1237 insertions, 854 deletions
diff --git a/tests/auto/other/atwrapper/atWrapperAutotest.cpp b/tests/auto/other/atwrapper/atWrapperAutotest.cpp index 7ece62806c..63116574b5 100644 --- a/tests/auto/other/atwrapper/atWrapperAutotest.cpp +++ b/tests/auto/other/atwrapper/atWrapperAutotest.cpp @@ -70,7 +70,7 @@ void atWrapperAutotest::runTest() atWrapper wrapper; if (!wrapper.runAutoTests()) - QSKIP("Arthur not tested on this machine"); + QSKIP("Arthur not tested on this machine"); QVERIFY(true); } diff --git a/tests/auto/other/collections/tst_collections.cpp b/tests/auto/other/collections/tst_collections.cpp index df622602c3..17ed9c8a45 100644 --- a/tests/auto/other/collections/tst_collections.cpp +++ b/tests/auto/other/collections/tst_collections.cpp @@ -210,231 +210,231 @@ void tst_Collections::typeinfo() void tst_Collections::list() { { - QList<int> list; - QVERIFY(list.isEmpty()); - list.append(1); - QVERIFY(list.size() == 1); + QList<int> list; + QVERIFY(list.isEmpty()); + list.append(1); + QVERIFY(list.size() == 1); - QVERIFY(*list.begin() == 1); + QVERIFY(*list.begin() == 1); - list.push_back(2); - list += (3); - list << 4 << 5 << 6; - QVERIFY(!list.isEmpty()); - QVERIFY(list.size() == 6); - QVERIFY(list.end() - list.begin() == list.size()); + list.push_back(2); + list += (3); + list << 4 << 5 << 6; + QVERIFY(!list.isEmpty()); + QVERIFY(list.size() == 6); + QVERIFY(list.end() - list.begin() == list.size()); #if !defined(Q_CC_MSVC) && !defined(Q_CC_SUN) - QVERIFY(std::binary_search(list.begin(), list.end(), 2) == true); - QVERIFY(std::binary_search(list.begin(), list.end(), 9) == false); + QVERIFY(std::binary_search(list.begin(), list.end(), 2) == true); + QVERIFY(std::binary_search(list.begin(), list.end(), 9) == false); #endif - QVERIFY(qBinaryFind(list.begin(), list.end(), 2) == list.begin() + 1); - QVERIFY(qLowerBound(list.begin(), list.end(), 2) == list.begin() + 1); + QVERIFY(qBinaryFind(list.begin(), list.end(), 2) == list.begin() + 1); + QVERIFY(qLowerBound(list.begin(), list.end(), 2) == list.begin() + 1); QVERIFY(qUpperBound(list.begin(), list.end(), 2) == list.begin() + 2); - QVERIFY(qBinaryFind(list.begin(), list.end(), 9) == list.end()); - QVERIFY(qLowerBound(list.begin(), list.end(), 9) == list.end()); + QVERIFY(qBinaryFind(list.begin(), list.end(), 9) == list.end()); + QVERIFY(qLowerBound(list.begin(), list.end(), 9) == list.end()); QVERIFY(qUpperBound(list.begin(), list.end(), 9) == list.end()); - { - int sum = 0; - QListIterator<int> i(list); - while (i.hasNext()) - sum += i.next(); - QVERIFY(sum == 21); - } - - { - QList<int> list1; + { + int sum = 0; + QListIterator<int> i(list); + while (i.hasNext()) + sum += i.next(); + QVERIFY(sum == 21); + } + + { + QList<int> list1; list1 << 1 << 2 << 3 << 5 << 7 << 8 << 9; - QList<int> list2 = list1; + QList<int> list2 = list1; - QMutableListIterator<int> i1(list1); + QMutableListIterator<int> i1(list1); while (i1.hasNext()) { - if (i1.next() % 2 != 0) - i1.remove(); - } + if (i1.next() % 2 != 0) + i1.remove(); + } - QMutableListIterator<int> i2(list2); + QMutableListIterator<int> i2(list2); i2.toBack(); while (i2.hasPrevious()) { - if (i2.previous() % 2 != 0) - i2.remove(); + if (i2.previous() % 2 != 0) + i2.remove(); } QVERIFY(list1.size() == 2); QVERIFY(list2.size() == 2); QVERIFY(list1 == list2); } - { - int sum = 0; - for (int i = 0; i < list.size(); ++i) - sum += list[i]; - QVERIFY(sum == 21); - } - { - int sum = 0; - QList<int>::const_iterator i = list.begin(); - while (i != list.end()) - sum += *i++; - QVERIFY(sum == 21); - } - { - int sum = 0; - QList<int>::ConstIterator i = list.begin(); - while (i != list.end()) - sum += *i++; - QVERIFY(sum == 21); - } - { - QList<int>::Iterator i = list.begin(); + { + int sum = 0; + for (int i = 0; i < list.size(); ++i) + sum += list[i]; + QVERIFY(sum == 21); + } + { + int sum = 0; + QList<int>::const_iterator i = list.begin(); + while (i != list.end()) + sum += *i++; + QVERIFY(sum == 21); + } + { + int sum = 0; + QList<int>::ConstIterator i = list.begin(); + while (i != list.end()) + sum += *i++; + QVERIFY(sum == 21); + } + { + QList<int>::Iterator i = list.begin(); i += 2; QCOMPARE(*i, 3); i -= 1; QCOMPARE(*i, 2); - } - { - QList<int>::ConstIterator i = list.begin(); + } + { + QList<int>::ConstIterator i = list.begin(); i += 2; QCOMPARE(*i, 3); i -= 1; QCOMPARE(*i, 2); - } - { - int sum = 0; - int i; - for (i = 0; i < list.size(); ++i) - list[i] = list[i] +1; - for (i = 0; i < list.size(); ++i) - sum += list[i]; - QVERIFY(sum == 21 + list.size()); - } - { - int sum = 0; - int i; - for (i = 0; i < list.size(); ++i) - --list[i]; - for (i = 0; i < list.size(); ++i) - sum += list[i]; - QVERIFY(sum == 21); - } - { - QMutableListIterator<int> i(list); - while (i.hasNext()) - i.setValue(2*i.next()); - } - { - int sum = 0; - QListIterator<int> i(list); - i.toBack(); - while (i.hasPrevious()) - sum += i.previous(); - QVERIFY(sum == 2*21); - } - { - QMutableListIterator<int> i(list); - i.toBack(); - while (i.hasPrevious()) - i.setValue(2*i.previous()); - } - { - int sum = 0; - QListIterator<int> i(list); - i.toBack(); - while (i.hasPrevious()) - sum += i.previous(); - QVERIFY(sum == 2*2*21); - } - { - QMutableListIterator<int> i(list); - while (i.hasNext()) { - int a = i.next(); - i.insert(a); - } - } - { - int sum = 0; - QList<int>::iterator i = list.begin(); - while (i != list.end()) - sum += *i++; - QVERIFY(sum == 2*2*2*21); - } - { - int duplicates = 0; - QListIterator<int> i(list); - while (i.hasNext()) { - int a = i.next(); - if (i.hasNext() && a == i.peekNext()) - duplicates++; - } - QVERIFY(duplicates == 6); - } - { - int duplicates = 0; - QListIterator<int> i(list); - i.toBack(); - while (i.hasPrevious()) { - int a = i.previous(); - if (i.hasPrevious() && a == i.peekPrevious()) - duplicates++; - } - QVERIFY(duplicates == 6); - } - { - QMutableListIterator<int> i(list); - while (i.hasNext()) { - int a = i.next(); - if (i.hasNext() && - i.peekNext() == a) - i.remove(); - } - } - { - int duplicates = 0; - QMutableListIterator<int> i = list; - i.toBack(); - while (i.hasPrevious()) { - int a = i.previous(); - if (i.hasPrevious() && a == i.peekPrevious()) - duplicates++; - } - QVERIFY(duplicates == 0); - } - { - QVERIFY(list.size() == 6); - QMutableListIterator<int> i = list; - while (i.hasNext()) { - int a = i.peekNext(); - i.insert(42); - QVERIFY(i.peekPrevious() == 42 && i.peekNext() == a); - i.next(); - } - QVERIFY(list.size() == 12); - i.toFront(); - while (i.findNext(42)) - i.remove(); - } - { - QList<int> l; - l << 4 << 8 << 12 << 16 << 20 << 24; - QVERIFY(l == list); - QList<int> copy = list; - list += list; - QVERIFY(l != list && l.size() == list.size()/2 && l == copy); - l += copy; - QVERIFY(l == list); - list = copy; - } - { - QList<int> copy = list; - list << 8; - QVERIFY(list.indexOf(8) == 1); - QVERIFY(list.indexOf(8, list.indexOf(8)+1) == 6); - int a = list.indexOf(8); - QVERIFY(list.count(8) == 2); - int r = list.removeAll(8); - QVERIFY(r == 2); - list.insert(a, 8); - QVERIFY(list == copy); - } + } + { + int sum = 0; + int i; + for (i = 0; i < list.size(); ++i) + list[i] = list[i] +1; + for (i = 0; i < list.size(); ++i) + sum += list[i]; + QVERIFY(sum == 21 + list.size()); + } + { + int sum = 0; + int i; + for (i = 0; i < list.size(); ++i) + --list[i]; + for (i = 0; i < list.size(); ++i) + sum += list[i]; + QVERIFY(sum == 21); + } + { + QMutableListIterator<int> i(list); + while (i.hasNext()) + i.setValue(2*i.next()); + } + { + int sum = 0; + QListIterator<int> i(list); + i.toBack(); + while (i.hasPrevious()) + sum += i.previous(); + QVERIFY(sum == 2*21); + } + { + QMutableListIterator<int> i(list); + i.toBack(); + while (i.hasPrevious()) + i.setValue(2*i.previous()); + } + { + int sum = 0; + QListIterator<int> i(list); + i.toBack(); + while (i.hasPrevious()) + sum += i.previous(); + QVERIFY(sum == 2*2*21); + } + { + QMutableListIterator<int> i(list); + while (i.hasNext()) { + int a = i.next(); + i.insert(a); + } + } + { + int sum = 0; + QList<int>::iterator i = list.begin(); + while (i != list.end()) + sum += *i++; + QVERIFY(sum == 2*2*2*21); + } + { + int duplicates = 0; + QListIterator<int> i(list); + while (i.hasNext()) { + int a = i.next(); + if (i.hasNext() && a == i.peekNext()) + duplicates++; + } + QVERIFY(duplicates == 6); + } + { + int duplicates = 0; + QListIterator<int> i(list); + i.toBack(); + while (i.hasPrevious()) { + int a = i.previous(); + if (i.hasPrevious() && a == i.peekPrevious()) + duplicates++; + } + QVERIFY(duplicates == 6); + } + { + QMutableListIterator<int> i(list); + while (i.hasNext()) { + int a = i.next(); + if (i.hasNext() && + i.peekNext() == a) + i.remove(); + } + } + { + int duplicates = 0; + QMutableListIterator<int> i = list; + i.toBack(); + while (i.hasPrevious()) { + int a = i.previous(); + if (i.hasPrevious() && a == i.peekPrevious()) + duplicates++; + } + QVERIFY(duplicates == 0); + } + { + QVERIFY(list.size() == 6); + QMutableListIterator<int> i = list; + while (i.hasNext()) { + int a = i.peekNext(); + i.insert(42); + QVERIFY(i.peekPrevious() == 42 && i.peekNext() == a); + i.next(); + } + QVERIFY(list.size() == 12); + i.toFront(); + while (i.findNext(42)) + i.remove(); + } + { + QList<int> l; + l << 4 << 8 << 12 << 16 << 20 << 24; + QVERIFY(l == list); + QList<int> copy = list; + list += list; + QVERIFY(l != list && l.size() == list.size()/2 && l == copy); + l += copy; + QVERIFY(l == list); + list = copy; + } + { + QList<int> copy = list; + list << 8; + QVERIFY(list.indexOf(8) == 1); + QVERIFY(list.indexOf(8, list.indexOf(8)+1) == 6); + int a = list.indexOf(8); + QVERIFY(list.count(8) == 2); + int r = list.removeAll(8); + QVERIFY(r == 2); + list.insert(a, 8); + QVERIFY(list == copy); + } { QList<QString> list; list << "one" << "two" << "three" << "four" << "five" << "six"; @@ -458,73 +458,73 @@ void tst_Collections::list() QVERIFY(!list.removeOne("one")); QVERIFY(list.isEmpty()); } - { - QList<int> copy = list; - list << 8; - QVERIFY(list.lastIndexOf(8) == 6); - QVERIFY(list.lastIndexOf(8, list.lastIndexOf(8)-1) == 1); - list = copy; - } - { - QList<int> copy = list; - list.insert(3, 999); - QVERIFY(list[3] == 999); - list.replace(3, 222); - QVERIFY(list[3] == 222); - QVERIFY(list.contains(222) && ! list.contains(999)); - list.removeAt(3); - list = copy; - QVERIFY(list == copy); - } - { - list.clear(); - QVERIFY(list.isEmpty()); - QVERIFY(list.begin() == list.end()); - QListIterator<int> i(list); - QVERIFY(!i.hasNext() && !i.hasPrevious()); - } - { - QList<int> l1; - QList<int> l2; - l1 << 1 << 2 << 3; - l2 << 4 << 5 << 6; - QList<int> l3 = l1 + l2; - l1 += l2; - QVERIFY(l3 == l1); - } - { - QList<int> list; - QVERIFY(list.isEmpty()); - list.append(1); - QList<int> list2; - list2 = list; - list2.clear(); - QVERIFY(list2.size() == 0); - QVERIFY(list.size() == 1); - } - { - QList<int> list; - list.append(1); - list = list; - QVERIFY(list.size() == 1); - } + { + QList<int> copy = list; + list << 8; + QVERIFY(list.lastIndexOf(8) == 6); + QVERIFY(list.lastIndexOf(8, list.lastIndexOf(8)-1) == 1); + list = copy; + } + { + QList<int> copy = list; + list.insert(3, 999); + QVERIFY(list[3] == 999); + list.replace(3, 222); + QVERIFY(list[3] == 222); + QVERIFY(list.contains(222) && ! list.contains(999)); + list.removeAt(3); + list = copy; + QVERIFY(list == copy); + } + { + list.clear(); + QVERIFY(list.isEmpty()); + QVERIFY(list.begin() == list.end()); + QListIterator<int> i(list); + QVERIFY(!i.hasNext() && !i.hasPrevious()); + } + { + QList<int> l1; + QList<int> l2; + l1 << 1 << 2 << 3; + l2 << 4 << 5 << 6; + QList<int> l3 = l1 + l2; + l1 += l2; + QVERIFY(l3 == l1); + } + { + QList<int> list; + QVERIFY(list.isEmpty()); + list.append(1); + QList<int> list2; + list2 = list; + list2.clear(); + QVERIFY(list2.size() == 0); + QVERIFY(list.size() == 1); + } + { + QList<int> list; + list.append(1); + list = list; + QVERIFY(list.size() == 1); + } } { - QList<void*> list; - list.append(0); - list.append((void*)42); - QCOMPARE(list.size(), 2); - QCOMPARE(list.at(0), (void*)0); - QCOMPARE(list.at(1), (void*)42); + QList<void*> list; + list.append(0); + list.append((void*)42); + QCOMPARE(list.size(), 2); + QCOMPARE(list.at(0), (void*)0); + QCOMPARE(list.at(1), (void*)42); } { - QVector<QString> vector(5); + QVector<QString> vector(5); vector[0] = "99"; vector[4] ="100"; QList<QString> list = vector.toList(); - QVERIFY(list.size() == 5); + QVERIFY(list.size() == 5); QVERIFY(list.at(0) == "99"); QVERIFY(list.at(4) == "100"); list[0] = "10"; @@ -783,145 +783,145 @@ void tst_Collections::list() void tst_Collections::linkedList() { { - QLinkedList<int> list; - QVERIFY(list.isEmpty()); - list.append(1); - list.push_back(2); - list += (3); - list << 4 << 5 << 6; - QVERIFY(!list.isEmpty()); - QVERIFY(list.size() == 6); - { - int sum = 0; - QLinkedListIterator<int> i = list; - while (i.hasNext()) { - sum += i.next(); - } - QVERIFY(sum == 21); - } - { - int sum = 0; - QLinkedList<int>::const_iterator i = list.begin(); - while (i != list.end()) - sum += *i++; - QVERIFY(sum == 21); - } - { - QMutableLinkedListIterator<int> i = list; - while (i.hasNext()) - i.setValue(2*i.next()); - } - { - int sum = 0; - QLinkedListIterator<int> i = list; - i.toBack(); - while (i.hasPrevious()) - sum += i.previous(); - QVERIFY(sum == 2*21); - } - { - QMutableLinkedListIterator<int> i = list; - i.toBack(); - while (i.hasPrevious()) - i.setValue(2*i.previous()); - } - { - int sum = 0; - QLinkedListIterator<int> i = list; - i.toBack(); - while (i.hasPrevious()) - sum += i.previous(); - QVERIFY(sum == 2*2*21); - } - { - QMutableLinkedListIterator<int> i = list; - while (i.hasNext()) { - int a = i.next(); - i.insert(a); - } - } - { - int sum = 0; - QLinkedList<int>::iterator i = list.begin(); - while (i != list.end()) - sum += *i++; - QVERIFY(sum == 2*2*2*21); - } - { - int duplicates = 0; - QLinkedListIterator<int> i = list; - while (i.hasNext()) { - int a = i.next(); - if (i.hasNext() && a == i.peekNext()) - duplicates++; - } - QVERIFY(duplicates == 6); - } - { - int duplicates = 0; - QLinkedListIterator<int> i = list; - i.toBack(); - while (i.hasPrevious()) { - int a = i.previous(); - if (i.hasPrevious() && a == i.peekPrevious()) - duplicates++; - } - QVERIFY(duplicates == 6); - } - { - QMutableLinkedListIterator<int> i = list; - while (i.hasNext()) { - int a = i.next(); - if (i.hasNext() && - i.peekNext() == a) - i.remove(); - } - } - { - int duplicates = 0; - QMutableLinkedListIterator<int> i = list; - i.toBack(); - while (i.hasPrevious()) { - int a = i.previous(); - if (i.hasPrevious() && a == i.peekPrevious()) - duplicates++; - } - QVERIFY(duplicates == 0); - } - { - QVERIFY(list.size() == 6); - QMutableLinkedListIterator<int> i = list; - while (i.hasNext()) { - int a = i.peekNext(); - i.insert(42); - QVERIFY(i.peekPrevious() == 42 && i.peekNext() == a); - i.next(); - } - QVERIFY(list.size() == 12); - i.toFront(); - while (i.findNext(42)) - i.remove(); - } - { - QLinkedList<int> l; - l << 4 << 8 << 12 << 16 << 20 << 24; - QVERIFY(l == list); - QLinkedList<int> copy = list; - list += list; - QVERIFY(l != list && l.size() == list.size()/2 && l == copy); - l += copy; - QVERIFY(l == list); - list = copy; - } - { - QLinkedList<int> copy = list; - list.prepend(999); - list.append(999); - QVERIFY(list.contains(999)); - QVERIFY(list.count(999) == 2); - list.removeAll(999); - QVERIFY(list == copy); - } + QLinkedList<int> list; + QVERIFY(list.isEmpty()); + list.append(1); + list.push_back(2); + list += (3); + list << 4 << 5 << 6; + QVERIFY(!list.isEmpty()); + QVERIFY(list.size() == 6); + { + int sum = 0; + QLinkedListIterator<int> i = list; + while (i.hasNext()) { + sum += i.next(); + } + QVERIFY(sum == 21); + } + { + int sum = 0; + QLinkedList<int>::const_iterator i = list.begin(); + while (i != list.end()) + sum += *i++; + QVERIFY(sum == 21); + } + { + QMutableLinkedListIterator<int> i = list; + while (i.hasNext()) + i.setValue(2*i.next()); + } + { + int sum = 0; + QLinkedListIterator<int> i = list; + i.toBack(); + while (i.hasPrevious()) + sum += i.previous(); + QVERIFY(sum == 2*21); + } + { + QMutableLinkedListIterator<int> i = list; + i.toBack(); + while (i.hasPrevious()) + i.setValue(2*i.previous()); + } + { + int sum = 0; + QLinkedListIterator<int> i = list; + i.toBack(); + while (i.hasPrevious()) + sum += i.previous(); + QVERIFY(sum == 2*2*21); + } + { + QMutableLinkedListIterator<int> i = list; + while (i.hasNext()) { + int a = i.next(); + i.insert(a); + } + } + { + int sum = 0; + QLinkedList<int>::iterator i = list.begin(); + while (i != list.end()) + sum += *i++; + QVERIFY(sum == 2*2*2*21); + } + { + int duplicates = 0; + QLinkedListIterator<int> i = list; + while (i.hasNext()) { + int a = i.next(); + if (i.hasNext() && a == i.peekNext()) + duplicates++; + } + QVERIFY(duplicates == 6); + } + { + int duplicates = 0; + QLinkedListIterator<int> i = list; + i.toBack(); + while (i.hasPrevious()) { + int a = i.previous(); + if (i.hasPrevious() && a == i.peekPrevious()) + duplicates++; + } + QVERIFY(duplicates == 6); + } + { + QMutableLinkedListIterator<int> i = list; + while (i.hasNext()) { + int a = i.next(); + if (i.hasNext() && + i.peekNext() == a) + i.remove(); + } + } + { + int duplicates = 0; + QMutableLinkedListIterator<int> i = list; + i.toBack(); + while (i.hasPrevious()) { + int a = i.previous(); + if (i.hasPrevious() && a == i.peekPrevious()) + duplicates++; + } + QVERIFY(duplicates == 0); + } + { + QVERIFY(list.size() == 6); + QMutableLinkedListIterator<int> i = list; + while (i.hasNext()) { + int a = i.peekNext(); + i.insert(42); + QVERIFY(i.peekPrevious() == 42 && i.peekNext() == a); + i.next(); + } + QVERIFY(list.size() == 12); + i.toFront(); + while (i.findNext(42)) + i.remove(); + } + { + QLinkedList<int> l; + l << 4 << 8 << 12 << 16 << 20 << 24; + QVERIFY(l == list); + QLinkedList<int> copy = list; + list += list; + QVERIFY(l != list && l.size() == list.size()/2 && l == copy); + l += copy; + QVERIFY(l == list); + list = copy; + } + { + QLinkedList<int> copy = list; + list.prepend(999); + list.append(999); + QVERIFY(list.contains(999)); + QVERIFY(list.count(999) == 2); + list.removeAll(999); + QVERIFY(list == copy); + } { QLinkedList<QString> list; list << "one" << "two" << "three" << "four" << "five" << "six"; @@ -946,12 +946,12 @@ void tst_Collections::linkedList() QVERIFY(list.isEmpty()); } { - list.clear(); - QVERIFY(list.isEmpty()); - QVERIFY(list.begin() == list.end()); - QLinkedListIterator<int> i(list); - QVERIFY(!i.hasNext() && !i.hasPrevious()); - } + list.clear(); + QVERIFY(list.isEmpty()); + QVERIFY(list.begin() == list.end()); + QLinkedListIterator<int> i(list); + QVERIFY(!i.hasNext() && !i.hasPrevious()); + } } { @@ -1102,7 +1102,7 @@ void tst_Collections::vector() dummy = new LargeStatic; vector.append(LargeStatic()); } - delete dummy; + delete dummy; } QVERIFY(LargeStatic::count == originalLargeStaticCount); @@ -1364,11 +1364,11 @@ void tst_Collections::byteArray() ba1 += ba1; QCOMPARE(ba1, QByteArray("yyyyyy")); - ba1.remove(1, -1); // do nothing - QCOMPARE(ba1, QByteArray("yyyyyy")); + ba1.remove(1, -1); // do nothing + QCOMPARE(ba1, QByteArray("yyyyyy")); - ba1.replace(0, -1, "ZZZ"); - QCOMPARE(ba1, QByteArray("ZZZyyyyyy")); + ba1.replace(0, -1, "ZZZ"); + QCOMPARE(ba1, QByteArray("ZZZyyyyyy")); } }; @@ -1382,16 +1382,16 @@ void tst_Collections::stack() i.toBack(); int sum = 0; while (i.hasPrevious()) - sum += i.previous(); + sum += i.previous(); QVERIFY(sum == 6); sum = 0; for (QStack<int>::iterator i = stack.begin(); i != stack.end(); ++i) - sum += *i; + sum += *i; QVERIFY(sum == 6); while (!stack.isEmpty()) - sum -= stack.pop(); + sum -= stack.pop(); QVERIFY(sum == 0); } @@ -1403,194 +1403,194 @@ void tst_Collections::hash() const char *monde = "monde"; { - typedef QHash<QString, QString> Hash; - Hash hash; - QString key; - for (int i = 0; i < 10; ++i) { - key[0] = i + '0'; - for (int j = 0; j < 10; ++j) { - key[1] = j + '0'; - hash.insert(key, "V" + key); - } - } - - for (int i = 0; i < 10; ++i) { - key[0] = i + '0'; - for (int j = 0; j < 10; ++j) { - key[1] = j + '0'; - hash.remove(key); - } - } + typedef QHash<QString, QString> Hash; + Hash hash; + QString key; + for (int i = 0; i < 10; ++i) { + key[0] = i + '0'; + for (int j = 0; j < 10; ++j) { + key[1] = j + '0'; + hash.insert(key, "V" + key); + } + } + + for (int i = 0; i < 10; ++i) { + key[0] = i + '0'; + for (int j = 0; j < 10; ++j) { + key[1] = j + '0'; + hash.remove(key); + } + } } { - typedef QHash<int, const char *> Hash; - Hash hash; - hash.insert(1, hello); - hash.insert(2, world); - - QVERIFY(hash.size() == 2); - QVERIFY(!hash.isEmpty()); - - { - Hash hash2 = hash; - hash2 = hash; - hash = hash2; - hash2 = hash2; - hash = hash; - hash2.clear(); - hash2 = hash2; - QVERIFY(hash2.size() == 0); - QVERIFY(hash2.isEmpty()); - } - QVERIFY(hash.size() == 2); - - { - Hash hash2 = hash; - hash2[1] = allo; - hash2[2] = monde; - - QVERIFY(hash2[1] == allo); - QVERIFY(hash2[2] == monde); - QVERIFY(hash[1] == hello); - QVERIFY(hash[2] == world); - - hash2[1] = hash[1]; - hash2[2] = hash[2]; - - QVERIFY(hash2[1] == hello); - QVERIFY(hash2[2] == world); - - hash[1] = hash[1]; - QVERIFY(hash[1] == hello); - } - - { - Hash hash2 = hash; - hash2.detach(); - hash2.remove(1); - QVERIFY(hash2.size() == 1); - hash2.remove(1); - QVERIFY(hash2.size() == 1); - hash2.remove(0); - QVERIFY(hash2.size() == 1); - hash2.remove(2); - QVERIFY(hash2.size() == 0); - QVERIFY(hash.size() == 2); - } - - hash.detach(); - - { - Hash::iterator it1 = hash.find(1); - QVERIFY(it1 != hash.end()); - - Hash::iterator it2 = hash.find(0); - QVERIFY(it2 != hash.begin()); - QVERIFY(it2 == hash.end()); - - *it1 = monde; - QVERIFY(*it1 == monde); - QVERIFY(hash[1] == monde); - - *it1 = hello; - QVERIFY(*it1 == hello); - QVERIFY(hash[1] == hello); - - hash[1] = monde; - QVERIFY(it1.key() == 1); - QVERIFY(it1.value() == monde); - QVERIFY(*it1 == monde); - QVERIFY(hash[1] == monde); - - hash[1] = hello; - QVERIFY(*it1 == hello); - QVERIFY(hash[1] == hello); - } - - { - const Hash hash2 = hash; - - Hash::const_iterator it1 = hash2.find(1); - QVERIFY(it1 != hash2.end()); - QVERIFY(it1.key() == 1); - QVERIFY(it1.value() == hello); - QVERIFY(*it1 == hello); - - Hash::const_iterator it2 = hash2.find(2); - QVERIFY(it1 != it2); - QVERIFY(it1 != hash2.end()); - QVERIFY(it2 != hash2.end()); - - int count = 0; - it1 = hash2.begin(); - while (it1 != hash2.end()) { - count++; - ++it1; - } - QVERIFY(count == 2); - - count = 0; - it1 = hash.begin(); - while (it1 != hash.end()) { - count++; - ++it1; - } - QVERIFY(count == 2); - } - - { - QVERIFY(hash.contains(1)); - QVERIFY(hash.contains(2)); - QVERIFY(!hash.contains(0)); - QVERIFY(!hash.contains(3)); - } - - { - QVERIFY(hash.value(1) == hello); - QVERIFY(hash.value(2) == world); - QVERIFY(hash.value(3) == 0); - QVERIFY(hash.value(1, allo) == hello); - QVERIFY(hash.value(2, allo) == world); - QVERIFY(hash.value(3, allo) == allo); - QVERIFY(hash.value(0, monde) == monde); - } - - { - QHash<int,LargeStatic> hash; - for (int i = 0; i < 10; i++) - hash.insert(i, LargeStatic()); - QVERIFY(LargeStatic::count == 10); - hash.remove(7); - QVERIFY(LargeStatic::count == 9); - - } - QVERIFY(LargeStatic::count == 0); - { - QHash<int, int*> hash; - QVERIFY(((const QHash<int,int*>*) &hash)->operator[](7) == 0); - } - - { - /* + typedef QHash<int, const char *> Hash; + Hash hash; + hash.insert(1, hello); + hash.insert(2, world); + + QVERIFY(hash.size() == 2); + QVERIFY(!hash.isEmpty()); + + { + Hash hash2 = hash; + hash2 = hash; + hash = hash2; + hash2 = hash2; + hash = hash; + hash2.clear(); + hash2 = hash2; + QVERIFY(hash2.size() == 0); + QVERIFY(hash2.isEmpty()); + } + QVERIFY(hash.size() == 2); + + { + Hash hash2 = hash; + hash2[1] = allo; + hash2[2] = monde; + + QVERIFY(hash2[1] == allo); + QVERIFY(hash2[2] == monde); + QVERIFY(hash[1] == hello); + QVERIFY(hash[2] == world); + + hash2[1] = hash[1]; + hash2[2] = hash[2]; + + QVERIFY(hash2[1] == hello); + QVERIFY(hash2[2] == world); + + hash[1] = hash[1]; + QVERIFY(hash[1] == hello); + } + + { + Hash hash2 = hash; + hash2.detach(); + hash2.remove(1); + QVERIFY(hash2.size() == 1); + hash2.remove(1); + QVERIFY(hash2.size() == 1); + hash2.remove(0); + QVERIFY(hash2.size() == 1); + hash2.remove(2); + QVERIFY(hash2.size() == 0); + QVERIFY(hash.size() == 2); + } + + hash.detach(); + + { + Hash::iterator it1 = hash.find(1); + QVERIFY(it1 != hash.end()); + + Hash::iterator it2 = hash.find(0); + QVERIFY(it2 != hash.begin()); + QVERIFY(it2 == hash.end()); + + *it1 = monde; + QVERIFY(*it1 == monde); + QVERIFY(hash[1] == monde); + + *it1 = hello; + QVERIFY(*it1 == hello); + QVERIFY(hash[1] == hello); + + hash[1] = monde; + QVERIFY(it1.key() == 1); + QVERIFY(it1.value() == monde); + QVERIFY(*it1 == monde); + QVERIFY(hash[1] == monde); + + hash[1] = hello; + QVERIFY(*it1 == hello); + QVERIFY(hash[1] == hello); + } + + { + const Hash hash2 = hash; + + Hash::const_iterator it1 = hash2.find(1); + QVERIFY(it1 != hash2.end()); + QVERIFY(it1.key() == 1); + QVERIFY(it1.value() == hello); + QVERIFY(*it1 == hello); + + Hash::const_iterator it2 = hash2.find(2); + QVERIFY(it1 != it2); + QVERIFY(it1 != hash2.end()); + QVERIFY(it2 != hash2.end()); + + int count = 0; + it1 = hash2.begin(); + while (it1 != hash2.end()) { + count++; + ++it1; + } + QVERIFY(count == 2); + + count = 0; + it1 = hash.begin(); + while (it1 != hash.end()) { + count++; + ++it1; + } + QVERIFY(count == 2); + } + + { + QVERIFY(hash.contains(1)); + QVERIFY(hash.contains(2)); + QVERIFY(!hash.contains(0)); + QVERIFY(!hash.contains(3)); + } + + { + QVERIFY(hash.value(1) == hello); + QVERIFY(hash.value(2) == world); + QVERIFY(hash.value(3) == 0); + QVERIFY(hash.value(1, allo) == hello); + QVERIFY(hash.value(2, allo) == world); + QVERIFY(hash.value(3, allo) == allo); + QVERIFY(hash.value(0, monde) == monde); + } + + { + QHash<int,LargeStatic> hash; + for (int i = 0; i < 10; i++) + hash.insert(i, LargeStatic()); + QVERIFY(LargeStatic::count == 10); + hash.remove(7); + QVERIFY(LargeStatic::count == 9); + + } + QVERIFY(LargeStatic::count == 0); + { + QHash<int, int*> hash; + QVERIFY(((const QHash<int,int*>*) &hash)->operator[](7) == 0); + } + + { + /* This test relies on a certain implementation of QHash. If you change the way QHash works internally, change this test as well. */ - QHash<int, int> hash; + QHash<int, int> hash; for (int i = 0; i < 1000; ++i) - hash.insert(i, i); - QVERIFY(hash.capacity() == 1031); + hash.insert(i, i); + QVERIFY(hash.capacity() == 1031); hash.squeeze(); QVERIFY(hash.capacity() == 521); - hash.insert(12345, 12345); + hash.insert(12345, 12345); QVERIFY(hash.capacity() == 1031); - for (int j = 0; j < 900; ++j) - hash.remove(j); + for (int j = 0; j < 900; ++j) + hash.remove(j); QVERIFY(hash.capacity() == 257); - hash.squeeze(); + hash.squeeze(); QVERIFY(hash.capacity() == 67); hash.reserve(0); } @@ -1643,211 +1643,211 @@ void tst_Collections::map() const char *monde = "monde"; { - typedef QMap<int, const char *> Map; - Map map; - map.insert(1, hello); - map.insert(2, world); - - QVERIFY(*map.begin() == hello); - - QVERIFY(map.size() == 2); - QVERIFY(!map.isEmpty()); - - { - Map map2 = map; - map2 = map; - map = map2; - map2 = map2; - map = map; - map2.clear(); - map2 = map2; - QVERIFY(map2.size() == 0); - QVERIFY(map2.isEmpty()); - } - QVERIFY(map.size() == 2); - - { - Map map2 = map; - map2[1] = allo; - map2[2] = monde; - - QVERIFY(map2[1] == allo); - QVERIFY(map2[2] == monde); - QVERIFY(map[1] == hello); - QVERIFY(map[2] == world); - - map2[1] = map[1]; - map2[2] = map[2]; - - QVERIFY(map2[1] == hello); - QVERIFY(map2[2] == world); - - map[1] = map[1]; - QVERIFY(map[1] == hello); - } - - { - Map map2 = map; - map2.detach(); - map2.remove(1); - QVERIFY(map2.size() == 1); - map2.remove(1); - QVERIFY(map2.size() == 1); - map2.remove(0); - QVERIFY(map2.size() == 1); - map2.remove(2); - QVERIFY(map2.size() == 0); - QVERIFY(map.size() == 2); - } - - map.detach(); - - { - Map::iterator it1 = map.find(1); - QVERIFY(it1 == map.begin()); - QVERIFY(it1 != map.end()); - - Map::iterator it2 = map.find(0); - QVERIFY(it2 != map.begin()); - QVERIFY(it2 == map.end()); - - *it1 = monde; - QVERIFY(*it1 == monde); - QVERIFY(map[1] == monde); - - *it1 = hello; - QVERIFY(*it1 == hello); - QVERIFY(map[1] == hello); - - map[1] = monde; - QVERIFY(it1.key() == 1); - QVERIFY(it1.value() == monde); - QVERIFY(*it1 == monde); - QVERIFY(map[1] == monde); - - map[1] = hello; - QVERIFY(*it1 == hello); - QVERIFY(map[1] == hello); - - *++it1 = allo; - QVERIFY(*it1 == allo); - QVERIFY(map[2] == allo); - *it1 = world; - - ++it1; - QVERIFY(it1 == map.end()); - - int count = 0; - it1 = map.begin(); - while (it1 != map.end()) { - count++; - ++it1; - } - QVERIFY(count == 2); - } - - { - const Map map2 = map; - - Map::const_iterator it1 = map2.find(1); - QVERIFY(it1 != map2.end()); - QVERIFY(it1.key() == 1); - QVERIFY(it1.value() == hello); - QVERIFY(*it1 == hello); - ++it1; - - Map::const_iterator it2 = map2.find(2); - QVERIFY(it1 == it2); - ++it1; - QVERIFY(it1 == map2.end()); - QVERIFY(it2 != map2.end()); - QVERIFY(it1 != it2); - - int count = 0; - it1 = map2.begin(); - while (it1 != map2.end()) { - count++; - ++it1; - } - QVERIFY(count == 2); - - count = 0; - it1 = map.begin(); - while (it1 != map.end()) { - count++; - ++it1; - } - QVERIFY(count == 2); - } - - { - QVERIFY(map.contains(1)); - QVERIFY(map.contains(2)); - QVERIFY(!map.contains(0)); - QVERIFY(!map.contains(3)); - } - - { - QVERIFY(map.value(1) == hello); - QVERIFY(map.value(2) == world); - QVERIFY(map.value(3) == 0); - QVERIFY(map.value(1, allo) == hello); - QVERIFY(map.value(2, allo) == world); - QVERIFY(map.value(3, allo) == allo); - QVERIFY(map.value(0, monde) == monde); - } - int originalLargeStaticCount = LargeStatic::count; - { - QMap<int,LargeStatic> map; - for (int i = 0; i < 10; i++) - map.insert(i, LargeStatic()); + typedef QMap<int, const char *> Map; + Map map; + map.insert(1, hello); + map.insert(2, world); + + QVERIFY(*map.begin() == hello); + + QVERIFY(map.size() == 2); + QVERIFY(!map.isEmpty()); + + { + Map map2 = map; + map2 = map; + map = map2; + map2 = map2; + map = map; + map2.clear(); + map2 = map2; + QVERIFY(map2.size() == 0); + QVERIFY(map2.isEmpty()); + } + QVERIFY(map.size() == 2); + + { + Map map2 = map; + map2[1] = allo; + map2[2] = monde; + + QVERIFY(map2[1] == allo); + QVERIFY(map2[2] == monde); + QVERIFY(map[1] == hello); + QVERIFY(map[2] == world); + + map2[1] = map[1]; + map2[2] = map[2]; + + QVERIFY(map2[1] == hello); + QVERIFY(map2[2] == world); + + map[1] = map[1]; + QVERIFY(map[1] == hello); + } + + { + Map map2 = map; + map2.detach(); + map2.remove(1); + QVERIFY(map2.size() == 1); + map2.remove(1); + QVERIFY(map2.size() == 1); + map2.remove(0); + QVERIFY(map2.size() == 1); + map2.remove(2); + QVERIFY(map2.size() == 0); + QVERIFY(map.size() == 2); + } + + map.detach(); + + { + Map::iterator it1 = map.find(1); + QVERIFY(it1 == map.begin()); + QVERIFY(it1 != map.end()); + + Map::iterator it2 = map.find(0); + QVERIFY(it2 != map.begin()); + QVERIFY(it2 == map.end()); + + *it1 = monde; + QVERIFY(*it1 == monde); + QVERIFY(map[1] == monde); + + *it1 = hello; + QVERIFY(*it1 == hello); + QVERIFY(map[1] == hello); + + map[1] = monde; + QVERIFY(it1.key() == 1); + QVERIFY(it1.value() == monde); + QVERIFY(*it1 == monde); + QVERIFY(map[1] == monde); + + map[1] = hello; + QVERIFY(*it1 == hello); + QVERIFY(map[1] == hello); + + *++it1 = allo; + QVERIFY(*it1 == allo); + QVERIFY(map[2] == allo); + *it1 = world; + + ++it1; + QVERIFY(it1 == map.end()); + + int count = 0; + it1 = map.begin(); + while (it1 != map.end()) { + count++; + ++it1; + } + QVERIFY(count == 2); + } + + { + const Map map2 = map; + + Map::const_iterator it1 = map2.find(1); + QVERIFY(it1 != map2.end()); + QVERIFY(it1.key() == 1); + QVERIFY(it1.value() == hello); + QVERIFY(*it1 == hello); + ++it1; + + Map::const_iterator it2 = map2.find(2); + QVERIFY(it1 == it2); + ++it1; + QVERIFY(it1 == map2.end()); + QVERIFY(it2 != map2.end()); + QVERIFY(it1 != it2); + + int count = 0; + it1 = map2.begin(); + while (it1 != map2.end()) { + count++; + ++it1; + } + QVERIFY(count == 2); + + count = 0; + it1 = map.begin(); + while (it1 != map.end()) { + count++; + ++it1; + } + QVERIFY(count == 2); + } + + { + QVERIFY(map.contains(1)); + QVERIFY(map.contains(2)); + QVERIFY(!map.contains(0)); + QVERIFY(!map.contains(3)); + } + + { + QVERIFY(map.value(1) == hello); + QVERIFY(map.value(2) == world); + QVERIFY(map.value(3) == 0); + QVERIFY(map.value(1, allo) == hello); + QVERIFY(map.value(2, allo) == world); + QVERIFY(map.value(3, allo) == allo); + QVERIFY(map.value(0, monde) == monde); + } + int originalLargeStaticCount = LargeStatic::count; + { + QMap<int,LargeStatic> map; + for (int i = 0; i < 10; i++) + map.insert(i, LargeStatic()); QVERIFY(LargeStatic::count == (originalLargeStaticCount + 10)); - map.remove(7); - QVERIFY(LargeStatic::count == (originalLargeStaticCount + 9)); - - } - QVERIFY(LargeStatic::count == originalLargeStaticCount); - { - QMap<int, int*> map; - QVERIFY(((const QMap<int,int*>*) &map)->operator[](7) == 0); - } - - { - QMap<int, int> map; - map[0] = 1; - map[1] = 2; - map[2] = 4; - map[3] = 8; - int sum = 0; - int sumkey = 0; - QMapIterator<int,int> i = map; - while (i.hasNext()) { - sum += i.next().value(); - sumkey += i.key(); - } - QVERIFY(sum == 15); - QVERIFY(sumkey == 6); - } - { - QMap<int, int> map; - map[0] = 1; - map[1] = 2; - map[2] = 4; - map[3] = 8; - int sum = 0; - QMutableMapIterator<int,int> i = map; - while(i.hasNext()) - if (i.next().key() == 2) - i.remove(); - i.toFront(); - while(i.hasNext()) { - sum += i.next().value(); + map.remove(7); + QVERIFY(LargeStatic::count == (originalLargeStaticCount + 9)); + + } + QVERIFY(LargeStatic::count == originalLargeStaticCount); + { + QMap<int, int*> map; + QVERIFY(((const QMap<int,int*>*) &map)->operator[](7) == 0); + } + + { + QMap<int, int> map; + map[0] = 1; + map[1] = 2; + map[2] = 4; + map[3] = 8; + int sum = 0; + int sumkey = 0; + QMapIterator<int,int> i = map; + while (i.hasNext()) { + sum += i.next().value(); + sumkey += i.key(); + } + QVERIFY(sum == 15); + QVERIFY(sumkey == 6); + } + { + QMap<int, int> map; + map[0] = 1; + map[1] = 2; + map[2] = 4; + map[3] = 8; + int sum = 0; + QMutableMapIterator<int,int> i = map; + while (i.hasNext()) + if (i.next().key() == 2) + i.remove(); + i.toFront(); + while (i.hasNext()) { + sum += i.next().value(); i.setValue(10); i.value() += 22; QVERIFY(i.value() == 32); } - QVERIFY(sum == 11); - } + QVERIFY(sum == 11); + } { QMap<int, int> map; map[0] = 1; @@ -2177,14 +2177,14 @@ void tst_Collections::qstring() QVERIFY(s == "stl rocks"); { - QString str("Bananas"); - QVERIFY(str.startsWith("Ban")); - QVERIFY(false == str.startsWith("Car")); + QString str("Bananas"); + QVERIFY(str.startsWith("Ban")); + QVERIFY(false == str.startsWith("Car")); } { - QString str("Bananas"); - QVERIFY(str.endsWith("anas")); - QVERIFY(false == str.endsWith("pple")); + QString str("Bananas"); + QVERIFY(str.endsWith("anas")); + QVERIFY(false == str.endsWith("pple")); } @@ -2257,7 +2257,7 @@ void tst_Collections::bitArray() QVERIFY(ba[4]); int sum = 0; for(int i = 0; i < 20; i++) - sum += ba.testBit(i) ? 1 : 0; + sum += ba.testBit(i) ? 1 : 0; QVERIFY(sum == 2); ba = QBitArray(7, true); @@ -2288,36 +2288,36 @@ int CacheFoo::counter = 0; void tst_Collections::cache() { { - QCache<int, CacheFoo> cache(120); - int i; - for (i = 0; i < 30; i++) { + QCache<int, CacheFoo> cache(120); + int i; + for (i = 0; i < 30; i++) { cache.object(10); - cache.insert(i, new CacheFoo(i), i); - } + cache.insert(i, new CacheFoo(i), i); + } - QVERIFY(cache.contains(10)); - QVERIFY(!cache.contains(1)); - QVERIFY(!cache.contains(2)); - delete cache.take(10); + QVERIFY(cache.contains(10)); + QVERIFY(!cache.contains(1)); + QVERIFY(!cache.contains(2)); + delete cache.take(10); } { - QCache<int, QString> cache(120); - int i; - QString two; - for (i = 0; i < 30; i++) { - QString s = QString::number(i); - cache.insert(i, new QString(s), i); - if (i == 2) - two = s; - } - QVERIFY(!cache.contains(3)); - QVERIFY(!cache.contains(2)); + QCache<int, QString> cache(120); + int i; + QString two; + for (i = 0; i < 30; i++) { + QString s = QString::number(i); + cache.insert(i, new QString(s), i); + if (i == 2) + two = s; + } + QVERIFY(!cache.contains(3)); + QVERIFY(!cache.contains(2)); } { - QCache<int, int> cache(100); - cache.insert(2, new int(2)); - *cache[2] = 3; - QVERIFY(*cache.object(2) == 3); + QCache<int, int> cache(100); + cache.insert(2, new int(2)); + *cache[2] = 3; + QVERIFY(*cache.object(2) == 3); } QVERIFY(CacheFoo::counter == 0); diff --git a/tests/auto/other/d3dcompiler/d3dcompiler.pro b/tests/auto/other/d3dcompiler/d3dcompiler.pro new file mode 100644 index 0000000000..6242d0a554 --- /dev/null +++ b/tests/auto/other/d3dcompiler/d3dcompiler.pro @@ -0,0 +1,5 @@ +CONFIG += testcase +TARGET = tst_d3dcompiler +QT = core testlib + +SOURCES = tst_d3dcompiler.cpp diff --git a/tests/auto/other/d3dcompiler/tst_d3dcompiler.cpp b/tests/auto/other/d3dcompiler/tst_d3dcompiler.cpp new file mode 100644 index 0000000000..1a34c2076b --- /dev/null +++ b/tests/auto/other/d3dcompiler/tst_d3dcompiler.cpp @@ -0,0 +1,372 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +// This test verifies the behavior of d3dcompiler_qt, which is only built when ANGLE is enabled + +#include <QCryptographicHash> +#include <QDir> +#include <QFuture> +#include <QObject> +#include <QStandardPaths> +#include <QTemporaryDir> +#include <QTest> +#include <QThread> + +#if defined(Q_OS_WIN) + +#include <d3dcommon.h> + +#ifndef Q_OS_WINRT +#define loadLibrary(library) LoadLibrary(library) +#else +#define loadLibrary(library) LoadPackagedLibrary(library, NULL) +#endif + +#ifdef D3DCOMPILER_DLL +#undef D3DCOMPILER_DLL +#endif + +#ifdef QT_NO_DEBUG +#define D3DCOMPILER_DLL L"d3dcompiler_qt" +#else +#define D3DCOMPILER_DLL L"d3dcompiler_qtd" +#endif + +#define getCompilerFunc(dll) reinterpret_cast<D3DCompileFunc>(GetProcAddress(dll, "D3DCompile")) + +typedef HRESULT (WINAPI *D3DCompileFunc)(const void *data, SIZE_T data_size, const char *filename, + const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint, + const char *target, UINT sflags, UINT eflags, ID3DBlob **shader, ID3DBlob **error_messages); + +static const wchar_t *compilerDlls[] = { + L"d3dcompiler_47.dll", + L"d3dcompiler_46.dll", + L"d3dcompiler_45.dll", + L"d3dcompiler_44.dll", + L"d3dcompiler_43.dll", + 0 +}; + +static const char hlsl[] = + "uniform SamplerState Sampler : register(s0);\n" + "uniform Texture2D Texture : register(t0);\n" + "float4 main(in float4 gl_Position : SV_POSITION, in float2 coord : TEXCOORD0) : SV_TARGET0\n" + "{\n" + "return Texture.Sample(Sampler, coord);\n" + "}\n"; + +static inline QByteArray blobToByteArray(ID3DBlob *blob) +{ + return blob ? QByteArray::fromRawData(reinterpret_cast<const char *>(blob->GetBufferPointer()), blob->GetBufferSize()) : QByteArray(); +} + +class CompileRunner : public QThread +{ +public: + CompileRunner(D3DCompileFunc d3dCompile, const QByteArray &data, ID3DBlob **shader, ID3DBlob **error) + : m_d3dCompile(d3dCompile), m_data(data), m_shader(shader), m_error(error) + { + } + + HRESULT result() const + { + return m_result; + } + +private: + void run() + { + m_result = m_d3dCompile(m_data.constData(), m_data.size(), 0, 0, 0, "main", "ps_4_0", 0, 0, m_shader, m_error); + } + + HRESULT m_result; + D3DCompileFunc m_d3dCompile; + QByteArray m_data; + ID3DBlob **m_shader; + ID3DBlob **m_error; +}; + +class tst_d3dcompiler : public QObject +{ + Q_OBJECT +private slots: + void initTestCase(); + void init(); + void cleanup(); + void service_data(); + void service(); + void offlineCompile(); + void onlineCompile(); + +private: + QString blobPath(); + + HMODULE d3dcompiler_qt; + HMODULE d3dcompiler_win; + + D3DCompileFunc d3dCompile; + + QTemporaryDir tempDir; +}; + +QString tst_d3dcompiler::blobPath() +{ + QDir path; + if (qEnvironmentVariableIsSet("QT_D3DCOMPILER_DIR")) + path.setPath(qgetenv("QT_D3DCOMPILER_DIR")); + else + path.setPath(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QStringLiteral("/d3dcompiler")); + + path.mkdir(QStringLiteral("binary")); + path.mkdir(QStringLiteral("source")); + + return path.absolutePath(); +} + +void tst_d3dcompiler::initTestCase() +{ + QVERIFY(tempDir.isValid()); +} + +void tst_d3dcompiler::init() +{ + qunsetenv("QT_D3DCOMPILER_DIR"); + qunsetenv("QT_D3DCOMPILER_TIMEOUT"); +} + +void tst_d3dcompiler::cleanup() +{ + FreeLibrary(d3dcompiler_qt); + FreeLibrary(d3dcompiler_win); + + QDir path(blobPath()); + foreach (const QString &entry, path.entryList(QStringList(), QDir::Files|QDir::NoDotAndDotDot)) + path.remove(entry); + foreach (const QString &entry, path.entryList(QStringList(), QDir::Dirs|QDir::NoDotAndDotDot)) { + QDir dir(path.absoluteFilePath(entry + QStringLiteral("/"))); + dir.removeRecursively(); + } +} + +void tst_d3dcompiler::service_data() +{ + QTest::addColumn<QByteArray>("compilerDir"); + QTest::addColumn<bool>("exists"); + QTest::addColumn<HRESULT>("result"); + + // Don't test the default case, as it would clutter the AppData directory + //QTest::newRow("default") << QByteArrayLiteral("") << true << E_ABORT; + QTest::newRow("temporary") << QFile::encodeName(tempDir.path()) << true << E_ABORT; + QTest::newRow("invalid") << QByteArrayLiteral("ZZ:\\") << false << S_OK; + QTest::newRow("empty") << QByteArrayLiteral("") << false << S_OK; +} + +void tst_d3dcompiler::service() +{ + QFETCH(QByteArray, compilerDir); + QFETCH(bool, exists); + QFETCH(HRESULT, result); + qputenv("QT_D3DCOMPILER_DIR", compilerDir); + const QDir path = blobPath(); + + if (exists) { + // Activate service + QVERIFY(path.exists()); + + QFile control(path.absoluteFilePath(QStringLiteral("control"))); + QVERIFY(control.open(QFile::WriteOnly)); + control.close(); + QVERIFY(control.exists()); + } else { + QVERIFY(!path.exists()); + } + + // Run compiler (fast fail) + d3dcompiler_qt = loadLibrary(D3DCOMPILER_DLL); + QVERIFY(d3dcompiler_qt); + d3dCompile = getCompilerFunc(d3dcompiler_qt); + QVERIFY(d3dCompile); + + qputenv("QT_D3DCOMPILER_TIMEOUT", "1"); + const QByteArray data(hlsl); + ID3DBlob *shader = 0, *errorMessage = 0; + HRESULT hr = d3dCompile(data.constData(), data.size(), 0, 0, 0, "main", "ps_4_0", 0, 0, &shader, &errorMessage); + QVERIFY2(hr == result, blobToByteArray(errorMessage)); + + // Check that passthrough works + if (hr == S_OK) { + for (int i = 0; compilerDlls[i]; ++i) { + d3dcompiler_win = loadLibrary(compilerDlls[i]); + if (d3dcompiler_win) + break; + } + QVERIFY(d3dcompiler_win); + d3dCompile = getCompilerFunc(d3dcompiler_win); + QVERIFY(d3dCompile); + + // Compile a shader to compare with + ID3DBlob *reference = 0; + HRESULT hr = d3dCompile(data.constData(), data.size(), 0, 0, 0, "main", "ps_4_0", 0, 0, &reference, &errorMessage); + QVERIFY2(SUCCEEDED(hr), blobToByteArray(errorMessage)); + + QByteArray shaderData(reinterpret_cast<const char *>(shader->GetBufferPointer()), shader->GetBufferSize()); + QByteArray referenceData(reinterpret_cast<const char *>(reference->GetBufferPointer()), reference->GetBufferSize()); + reference->Release(); + QCOMPARE(shaderData, referenceData); + } else { + QVERIFY(FAILED(hr)); + } + + if (shader) + shader->Release(); +} + +void tst_d3dcompiler::offlineCompile() +{ + qputenv("QT_D3DCOMPILER_DIR", QFile::encodeName(tempDir.path())); + + for (int i = 0; compilerDlls[i]; ++i) { + d3dcompiler_win = loadLibrary(compilerDlls[i]); + if (d3dcompiler_win) + break; + } + QVERIFY(d3dcompiler_win); + d3dCompile = getCompilerFunc(d3dcompiler_win); + QVERIFY(d3dCompile); + + // Compile a shader to place in binary directory + const QByteArray data(hlsl); + ID3DBlob *shader = 0, *errorMessage = 0; + HRESULT hr = d3dCompile(data.constData(), data.size(), 0, 0, 0, "main", "ps_4_0", 0, 0, &shader, &errorMessage); + QVERIFY2(SUCCEEDED(hr), blobToByteArray(errorMessage)); + QVERIFY(shader); + + QDir outputPath(blobPath()); + QVERIFY(outputPath.exists()); + QVERIFY(outputPath.exists(QStringLiteral("binary"))); + outputPath.cd(QStringLiteral("binary")); + QFile output(outputPath.absoluteFilePath(QCryptographicHash::hash(data, QCryptographicHash::Sha1).toHex())); + QVERIFY(output.open(QFile::WriteOnly)); + output.write(reinterpret_cast<const char *>(shader->GetBufferPointer()), shader->GetBufferSize()); + shader->Release(); + + // Run compiler + d3dcompiler_qt = loadLibrary(D3DCOMPILER_DLL); + QVERIFY(d3dcompiler_qt); + d3dCompile = getCompilerFunc(d3dcompiler_qt); + QVERIFY(d3dCompile); + + hr = d3dCompile(data.constData(), data.size(), 0, 0, 0, "main", "ps_4_0", 0, 0, &shader, &errorMessage); + // Returns S_FALSE if a cached shader was found + QVERIFY2(hr == S_FALSE, blobToByteArray(errorMessage)); +} + +void tst_d3dcompiler::onlineCompile() +{ + qputenv("QT_D3DCOMPILER_DIR", QFile::encodeName(tempDir.path())); + + QByteArray data(hlsl); + + const QDir path = blobPath(); + + // Activate service + QVERIFY(path.exists()); + QFile control(path.absoluteFilePath(QStringLiteral("control"))); + QVERIFY(control.open(QFile::WriteOnly)); + control.close(); + QVERIFY(control.exists()); + + d3dcompiler_qt = loadLibrary(D3DCOMPILER_DLL); + QVERIFY(d3dcompiler_qt); + D3DCompileFunc concurrentCompile = getCompilerFunc(d3dcompiler_qt); + QVERIFY(d3dCompile); + + // Run async + ID3DBlob *shader = 0, *errorMessage = 0; + CompileRunner runner(concurrentCompile, data, &shader, &errorMessage); + runner.start(); + + // Wait for source to appear + QVERIFY(path.exists()); + QVERIFY(path.exists(QStringLiteral("source"))); + QVERIFY(path.exists(QStringLiteral("binary"))); + + const QString fileName = QCryptographicHash::hash(data, QCryptographicHash::Sha1).toHex() + + QStringLiteral("!main!ps_4_0!0"); + QFile input(path.absoluteFilePath(QStringLiteral("source/") + fileName)); + QTRY_VERIFY_WITH_TIMEOUT(input.exists(), 3000); + QTRY_VERIFY_WITH_TIMEOUT(input.isOpen() || input.open(QFile::ReadOnly), 1000); + + // Compile passed source + const QByteArray inputData = input.readAll(); + for (int i = 0; compilerDlls[i]; ++i) { + d3dcompiler_win = loadLibrary(compilerDlls[i]); + if (d3dcompiler_win) + break; + } + QVERIFY(d3dcompiler_win); + d3dCompile = getCompilerFunc(d3dcompiler_win); + QVERIFY(d3dCompile); + ID3DBlob *reference = 0, *errorMessage2 = 0; + HRESULT hr = d3dCompile(inputData.constData(), inputData.size(), 0, 0, 0, "main", "ps_4_0", 0, 0, &reference, &errorMessage2); + QVERIFY2(SUCCEEDED(hr), blobToByteArray(errorMessage2)); + const QByteArray referenceData(reinterpret_cast<const char *>(reference->GetBufferPointer()), reference->GetBufferSize()); + reference->Release(); + + // Write to output directory + QFile output(path.absoluteFilePath(QStringLiteral("binary/") + fileName)); + QVERIFY(output.open(QFile::WriteOnly)); + output.write(referenceData); + output.close(); + + // All done + QVERIFY(runner.wait(3000)); + hr = runner.result(); + QVERIFY2(hr == S_FALSE, blobToByteArray(errorMessage2)); + const QByteArray resultData(reinterpret_cast<const char *>(shader->GetBufferPointer()), shader->GetBufferSize()); + shader->Release(); + QVERIFY(referenceData == resultData); +} + +QTEST_MAIN(tst_d3dcompiler) +#include "tst_d3dcompiler.moc" + +#endif // Q_OS_WIN diff --git a/tests/auto/other/languagechange/tst_languagechange.cpp b/tests/auto/other/languagechange/tst_languagechange.cpp index cc01d70454..16c3d56385 100644 --- a/tests/auto/other/languagechange/tst_languagechange.cpp +++ b/tests/auto/other/languagechange/tst_languagechange.cpp @@ -188,11 +188,11 @@ void tst_languageChange::retranslatability_data() //next we fill it with data QTest::newRow( "QInputDialog" ) << int(InputDialog) << (QSet<QByteArray>() - << "QDialogButtonBox::Cancel"); + << "QPlatformTheme::Cancel"); QTest::newRow( "QColorDialog" ) << int(ColorDialog) << (QSet<QByteArray>() - << "QDialogButtonBox::Cancel" + << "QPlatformTheme::Cancel" << "QColorDialog::&Sat:" << "QColorDialog::&Add to Custom Colors" << "QColorDialog::&Green:" @@ -237,8 +237,8 @@ void tst_languageChange::retranslatability_data() << "QFileSystemModel::Type::All other platforms" #endif // << "QFileSystemModel::%1 KB" - << "QDialogButtonBox::Cancel" - << "QDialogButtonBox::Open" + << "QPlatformTheme::Cancel" + << "QPlatformTheme::Open" << "QFileDialog::File &name:"); } diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro index 63cbca539d..2bddc8d127 100644 --- a/tests/auto/other/other.pro +++ b/tests/auto/other/other.pro @@ -4,6 +4,7 @@ SUBDIRS=\ baselineexample \ collections \ compiler \ + d3dcompiler \ gestures \ headersclean \ lancelot \ @@ -57,6 +58,8 @@ cross_compile: SUBDIRS -= \ wince*|!contains(QT_CONFIG, accessibility): SUBDIRS -= qaccessibility +!angle_d3d11: SUBDIRS -= d3dcompiler + !contains(QT_CONFIG, accessibility-atspi-bridge): SUBDIRS -= qaccessibilitylinux !mac: SUBDIRS -= \ diff --git a/tests/auto/other/qaccessibility/qaccessibility.pro b/tests/auto/other/qaccessibility/qaccessibility.pro index 70f6633195..e6c5bb1149 100644 --- a/tests/auto/other/qaccessibility/qaccessibility.pro +++ b/tests/auto/other/qaccessibility/qaccessibility.pro @@ -13,10 +13,11 @@ wince*: { } win32 { - !*g++ { + !*g++:!winrt { include(../../../../src/3rdparty/iaccessible2/iaccessible2.pri) DEFINES += QT_SUPPORTS_IACCESSIBLE2 } - LIBS += -loleacc -loleaut32 -lole32 -luuid + LIBS += -luuid + !winphone: LIBS += -loleacc -loleaut32 -lole32 } DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 73bf4aab6a..dc3f266025 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -43,7 +43,9 @@ #include <QtCore/qglobal.h> #ifdef Q_OS_WIN # include <QtCore/qt_windows.h> +#ifndef Q_OS_WINRT # include <oleacc.h> +#endif # include <servprov.h> # include <winuser.h> # ifdef QT_SUPPORTS_IACCESSIBLE2 @@ -3366,7 +3368,7 @@ void tst_QAccessibility::bridgeTest() { // For now this is a simple test to see if the bridge is working at all. // Ideally it should be extended to test all aspects of the bridge. -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) // First, test MSAA part of bridge QWidget *window = new QWidget; QVBoxLayout *lay = new QVBoxLayout(window); diff --git a/tests/auto/other/qcomplextext/tst_qcomplextext.cpp b/tests/auto/other/qcomplextext/tst_qcomplextext.cpp index ff440948a2..7eb8479372 100644 --- a/tests/auto/other/qcomplextext/tst_qcomplextext.cpp +++ b/tests/auto/other/qcomplextext/tst_qcomplextext.cpp @@ -102,12 +102,12 @@ void tst_QComplexText::bidiReorderString_data() const LV *data = logical_visual; while ( data->name ) { - //next we fill it with data - QTest::newRow( data->name ) - << QString::fromUtf8( data->logical ) - << QString::fromUtf8( data->visual ) - << (int) data->basicDir; - data++; + //next we fill it with data + QTest::newRow( data->name ) + << QString::fromUtf8( data->logical ) + << QString::fromUtf8( data->visual ) + << (int) data->basicDir; + data++; } } @@ -127,34 +127,34 @@ void tst_QComplexText::bidiReorderString() int nitems = e.layoutData->items.size(); int i; for (i = 0; i < nitems; ++i) { - //qDebug("item %d bidiLevel=%d", i, e.items[i].analysis.bidiLevel); - levels[i] = e.layoutData->items[i].analysis.bidiLevel; + //qDebug("item %d bidiLevel=%d", i, e.items[i].analysis.bidiLevel); + levels[i] = e.layoutData->items[i].analysis.bidiLevel; } e.bidiReorder(nitems, levels, visualOrder); QString visual; for (i = 0; i < nitems; ++i) { - QScriptItem &si = e.layoutData->items[visualOrder[i]]; - QString sub = logical.mid(si.position, e.length(visualOrder[i])); - if (si.analysis.bidiLevel % 2) { - // reverse sub - QChar *a = (QChar *)sub.unicode(); - QChar *b = a + sub.length() - 1; - while (a < b) { - QChar tmp = *a; - *a = *b; - *b = tmp; - ++a; - --b; - } - a = (QChar *)sub.unicode(); - b = a + sub.length(); - while (a<b) { - *a = a->mirroredChar(); - ++a; - } - } - visual += sub; + QScriptItem &si = e.layoutData->items[visualOrder[i]]; + QString sub = logical.mid(si.position, e.length(visualOrder[i])); + if (si.analysis.bidiLevel % 2) { + // reverse sub + QChar *a = (QChar *)sub.unicode(); + QChar *b = a + sub.length() - 1; + while (a < b) { + QChar tmp = *a; + *a = *b; + *b = tmp; + ++a; + --b; + } + a = (QChar *)sub.unicode(); + b = a + sub.length(); + while (a<b) { + *a = a->mirroredChar(); + ++a; + } + } + visual += sub; } // replace Unicode newline back with \n to compare. visual.replace(QChar(0x2028), QChar('\n')); diff --git a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp index b194d08a65..df26407fe6 100644 --- a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp +++ b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp @@ -72,14 +72,14 @@ protected: { QLineEdit::focusInEvent( e ); focusInEventReason = e->reason(); - focusInEventGotFocus = e->gotFocus(); + focusInEventGotFocus = e->gotFocus(); focusInEventRecieved = true; } void focusOutEvent( QFocusEvent* e ) { QLineEdit::focusOutEvent( e ); focusOutEventReason = e->reason(); - focusOutEventLostFocus = !e->gotFocus(); + focusOutEventLostFocus = !e->gotFocus(); focusOutEventRecieved = true; } }; diff --git a/tests/auto/other/qvariant_common/tst_qvariant_common.h b/tests/auto/other/qvariant_common/tst_qvariant_common.h index fc3eff4b91..7a34d7b0c2 100644 --- a/tests/auto/other/qvariant_common/tst_qvariant_common.h +++ b/tests/auto/other/qvariant_common/tst_qvariant_common.h @@ -107,7 +107,7 @@ protected: currentName.chop(1); ok &= (msg.contains(", " + currentName) || msg.contains(", 0x0")); } - ok &= msg.endsWith(") "); + ok &= msg.endsWith(")"); QVERIFY2(ok, (QString::fromLatin1("Message is not correctly finished: '") + msg + '\'').toLatin1().constData()); } |