Exemple #1
0
void TestAttal::testGame()
{
    //setLogLevel((LogLevel) 5 );
    FakeLoader *  loader = new FakeLoader();

    Analyst * ai = new Analyst();
    AttalSocket * oldSocket = ai->getSocket();
    ai->start();
    AttalSocket * newSocket = ai->getSocket();
    QCOMPARE( (oldSocket == newSocket), true );
    ai->connectAi( "localhost", loader->getServer()->serverPort()  );

    QString path = THEME_PATH + "scenarii/demo_1player.scn";

    loader->load( path );
    loader->endGame2();

    ai->disconnectAi();

    ai->exit(0);
    ai->wait();
    delete ai;

    delete loader;
}
GLuint Tools::loadTexture2DFake ()
{
        GLuint textureHandle;

        FakeLoader fakeLoader;
		int iRet;

        glGenTextures(1,&textureHandle);
		(void)fakeLoader.load();

        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
        glBindTexture(GL_TEXTURE_2D, textureHandle);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

		glTexImage2D(GL_TEXTURE_2D,
			0,
			fakeLoader.getBPP() == 24 ? GL_RGB : GL_RGBA,
			fakeLoader.getWidth(),
			fakeLoader.getHeight(),
			0,
			fakeLoader.getBPP() == 24 ? GL_RGB : GL_RGBA,
			GL_UNSIGNED_BYTE,
			fakeLoader.getData()
			);

			//glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
			glGenerateMipmap(GL_TEXTURE_2D);


        return(textureHandle);
}
Exemple #3
0
void TestAttal::testGameAi()
{
    /*
     * test connectAi before and after start in threads
     * test disconnectAi before the end of thread or thread that end without disconnect
     * port set to 1718 cause operating system don't release fast enough sockets from test before
     */
    //setLogLevel((LogLevel) 5 );
    QString port = "1718";
    FakeLoader *  loader = new FakeLoader(port);
    QCOMPARE( (loader->getServer() != NULL ), true );

    Analyst * ai = new Analyst();
    ai->start();

    ai->connectAi( "localhost", loader->getServer()->serverPort() );

    QString path = THEME_PATH + "scenarii/demo_1player.scn";

    loader->load( path );
    loader->endGame2();

    ai->disconnectAi();

    ai->exit(0);
    ai->wait();
    delete ai;

    QCOMPARE( (loader->getServer() != NULL ), true );

    ai = new Analyst();
    ai->connectAi( "localhost", loader->getServer()->serverPort() );
    ai->start();

    path = THEME_PATH + "scenarii/demo_1player.scn";

    loader->load( path );
    loader->endGame2();

    ai->exit(0);
    ai->wait();
    delete ai;

    delete loader;
}