亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? clienttest.cpp

?? funambol windows mobile plugin source code, the source code is taken from the funambol site
?? CPP
?? 第 1 頁 / 共 5 頁
字號:
/*
 * Copyright (C) 2003-2007 Funambol, Inc
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY, TITLE, NONINFRINGEMENT or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 * 02111-1307  USA
 */

/** @cond API */
/** @addtogroup ClientTest */
/** @{ */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#ifdef ENABLE_INTEGRATION_TESTS

#include "ClientTest.h"
#include "base/test.h"
#include "base/util/StringBuffer.h"

#include <memory>
#include <vector>
#include <utility>
#include <sstream>
#include <iomanip>
#include <fstream>
#include <iostream>
#include <algorithm>

/** utility function to iterate over different kinds of items in a sync source */
static int countAnyItems(
    SyncSource *source,
    SyncItem * (SyncSource::*first)(),
    SyncItem * (SyncSource::*next)() )
{
    SyncItem *item;
    int count = 0;

    CPPUNIT_ASSERT(source);
    CPPUNIT_ASSERT(!source->getReport() || source->getReport()->getState() != SOURCE_ERROR);
    SOURCE_ASSERT_NO_FAILURE(source, item = (source->*first)());
    while ( item ) {
        count++;
        delete item;
        SOURCE_ASSERT_NO_FAILURE(source, item = (source->*next)());
    }

    return count;
}

static int countNewItems( SyncSource *source )
{
    int res = countAnyItems(
        source,
        &SyncSource::getFirstNewItem,
        &SyncSource::getNextNewItem );
    return res;
}

static int countUpdatedItems( SyncSource *source )
{
    int res = countAnyItems(
        source,
        &SyncSource::getFirstUpdatedItem,
        &SyncSource::getNextUpdatedItem );
    return res;
}

static int countDeletedItems( SyncSource *source )
{
    int res = countAnyItems(
        source,
        &SyncSource::getFirstDeletedItem,
        &SyncSource::getNextDeletedItem );
    return res;
}

static int countItems( SyncSource *source )
{
    int res = countAnyItems(
        source,
        &SyncSource::getFirstItem,
        &SyncSource::getNextItem );
    return res;
}

int countItemsOfType(SyncSource *source, itemType type)
{
    int res = 0;
    
    switch(type) {
     case NEW_ITEMS:
        res = countNewItems(source);
        break;
     case UPDATED_ITEMS:
        res = countUpdatedItems(source);
        break;
     case DELETED_ITEMS:
        res = countDeletedItems(source);
        break;
     case TOTAL_ITEMS:
        res = countItems(source);
        break;
     default:
        CPPUNIT_ASSERT(false);
        break;
    }
    return res;
}

static void importItem(SyncSource *source, std::string &data)
{
    CPPUNIT_ASSERT(source);
    if (data.size()) {
        SyncItem item;
        item.setData( data.c_str(), (long)data.size() );
        item.setDataType( TEXT("raw") );
        int status;
        SOURCE_ASSERT_NO_FAILURE(source, status = source->addItem(item));
        CPPUNIT_ASSERT(status == STC_OK || status == STC_ITEM_ADDED);
        CPPUNIT_ASSERT(item.getKey() != 0);
        CPPUNIT_ASSERT(wcslen(item.getKey()) > 0);
    }
}

/** adds the supported tests to the instance itself */
void LocalTests::addTests() {
    if (config.createSourceA) {
        ADD_TEST(LocalTests, testOpen);
        ADD_TEST(LocalTests, testIterateTwice);
        if (config.insertItem) {
            ADD_TEST(LocalTests, testSimpleInsert);
            ADD_TEST(LocalTests, testLocalDeleteAll);
            ADD_TEST(LocalTests, testComplexInsert);

            if (config.updateItem) {
                ADD_TEST(LocalTests, testLocalUpdate);

                if (config.createSourceB) {
                    ADD_TEST(LocalTests, testChanges);
                }
            }

            if (config.import &&
                config.dump &&
                config.compare &&
                config.testcases) {
                ADD_TEST(LocalTests, testImport);
                ADD_TEST(LocalTests, testImportDelete);
            }

            if (config.templateItem &&
                config.uniqueProperties) {
                ADD_TEST(LocalTests, testManyChanges);
            }
        }
    }
}

/**
 * opens source and inserts the given item; can be called
 * regardless whether the data source already contains items or not
 *
 * The type of the item is unset; it is assumed that the source
 * can handle that.
 */
void LocalTests::insert(CreateSource createSource, const char *data) {
    // create source
    std::auto_ptr<SyncSource> source(createSource());
    CPPUNIT_ASSERT(source.get() != 0);

    // count number of already existing items
    SOURCE_ASSERT(source.get(), source->beginSync() == 0);
    int numItems;
    CPPUNIT_ASSERT_NO_THROW(numItems = countItems(source.get()));
    SyncItem item;
    item.setData(data, (long)strlen(data));
    int status;
    SOURCE_ASSERT_NO_FAILURE(source.get(), status = source->addItem(item));
    CPPUNIT_ASSERT(item.getKey() != 0);
    CPPUNIT_ASSERT(wcslen(item.getKey()) > 0);
    SOURCE_ASSERT(source.get(), source->endSync() == 0);

    // delete source again
    CPPUNIT_ASSERT_NO_THROW(source.reset());

    // two possible results:
    // - a new item was added
    // - the item was matched against an existing one
    CPPUNIT_ASSERT_NO_THROW(source.reset(createSource()));
    CPPUNIT_ASSERT(source.get() != 0);
    SOURCE_ASSERT(source.get(), source->beginSync() == 0);
    CPPUNIT_ASSERT(status == STC_OK || status == STC_ITEM_ADDED || status == STC_CONFLICT_RESOLVED_WITH_MERGE);
    CPPUNIT_ASSERT_EQUAL(numItems + (status == STC_CONFLICT_RESOLVED_WITH_MERGE ? 0 : 1),
                         countItems(source.get()));
    CPPUNIT_ASSERT(countNewItems(source.get()) == 0);
    CPPUNIT_ASSERT(countUpdatedItems(source.get()) == 0);
    CPPUNIT_ASSERT(countDeletedItems(source.get()) == 0);
    SOURCE_ASSERT(source.get(), source->endSync() == 0 );
    CPPUNIT_ASSERT_NO_THROW(source.reset());

#if 0
    /* source.createItem() is a SyncEvolution extension which cannot be used here */
    SyncItem *sameItem;
    SOURCE_ASSERT_NO_FAILURE(
        source,
        sameItem = source.createItem(item.getKey(), item.getState()));
    CPPUNIT_ASSERT(sameItem != 0);
    CPPUNIT_ASSERT(!strcmp( sameItem->getKey(), item.getKey()));
    delete sameItem;
#endif
}

/**
 * assumes that exactly one element is currently inserted and updates it with the given item
 *
 * The type of the item is cleared, as in insert() above.
 */
void LocalTests::update(CreateSource createSource, const char *data, bool check) {
    CPPUNIT_ASSERT(createSource.createSource);
    CPPUNIT_ASSERT(data);

    // create source
    std::auto_ptr<SyncSource> source(createSource());
    CPPUNIT_ASSERT(source.get() != 0);
    SOURCE_ASSERT(source.get(), source->beginSync() == 0);

    // get existing item, then update it
    SOURCE_ASSERT(source.get(), source->beginSync() == 0 );
    std::auto_ptr<SyncItem> item;
    SOURCE_ASSERT_NO_FAILURE(source.get(), item.reset(source->getFirstItem()) );
    CPPUNIT_ASSERT(item.get());
    item->setData(data, (long)strlen(data) + 1);
    item->setDataType(TEXT(""));
    SOURCE_ASSERT_EQUAL(source.get(), (int)STC_OK, source->updateItem(*item));
    SOURCE_ASSERT(source.get(), source->endSync() == 0);
    CPPUNIT_ASSERT_NO_THROW(source.reset());

    if (!check) {
        return;
    }

    // check that the right changes are reported when reopening the source
    SOURCE_ASSERT_NO_FAILURE(source.get(), source.reset(createSource()));
    SOURCE_ASSERT(source.get(), source->beginSync() == 0 );
    CPPUNIT_ASSERT_EQUAL(1, countItems(source.get()));
    CPPUNIT_ASSERT_EQUAL(0, countNewItems(source.get()));
    CPPUNIT_ASSERT_EQUAL(0, countUpdatedItems(source.get()));
    CPPUNIT_ASSERT_EQUAL(0, countDeletedItems(source.get()));
    std::auto_ptr<SyncItem> modifiedItem;
    SOURCE_ASSERT_NO_FAILURE(source.get(), modifiedItem.reset(source->getFirstItem()) );
    CPPUNIT_ASSERT(modifiedItem.get());
    CPPUNIT_ASSERT( wcslen( item->getKey() ) );
    CPPUNIT_ASSERT( !wcscmp( item->getKey(), modifiedItem->getKey() ) );
}

/** deletes all items locally via sync source */
void LocalTests::deleteAll(CreateSource createSource) {
    CPPUNIT_ASSERT(createSource.createSource);

    // create source
    std::auto_ptr<SyncSource> source(createSource());
    CPPUNIT_ASSERT(source.get() != 0);
    SOURCE_ASSERT(source.get(), source->beginSync() == 0);

    // delete all items
    std::auto_ptr<SyncItem> item;
    SOURCE_ASSERT_NO_FAILURE(source.get(), item.reset(source->getFirstItem()));
    while (item.get()) {
        SOURCE_ASSERT_EQUAL(source.get(), (int)STC_OK, source->deleteItem(*item));
        SOURCE_ASSERT_NO_FAILURE(source.get(), item.reset(source->getNextItem()));
    }
    SOURCE_ASSERT(source.get(), source->endSync() == 0);
    CPPUNIT_ASSERT_NO_THROW(source.reset());

    // check that all items are gone
    SOURCE_ASSERT_NO_FAILURE(source.get(), source.reset(createSource()));
    SOURCE_ASSERT_EQUAL(source.get(), 0, source->beginSync());
    SOURCE_ASSERT_MESSAGE(
        "should be empty now",
        source.get(),
        countItems(source.get()) == 0);
    CPPUNIT_ASSERT_EQUAL( 0, countNewItems(source.get()) );
    CPPUNIT_ASSERT_EQUAL( 0, countUpdatedItems(source.get()) );
    CPPUNIT_ASSERT_EQUAL( 0, countDeletedItems(source.get()) );
    SOURCE_ASSERT_EQUAL(source.get(), 0, source->endSync());
    CPPUNIT_ASSERT_NO_THROW(source.reset());
}

/**
 * takes two databases, exports them,
 * then compares them using synccompare
 *
 * @param refFile      existing file with source reference items, NULL uses a dump of sync source A instead
 * @param copy         a sync source which contains the copied items, begin/endSync will be called
 * @param raiseAssert  raise assertion if comparison yields differences (defaults to true)
 */
void LocalTests::compareDatabases(const char *refFile, SyncSource &copy, bool raiseAssert) {
    CPPUNIT_ASSERT(config.dump);

    std::string sourceFile, copyFile;

    if (refFile) {
        sourceFile = refFile;
    } else {
        sourceFile = getCurrentTest() + ".source.test.dat";
        simplifyFilename(sourceFile);
        std::auto_ptr<SyncSource> source;
        SOURCE_ASSERT_NO_FAILURE(source.get(), source.reset(createSourceA()));
        SOURCE_ASSERT_EQUAL(source.get(), 0, source->beginSync());
        SOURCE_ASSERT_EQUAL(source.get(), 0, config.dump(client, *source.get(), sourceFile.c_str()));

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产色产综合产在线视频| 激情文学综合插| 日韩在线一二三区| 久久超碰97中文字幕| 国产白丝精品91爽爽久久| 91美女在线看| 日韩写真欧美这视频| 欧美激情在线免费观看| 亚洲成国产人片在线观看| 自拍偷在线精品自拍偷无码专区| 五月婷婷久久丁香| 国产一区二区三区高清播放| av一区二区三区黑人| 在线播放国产精品二区一二区四区 | 亚洲欧洲日产国产综合网| 夜夜爽夜夜爽精品视频| 国产一区二区三区久久久| 在线欧美日韩精品| 26uuu精品一区二区三区四区在线| 亚洲欧美在线另类| 天天色天天爱天天射综合| 久热成人在线视频| 色8久久人人97超碰香蕉987| 日韩欧美国产一区二区在线播放 | 久久婷婷成人综合色| 亚洲一区二区av在线| 国产精品77777竹菊影视小说| 欧美色偷偷大香| 中文字幕一区在线| 亚洲一区二区三区视频在线播放 | 日韩美女视频在线| 亚洲成人午夜影院| 91啦中文在线观看| 国产精品三级在线观看| 久久99精品一区二区三区| 欧美日韩一区久久| 亚洲黄色小说网站| 99久久婷婷国产| 中文字幕av一区 二区| 精油按摩中文字幕久久| 在线91免费看| 日韩av一区二区在线影视| 欧美午夜不卡在线观看免费| 亚洲欧洲制服丝袜| 成人黄色一级视频| 欧美一区二区三区成人| 亚洲午夜在线视频| 欧美伊人久久久久久久久影院| 1区2区3区国产精品| 成人aaaa免费全部观看| 欧美激情艳妇裸体舞| 国产一区二区三区四| 久久亚洲私人国产精品va媚药| 秋霞国产午夜精品免费视频| 91精品国产综合久久小美女| 亚洲最大成人综合| 欧美丝袜第三区| 亚洲午夜一二三区视频| 99久久久国产精品免费蜜臀| 日韩理论片在线| 欧美综合视频在线观看| 香蕉乱码成人久久天堂爱免费| 在线精品视频免费播放| 一个色综合网站| 欧美男生操女生| 毛片av中文字幕一区二区| 一本色道久久加勒比精品| 久久影院视频免费| 精品一区二区三区在线观看国产| 精品sm在线观看| 国产成人99久久亚洲综合精品| 国产精品丝袜一区| 色综合久久九月婷婷色综合| 一区二区三区免费在线观看| 欧美理论片在线| 国产一区三区三区| 亚洲精品视频自拍| 91精品国产综合久久婷婷香蕉| 国产在线不卡一区| 亚洲精品第1页| 91精品国产91热久久久做人人| 国模无码大尺度一区二区三区| 国产精品日日摸夜夜摸av| 欧美中文一区二区三区| 久久aⅴ国产欧美74aaa| 久久久天堂av| 欧美在线影院一区二区| 激情综合亚洲精品| 亚洲人成7777| 久久综合中文字幕| 欧美在线观看视频在线| 国产在线乱码一区二区三区| 国产欧美精品一区二区色综合| 欧美在线不卡视频| 国产一区二三区| 午夜久久久影院| 亚洲人亚洲人成电影网站色| 欧美卡1卡2卡| 菠萝蜜视频在线观看一区| 男女性色大片免费观看一区二区 | 九色|91porny| 亚洲精品日日夜夜| 久久久精品国产99久久精品芒果 | 色吧成人激情小说| 日韩av中文字幕一区二区三区| 69av一区二区三区| 成a人片亚洲日本久久| 美女视频黄免费的久久| 亚洲美女少妇撒尿| 欧美一激情一区二区三区| 国产福利不卡视频| 天天综合色天天| 亚洲最新视频在线观看| 精品欧美一区二区久久 | 欧美一区二区免费| 欧美在线看片a免费观看| 成人激情小说网站| 国产一区二区在线视频| 另类人妖一区二区av| 亚洲日本免费电影| 国产精品久久综合| 国产精品毛片久久久久久久| 久久午夜免费电影| 欧美不卡123| 欧美mv日韩mv国产网站app| 欧美日韩精品一区视频| 在线视频国产一区| 日本精品一区二区三区四区的功能| 国产99精品国产| 国产成人精品亚洲777人妖| 国产一区中文字幕| 国产麻豆成人传媒免费观看| 精东粉嫩av免费一区二区三区| 免费人成网站在线观看欧美高清| 亚洲高清三级视频| 午夜精品久久久久久久99水蜜桃 | 蜜桃视频一区二区三区在线观看 | 天堂久久一区二区三区| 亚洲成人激情社区| 青青草精品视频| 狠狠色综合日日| 国产精品夜夜嗨| 成人av影视在线观看| 91亚洲国产成人精品一区二三| 99这里都是精品| 欧美亚洲日本一区| 在线亚洲高清视频| 制服丝袜亚洲色图| 亚洲精品在线免费播放| 国产亚洲一区字幕| 国产精品毛片久久久久久| 中文字幕中文字幕一区| 亚洲精品高清视频在线观看| 亚洲丰满少妇videoshd| 蜜臀91精品一区二区三区| 国产一区二区调教| caoporen国产精品视频| 欧美视频中文字幕| 3atv在线一区二区三区| 久久精品人人做人人爽97| 中文字幕在线观看一区二区| 一区二区高清免费观看影视大全| 日韩av网站免费在线| 国模冰冰炮一区二区| 91麻豆国产精品久久| 69堂成人精品免费视频| 久久免费看少妇高潮| 亚洲免费观看高清完整版在线观看熊| 亚洲成精国产精品女| 国产精品自拍网站| 欧美性大战久久久| 久久久亚洲精华液精华液精华液| 亚洲精品中文在线观看| 麻豆精品一区二区综合av| www..com久久爱| 在线观看欧美黄色| 久久久国产午夜精品| 亚洲男人都懂的| 久久精品免费观看| 在线观看av不卡| 国产亚洲成av人在线观看导航| 国产欧美一区二区精品性色| 亚洲国产精品欧美一二99| 六月丁香综合在线视频| 99久久精品国产一区二区三区| 色欧美片视频在线观看在线视频| 欧美sm美女调教| 亚洲成av人片一区二区梦乃| 丰满少妇在线播放bd日韩电影| 欧美一区二区三区视频免费 | 成年人国产精品| 日韩精品中文字幕一区 | 日本精品视频一区二区三区| 久久久欧美精品sm网站| 视频一区中文字幕国产| 色美美综合视频| 一区二区在线观看视频| 在线观看一区二区视频| 亚洲综合激情网| 欧美三级中文字幕在线观看|