testing v1
This commit is contained in:
35
.gitignore
vendored
Normal file
35
.gitignore
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
*.a
|
||||
*.o
|
||||
*.md
|
||||
*.exe
|
||||
*.user
|
||||
*.Debug
|
||||
*.Release
|
||||
*.stash
|
||||
MakeFile
|
||||
*.bin
|
||||
*.m
|
||||
*.txt
|
||||
*.mpd
|
||||
*.sens
|
||||
*.kna
|
||||
*.djvu
|
||||
resource/
|
||||
*.qrc
|
||||
resource.h
|
||||
*.png
|
||||
*.jpeg
|
||||
*.mp3
|
||||
*.wav
|
||||
*.db
|
||||
*.dll
|
||||
data/
|
||||
debug/
|
||||
platforms/
|
||||
release/
|
||||
compiler/
|
||||
src_build/
|
||||
html/
|
||||
log/
|
||||
doc/
|
||||
QtXml/
|
18
TestTa1.pro
Normal file
18
TestTa1.pro
Normal file
@@ -0,0 +1,18 @@
|
||||
QT += testlib
|
||||
QT -= gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
SOURCES += \
|
||||
WDMTMKv2.cpp \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
stdafx.cpp \
|
||||
testinfo.cpp
|
||||
|
||||
HEADERS += \
|
||||
WDMTMKv2.h \
|
||||
declarations.h \
|
||||
mainwindow.h \
|
||||
stdafx.h \
|
||||
testinfo.h
|
2105
WDMTMKv2.cpp
Normal file
2105
WDMTMKv2.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1020
WDMTMKv2.h
Normal file
1020
WDMTMKv2.h
Normal file
File diff suppressed because it is too large
Load Diff
22
declarations.h
Normal file
22
declarations.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef DECLARATIONS_H
|
||||
#define DECLARATIONS_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QTableWidget>
|
||||
#include <QTableWidgetItem>
|
||||
#include <QVBoxLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QHeaderView>
|
||||
#include <QLabel>
|
||||
#include <QComboBox>
|
||||
#include <QPushButton>
|
||||
#include <QTextEdit>
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
#include <QTextCodec>
|
||||
#include <QLineEdit>
|
||||
#include <QString>
|
||||
#include <QScopedPointer>
|
||||
#include <QTest>
|
||||
|
||||
#endif // DECLARATIONS_H
|
14
main.cpp
Normal file
14
main.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "mainwindow.h"
|
||||
#include "testinfo.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
//MainWindow w;
|
||||
//w.show();
|
||||
|
||||
QTest::qExec(new testInfo, argc, argv);
|
||||
return a.exec();
|
||||
}
|
61
mainwindow.cpp
Normal file
61
mainwindow.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <stdio.h>
|
||||
//#include "WDMTMKv2.cpp"
|
||||
|
||||
int hTmk;
|
||||
|
||||
MainWindow::MainWindow()
|
||||
{
|
||||
init_mainwindowobj();
|
||||
init_connections();
|
||||
}
|
||||
|
||||
void MainWindow::init_mainwindowobj()
|
||||
{
|
||||
qDebug() << "Startyem";
|
||||
|
||||
Window = new QWidget;
|
||||
|
||||
Button = new QPushButton("Start");
|
||||
Label = new QLabel("Test");
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout(Window);
|
||||
layout->addWidget(Label);
|
||||
layout->addWidget(Button);
|
||||
|
||||
Window->setLayout(layout);
|
||||
setCentralWidget(Window);
|
||||
}
|
||||
|
||||
void MainWindow::init_connections()
|
||||
{
|
||||
connect(Button,
|
||||
SIGNAL(clicked()),
|
||||
this,
|
||||
SLOT(test_tmkopen()));
|
||||
}
|
||||
|
||||
void MainWindow::test_tmkopen()
|
||||
{
|
||||
/*if(TmkOpen())
|
||||
Label->setText("TmkOpen() failed");
|
||||
else
|
||||
Label->setText("TmkOpen() successful!");
|
||||
|
||||
qDebug() << tmkgetmaxn();
|
||||
qDebug() << mrtgetmaxn();
|
||||
|
||||
hTmk = 0;
|
||||
if (tmkconfig(hTmk) != 0)
|
||||
qDebug() << "tmkconfig() failed!";
|
||||
else
|
||||
qDebug() << "tmkconfig() successful!";
|
||||
|
||||
TmkClose();*/
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
qDebug() << "End";
|
||||
}
|
24
mainwindow.h
Normal file
24
mainwindow.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include "declarations.h"
|
||||
|
||||
class MainWindow:public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
void init_mainwindowobj(); //the function of this class
|
||||
explicit MainWindow(); //constructor
|
||||
void init_connections();
|
||||
~MainWindow(); //destructor
|
||||
|
||||
public slots:
|
||||
void test_tmkopen();
|
||||
|
||||
private:
|
||||
QWidget *Window = new QWidget;
|
||||
QLabel *Label;
|
||||
QPushButton *Button;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
5
stdafx.cpp
Normal file
5
stdafx.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// bcrt.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
15
stdafx.h
Normal file
15
stdafx.h
Normal file
@@ -0,0 +1,15 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _WIN64_WINNT // Allow use of features specific to Windows XP or later.
|
||||
#define _WIN64_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include <windows.h>
|
303
testinfo.cpp
Normal file
303
testinfo.cpp
Normal file
@@ -0,0 +1,303 @@
|
||||
#include <QTest>
|
||||
#include "testinfo.h"
|
||||
#include "WDMTMKv2.cpp"
|
||||
#include <windows.h>
|
||||
|
||||
void testInfo::init()
|
||||
{
|
||||
if (isFailed)
|
||||
{
|
||||
qDebug() << "Skip";
|
||||
QSKIP("");
|
||||
}
|
||||
}
|
||||
|
||||
void testInfo::cleanup()
|
||||
{
|
||||
bool a = QTest::currentTestFailed();
|
||||
if (a)
|
||||
isFailed = a;
|
||||
}
|
||||
|
||||
void testInfo::cleanupTestCase()
|
||||
{
|
||||
qDebug() << "TmkClose()";
|
||||
TmkClose();
|
||||
}
|
||||
|
||||
void testInfo::testTmkOpen()
|
||||
{
|
||||
DWORD a;
|
||||
|
||||
a = TmkOpen();
|
||||
QCOMPARE(a, DWORD(0));
|
||||
}
|
||||
|
||||
void testInfo::testtmkgetmaxn()
|
||||
{
|
||||
QCOMPARE(tmkgetmaxn(), (int)(0));
|
||||
}
|
||||
|
||||
void testInfo::testmrtgetmaxn()
|
||||
{
|
||||
QCOMPARE(tmkgetmaxn(), (int)(0));
|
||||
}
|
||||
|
||||
void testInfo::testtmkconfig()
|
||||
{
|
||||
int hTmk = 0;
|
||||
|
||||
QCOMPARE(tmkconfig(hTmk), (int)(0));
|
||||
}
|
||||
|
||||
void testInfo::testtmkselect()
|
||||
{
|
||||
int hTmk = 0;
|
||||
|
||||
QCOMPARE(tmkselect(hTmk), (int)(0));
|
||||
}
|
||||
|
||||
void testInfo::testtmkgetinfo()
|
||||
{
|
||||
TTmkConfigData tmkCfg;
|
||||
int hTmk = 0;
|
||||
|
||||
tmkgetinfo(&tmkCfg);
|
||||
QCOMPARE(hTmk, (int)(0)); //Device Number
|
||||
QCOMPARE(tmkCfg.nType, (short)(9)); //Device Type
|
||||
QCOMPARE(tmkCfg.szName, "TA1USB"); //Device Name
|
||||
QCOMPARE(tmkCfg.wPorts1, (unsigned short)(0)); //Device I/O Ports
|
||||
|
||||
if (tmkCfg.wPorts2 == (unsigned short)(0xFFFF)) //Device I/O Ports
|
||||
;
|
||||
else
|
||||
QCOMPARE(tmkCfg.wPorts2, (unsigned short)(0));
|
||||
|
||||
if (tmkCfg.wIrq2 == (unsigned short)(0xFF))
|
||||
QCOMPARE(tmkCfg.wIrq1, (unsigned short)(0)); //Device Interrupt
|
||||
else
|
||||
{
|
||||
QCOMPARE(tmkCfg.wIrq1, (unsigned short)(0)); //Device Interrupts
|
||||
QCOMPARE(tmkCfg.wIrq2, (unsigned short)(0));
|
||||
}
|
||||
|
||||
QCOMPARE(tmkCfg.wIODelay, (unsigned short)(0)); //Device I/O Delay
|
||||
}
|
||||
|
||||
void testInfo::testtmkgethwver()
|
||||
{
|
||||
QCOMPARE(tmkgethwver(), (unsigned short)(11));
|
||||
}
|
||||
|
||||
void testInfo::testbcreset()
|
||||
{
|
||||
QCOMPARE(bcreset(), (int)(0));
|
||||
}
|
||||
|
||||
void testInfo::testbcgetmaxbase()
|
||||
{
|
||||
QCOMPARE(bcgetmaxbase(), (unsigned short)(1023));
|
||||
}
|
||||
|
||||
void testInfo::testbcputgetw()
|
||||
{
|
||||
int fError;
|
||||
unsigned short wBase, wAddr;
|
||||
unsigned short wMaxBase = bcgetmaxbase();
|
||||
|
||||
for (wBase = 0; wBase <= wMaxBase; ++wBase)
|
||||
{
|
||||
bcdefbase(wBase);
|
||||
for (wAddr = 0; wAddr <= 63; ++wAddr)
|
||||
{
|
||||
bcputw(wAddr, wAddr|(wBase<<6));
|
||||
}
|
||||
}
|
||||
|
||||
fError = 0;
|
||||
for (wBase = 0; wBase <= wMaxBase; ++wBase)
|
||||
{
|
||||
bcdefbase(wBase);
|
||||
for (wAddr = 0; wAddr <= 63; ++wAddr)
|
||||
{
|
||||
if (bcgetw(wAddr) != (unsigned short)(wAddr|(wBase<<6)))
|
||||
fError = 1;
|
||||
}
|
||||
}
|
||||
|
||||
QCOMPARE(fError, (int)(0));
|
||||
}
|
||||
|
||||
void testInfo::testbcputgetblk()
|
||||
{
|
||||
int fError;
|
||||
unsigned short awBuf[64];
|
||||
unsigned short wBase, wAddr;
|
||||
unsigned short wMaxBase = bcgetmaxbase();
|
||||
|
||||
for (wBase = 0; wBase <= wMaxBase; ++wBase)
|
||||
{
|
||||
bcdefbase(wBase);
|
||||
for (wAddr = 0; wAddr <= 63; ++wAddr)
|
||||
{
|
||||
awBuf[63-wAddr] = wBase+(wAddr<<8);
|
||||
}
|
||||
bcputblk(0, awBuf, 64);
|
||||
}
|
||||
|
||||
fError = 0;
|
||||
for (wBase = 0; wBase <= wMaxBase; ++wBase)
|
||||
{
|
||||
bcdefbase(wBase);
|
||||
bcgetblk(0, awBuf, 64);
|
||||
for (wAddr = 0; wAddr <= 63; ++wAddr)
|
||||
{
|
||||
if (awBuf[63-wAddr] != (wBase+(wAddr<<8)))
|
||||
fError = 1;
|
||||
}
|
||||
}
|
||||
|
||||
QCOMPARE(fError, (int)(0));
|
||||
}
|
||||
|
||||
void testInfo::testrtreset()
|
||||
{
|
||||
QCOMPARE(rtreset(), (int)(0));
|
||||
}
|
||||
|
||||
void testInfo::testrtgetmaxpage()
|
||||
{
|
||||
QCOMPARE(rtgetmaxpage(), (unsigned short)(0));
|
||||
}
|
||||
|
||||
void testInfo::testrtputgetw()
|
||||
{
|
||||
int fError;
|
||||
unsigned short wPage, wAddr, wSubAddr;
|
||||
unsigned short wMaxPage = rtgetmaxpage();
|
||||
|
||||
for (wPage = 0; wPage <= wMaxPage; ++wPage)
|
||||
{
|
||||
rtdefpage(wPage);
|
||||
for (wSubAddr = 0; wSubAddr <= 0x1F; ++wSubAddr)
|
||||
{
|
||||
rtdefsubaddr(RT_RECEIVE, wSubAddr);
|
||||
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||
rtputw(wAddr, wAddr|(wSubAddr<<8)|(wPage<<13));
|
||||
rtdefsubaddr(RT_TRANSMIT, wSubAddr);
|
||||
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||
rtputw(wAddr, (wAddr+32)|(wSubAddr<<8)|(wPage<<13));
|
||||
}
|
||||
}
|
||||
|
||||
fError = 0;
|
||||
for (wPage = 0; wPage <= wMaxPage; ++wPage)
|
||||
{
|
||||
rtdefpage(wPage);
|
||||
for (wSubAddr = 0; wSubAddr <= 0x1F; ++wSubAddr)
|
||||
{
|
||||
rtdefsubaddr(RT_RECEIVE, wSubAddr);
|
||||
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||
{
|
||||
if (rtgetw(wAddr) != (wAddr|(wSubAddr<<8)|(wPage<<13)))
|
||||
fError = 1;
|
||||
}
|
||||
rtdefsubaddr(RT_TRANSMIT, wSubAddr);
|
||||
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||
{
|
||||
if (rtgetw(wAddr) != ((wAddr+32)|(wSubAddr<<8)|(wPage<<13)))
|
||||
fError = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QCOMPARE(fError, (int)(0));
|
||||
}
|
||||
|
||||
void testInfo::testrtputgetblk()
|
||||
{
|
||||
int fError;
|
||||
unsigned short awBuf[64];
|
||||
unsigned short wPage, wAddr, wSubAddr;
|
||||
unsigned short wMaxPage = rtgetmaxpage();
|
||||
|
||||
for (wPage = 0; wPage <= wMaxPage; ++wPage)
|
||||
{
|
||||
rtdefpage(wPage);
|
||||
for (wSubAddr = 0; wSubAddr <= 0x1F; ++wSubAddr)
|
||||
{
|
||||
rtdefsubaddr(RT_RECEIVE, wSubAddr);
|
||||
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||
awBuf[31-wAddr] = wSubAddr|(wAddr<<8)|(wPage<<13);
|
||||
rtputblk(0, awBuf, 32);
|
||||
rtdefsubaddr(RT_TRANSMIT, wSubAddr);
|
||||
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||
awBuf[31-wAddr] = (wSubAddr+32)|(wAddr<<8)|(wPage<<13);
|
||||
rtputblk(0, awBuf, 32);
|
||||
}
|
||||
}
|
||||
|
||||
fError = 0;
|
||||
for (wPage = 0; wPage <= wMaxPage; ++wPage)
|
||||
{
|
||||
rtdefpage(wPage);
|
||||
for (wSubAddr = 0; wSubAddr <= 0x1F; ++wSubAddr)
|
||||
{
|
||||
rtdefsubaddr(RT_RECEIVE, wSubAddr);
|
||||
rtgetblk(0, awBuf, 32);
|
||||
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||
{
|
||||
if (awBuf[31-wAddr] != (wSubAddr|(wAddr<<8)|(wPage<<13)))
|
||||
fError = 1;
|
||||
}
|
||||
rtdefsubaddr(RT_TRANSMIT, wSubAddr);
|
||||
rtgetblk(0, awBuf, 32);
|
||||
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||
{
|
||||
if (awBuf[31-wAddr] != ((wSubAddr+32)|(wAddr<<8)|(wPage<<13)))
|
||||
fError = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QCOMPARE(fError, (int)(0));
|
||||
}
|
||||
|
||||
void testInfo::testgetInt()
|
||||
{
|
||||
HANDLE hEvent;
|
||||
TTmkEventData tmkEvD;
|
||||
|
||||
hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
QVERIFY(hEvent);
|
||||
tmkdefevent(hEvent, TRUE);
|
||||
tmkgetevd(&tmkEvD);
|
||||
QCOMPARE(tmkEvD.nInt, (int)(0));
|
||||
bcdefbase(0);
|
||||
bcputw(0, 0xFFE1);
|
||||
bcstart(0, CTRL_C_BRCST);
|
||||
|
||||
switch (WaitForSingleObject(hEvent, 1000))
|
||||
{
|
||||
case WAIT_OBJECT_0:
|
||||
ResetEvent(hEvent);
|
||||
qDebug() << "We got interrupt!";
|
||||
break;
|
||||
|
||||
case WAIT_TIMEOUT:
|
||||
qDebug() << "We didn't get interrupt!";
|
||||
break;
|
||||
|
||||
default:
|
||||
qDebug() << "Somebody abandon our interrupt waiting!";
|
||||
break;
|
||||
}
|
||||
|
||||
tmkgetevd(&tmkEvD);
|
||||
QCOMPARE(tmkEvD.nInt, (int)(1));
|
||||
|
||||
tmkdefevent(0,TRUE);
|
||||
CloseHandle(hEvent);
|
||||
}
|
||||
|
||||
|
46
testinfo.h
Normal file
46
testinfo.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef TESTINFO_H
|
||||
#define TESTINFO_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QTest>
|
||||
|
||||
class testInfo:public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
|
||||
void testTmkOpen();
|
||||
void testtmkgetmaxn();
|
||||
void testmrtgetmaxn();
|
||||
void testtmkconfig();
|
||||
void testtmkselect();
|
||||
void testtmkgetinfo();
|
||||
void testtmkgethwver();
|
||||
|
||||
//Now we'll test onboard RAM in Bus Controller mode
|
||||
void testbcreset();
|
||||
void testbcgetmaxbase();
|
||||
void testbcputgetw();
|
||||
void testbcputgetblk();
|
||||
|
||||
//Now we'll test onboard RAM in Remote Terminal mode
|
||||
void testrtreset();
|
||||
void testrtgetmaxpage();
|
||||
void testrtputgetw();
|
||||
void testrtputgetblk();
|
||||
|
||||
|
||||
//Now we'll test interrupt in Bus Controller mode
|
||||
void testgetInt();
|
||||
|
||||
void init();
|
||||
void cleanup();
|
||||
void cleanupTestCase();
|
||||
|
||||
protected:
|
||||
|
||||
bool isFailed = false;
|
||||
};
|
||||
|
||||
#endif // TESTINFO_H
|
Reference in New Issue
Block a user