Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
    testArray();
    testPlugin();
    testList();
    return 0;
    testByteArray();
    testHash();
    testImage();
    testIO();
    testMap();
    testString();
    testStringList();
    testStruct();
    testThreads();
    testVariant1();
    testVariant2();
    testVariant3();
    testVector();
    testVectorOfList();

    testObject(argc, argv);

    QColor color(255,128,10);
    QFont font;

    while(true)
        ;

    return 0;
}
/**
* @test Verifies Transport Reading When Dispatching Watches.
* 	- get proxy with available flag = true
* 	- generate big test data
* 	- send asynchronous test message
* 	- dispatch dispatchSource: the message must not be arrived
* 	- dispatch watches (reads transport).
* 	- dispatch dispatchSources again: now the message must be arrived.
*/
TEST_F(MainLoopTest, VerifyTransportReadingWhenDispatchingWatches) {
    auto proxy = mainloopFactoryProxy_->buildProxy<commonapi::tests::TestInterfaceProxy>(testAddress8);
    ASSERT_TRUE((bool) proxy);

    std::thread stubThread = std::thread([&](){ mainLoopForStub_->run(); });

    while (!proxy->isAvailable()) {
        mainLoopForProxy_->doSingleIteration();
        usleep(500);
    }

    ASSERT_TRUE(proxy->isAvailable());

    mainLoopForStub_->stop();
    stubThread.join();

    uint32_t uint32Value = 42;
    std::string stringValue = "Hai :)";
    bool running = true;

    commonapi::tests::DerivedTypeCollection::TestEnumExtended2 testEnumExtended2InValue =
                    commonapi::tests::DerivedTypeCollection::TestEnumExtended2::E_OK;
    commonapi::tests::DerivedTypeCollection::TestMap testMapInValue;

    // Estimated amount of data (differring padding at beginning/end of Map/Array etc. not taken into account):
    // 4 + 4 + 500 * (4 + (4 + 4 + 100 * (11 + 1 + 4)) + 4 ) = 811008
    for (uint32_t i = 0; i < 500; ++i) {
        commonapi::tests::DerivedTypeCollection::TestArrayTestStruct testArrayTestStruct;
        for (uint32_t j = 0; j < 100; ++j) {
            commonapi::tests::DerivedTypeCollection::TestStruct testStruct("Hai all (:", j);
            testArrayTestStruct.push_back(testStruct);
        }
        testMapInValue.insert( {i, testArrayTestStruct});
    }

    std::future<CommonAPI::CallStatus> futureStatus =
                    proxy->testDerivedTypeMethodAsync(
                                    testEnumExtended2InValue,
                                    testMapInValue,
                                    [&] (const CommonAPI::CallStatus& status,
                                                    commonapi::tests::DerivedTypeCollection::TestEnumExtended2 testEnumExtended2OutValue,
                                                    commonapi::tests::DerivedTypeCollection::TestMap testMapOutValue) {
                                        mainLoopForProxy_->stop();
                                        callbackCalled++;
                                    }
                                    );

    mainLoopForProxy_->runVerification(15, true, true);

    // 1. just dispatch dispatchSources
    mainLoopForStub_->runVerification(15, false, true);
    EXPECT_EQ(stub_->getCalledTestDerivedTypeMethod(), 0);

    // 2. just dispatch watches (reads transport)
    mainLoopForStub_->runVerification(20, true, false);
    EXPECT_EQ(stub_->getCalledTestDerivedTypeMethod(), 0);

    // 3. just dispatch dispatchSources again. This should dispatch the messages already read from transport in 2.
    mainLoopForStub_->doVerificationIteration(false, true);
    EXPECT_EQ(stub_->getCalledTestDerivedTypeMethod(), 1);
}