blob: 54d19901f8323de37aa379ef00d1bb9b6a197ee8 [file] [log] [blame]
// XGL tests
//
// Copyright (C) 2014 LunarG, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#ifndef XGLTESTFRAMEWORK_H
#define XGLTESTFRAMEWORK_H
#include "gtest-1.7.0/include/gtest/gtest.h"
#include "xglimage.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <iostream>
#include <fstream>
#include <list>
using namespace std;
class XglTestImageRecord
{
public:
XglTestImageRecord();
XglTestImageRecord(const XglTestImageRecord &);
~XglTestImageRecord();
XglTestImageRecord &operator=(const XglTestImageRecord &rhs);
int operator==(const XglTestImageRecord &rhs) const;
int operator<(const XglTestImageRecord &rhs) const;
string m_title;
void *m_data;
unsigned m_data_size;
int m_width;
int m_height;
};
class XglTestFramework : public ::testing::Test
{
public:
XglTestFramework();
static void InitArgs(int *argc, char *argv[]);
static void Finish();
void WritePPM( const char *basename, XglImage *image );
void Show(const char *comment, XglImage *image);
void RecordImage(XglImage *image);
private:
static void Reshape( int w, int h );
static void Display();
static void Key(unsigned char key, int x, int y);
static void SpecialKey( int key, int x, int y );
void InitGLUT(int w, int h);
static bool m_show_images;
static bool m_save_images;
static std::list<XglTestImageRecord> m_images;
static std::list<XglTestImageRecord>::iterator m_display_image;
static int m_display_image_idx;
bool m_glut_initialized;
static int m_window;
static int m_width; // Window width
static int m_height; // Window height
};
#endif // XGLTESTFRAMEWORK_H