void KGlobalShortcutTest::testSaveRestore() { setupTest("testSaveRestore"); //It /would be nice/ to test persistent storage. That is not so easy... KShortcut cutA = m_actionA->globalShortcut(); // Delete the action delete m_actionA; // Recreate it m_actionA = new KAction("Text For Action A", this); m_actionA->setObjectName("Action A:testSaveRestore"); // Now it's empty QVERIFY(m_actionA->globalShortcut().isEmpty()); m_actionA->setGlobalShortcut(KShortcut()); // Now it's restored QCOMPARE(m_actionA->globalShortcut(), cutA); // And again delete m_actionA; m_actionA = new KAction("Text For Action A", this); m_actionA->setObjectName("Action A:testSaveRestore"); m_actionA->setGlobalShortcut(KShortcut(QKeySequence(), cutA.primary())); QCOMPARE(m_actionA->globalShortcut(), cutA); }
void TestTableLayout::testColumnWidthFixedShrink() { KoTableStyle *tableStyle = new KoTableStyle; //tableStyle->setWidth(QTextLength(QTextLength::FixedLength, 200.0)); // no table-width defined setupTest("merged text", "top right text", "mid right text", "bottom left text", "bottom mid text", "bottom right text", tableStyle); KoTableColumnAndRowStyleManager styleManager = KoTableColumnAndRowStyleManager::getManager(m_table); KoTableColumnStyle column1style; column1style.setColumnWidth(2.3); styleManager.setColumnStyle(0, column1style); KoTableColumnStyle column2style; column2style.setColumnWidth(122.5); styleManager.setColumnStyle(1, column2style); KoTableColumnStyle column3style; column3style.setColumnWidth(362.9); styleManager.setColumnStyle(2, column3style); m_layout->layout(); QVERIFY(qAbs(QTextCursor(m_table->parentFrame()).block().layout()->lineAt(0).width() - 200.0) < ROUNDING); // table should grow to 200 QVERIFY(qAbs(mergedCellBlock().layout()->lineAt(0).width() - 26.5938) < ROUNDING); QVERIFY(qAbs(topRightCellBlock().layout()->lineAt(0).width() - 267) < ROUNDING); QVERIFY(qAbs(bottomMidCellBlock().layout()->lineAt(0).width() - 26.5938) < ROUNDING); QVERIFY(qAbs(bottomRightCellBlock().layout()->lineAt(0).width() - 267) < ROUNDING); }
void KGlobalShortcutTest::testFindActionByKey() { // Skip this. The above testcase hasn't changed the actions setupTest("testFindActionByKey"); if (!m_daemonInstalled) QSKIP("kglobalaccel not installed", SkipAll); QList<KGlobalShortcutInfo> actionId = KGlobalAccel::self()->getGlobalShortcutsByKey(sequenceB); QCOMPARE(actionId.size(), 1); QString actionIdAComponentUniqueName("qttest"); QString actionIdAUniqueName("Action A:testFindActionByKey"); QString actionIdAComponentFriendlyName("KDE Test Program"); QString actionIdAFriendlyName("Text For Action A"); QCOMPARE(actionId.first().componentUniqueName(), actionIdAComponentUniqueName); QCOMPARE(actionId.first().uniqueName(), actionIdAUniqueName); QCOMPARE(actionId.first().componentFriendlyName(), actionIdAComponentFriendlyName); QCOMPARE(actionId.first().friendlyName(), actionIdAFriendlyName); actionId = KGlobalAccel::self()->getGlobalShortcutsByKey(sequenceA); QCOMPARE(actionId.size(), 1); QCOMPARE(actionId.first().componentUniqueName(), actionIdAComponentUniqueName); QCOMPARE(actionId.first().uniqueName(), actionIdAUniqueName); QCOMPARE(actionId.first().componentFriendlyName(), actionIdAComponentFriendlyName); QCOMPARE(actionId.first().friendlyName(), actionIdAFriendlyName); }
void KGlobalShortcutTest::testChangeShortcut() { // Skip this. The above testcase hasn't changed the actions setupTest("testChangeShortcut"); if (!m_daemonInstalled) QSKIP("kglobalaccel not installed", SkipAll); // Change the shortcut KShortcut newCutA(sequenceC); m_actionA->setGlobalShortcut(newCutA, KAction::ActiveShortcut, KAction::NoAutoloading); // Ensure that the change is active QCOMPARE(m_actionA->globalShortcut(), newCutA); // We haven't changed the default shortcut, ensure it is unchanged KShortcut cutA(sequenceA, sequenceB); QCOMPARE(m_actionA->globalShortcut(KAction::DefaultShortcut), cutA); // Try to set a already take shortcut KShortcut cutB(m_actionA->globalShortcut().primary(), QKeySequence(sequenceE)); m_actionB->setGlobalShortcut(cutB, KAction::ActiveShortcut, KAction::NoAutoloading); // Ensure that no change was made to the primary active shortcut QVERIFY(m_actionB->globalShortcut().primary().isEmpty()); // Ensure that the change to the secondary active shortcut was made QCOMPARE(m_actionB->globalShortcut().alternate(), QKeySequence(sequenceE)); // Ensure that the default shortcut is still empty QVERIFY(m_actionB->globalShortcut(KAction::DefaultShortcut).isEmpty()); // unchanged // Only change the active shortcut cutB.setPrimary(sequenceD); m_actionB->setGlobalShortcut(cutB, KAction::ActiveShortcut, KAction::NoAutoloading); // Check that the change went through QCOMPARE(m_actionB->globalShortcut(), cutB); // Check that the default shortcut is not active QVERIFY(m_actionB->globalShortcut(KAction::DefaultShortcut).isEmpty()); // unchanged }
void TouchActionTest::runShadowDOMTest(std::string file) { TouchActionTrackingWebViewClient client; WebView* webView = setupTest(file, client); TrackExceptionState es; // Oilpan: see runTouchActionTest() comment why these are persistent // references. Persistent<Document> document = static_cast<Document*>(webView->mainFrame()->document()); Persistent<StaticElementList> hostNodes = document->querySelectorAll("[shadow-host]", es); ASSERT_FALSE(es.hadException()); ASSERT_GE(hostNodes->length(), 1u); for (unsigned index = 0; index < hostNodes->length(); index++) { ShadowRoot* shadowRoot = hostNodes->item(index)->openShadowRoot(); runTestOnTree(shadowRoot, webView, client); } // Projections show up in the main document. runTestOnTree(document.get(), webView, client); // Explicitly reset to break dependency on locally scoped client. m_webViewHelper.reset(); }
void KGlobalShortcutTest::testOverrideMainComponentData() { setupTest("testOverrideMainComponentData"); KComponentData otherComponent("test_component1"); KActionCollection coll((QObject*)NULL); coll.setComponentData(otherComponent); KShortcut cutB; // Action without action collection KAction *action = new KAction("Text For Action A", this); QVERIFY(action->d->componentData == KGlobal::mainComponent()); action->setObjectName("Action A"); action->setGlobalShortcut(cutB, KAction::ActiveShortcut, KAction::NoAutoloading); QVERIFY(action->d->componentData == KGlobal::mainComponent()); // Action with action collection action->forgetGlobalShortcut(); delete action; action = coll.addAction("Action A"); QVERIFY(action->d->componentData == otherComponent); action->setGlobalShortcut(cutB, KAction::ActiveShortcut, KAction::NoAutoloading); QVERIFY(action->d->componentData == otherComponent); // cleanup action->forgetGlobalShortcut(); delete coll.takeAction(action); }
void TestTableLayout::testColumnWidthRelative() { setupTest("merged text", "top right text", "mid right text", "bottom left text", "bottom mid text", "bottom right text"); KoTableColumnAndRowStyleManager styleManager = KoTableColumnAndRowStyleManager::getManager(m_table); KoTableColumnStyle column1style; column1style.setRelativeColumnWidth(0.2); styleManager.setColumnStyle(0, column1style); KoTableColumnStyle column2style; column2style.setRelativeColumnWidth(0.5); styleManager.setColumnStyle(1, column2style); KoTableColumnStyle column3style; column3style.setRelativeColumnWidth(0.1); styleManager.setColumnStyle(2, column3style); m_layout->layout(); QVERIFY(qAbs(mergedCellBlock().layout()->lineAt(0).width() - 200.0*0.2 - 200.0*0.5) < ROUNDING); QVERIFY(qAbs(topRightCellBlock().layout()->lineAt(0).width() - 200.0*0.1) < ROUNDING); QVERIFY(qAbs(bottomLeftCellBlock().layout()->lineAt(0).width() - 200.0*0.2) < ROUNDING); QVERIFY(qAbs(bottomMidCellBlock().layout()->lineAt(0).width() - 200.0*0.5) < ROUNDING); QVERIFY(qAbs(bottomRightCellBlock().layout()->lineAt(0).width() - 200.0*0.1) < ROUNDING); }
int main (int argc, char** argv) { struct gameState G; int cardsInPlay[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, sea_hag, baron, smithy}; setupTest(&G, 5, cardsInPlay); //game state and handcount testSmithy(&G, cardsInPlay); return 0; }
void TestTableLayout::testSetupTest() { setupTest("m","02","12","20","21","22"); m_layout->layout(); QCOMPARE(mergedCellBlock().text(), QString("m")); QCOMPARE(topRightCellBlock().text(), QString("02")); QCOMPARE(midRightCellBlock().text(), QString("12")); QCOMPARE(bottomLeftCellBlock().text(), QString("20")); QCOMPARE(bottomMidCellBlock().text(), QString("21")); QCOMPARE(bottomRightCellBlock().text(), QString("22")); }
void KGlobalShortcutTest::testListActions() { setupTest("testListActions"); if (!m_daemonInstalled) QSKIP("kglobalaccel not installed", SkipAll); // As in kdebase/workspace/kcontrol/keys/globalshortcuts.cpp KGlobalAccel *kga = KGlobalAccel::self(); Q_UNUSED(kga); }
void TestTableLayout::testRowHeightMinimum() { KoTableStyle *tableStyle = new KoTableStyle; setupTest("merged text", "top right text", "mid right text", "bottom left text", "bottom mid text", "bottom right text", tableStyle); KoTableColumnAndRowStyleManager styleManager = KoTableColumnAndRowStyleManager::getManager(m_table); KoTableRowStyle row1style; row1style.setMinimumRowHeight(3.2); styleManager.setRowStyle(1, row1style); m_layout->layout(); QVERIFY(!dynamic_cast<MockRootAreaProvider*>(m_layout->provider())->m_askedForMoreThenOneArea); //QVERIFY(qAbs(mergedCellBlock().layout()->lineAt(0).height() - 14) < ROUNDING); }
void KGlobalShortcutTest::testSetShortcut() { setupTest("testSetShortcut"); if (!m_daemonInstalled) QSKIP("kglobalaccel not installed", SkipAll); // Just ensure that the desired values are set for both actions KShortcut cutA(sequenceA, sequenceB); QCOMPARE(m_actionA->globalShortcut(), cutA); QCOMPARE(m_actionA->globalShortcut(KAction::DefaultShortcut), cutA); QVERIFY(m_actionB->globalShortcut().isEmpty()); QVERIFY(m_actionB->globalShortcut(KAction::DefaultShortcut).isEmpty()); }
void TestTableLayout::testMergedCells() { QTextCursor cursor = setupTest(); m_table = cursor.insertTable(3, 5); m_table->mergeCells(0,0,2,2); m_table->mergeCells(0,2,3,1); m_table->mergeCells(0,3,3,1); m_table->mergeCells(0,4,3,1); m_table->mergeCells(2,0,1,1); m_table->mergeCells(2,1,1,1); m_layout->layout(); QVERIFY(!dynamic_cast<MockRootAreaProvider*>(m_layout->provider())->m_askedForMoreThenOneArea); }
int test_BR_LLSC_6_10_005(MYKI_BR_ContextData_t *pData) { testIf_t tIf; /* ** Setup test conditions */ if (setupTest( pData, PRODUCT_TYPE_SINGLE, &tIf) < 0) { return FALSE; } /* ** Run the Test and examine the results */ return runTest(pData, RULE_RESULT_ERROR, 3); }
void KGlobalShortcutTest::testStealShortcut() { setupTest("testStealShortcut"); if (!m_daemonInstalled) QSKIP("kglobalaccel not installed", SkipAll); // Steal a shortcut from an action. First ensure the initial state is // correct KShortcut cutA(sequenceA, sequenceB); QCOMPARE(m_actionA->globalShortcut(), cutA); QCOMPARE(m_actionA->globalShortcut(KAction::DefaultShortcut), cutA); KGlobalAccel::stealShortcutSystemwide(sequenceA); //let DBus do its thing in case it happens asynchronously QTest::qWait(200); QVERIFY(m_actionB->globalShortcut(KAction::ActiveShortcut).primary().isEmpty()); }
void doTest (int argc, char **argv, int n, int fatal_if_bad_n) { test_num = n; iteration = 0; max_iterations = 300; max_error = 0; if (! setupTest (n)) { if (fatal_if_bad_n) dError (0,"bad test number"); return; } // setup pointers to drawstuff callback functions dsFunctions fn; fn.version = DS_VERSION; fn.start = &start; fn.step = &simLoop; fn.command = 0; fn.stop = 0; if (cmd_path_to_textures) fn.path_to_textures = cmd_path_to_textures; else fn.path_to_textures = "../../drawstuff/textures"; // run simulation if (cmd_graphics) { dsSimulationLoop (argc,argv,352,288,&fn); } else { for (int i=0; i < max_iterations; i++) simLoop (0); } dWorldDestroy (world); body[0] = 0; body[1] = 0; joint = 0; // print results printf ("test %d: ",n); if (max_error == dInfinity) printf ("error not computed\n"); else { printf ("max scaled error = %.4e",max_error); if (max_error < 1) printf (" - passed\n"); else printf (" - FAILED\n"); } }
int test_BR_LLSC_6_10_002(MYKI_BR_ContextData_t *pData) { testIf_t tIf; /* ** Setup test conditions */ if (setupTest( pData, PRODUCT_TYPE_WEEKLY, &tIf) < 0) { return FALSE; } tIf.pMYKI_TAControl->ProductInUse = 0; /* ** Run the Test and examine the results */ return runTest(pData, RULE_RESULT_BYPASSED, 1 ); }
void KGlobalShortcutTest::testNotification() { setupTest("testNotification"); // Action without action collection KAction *action = new KAction("Text For Action A", this); QVERIFY(action->d->componentData == KGlobal::mainComponent()); action->setObjectName("Action A"); KShortcut cutB; action->setGlobalShortcut(cutB, KAction::ActiveShortcut, KAction::NoAutoloading); QVERIFY(action->d->componentData == KGlobal::mainComponent()); // kglobalacceld collects registrations and shows the together. Give it // time to kick in. sleep(2); action->forgetGlobalShortcut(); }
void TouchActionTest::runIFrameTest(std::string file) { TouchActionTrackingWebViewClient client; WebView* webView = setupTest(file, client); WebFrame* curFrame = webView->mainFrame()->firstChild(); ASSERT_TRUE(curFrame); for (; curFrame; curFrame = curFrame->nextSibling()) { // Oilpan: see runTouchActionTest() comment why these are persistent // references. Persistent<Document> contentDoc = static_cast<Document*>(curFrame->document()); runTestOnTree(contentDoc.get(), webView, client); } // Explicitly reset to break dependency on locally scoped client. m_webViewHelper.reset(); }
int test_BR_LLSC_6_10_003(MYKI_BR_ContextData_t *pData) { testIf_t tIf; /* ** Setup test conditions */ if (setupTest( pData, PRODUCT_TYPE_WEEKLY, &tIf) < 0) { return FALSE; } tIf.pProductInUse->ControlBitmap &= ~TAPP_TPRODUCT_CONTROL_PROVISIONAL_BITMAP; /* ** Run the Test and examine the results */ return runTest(pData, RULE_RESULT_BYPASSED, 2); }
void KGlobalShortcutTest::testConfigurationActions() { setupTest("testConfigurationActions"); // Create a configuration action KAction cfg_action("Text For Action A", NULL); cfg_action.setObjectName("Action A:testConfigurationActions"); cfg_action.setProperty("isConfigurationAction", true); cfg_action.setGlobalShortcut(KShortcut()); // Check that the configuration action has the correct shortcuts QCOMPARE(m_actionA->globalShortcut(), cfg_action.globalShortcut()); // TODO: // - change shortcut from configuration action and test for // yourShortcutGotChanged // - Ensure that the config action doesn't trigger(how?) // - Ensure that the original action is still working when the // configuration action is deleted }
void TestTableLayout::testColumnWidthUndefined() { setupTest("","","","","",""); m_layout->layout(); QCOMPARE(m_table->columns(), 3); QCOMPARE(m_table->rows(), 3); QVERIFY(qAbs(m_block.layout()->lineAt(0).width() - 200.0) < ROUNDING); QTextLayout *lay = bottomLeftCellBlock().layout(); QVERIFY(lay); QCOMPARE(lay->lineCount(), 1); QVERIFY(qAbs(lay->lineAt(0).width() - 200.0/3) < ROUNDING); lay = bottomMidCellBlock().layout(); QVERIFY(lay); QCOMPARE(lay->lineCount(), 1); QVERIFY(qAbs(lay->lineAt(0).width() - 200.0/3) < ROUNDING); lay = bottomRightCellBlock().layout(); QVERIFY(lay); QCOMPARE(lay->lineCount(), 1); QVERIFY(qAbs(lay->lineAt(0).width() - 200.0/3) < ROUNDING); }
void KGlobalShortcutTest::testForgetGlobalShortcut() { setupTest("testForgetGlobalShortcut"); // Ensure that forgetGlobalShortcut can be called on any action. KAction a("Test", NULL); a.forgetGlobalShortcut(); if (!m_daemonInstalled) QSKIP("kglobalaccel not installed", SkipAll); // We forget these two shortcuts and check that the component is gone // after that. If not it can mean the forgetGlobalShortcut() call is // broken OR someone messed up these tests to leave an additional global // shortcut behind. m_actionB->forgetGlobalShortcut(); m_actionA->forgetGlobalShortcut(); // kglobalaccel writes asynchronous. sleep(1); KGlobalAccel *kga = KGlobalAccel::self(); Q_UNUSED(kga); }
void TouchActionTest::runTouchActionTest(std::string file) { TouchActionTrackingWebViewClient client; // runTouchActionTest() loads a document in a frame, setting up a // nested message loop. Should any Oilpan GC happen while it is in // effect, the implicit assumption that we're outside any event // loop (=> there being no pointers on the stack needing scanning) // when that GC strikes will no longer hold. // // To ensure that the references on the stack are also traced, we // turn them into persistent, stack allocated references. This // workaround is sufficient to handle this artificial test // scenario. WebView* webView = setupTest(file, client); Persistent<Document> document = static_cast<Document*>(webView->mainFrame()->document()); runTestOnTree(document.get(), webView, client); // Explicitly reset to break dependency on locally scoped client. m_webViewHelper.reset(); }
void TestTableLayout::setupTest(const QString &mergedText, const QString &topRightText, const QString &midRightText, const QString &bottomLeftText, const QString &bottomMidText, const QString &bottomRightText, KoTableStyle* tableStyle) { QTextCursor cursor = setupTest(); KoParagraphStyle style; style.setStyleId(101); // needed to do manually since we don't use the stylemanager style.applyStyle(m_block); QTextTableFormat tableFormat; if (tableStyle) tableStyle->applyStyle(tableFormat); m_table = cursor.insertTable(3,3,tableFormat); m_table->mergeCells(0,0,2,2); if (mergedText.length() > 0) { m_table->cellAt(0,0).firstCursorPosition().insertText(mergedText); QTextBlock b2 = m_table->cellAt(0,0).firstCursorPosition().block(); while (b2.isValid()) { style.applyStyle(b2); b2 = b2.next(); } } if (topRightText.length() > 0) { m_table->cellAt(0,2).firstCursorPosition().insertText(topRightText); QTextBlock b2 = m_table->cellAt(0,2).firstCursorPosition().block(); while (b2.isValid()) { style.applyStyle(b2); b2 = b2.next(); } } if (midRightText.length() > 0) { m_table->cellAt(1,2).firstCursorPosition().insertText(midRightText); QTextBlock b2 = m_table->cellAt(1,2).firstCursorPosition().block(); while (b2.isValid()) { style.applyStyle(b2); b2 = b2.next(); } } if (bottomLeftText.length() > 0) { m_table->cellAt(2,0).firstCursorPosition().insertText(bottomLeftText); QTextBlock b2 = m_table->cellAt(2,0).firstCursorPosition().block(); while (b2.isValid()) { style.applyStyle(b2); b2 = b2.next(); } } if (bottomMidText.length() > 0) { m_table->cellAt(2,1).firstCursorPosition().insertText(bottomMidText); QTextBlock b2 = m_table->cellAt(2,1).firstCursorPosition().block(); while (b2.isValid()) { style.applyStyle(b2); b2 = b2.next(); } } if (bottomRightText.length() > 0) { m_table->cellAt(2,2).firstCursorPosition().insertText(bottomRightText); QTextBlock b2 = m_table->cellAt(2,2).firstCursorPosition().block(); while (b2.isValid()) { style.applyStyle(b2); b2 = b2.next(); } } }