msvc compatible changes got haltests

This commit is contained in:
zhhou 2024-10-16 13:41:28 +08:00
parent c6453a568f
commit 8f7575df82
12 changed files with 68 additions and 26 deletions

View File

@ -27,7 +27,6 @@
#include<iostream>
#include<fstream>
#include<vector>
//#include<cdlog.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>

View File

@ -1,5 +1,3 @@
add_definitions(--include cdtypes.h)
add_definitions(--include cdlog.h)
find_package(GTEST)
if (BUILD_CDROID_TESTS AND GTEST_FOUND)
add_subdirectory(gui)

View File

@ -1,7 +1,11 @@
#include <stdio.h>
#if defined(__linux__)||defined(__unix__)
#include <sys/time.h>
#elif defined(_WIN32)||defined(_WIN64)
#include <Windows.h>
#endif
#include <gtest/gtest.h>
#include <dtvos.h>
#include <porting/dtvos.h>
class OSEVENT:public testing::Test{
public :

View File

@ -1,7 +1,30 @@
#include<cdgraph.h>
#include<cdlog.h>
#include<porting/cdgraph.h>
#include<porting/cdlog.h>
#include <gtest/gtest.h>
#if defined(__Linux__)||defined(__unix__)
#include <sys/time.h>
#elif defined(_WIN32)||defined(_WIN64)
#include <Windows.h>
void usleep(unsigned int microseconds) {
LARGE_INTEGER frequency;
QueryPerformanceFrequency(&frequency);
LARGE_INTEGER start;
QueryPerformanceCounter(&start);
long long end = start.QuadPart + static_cast<long long>(microseconds) * frequency.QuadPart / 1000000;
do {
QueryPerformanceCounter(&start);
} while (start.QuadPart < end);
}
void sleep(unsigned int secs) {
usleep(secs * 1000000);
}
void gettimeofday(struct timeval* t1,struct timezone* zone) {
auto tt = GetTickCount64();
t1->tv_sec = tt%1000;
t1->tv_usec = (tt % 1000) * 1000;
}
#endif
#define INVALID_COLOR 0x01010101
typedef struct{
@ -148,7 +171,7 @@ TEST_F(GRAPH,CreateSurface_1){
}
TEST_F(GRAPH,CreateSurface_2){
uint32_t width,height,pitch;
uint32_t width=0,height=0,pitch=0;
int fmts[]={GPF_ARGB4444,GPF_ARGB1555,GPF_ARGB,GPF_ABGR,GPF_RGB32};
int bps[] ={ 2, 2 , 4 , 4 , 4 };
ASSERT_EQ(0,GFXGetDisplaySize(0,&width,&height));
@ -192,7 +215,7 @@ TEST_F(GRAPH,Alpha){
TEST_F(GRAPH,Colors){
HANDLE surface=0;
uint32_t width,height;
uint32_t width=0,height=0;
GFXRect r={0,0,0,0};
ASSERT_EQ(0,GFXGetDisplaySize(0,&width,&height));
ASSERT_EQ(0,GFXCreateSurface(0,&surface,width,height,GPF_ARGB,1));
@ -212,7 +235,7 @@ TEST_F(GRAPH,Colors){
TEST_F(GRAPH,Blit){
HANDLE mainsurface=0,surface;
uint32_t width,height;
uint32_t width=0,height=0;
GFXRect r={0,0,0,0};
ASSERT_EQ(0,GFXGetDisplaySize(0,&width,&height));
ASSERT_EQ(0,GFXCreateSurface(0,&mainsurface,width,height,GPF_ARGB,1));
@ -253,10 +276,10 @@ TEST_F(GRAPH,Multilayer){
for(int i=0;i<4;i++){
int sw,sh,fmt;
gettimeofday(&tv,NULL);
srandom(tv.tv_usec);
srand(tv.tv_usec);
if(layers[i]){
int x=k-500+random()%width;
int y=k-500+random()%height;
int x=k-500+rand()%width;
int y=k-500+rand()%height;
GFXGetSurfaceInfo(layers[i],(uint32_t*)&sw,(uint32_t*)&sh,&fmt);
if((x+sw>0) && (y+sh>0) && (x<(int)width) && (y<(int)height))
ASSERT_EQ(0,GFXBlit(hwsurface,x,y,layers[i],NULL));
@ -307,7 +330,7 @@ TEST_F(GRAPH,Benchmark_Fill){
r.w=width;r.h=height;
gettimeofday(&t1,NULL);
for(int i=0;i<TEST_TIMES;i++){
GFXFillRect(surface,&r,0xFF000000|(i<<8)|(i+i<<16));
GFXFillRect(surface,&r,0xFF000000|(i<<8)|((i+i)<<16));
}
gettimeofday(&t2,NULL);
int usedtime=(t2.tv_sec*1000+t2.tv_usec/1000-t1.tv_sec*1000+t1.tv_usec/1000);

View File

@ -1,7 +1,11 @@
#include <stdio.h>
#include <gtest/gtest.h>
#include <cdinput.h>
#include <porting/cdinput.h>
#if defined(__linux__)||defined(__unix__)
#include <linux/input.h>
#else
#include <core/eventcodes.h>
#endif
#include <fcntl.h>
class INPUT:public testing::Test{
public :
@ -27,7 +31,7 @@ TEST_F(INPUT,InjectEvent){
INPUTEVENT e;
INPUTEVENT e2;
e.type=EV_KEY;
e.code=KEY_ENTER;
e.code = 100;// KEY_ENTER;
e.device=INJECTDEV_KEY;
ASSERT_EQ(1,InputInjectEvents(&e,1,0));
ASSERT_EQ(1,InputGetEvents(&e2,1,1));

View File

@ -1,6 +1,6 @@
#include <stdio.h>
#include <gtest/gtest.h>
#include <dtvos.h>
#include <porting/dtvos.h>
class OSMEM:public testing::Test{
public :

View File

@ -1,9 +1,13 @@
#include <stdio.h>
#if defined(__linux__)||defined(__unix___)
#include <sys/time.h>
#else
#include <Windows.h>
#endif
#include <gtest/gtest.h>
extern "C"{
#include <dtvos.h>
#include <dtvmsgq.h>
#include <porting/dtvos.h>
#include <porting/dtvmsgq.h>
}
class OSMSGQ:public testing::Test{
@ -14,9 +18,13 @@ class OSMSGQ:public testing::Test{
virtual void TearDown(){
}
unsigned long long gettime(){
#if defined(__linux__)||defined(__unix__)
struct timeval tv;
gettimeofday(&tv,NULL);
return tv.tv_sec*1000+tv.tv_usec/1000;
#elif defined(_WIN32)||defined(_WIN64)
return GetTickCount64();
#endif
}
};
typedef struct{

View File

@ -1,8 +1,10 @@
#include <stdio.h>
#if defined(__linux__)||defined(__unix__)
#include <sys/time.h>
#endif
#include <gtest/gtest.h>
extern "C"{
#include <dtvos.h>
#include <porting/dtvos.h>
}
class OSMUTEX:public testing::Test{

View File

@ -1,7 +1,11 @@
#include <stdio.h>
#if defined(__linux__)||defined(__unix__)
#include <sys/time.h>
#elif defined(_WIN32)||defined(_WIN64)
#include <Windows.h>
#endif
#include <gtest/gtest.h>
#include <dtvos.h>
#include <porting/dtvos.h>
class OSSEM:public testing::Test{
public :

View File

@ -1,7 +1,7 @@
#include <gtest/gtest.h>
#include <cdtypes.h>
#include <cdlog.h>
#include <cdgraph.h>
#include <porting/cdtypes.h>
#include <porting/cdlog.h>
#include <porting/cdgraph.h>
#include <math.h>
class HALEnvironment: public testing::Environment{

View File

@ -1,5 +1,5 @@
#include <gtest/gtest.h>
#include <dtvtimer.h>
#include <porting/dtvtimer.h>
#include <time.h>
class TIMER:public testing::Test{

View File

@ -1,6 +1,6 @@
#ifndef __DTV_UTILS_H__
#define __DTV_UTILS_H__
#include <cdtypes.h>
#include <porting/cdtypes.h>
#include <ngl_tuner.h>
namespace tvutils{