msvc compatible changes

This commit is contained in:
zhhou 2024-10-24 19:57:35 +08:00
parent 986d18a977
commit 034842db76
2 changed files with 14 additions and 20 deletions

View File

@ -5,10 +5,11 @@
extern void sleep(uint32_t);
extern void usleep(uint32_t);
#endif
static const char*texts[]={"Creates 中国智造"," the specified format and dimensions.",
static const std::vector<std::string>texts={//std::string("Creates 中国智造"),
std::string("the specified format and dimensions."),
"Initially the surface contents"," are set to 0.","(Specifically, within each pixel,",
" each color or alpha channel","belonging to format will be 0.","The contents","of bits within a pixel,",
" but not belonging","必须使用UTF8编码 " };
" but not belonging"/*,"必须使用UTF8编码 "*/};
class WINDOW:public testing::Test{
public :
@ -155,7 +156,7 @@ TEST_F(WINDOW,LinearLayout){
LinearLayout*g1=new LinearLayout(0,0,800,400);
LinearLayout*g2=new LinearLayout(0,410,800,200);
int count=sizeof(texts)/sizeof(char*);
size_t count=texts.size();
for(int i=0;i<8;i++){
g1->addView(new Button(texts[i%count],200,40));
g2->addView(new Button(texts[(i+7)%count],200,40));

View File

@ -7,20 +7,13 @@
#include<porting/cdlog.h>
#include<porting/cderrors.h>
#include <gtest/gtest.h>
#if defined(_WIN32)||defined(_WIN64)
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);
#if defined(_WIN32)||defined(_WIN64)
void usleep(uint32_t us) {
Sleep(us / 1000);
}
void sleep(unsigned int secs) {
usleep(secs * 1000000);
void sleep(uint32_t s) {
Sleep(s * 1000);
}
void gettimeofday(struct timeval* t1, struct timezone* zone) {
auto tt = GetTickCount64();
@ -368,12 +361,11 @@ typedef struct {
unsigned int rgb[4];
}TSTPIXEL;
#if 0
TEST_F(GRAPH,Format){
//this case show four color block ,RED,GREEN,BLUE,WHITE.
GFXHANDLE surface;
uint32_t width,height;
GFXGetDisplaySize(&width,&height);
GFXGetDisplaySize(0,&width,&height);
TSTPIXEL fpixels[]={
{GPF_ARGB, {0xFFFF0000,0xFF00FF00,0xFF0000FF,0xFFFFFFFF}},
{GPF_ABGR, {0xFF0000FF,0xFF00FF00,0xFFFF0000,0xFFFFFFFF}},
@ -383,7 +375,7 @@ TEST_F(GRAPH,Format){
};
for(int i=0;i<sizeof(fpixels)/sizeof(TSTPIXEL)-3;i++){
GFXCreateSurface(&surface,width,height,fpixels[i].format,1);
GFXCreateSurface(0,&surface,width,height,fpixels[i].format,1);
GFXRect r={100,100,100,100};
GFXFillRect(surface,&r,0xFFFF0000);
ASSERT_EQ(getPixel(surface,101,101),fpixels[i].rgb[0]);
@ -399,10 +391,10 @@ TEST_F(GRAPH,Format){
GFXFlip(surface);
GFXDestroySurface(surface);
GFXSleep(5000);
usleep(5000);
}
}
#endif
TEST_F(GRAPH,Blit_Normal){
GFXHANDLE hwsurface;
@ -528,3 +520,4 @@ TEST_F(GRAPH,canvas){
GFXDestroySurface(surface);
}
#endif