Exemplo n.º 1
0
// make sure when we delete a Buffer, *all* the allocated
// memory goes away. As the only way to do this is to examine
// the malloc buffers in the kernel, this will only work on
// POSIX conforming systems, and probabably only Linux & BSD.
void
test_destruct()
{
// these tests are bogus unless you have both mallinfo()
// and also have memory statistics gathering turned on.
#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
    Memory mem(5);
    mem.addStats(__LINE__);             // take a sample
    Buffer *buf1, *buf2;

    mem.startCheckpoint();
    buf1 = new Buffer(NETBUFSIZE);
    delete buf1;
    
    if (mem.endCheckpoint()) {
        runtest.pass ("Buffer::~Buffer()");
    } else {
        runtest.fail ("Buffer::~Buffer()");
    }

    mem.startCheckpoint();
    buf2 = new Buffer(124);
    delete buf2;
    
    if (mem.endCheckpoint()) {
        runtest.pass ("Buffer::~Buffer(size_t)");
    } else {
        runtest.fail ("Buffer::~Buffer(size_t)");
    }
#endif
}
Exemplo n.º 2
0
// Make sure we can read and write binary AMF strings
void
test_String(void)
{
    AMF amf_obj;
    int fd, ret;
    char buf[AMF_VIDEO_PACKET_SIZE+1];

    // First see if we can read strings. This file is produced by
    // using a network packet sniffer, and should be binary correct.
    memset(buf, 0, AMF_VIDEO_PACKET_SIZE+1);
    fd = open("string1.amf", O_RDONLY);
    ret = read(fd, buf, AMF_VIDEO_PACKET_SIZE);
    close(fd);

    char *str = amf_obj.extractString(buf);
    if (strcmp(str, "connect") == 0) {
        runtest.pass("Extracted \"connect\" string");
    } else {
        runtest.fail("Extracted \"connect\" string");
    }

    // Now make sure we can also create strings. We'll create the same
    // string we just read, and make sure they match.
    char *connect = "connect";
    void *out = amf_obj.encodeElement(AMF::STRING, connect, strlen(connect));
    if (memcmp(out, buf, 10) == 0) {
        runtest.pass("Encoded \"connect\" string");
    } else {
        runtest.fail("Encoded \"connect\" string");
    }

    delete str;
}
Exemplo n.º 3
0
void
test_read(std::string &filespec)
{
    GNASH_REPORT_FUNCTION;
    struct stat st;

    boost::shared_ptr<Buffer> hex1(new Buffer("00 bf 00 00 01 28 54 43 53 4f 00 04 00 00 00 00 00 08 73 65 74 74 69 6e 67 73 00 00 00 00 00 04 67 61 69 6e 00 40 49 00 00 00 00 00 00 00 00 0f 65 63 68 6f 73 75 70 70 72 65 73 73 69 6f 6e 01 00 00 00 11 64 65 66 61 75 6c 74 6d 69 63 72 6f 70 68 6f 6e 65 02 00 0e 2f 64 65 76 2f 69 6e 70 75 74 2f 6d 69 63 00 00 0d 64 65 66 61 75 6c 74 63 61 6d 65 72 61 02 00 00 00 00 0d 64 65 66 61 75 6c 74 6b 6c 69 6d 69 74 00 40 59 00 00 00 00 00 00 00 00 0d 64 65 66 61 75 6c 74 61 6c 77 61 79 73 01 00 00 00 10 63 72 6f 73 73 64 6f 6d 61 69 6e 41 6c 6c 6f 77 01 01 00 00 11 63 72 6f 73 73 64 6f 6d 61 69 6e 41 6c 77 61 79 73 01 01 00 00 18 61 6c 6c 6f 77 54 68 69 72 64 50 61 72 74 79 4c 53 4f 41 63 63 65 73 73 01 01 00 00 0c 74 72 75 73 74 65 64 50 61 74 68 73 03 00 00 09 00 00 0c 6c 6f 63 61 6c 53 65 63 50 61 74 68 02 00 00 00 00 10 6c 6f 63 61 6c 53 65 63 50 61 74 68 54 69 6d 65 00 42 71 6d 14 10 22 e0 00 00"));

    if (stat(filespec.c_str(), &st) == 0) {
        SOL sol;
        sol.readFile(filespec);
        vector<boost::shared_ptr<cygnal::Element> > els = sol.getElements();

        if (els.size() > 1) {
            string str = els[2]->to_string();

            // Make sure multiple elements of varying datatypes are checked for.
            if ((strcmp(els[0]->getName(), "gain") == 0) &&
                (strcmp(els[2]->getName(), "defaultmicrophone") == 0) &&
                (str == "/dev/input/mic") &&
                (strcmp(els[5]->getName(), "defaultalways") == 0) &&
                 (strcmp(els[9]->getName(), "trustedPaths") == 0)) {
                runtest.pass("Read SOL File");
            } else {
                runtest.fail("Read SOL file");
            }
        } else {
            runtest.fail("Read SOL file");
        }
//        sol.dump();
    }
}
Exemplo n.º 4
0
//
// Machinery for delayed images rendering (e.g. Xv with YV12 or VAAPI)
//
void
test_iterators(Renderer *renderer, const std::string &type)
{
    cout << "\t"<< type << " iterator tests" << endl;
    
    if (!renderer) {
        runtest.unresolved("No renderer to test!");
        return;
    }

    Renderer::RenderImages::iterator fit = renderer->getFirstRenderImage();
    Renderer::RenderImages::iterator lit = renderer->getLastRenderImage();
    // When there are no images, the first and last are the same obviously
    if (fit == lit) {
         runtest.pass("getFirstRenderImage()");
    } else {
        runtest.fail("getFirstRenderImage()");
    }

#if 0    
    geometry::Point2d a(1, 2);
    geometry::Point2d c(3, 4);
    Renderer::RenderImage image;
    image::GnashImage *frame = new image::ImageRGBA(10, 10);
    // gnash::GnashVaapiImage *foo = static_cast<gnash::GnashVaapiImage *>(frame);
    // gnash::GnashVaapiImageProxy *bar = new gnash::GnashVaapiImageProxy(foo, a.x, a.y, c.x - a.x, c.y - a.y);
    std::auto_ptr<image::GnashImage> rgba(frame);
//    image.reset(new gnash::GnashVaapiImageProxy(foo, a.x, a.y, c.x - a.x, c.y - a.y));

    renderer->addRenderImage(image);
//    image.reset(new gnash::GnashVaapiImageProxy(foo, a.x, a.y, c.x - a.x, c.y - a.y));
    renderer->addRenderImage(image);
#endif
    
    fit = renderer->getFirstRenderImage();
    lit = renderer->getLastRenderImage();
    // When there are no images, the first and last are the same obviously
    if (fit != lit) {
         runtest.pass("addRenderImage()");
    } else {
        runtest.fail("addRenderImage()");
    }
    
#if 0
    typedef boost::shared_ptr<GnashVaapiImageProxy> RenderImage;
    typedef std::vector<RenderImage> RenderImages;

    // Get first render image
    virtual RenderImages::iterator getFirstRenderImage()
            { return _render_images.begin(); }
    virtual RenderImages::const_iterator getFirstRenderImage() const
            { return _render_images.begin(); }

    // Get last render image
    virtual RenderImages::iterator getLastRenderImage()
            { return _render_images.end(); }
    virtual RenderImages::const_iterator getLastRenderImage() const
            { return _render_images.end(); }
#endif
}
Exemplo n.º 5
0
		void TestWriteMethod() 
		{
			TestState* state = WriteNextStateStart();
			state->Write();
			state->Write();
			state->Write();
			WriteNextStateStop(); 
		}
Exemplo n.º 6
0
void
test_bool(as_value boolval)
{
    if (boolval.is_bool()) {
        runtest.pass("as_value(bool)");
    } else {
        runtest.fail("as_value(bool)");
    }
}
Exemplo n.º 7
0
void
test_string(as_value val)
{
    if (val.is_string()) {
        runtest.pass("as_value(string)");
    } else {
        runtest.fail("as_value(string)");
    }
}
Exemplo n.º 8
0
void
test_int(as_value val)
{
    if (val.is_number()) {
        runtest.pass("as_value(int)");
    } else {
        runtest.fail("as_value(int)");
    }
}
Exemplo n.º 9
0
void
test_data()
{
    LcShm lcs;
//  LcShm lcs=LcShm();
    char *shmaddr;

    const string con1 = "localhost:WeBuildTheseOOOOOOOOOOOOOOOOO";
    if (lcs.connect(con1)) {
        runtest.pass("LcShm::connect(localhost:lc_reply)");
    } else {
        runtest.fail("LcShm::connect(localhost:lc_reply)");
    }

    shmaddr = reinterpret_cast<char*>(lcs.begin());     // for gdb

    Element *el;
    vector<amf::Element *> els;

#if 0
    // Apparently this constructor no longer exists.

    el = new Element(true, 123.456, 987.654, "IAmReplyingNow");
//    el->dump();
    els.push_back(el);
    delete el;    
#endif
#if 0
    // 
    el = new Element(true);
    els.push_back(el);

    el = new Element(12.34);
    els.push_back(el);

    el = new Element(12.34);
    els.push_back(el);

    string str = "IAmReplyingNow";
    el = new Element(str);
    els.push_back(el);
#endif
    
    string str = "Volume Level 10 ";
    el = new Element(str);
    els.push_back(el);

    // Send the AMF objects
    const std::string localS="localhost";
  lcs.send(con1, localS, els);
//    system("ipcs");
//    system("dumpshm -i");
    sleep(3);
    delete el;
}
Exemplo n.º 10
0
void
test_Boolean(void)
{
    AMF amf_obj;
    bool bo = false;

    // Write a number element
    void *out = amf_obj.encodeElement(AMF::BOOLEAN, &bo, 0);
    if (amf_obj.extractElementHeader(out) == AMF::BOOLEAN) {
        runtest.pass("Boolean header correct");
    } else {
        runtest.fail("Boolean header not correct");
    }
    if (amf_obj.extractElementLength(out) == 1) {
        runtest.pass("Boolean length returned correct");
    } else {
        runtest.fail("Boolean length returned not correct");
    }
    if (*((char *)out + 1) == 0) {
        pass("Boolean false returned correct");
    } else {
        runtest.fail("Boolean false returned not correct");
    }
    bo = true;
    out = amf_obj.encodeElement(AMF::BOOLEAN, &bo, 0);
    if (*((char *)out + 1) == 1) {
        runtest.pass("Boolean true returned correct");
    } else {
        runtest.fail("Boolean true returned not correct");
    }
}
Exemplo n.º 11
0
		void TestReadMethod() 
		{
			TestState* state;
			int fCount = 0;
			long result[SIZE];
            UInt16 cur_index;
            UInt16 next_index;
			do {
                cur_index = GetCurrentIndex();
                fCount++;
				state = ReadCurrentState();
				bool res = state->ReadCopy(result);
			    next_index = GetCurrentIndex();
                if (!res) 
                    printf("TestReadMethod fCount %ld cur %ld next %ld\n", fCount, cur_index, next_index);
        	}while (cur_index != next_index);
			state->Check(result);
		}
Exemplo n.º 12
0
int
main(int /*argc*/, char** /*argv*/)
{
	const char* input = INPUT; // Should be the path to this file
	const char* cachename = "NoSeekFileTestCache";

	int fd = open(input, O_RDONLY);
	int raw = open(input, O_RDONLY);

	dup2(fd, 0);

	gnash::IOChannel* reader = gnash::noseek_fd_adapter::make_stream(0, cachename);
	assert(reader);

	compare_reads(reader, raw, "wrapped", "raw");

	lseek(raw, 0, SEEK_SET);
	reader->seek(0);
	compare_reads(reader, raw, "wrapped-rewind", "raw-rewind");


    FILE* f = std::fopen(cachename, "r");
    std::auto_ptr<gnash::IOChannel> orig = gnash::makeFileChannel(f, false);
	lseek(raw, 0, SEEK_SET);
	compare_reads(orig.get(), raw, "cache", "raw");


    if (sizeof(size_t) != sizeof(std::streamoff)) {
        std::streampos pos = std::numeric_limits<size_t>::max();
        pos += orig->size() / 2;
        // Check that seek() handles integer overflow situations gracefully.
        if (orig->seek(pos)) {
            runtest.fail("Successfully sought to an invalid position.");
        } else {
            runtest.pass("Gracefully handled invalid seek.");
        }
    }



	return 0;
}
Exemplo n.º 13
0
// Each Renderer has an associated display device, currently EGL
// for OpenVG, OpenGLES1, and OpenGLES2. The DirectFB device is
// also available for these three renderers. The EGL device can
// also be run under X11 using the Mesa libraries. Both EGL and
// DirectFB are primarily for framebuffers. While all of the methods
// of each device class are available to the Renderer, most aren't
// exposed with more accesors beyond these for manipulating the
// device setting itself.
void
test_device(Renderer *renderer, const std::string &type)
{
    cout << endl << "Testing " << type << " Device" << endl;

#if 0
    boost::shared_array<renderer::GnashDevice::dtype_t> devs = renderer->probeDevices();
    if (devs) {
        runtest.pass("Renderer::probeDevices()");
    } else {
        runtest.fail("Renderer::probeDevices()");
    }
    // Be default, there should be no device associated with this
    // renderer yet.
    if (renderer->getDevice() == GnashDevice::NODEV) {
        runtest.pass("Renderer::getDevice()");
    } else {
        runtest.fail("Renderer::getDevice()");
    }

    // Set to a device and see if it's axctually set
    renderer->setDevice(GnashDevice::X11);
    if (renderer->getDevice() == GnashDevice::X11) {
        runtest.pass("Renderer::setDevice()");
    } else {
        runtest.fail("Renderer::setDevice()");
    }

    // reset to the original value so we don't screw up future tests
    renderer->resetDevice();
#endif
}
Exemplo n.º 14
0
void
load_data()
{

    LcShm lc;
    char *shmaddr;

    string con1 = "lc_reply";
    if (!lc.connect(con1)) {
        if (errno == EACCES) {
            runtest.untested("Couldn't map input file, permission problems!!");
        } else {
            runtest.unresolved("LcShm::connect()");
        }
        exit(0);
    }

    shmaddr = reinterpret_cast<char*>(lc.begin());
//    if (memcmp(shmaddr, con1.c_str():
    // Since this is a test case, populate the memory with known good data
    string srcdir = SRCDIR;
    srcdir += "/segment.raw";
    int fd = ::open(srcdir.c_str(), O_RDONLY);
    void *dataptr = mmap(0, 64528, PROT_READ, MAP_SHARED, fd, 0);

    if (dataptr != (void*)-1) {
        memcpy(shmaddr, dataptr, 64528);
    } else {
        if (errno == EACCES) {
            runtest.unresolved("Couldn't map input file, permission problems!!");
        } else {
            runtest.unresolved("Couldn't map input file!");
            log_debug("Error was: %s", strerror(errno));
        }
        exit(0);
    }

    ::close(fd);
}
Exemplo n.º 15
0
void
test_remove()
{
    Network::byte_t *data1 = new Network::byte_t[20];
    memset(data1, 0, 20);
    Network::byte_t *data2 = new Network::byte_t[20];
    memset(data2, 0, 20);
    Network::byte_t *data3 = new Network::byte_t[20];
    memset(data3, 0, 20);

    // populate a buffer with some data
    for (size_t i=0; i< 19; i++) {
        data1[i] = i + 'a';
    }

    // Build identical buffer nissing one character
    memcpy(data2, data1, 6);
    memcpy(data2 + 6, data1 + 7, 20-7);

    // Remove a single byte
    Network::byte_t byte = 'g';
    Buffer buf1(20);
    buf1.clear();
    buf1.copy(data1, 20);
    buf1.remove(byte);
    if (memcmp(data2, buf1.reference(), 19) == 0) {
         runtest.pass ("Buffer::remove(Network::byte_t)");
    } else {
         runtest.fail ("Buffer::remove(Network::byte_t)");
    }
    
    Buffer buf2(20);
    buf2.clear();
    buf2.copy(data1, 20);
    buf2.remove(6);
    if (memcmp(data2, buf2.reference(), 18) == 0) {
         runtest.pass ("Buffer::remove(int)");
    } else {
         runtest.fail ("Buffer::remove(int)");
    }

    // Remove a range of bytes
    memcpy(data3, data1, 6);
    memcpy(data3 + 6, data1 + 9, 1);
    
    Buffer buf3(20);
    buf3.clear();
    buf3.copy(data1, 20);
    buf3.remove(6, 8);
    if (memcmp(data3, buf3.reference(), 6) == 0) {
         runtest.pass ("Buffer::remove(int, int)");
    } else {
         runtest.fail ("Buffer::remove(int, int)");
    }

    delete[] data1;
    delete[] data2;
    delete[] data3;
}
Exemplo n.º 16
0
void
test_mem()
{
    boost::shared_ptr<cygnal::Buffer> buf1(new cygnal::Buffer(12));
    *buf1 = "Hello World";
    // drop the null terminator byte we inherit when using a simnple
    // string for testing
    buf1->resize(buf1->size() - 1);

    DiskStream ds("fooBar1", *buf1);
    ds.writeToDisk();
    ds.close();

    struct stat st;
    memset(&st, 0, sizeof(struct stat));
    
    if (stat("fooBar1", &st) == 0) {
        runtest.pass("DiskStream::writeToDisk()");
    } else {
        runtest.fail("DiskStream::writeToDisk()");
    }
}
Exemplo n.º 17
0
void
test_find()
{
    // Make some data for the buffers
    Network::byte_t *data = new Network::byte_t[10];
    for (size_t i=0; i<10; i++) {
        data[i] = i + 'a';
    }

    Buffer buf1, buf2, buf3;
    Network::byte_t *ptr1 = buf1.reference();

    // populate the buffer
    buf1.copy(data, 10);
    delete[] data;
    
    // See if we can find a character
    Network::byte_t *fptr = std::find(buf1.begin(), buf1.end(), 'c'); 
    if (fptr == (ptr1 + 2)) {
         runtest.pass ("Buffer::find(Network::byte_t)");
    } else {
         runtest.fail ("Buffer::find(Network::byte_t)");
    }

    const char *sub = "fgh";
#if 0
    Network::byte_t *ptr2 = const_cast<Network::byte_t *>(reinterpret_cast<const Network::byte_t *>(sub));
#endif
    fptr = std::search(buf1.begin(), buf1.end(), sub, sub+3);
    if (fptr == (ptr1 + 5)) {
         runtest.pass ("Buffer::find(Network::byte_t *, size_t)");
    } else {
         runtest.fail ("Buffer::find(Network::byte_t *, size_t)");
    }

// cygnal::Buffer::init(unsigned int)
}
void check_localization_variable( TestState& state ) {
    dStorm::input::Traits<dStorm::Localization> traits;
    dStorm::Localization loc;

    loc.position_x() = 15 * boost::units::si::meter;

    ValueVariable<localization::PositionX> v;

    try {
        v.get(traits);
        state.fail( "No error thrown when traits with X coordinate unset were provided to get()" );
    } catch (...) {}

    DynamicUnit meter_only;
    meter_only[ *UnitTable().find("m") ] = 1;
    DynamicQuantity fifteen_meters( 15, meter_only );

    traits.position_x().is_given = true;
    state( v.is_static(traits) == false );
    state( v.get(traits) != fifteen_meters );
    state( v.get(loc) == fifteen_meters );
}
Exemplo n.º 19
0
void
test_construct()
{
// these tests are bogus unless you have both mallinfo()
// and also have memory statistics gathering turned on.
#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
    bool valgrind = false;
    
    size_t fudge = sizeof(long *)*5;
    
    Memory mem(5);
    mem.addStats(__LINE__);             // take a sample
    Buffer buf1;
    mem.addStats(__LINE__);             // take a sample
    size_t diff = mem.diffStats() - sizeof(buf1);    
    if (diff > NETBUFSIZE) {
        valgrind = true;
        log_debug("Running this test case under valgrind screws up mallinfo(), so the results get skewed");
    }
    // Different systems allocate memory slightly differently, so about all we can do to see
    // if it worked is check to make sure it's within a tight range of possible values.
     if ((buf1.size() == NETBUFSIZE) && (diff >= (NETBUFSIZE - fudge)) && diff <= (NETBUFSIZE + fudge)) {
        runtest.pass ("Buffer::Buffer()");
    } else {
        if (valgrind) {
            runtest.unresolved("Buffer::Buffer()) under valgrind");
        } else {
            runtest.fail("Buffer::Buffer()");
        }
    }
    
    mem.addStats(__LINE__);             // take a sample
    Buffer buf2(124);
    mem.addStats(__LINE__);             // take a sample
    diff = mem.diffStats() - sizeof(long *);
    if ((buf2.size() == 124) && (124 - fudge) && diff <= (124 + fudge)) {
        runtest.pass ("Buffer::Buffer(size_t)");
    } else {
        if (valgrind) {
            runtest.unresolved("Buffer::Buffer(size_t) under valgrind");
        } else {
            runtest.fail("Buffer::Buffer(size_t)");
        }
    }
#endif
}
Exemplo n.º 20
0
void
test_resize()
{
    Buffer buf;
#ifdef HAVE_MALLINFO
    if (memdebug) {
        mem->addStats(__LINE__);             // take a sample
    }
#endif    
    if (buf.size() == cygnal::NETBUFSIZE) {
        runtest.pass ("Buffer::size(NETBUFSIZE)");
    } else {
        runtest.fail ("Buffer::size(NETBUFSIZE)");
    }
    
#ifdef HAVE_MALLINFO
    if (memdebug) {
        mem->addStats(__LINE__);             // take a sample
    }
#endif
    buf.resize(112);
#ifdef HAVE_MALLINFO
    if (memdebug) {
        mem->addStats(__LINE__);             // take a sample
    }
#endif
    if (buf.size() == 112) {
         runtest.pass ("Buffer::resize(112)");
     } else {
         runtest.fail ("Buffer::resize(112)");
    }
#ifdef HAVE_MALLINFO
    if (memdebug) {
        mem->addStats(__LINE__);             // take a sample
    }
#endif

    string str = "Hello World";
    buf = str;
    buf.resize(5);
    if (memcmp(buf.begin(), str.c_str(), 5) == 0) {
        runtest.pass ("Buffer resize(5)");
    } else {
        runtest.fail ("Buffer resize(5)");
    }
}
Exemplo n.º 21
0
// Each header consists of the following:
//
// * UTF string (including length bytes) - name
// * Boolean - specifies if understanding the header is `required'
// * Long - Length in bytes of header
// * Variable - Actual data (including a type code)
void
test_Header(void){
    AMF amf_obj;
    amfutf8_t name, headname;
    amfnum_t num;
    void *element;
    amfhead_t *head;

    note("Test the Header");

    num = 123456789;

    char *test = "NumberTest";
    name.length = strlen(test);
    name.data = test;
    
    element = amf_obj.encodeElement(AMF::NUMBER, &num, 0);
    head = amf_obj.encodeHeader(&name, true, sizeof(amfnum_t), &num);

    char *ptr = ((char *)head) + 2;
    if ((strncmp(ptr, test, name.length) == 0) && (ntohs(*(short *)head) == name.length)) {
        runtest.pass("Header name correct");
    } else {
        runtest.fail("Header name not correct");
    }

    ptr = ((char *)head) + 2 + name.length + 1;
    if (*ptr == AMF::NUMBER) {
        runtest.pass("Header Object type correct");
    } else {
        runtest.fail("Header Object type not correct");
    }
    
    ptr++;
    if (*ptr == htonl(num)) {
        runtest.pass("Header Object data correct");
    } else {
        runtest.fail("Header Object data not correct");
    }    
}
Exemplo n.º 22
0
void
test_renderer(Renderer *renderer, const std::string &type)
{
    cout << "Testing " << type << " Renderer" << endl;
//    Timer trend("Renderer Tests", true);
    
    if (!renderer) {
        runtest.unresolved("No renderer to test!");
        return;
    }
    
    if (renderer > 0) {
        runtest.pass("Got Renderer");
    } else {
        runtest.fail("Couldn't get Renderer");
    }

    if (!renderer->description().empty()) {
        if (renderer->description() == type) {
            runtest.pass("description is correct");
        } else {
            runtest.fail("description is wrong");
        }
    } else {
        runtest.fail("Couldn't get description!");
    }

#if 0
    if (renderer->getBitsPerPixel()) {
        runtest.pass("getBitsPerPixel()");
    } else {
        runtest.fail("getBitsPerPixel()");
    }
#endif
    
    image::GnashImage *frame1 = new image::ImageRGBA(10, 12);
    std::auto_ptr<image::GnashImage> im1(frame1);
    CachedBitmap *cb = renderer->createCachedBitmap(im1);
    if (cb) {
        image::GnashImage &gi = cb->image();
        if ((gi.width() == 10) && (gi.height() == 12)) {
            runtest.pass("createCachedBitmap()");
        } else {
            runtest.fail("createCachedBitmap()");
        }
    } else {
        runtest.unresolved("createCachedBitmap()");
    }

#if 0
    // FIXME: initTestBuffer() is going away, replaced by the fake
    // framebuffer code.
    // Initializes the renderer for off-screen rendering used by the testsuite.
    if (renderer->initTestBuffer(10, 10)) {
        runtest.pass("initTestBuffer()");
    } else {
        runtest.fail("initTestBuffer()");
    }
#endif
    
    /// @coords an array of 16-bit signed integer coordinates. Even indices
    ///         (and 0) are x coordinates, while uneven ones are y coordinates.
    /// @vertex_count the number of x-y coordinates (vertices).
    /// @color the color to be used to draw the line strip.
    /// @mat the SWFMatrix to be used to transform the vertices.
    boost::uint16_t x = 10;
    boost::uint16_t y = 10;
    boost::uint16_t h = 10;
    std::vector<point> box = boost::assign::list_of
        (point(x, y))
        (point(x, y + h));

    rgba color(0, 0, 0, 255);
    SWFMatrix mat;
    mat.set_scale_rotation(1, 3, 0);

    Timer tdrawline("drawline");
    renderer->drawLine(box, color, mat);
    tdrawline.stop();
    
    // if (1) {
    //     runtest.pass("drawLine()");
    // } else {
    //     runtest.fail("drawLine()");
    // }
    runtest.unresolved(std::string("drawLine() ") + tdrawline.elapsed());

    //drawVideoFrame(image::GnashImage* frame, const Transform& xform, const SWFRect* bounds, bool smooth);
#if 0
    image::GnashImage *frame;
    const Transform xform;
    const SWFRect bounds;
    bool smooth;
    Timer tdrawvideo("drawVideoFrame");
    renderer->drawVideoFrame(frame, xform, bounds, smooth);
    tdrawvideo.stop();
#endif
    runtest.untested("drawVideoFrame()");

    point *corners = 0;
    size_t corner_count = 0;
    rgba fill(0, 0, 0, 255);;
    rgba outline(0, 0, 0, 255);;
    bool masked = true;
    Timer tdrawpoly("drawPoly");
    renderer->draw_poly(corners, corner_count, fill, outline, mat, masked);
    tdrawpoly.stop();
    runtest.unresolved(std::string("drawPoly() ") + tdrawpoly.elapsed());
    
//    SWF::ShapeRecord shape;
    SWFMatrix mat2(0x10000, 0x0, 0x0, 0x10000, 0x0, 0x0);
    SWFCxForm cxform;
    //(0x100, 0x100, 0x100, 0x100, 0x0, 0x0, 0x0, 0x0);
    Transform xform(mat2, cxform);
    SWF::ShapeRecord shape;
    // _bounds = {0x80000000, 0x7fffffff,
    //            0x80000000, 0x80000000,
    //            0x80000000, 0x80000000}}
    Timer drawshape("drawShape");
    renderer->drawShape(shape, xform);
    runtest.unresolved("drawShape()");
    drawshape.stop();
    
//    SWF::ShapeRecord rec;
    // rgba color;
    // SWFMatrix mat;
//    Timer drawGlyph("drawGlyph");
//    renderer->drawGlyph(rec, color, mat);
    runtest.untested("drawGlyph()");
//   drawglyph.stop();

#if 0
    boost::shared_ptr<IOChannel> io;
    FileType ftype;
    Timer renderi("renderToImage");
    renderer->renderToImage(io, ftype);
    renderi.stop();
#endif
    runtest.untested("renderToImage()");

    CachedBitmap *bitmap = 0;
    image::GnashImage *frame2 = new image::ImageRGBA(10, 10);
    std::auto_ptr<image::GnashImage> im(frame2);
    Timer cbit("createCachedBitmap");
    bitmap = renderer->createCachedBitmap(im);
    cbit.stop();
    if (bitmap) {
        runtest.pass(std::string("createCachedBitmap() ") + cbit.elapsed());
    } else {
        runtest.fail(std::string("createCachedBitmap() ") + cbit.elapsed());
    }
    
}
Exemplo n.º 23
0
void
test_listen()
{

    LcShm lc;
    char *shmaddr;
    
    string con1 = "localhost:lc_reply";
    if (lc.connect("lc_reply")) {
        runtest.pass("LcShm::connect()");
    } else {
        runtest.fail("LcShm::connect()");
    }
    
    //
    shmaddr = reinterpret_cast<char*>(lc.begin());
    if (shmaddr == 0) {
        runtest.unresolved("LcShm::begin()");
        return;
    } else {
        runtest.pass("LcShm::begin()");
    }
    
    char *addr = shmaddr + LC_LISTENERS_START;
    memset(addr, 0, 1024);
    
    lc.close();

    // Now reconnect to the memory segment, and see if our name
    // is set.
    if (lc.connect(con1)) {
        runtest.pass("LcShm::connect()");
    } else {
        runtest.fail("LcShm::connect()");
    }
    
    if (strcmp(addr, "localhost:lc_reply") == 0) {
        runtest.pass("LcShm::addListener(lc_reply)");
    } else {
        runtest.fail("LcShm::addListener(lc_reply)");
    }
    
    string con2 = "localhost:lc_name1";
    if (lc.connect(con2)) {
        runtest.pass("LcShm::connect(lc_name1)");
    } else {
        runtest.fail("LcShm::connect(lc_name1)");
    }

    if (strcmp(addr, "localhost:lc_reply") == 0) {
        runtest.pass("LcShm::addListener(lc_reply)");
    } else {
        runtest.fail("LcShm::addListener(lc_reply)");
    }

    // Aftyer removing a listener, everything gets moved up
    // in the table. The last element gets zero'd out, so
    // we don't have duplicate entries.
    lc.removeListener(con1);
    if ((strcmp(addr, "localhost:lc_name1") == 0)
    && (addr[con1.size() + 1] == 0)
    && (addr[con1.size() + 2] == 0)
    && (addr[con1.size() + 3] == 0)) {
        runtest.pass("LcShm::removeListener(lc_reply)");
    } else {
        runtest.fail("LcShm::removeListener(lc_reply)");
    }
    
    Listener list(reinterpret_cast<uint8_t *>(shmaddr));
    vector<string>::const_iterator it;
    auto_ptr< vector<string> > listeners ( list.listListeners() );
    if (listeners->size() == 0) {
        cout << "Nobody is listening" << endl;
    } else {
        for (it=listeners->begin(); it!=listeners->end(); it++) {
            string str = *it;
	    if ((str[0] != ':') || (dbglogfile.getVerbosity() > 0)) {
		cout << " Listeners: " << str << endl;
	    }
        }
    }
    
}
Exemplo n.º 24
0
static bool 
compare_reads(gnash::IOChannel* reader, int fd, const char* first, const char* second)
{
	char buf[CHUNK_SIZE];
	char buf2[CHUNK_SIZE];

	stringstream ss;


	size_t consumed = 0;

	for(;;)
	{
		size_t sz1 = reader->read(buf, CHUNK_SIZE);
		size_t sz2 = read(fd, buf2, CHUNK_SIZE);

		if ( sz1 != sz2 )
		{
			ss << "Different read size from " << first
				<< " (" << sz1 << ") and " << second
				<< " (" << sz2 << ") file";
			runtest.fail(ss.str());
			dump_buffer("wrapped", buf, sz1, cout);
			dump_buffer("raw", buf2, sz2, cout);
			return false;
		}

		if ( sz1 == 0 ) {
			break;
		}

		if ( memcmp(buf, buf2, sz1) )
		{
			ss << "Different read content from " << first
				<< " and " << second << " file";
			runtest.fail(ss.str());
			dump_buffer("wrapped", buf, sz1, cout);
			dump_buffer("raw", buf2, sz2, cout);
			return false;
		}

		consumed+=sz1;
	}

	if ( consumed == 0 ) 
	{
		runtest.fail("No bytes read from either " + string(first) + " or " + string(second) + " file");
		return false;
	}

	if ( ! reader->eof() )
	{
		ss << "tu_file not at EOF at end of read";
		runtest.fail(ss.str());
		return false;
	}

	ss << "compared " << consumed << " bytes from "
		<< first << " and " << second;

	runtest.pass(ss.str());
	return true;


	return true;

}
Exemplo n.º 25
0
void
test_write(std::string &filespec)
{
    GNASH_REPORT_FUNCTION;
    
    SOL sol;
    AMF amf_obj;
    
//    char *data = const_cast<char *>("/dev/input/mic");
//    el.getData() = reinterpret_cast<uint8_t *>(data);
    amf::Element newel;

    double dub = 50.0;

//    amf::Element *el = new amf::Element("gain", dub);
    amf::Element *el = new amf::Element("gain", dub);
//    amf_obj.createElement(&el, "gain", dub);
    sol.addObj(el);

    if ((strcmp(el->getName(), "gain") == 0) &&
        (el->getType() == Element::NUMBER_AMF0) &&
        (el->to_number() == dub) &&
        (el->getLength() == AMF0_NUMBER_SIZE)) {
        runtest.pass("gain set");
    } else {
        runtest.fail("gain set");
    }
    
    el = new amf::Element("echosuppression", false);
    sol.addObj(el);
    if ((strcmp(el->getName(), "echosuppression") == 0) &&
        (el->getType() == Element::BOOLEAN_AMF0) &&
        (*el->getData() == 0) &&
        (el->getLength() == 1)) {
        runtest.pass("echosupression set");
    } else {
        runtest.fail("echosupression set");
    }
    
    string name = "defaultmicrophone";
    string data = "/dev/input/mic";
    el = new amf::Element("defaultmicrophone", data);
    sol.addObj(el);
    if ((el->getName() == name) &&
        (el->getType() == Element::STRING_AMF0) &&
        (memcmp(el->getData(), data.c_str(), el->getLength()) == 0) &&
        (el->getLength() == data.size())) {
        runtest.pass("defaultmicrophone set");
    } else {
        runtest.fail("defaultmicrophone set");
    }

    data = "";
    el = new amf::Element("defaultcamera", data);
    sol.addObj(el);
    if ((strcmp(el->getName(), "defaultcamera") == 0) &&
        (el->getType() == Element::STRING_AMF0) &&
        (el->getLength() == 0)) {
        runtest.pass("defaultcamera set");
    } else {
        runtest.fail("defaultcamera set");
    }
    
    dub = 100.0;
    el = new amf::Element("defaultklimit", dub);
//    el = new amf::Element("defaultklimit", dub);
    sol.addObj(el);
    if ((strcmp(el->getName(), "defaultklimit") == 0) &&
        (el->getType() == Element::NUMBER_AMF0) &&
        (el->to_number() == dub) &&
        (el->getLength() == AMF0_NUMBER_SIZE)) {
        runtest.pass("defaultklimit set");
    } else {
        runtest.fail("defaultklimit set");
    }
    
    el = new amf::Element("defaultalways", false);
    sol.addObj(el);
    if ((strcmp(el->getName(), "defaultalways") == 0) &&
        (el->getType() == Element::BOOLEAN_AMF0) &&
        (el->to_bool() == false) &&
        (el->getLength() == 1)) {
        runtest.pass("defaultalways set");
    } else {
        runtest.fail("defaultalways set");
    }

    el = new amf::Element("crossdomainAllow", true);
    sol.addObj(el);
    if ((strcmp(el->getName(), "crossdomainAllow") == 0) &&
        (el->getType() == Element::BOOLEAN_AMF0) &&
        (el->to_bool() == true) &&
        (el->getLength() == 1)) {
        runtest.pass("crossdomainAllow set");
    } else {
        runtest.fail("crossdomainAllow set");
    }

    el = new amf::Element("crossdomainAlways", true);
    sol.addObj(el);
    if ((strcmp(el->getName(), "crossdomainAlways") == 0) &&
        (el->getType() == Element::BOOLEAN_AMF0) &&
        (*el->getData() == 1) &&
        (el->getLength() == 1)) {
        runtest.pass("crossdomainAlways set");
    } else {
        runtest.fail("crossdomainAlways set");
    }

    el = new amf::Element("allowThirdPartyLSOAccess", true);
    sol.addObj(el);
    if ((strcmp(el->getName(), "allowThirdPartyLSOAccess") ==0) &&
        (el->getType() == Element::BOOLEAN_AMF0) &&
        (*el->getData() == 1) &&
        (el->getLength() == 1)) {
        runtest.pass("allowThirdPartyLSOAccess set");
    } else {
        runtest.fail("allowThirdPartyLSOAccess set");
    }
    
    el = new amf::Element("localSecPath", data);
    sol.addObj(el);
    if ((strcmp(el->getName(), "localSecPath") == 0) &&
        (el->getType() == Element::STRING_AMF0) &&
        (el->getLength() == 0)) {
        runtest.pass("localSecPath set");
    } else {
        runtest.fail("localSecPath set");
    }

    // Grabbed from GDB when reading this huge value
    dub = 1.8379389592608646e-304;
    swapBytes(&dub, 8);
    
    el = new amf::Element("localSecPathTime", dub);
    sol.addObj(el);
    if ((strcmp(el->getName(), "localSecPathTime") ==0) &&
        (el->getType() == Element::NUMBER_AMF0) &&
        (memcmp(el->getData(), &dub, AMF0_NUMBER_SIZE) == 0) &&
        (*((double *)el->getData()) == dub) &&
        (el->getLength() == AMF0_NUMBER_SIZE)) {
        runtest.pass("localSecPathTime set");
    } else {
        runtest.fail("localSecPathTime set");
    }
    sol.dump();
    // now write the data to disk
    sol.writeFile(filespec, "settings");
}
Exemplo n.º 26
0
void
test_isnan()
{
	float num = 0;

	if(!isNaN(num)) {
            runtest.pass("isNaN(0)");
        } else {
            runtest.fail("isNaN(0)");
        }
        
	num /= 9999999;

	if(!isNaN(num)) {
            runtest.pass("isNaN(9999999)");
        } else {
            runtest.fail("isNaN(9999999)");
        }
	if(isFinite(num)) {
            runtest.pass("isFinite(9999999)");
        } else {
            runtest.fail("isFinite(9999999)");
        }

	num = std::numeric_limits<float>::quiet_NaN();

	if(isNaN(num)) {
            runtest.pass("isNaN(quiet_NaN)");
        } else {
            runtest.fail("isNaN(quiet_NaN)");
        }
	if(!isFinite(num)) {
            runtest.pass("isFinite(quiet_NaN)");
        } else {
            runtest.fail("isFinite(quiet_NaN)");
        }

	num = std::numeric_limits<float>::infinity();
	
	if(!isNaN(num)) {
            runtest.pass("isNaN(infinity)");
        } else {
            runtest.fail("isNaN(infinity)");
        }
	if(!isFinite(num)) {
            runtest.pass("isFinite(infinity)");
        } else {
            runtest.fail("isFinite(infinity)");
        }

	num = 1.0 / 0.0;

	if(!isNaN(num)) {
            runtest.pass("isNaN(1.0/0.0)");
        } else {
            runtest.fail("isNaN(1.0/0.0)");
        }
	if(!isFinite(num)) {
            runtest.pass("isFinite(1.0/0.0)");
        } else {
            runtest.fail("isFinite(1.0/0.0)");
        }

	int intgr = num;

	num = intgr;

	if(!isNaN(num)) {
            runtest.pass("isNaN(int)");
        } else {
            runtest.fail("isNaN(int)");
        }
	if(isFinite(num)) {
            runtest.pass("isFinite(int)");
        } else {
            runtest.fail("isFinite(int)");
        }
}
Exemplo n.º 27
0
int
main(int argc, char *argv[])
{
    // FIXME: for now, always run verbose till this supports command line args
    dbglogfile.setVerbosity();

    rawfb::RawFBDevice rfb;
    
    if (!rfb.initDevice(argc, argv)) {
        runtest.fail("RawFBDevice:InitDevice()");
    } else {
        runtest.pass("RawFBDevice:InitDevice()");
    }

    bool ret = rfb.attachWindow(rfb.getHandle());
    if (rfb.getFBMemory()) {
        runtest.pass("RawFBDevice::attachWindow()");
    } else {
        runtest.fail("RawFBDevice::attachWindow()");
    }
    
#ifdef ENABLE_DOUBLE_BUFFERING
    if (rfb.getOffscreenBuffer()) {
        runtest.pass("RawFBDevice::getOffscreenBuffer()");
    } else {
        runtest.fail("RawFBDevice::getOffscreenBuffer()");
    }
#else
    runtest.untested("RawFBDevice::getOffscreenBuffer()");
#endif
    
    if (ret && rfb.getStride()) {
        runtest.pass("RawFBDevice::getStride()");
    } else {
        runtest.fail("RawFBDevice::getStride()");
    }
    
    if (ret && rfb.getWidth()) {
        runtest.pass("RawFBDevice::getWidth()");
    } else {
        runtest.fail("RawFBDevice::getWidth()");
    }
    
    if (ret && rfb.getHeight()) {
        runtest.pass("RawFBDevice::getHeight()");
    } else {
        runtest.fail("DirecTFBDevice::getHeight()");
    }

    if (ret && rfb.isSingleBuffered()) {
        runtest.pass("RawFBDevice::is*Buffered()");
    } else {
        runtest.fail("RawFBDevice::is*Buffered()");
    }
    
    if (ret && rfb.getDepth()) {
        runtest.pass("RawFBDevice::getDepth()");
    } else {
        runtest.fail("RawFBDevice::getDepth()");
    }
    
    if (ret && rfb.getRedSize() > 0) {
        runtest.pass("RawFBDevice::getRedSize()");
    } else {
        runtest.fail("RawFBDevice::getRedSize()");
    }

    if (ret && rfb.getGreenSize() > 0) {
        runtest.pass("RawFBDevice::getGreenSize()");
    } else {
        runtest.fail("RawFBDevice::getGreenSize()");
    }

    if (ret && rfb.getBlueSize() > 0) {
        runtest.pass("RawFBDevice::getBlueSize()");
    } else {
        runtest.fail("RawFBDevice::getBlueSize()");
    }

#if 0
    if (rfb.setGrayscaleLUT8()) {
        runtest.pass("RawFBDevice::setGrayscaleLUT8()");
    } else {
        runtest.fail("RawFBDevice::setGrayscaleLUT8()");
    }
#endif
    
    // AGG uses these to calculate the poixel format
#ifdef RENDERER_AGG
    if (ret && rfb.getRedOffset() > 0) {
        runtest.pass("RawFBDevice::getRedOffset()");
    } else {
        runtest.fail("RawFBDevice::getRedOffset()");
    }
    
    if (ret && rfb.getGreenOffset() > 0) {
        runtest.pass("RawFBDevice::getGreenOffset()");
    } else {
        runtest.fail("RawFBDevice::getGreenOffset()");
    }
    
    if (ret && rfb.getBlueOffset() == 0) {
        runtest.pass("RawFBDevice::getBlueOffset()");
    } else {
        runtest.fail("RawFBDevice::getBlueOffset()");
    }
#endif

    // This is a manual test to see if we can draw a line on the
    // raw framebuffer to make sure it got initialized correctly.
    int x = 0, y = 0;
    long location = 0;
    int line_length = rfb.getStride();

    std::uint8_t *fbp = 0;
    fbp = rfb.getFBMemory();

    if (fbp > 0) {
        runtest.pass("RawFBDevice::getFBMemory()");
    } else {
        runtest.fail("RawFBDevice::getFBMemory()");
        exit;
    }
    
    for(y=100; y<102; y++);            /* Where we are going to put the pixel */
    
    for(x=0; x<200; x++) {
        /* Figure out where in memory to put the pixel */
        location = x * (rfb.getDepth()/8) + y * line_length;
        
        *(fbp + location) = 89;    /* Some blue */
        *(fbp + location + 1) = 40; /* A little green */
        *(fbp + location + 2) = 200; /* A lot of red */
        *(fbp + location + 3) = 0; /* No transparency */
    }
    return 0;
}
Exemplo n.º 28
0
void
test_read()
{

    LcShm lc;
    char *shmaddr;

    string con1 = "lc_reply";
    if (lc.connect(con1)) {
        runtest.pass("LcShm::connect()");
    } else {
        runtest.fail("LcShm::connect()");
    }

    shmaddr = reinterpret_cast<char*>(lc.begin());
//    if (memcmp(shmaddr, con1.c_str():
    // Since this is a test case, populate the memory with known good data
    string srcdir = SRCDIR;
    srcdir += "/segment.raw";
    int fd = ::open(srcdir.c_str(), O_RDONLY);
    void *dataptr = mmap(0, 64528, PROT_READ, MAP_SHARED, fd, 0);
#if 1
    if (dataptr != (void*)-1) {
        memcpy(shmaddr, dataptr, 64528);
    } else {
        cerr << "ERROR: couldn't map input file!" << endl;
    }
#endif
    ::close(fd);
    
    Listener list(reinterpret_cast<uint8_t *>(shmaddr));
    vector<string>::const_iterator it;
    auto_ptr< vector<string> > listeners ( list.listListeners() );
    if (listeners->size() == 0) {
        cout << "Nobody is listening" << endl;
    } else {
        for (it=listeners->begin(); it!=listeners->end(); it++) {
            string str = *it;
	    if ((str[0] != ':') || (dbglogfile.getVerbosity() > 0)) {
		cout << " Listeners: " << str << endl;
	    }
        }
    }

#if 0
    string str = "localhost:lc_name1";
    if (list.findListener(str)) {
        runtest.pass("LcShm::findListener()");
    } else {
        runtest.fail("LcShm::findListener()");
    }
#endif
    
//    list.addListener(filespec);
    listeners = list.listListeners(); // will delete former listener list
    if (listeners->empty()) {
        cout << "Nobody is listening" << endl;
    } else {
        for (it=listeners->begin(); it!=listeners->end(); it++) {
            string str = *it;
	    if ((str[0] != ':') || (dbglogfile.getVerbosity() > 0)) {
		cout << " Listeners: " << str << endl;
	    }
        }
    }

//    boost::uint8_t *ptr = lc.parseHeader(reinterpret_cast<boost::uint8_t *>(shmaddr));
//    vector<amf::Element *> ellist = lc.parseBody(ptr);
//    cout << "# of AMF Elements in file: " << ellist.size() << endl;
//    lc.dump();
    lc.close();

    // cleanup
//    delete ptr;
}
Exemplo n.º 29
0
void
test_write()
{
#if 0
    AMF amf_obj;
    
//    char *data = const_cast<char *>("/dev/input/mic");
//    el.data = reinterpret_cast<uint8_t *>(data);
    AMF::amf_element_t el;
    AMF::amf_element_t newel;

    double dub = 50.0;
    amf_obj.createElement(&el, "gain", dub);
    sol.addObj(el);
    if ((el.name == "gain") &&
        (el.type == AMF::NUMBER) &&
        (memcmp(el.data, &dub, AMF0_NUMBER_SIZE) == 0) &&
        (*((double *)el.data) == dub) &&
        (el.length == AMF0_NUMBER_SIZE)) {
        runtest.pass("gain set");
    } else {
        runtest.fail("gain set");
    }

    boost::uint8_t *foo = amf_obj.encodeVariable(el); 
    char *ptr = (char *)amf_obj.extractVariable(&newel, foo);
    if ((el.name == newel.name) &&
        (el.length == newel.length) &&
        (newel.type == AMF::NUMBER) &&
        (memcmp(el.data, newel.data, el.length) == 0)) {
        runtest.pass("gain number encoded/extracted");
    } else {
        runtest.fail("gain number encoded/extracted");
    }
    
    
    amf_obj.createElement(&el, "echosuppression", false);
    sol.addObj(el);
    if ((el.name == "echosuppression") &&
        (el.type == AMF::BOOLEAN) &&
        (*el.data == 0) &&
        (el.length == 1)) {
        runtest.pass("echosupression set");
    } else {
        runtest.fail("echosupression set");
    }
    
    foo = amf_obj.encodeVariable(el); 
    ptr = (char *)amf_obj.extractVariable(&newel, reinterpret_cast<uint8_t *>(foo));
    if ((el.name == newel.name) &&
        (el.type == AMF::BOOLEAN) &&
        (el.length == newel.length) &&
        (memcmp(el.data, newel.data, el.length) == 0)) {
        runtest.pass("echosupression bool(false) encoded/extracted");
    } else {
        runtest.fail("echosupression bool(false) encoded/extracted");
    }
    

    string name = "defaultmicrophone";
    string data = "/dev/input/mic";
    amf_obj.createElement(&el, name, data);
    sol.addObj(el);
    if ((el.name == name) &&
        (el.type == AMF::STRING) &&
        (memcmp(el.data, data.c_str(), el.length) == 0) &&
        (el.length == data.size())) {
        runtest.pass("defaultmicrophone set");
    } else {
        runtest.fail("defaultmicrophone set");
    }

    amf_obj.createElement(&el, "defaultcamera", "");
    sol.addObj(el);
    if ((el.name == "defaultcamera") &&
        (el.type == AMF::STRING) &&
        (*el.data == 0) &&
        (el.length == 0)) {
        runtest.pass("defaultcamera set");
    } else {
        runtest.fail("defaultcamea set");
    }

    dub = 100.0;
    amf_obj.createElement(&el, "defaultklimit", dub);
    sol.addObj(el);
    if ((el.name == "defaultklimit") &&
        (el.type == AMF::NUMBER) &&
        (memcmp(el.data, &dub, AMF0_NUMBER_SIZE) == 0) &&
        (*((double *)el.data) == dub) &&
        (el.length == AMF0_NUMBER_SIZE)) {
        runtest.pass("defaultklimit set");
    } else {
        runtest.fail("defaultklimit set");
    }

    amf_obj.createElement(&el, "defaultalways", false);
    sol.addObj(el);
    if ((el.name == "defaultalways") &&
        (el.type == AMF::BOOLEAN) &&
        (*el.data == 0) &&
        (el.length == 1)) {
        runtest.pass("defaultalways set");
    } else {
        runtest.fail("defaultalways set");
    }

    amf_obj.createElement(&el, "crossdomainAllow", true);
    sol.addObj(el);
    if ((el.name == "crossdomainAllow") &&
        (el.type == AMF::BOOLEAN) &&
        (*el.data == 1) &&
        (el.length == 1)) {
        runtest.pass("crossdomainAllow set");
    } else {
        runtest.fail("crossdomainAllow set");
    }

    amf_obj.createElement(&el, "crossdomainAlways", true);
    sol.addObj(el);
    if ((el.name == "crossdomainAlways") &&
        (el.type == AMF::BOOLEAN) &&
        (*el.data == 1) &&
        (el.length == 1)) {
        runtest.pass("crossdomainAlways set");
    } else {
        runtest.fail("crossdomainAlways set");
    }

    amf_obj.createElement(&el, "allowThirdPartyLSOAccess", true);
    sol.addObj(el);
    if ((el.name == "allowThirdPartyLSOAccess") &&
        (el.type == AMF::BOOLEAN) &&
        (*el.data == 1) &&
        (el.length == 1)) {
        runtest.pass("allowThirdPartyLSOAccess set");
    } else {
        runtest.fail("allowThirdPartyLSOAccess set");
    }

    // FIXME: Why does GCC keep linking this to the bool
    // version instead ?
    boost::intrusive_ptr<gnash::as_object> as;
    amf_obj.createElement(&el, "trustedPaths", &as);
    if ((el.name == "trustedPaths") &&
        (el.type == AMF::OBJECT)) {
        runtest.pass("trustedPaths set");
    } else {
        runtest.fail("trustedPaths set");
        // force the type so the binary output stays correct.
        // As this builds a null object, we get away with it,
        // and it helps debugging to have the hexdumps of the
        // .sol files match the originals.
        el.type = AMF::OBJECT;        
        el.length = 0;
    }
    sol.addObj(el);

    amf_obj.createElement(&el, "localSecPath", "");
    sol.addObj(el);
    if ((el.name == "localSecPath") &&
        (el.type == AMF::STRING) &&
        (*el.data == 0) &&
        (el.length == 0)) {
        runtest.pass("localSecPath set");
    } else {
        runtest.fail("localSecPath set");
    }

    // Grabbed from GDB when reading this huge value
    dub = 1.8379389592608646e-304;
    swapBytes(&dub, 8);
    
    amf_obj.createElement(&el, "localSecPathTime", dub);
    sol.addObj(el);
    if ((el.name == "localSecPathTime") &&
        (el.type == AMF::NUMBER) &&
        (memcmp(el.data, &dub, AMF0_NUMBER_SIZE) == 0) &&
        (*((double *)el.data) == dub) &&
        (el.length == AMF0_NUMBER_SIZE)) {
        runtest.pass("localSecPathTime set");
    } else {
        runtest.fail("localSecPathTime set");
    }

//    sol.dump();
    // now write the data to disk
    sol.writeFile(filespec, "settings");
#endif
}
Exemplo n.º 30
0
void
test_geometry(Renderer *renderer, const std::string &type)
{
    cout << "\t" << type << " geometry tests" << endl;
    
    if (!renderer) {
        runtest.unresolved("No renderer to test!");
        return;
    }
    
    int x = 10;
    int y = 10;
    geometry::Point2d nz(200, 0);
    geometry::Point2d z(x, y);
    geometry::Range2d<int> pixelbounds;
    geometry::Range2d<int> worldbounds;
    Timer tpixtow("pixel_to_world(int, int)");
    z = renderer->pixel_to_world(x, y);
    tpixtow.stop();
    
    if ((z.x >= 199) || (z.y >= 199)) {
        runtest.pass(std::string("pixel_to_world(int, int) ") + tpixtow.elapsed());
    } else {
        runtest.fail(std::string("pixel_to_world(int, int) ") + tpixtow.elapsed());
    }
    
#if 0
    Timer tpixtow2("pixel_to_world(pixelbounds)");
    worldbounds = renderer->pixel_to_world(pixelbounds);
    tpixtow2.stop();
    if (worldbounds.isNull()) {
        runtest.pass(std::string("pixel_to_world(geometry::Range2d<int>) ") + tpixtow2.elapsed());
    } else {
        runtest.fail(std::string("pixel_to_world(geometry::Range2d<int>) ") + tpixtow2.elapsed());
    }
#else
    runtest.untested("pixel_to_world(geometry::Range2d<int>)");
#endif
    
    Timer twtop("world_to_pixel(geometry::Range2d<int>)");
    pixelbounds = renderer->world_to_pixel(worldbounds);
    twtop.stop();
    if (pixelbounds.isNull()) {
        runtest.pass(std::string("world_to_pixel(geometry::Range2d<int>) ") + twtop.elapsed());
    } else {
        runtest.fail(std::string("world_to_pixel(geometry::Range2d<int>) ") + twtop.elapsed());
    }
    
    SWFRect bounds;
    Timer tbounds1("bounds_in_clipping_area(SWFRect)");
    bool ret = renderer->bounds_in_clipping_area(bounds);
    tbounds1.stop();
    if (ret) {
        runtest.pass(std::string("bounds_in_clipping_area(SWFRect) ") + tbounds1.elapsed());
    } else {
        runtest.fail(std::string("bounds_in_clipping_area(SWFRect) ") + tbounds1.elapsed());
    }
    
    InvalidatedRanges ranges;
    Timer tbounds2("bounds_in_clipping_area(InvalidatedRanges)");
    ret = renderer->bounds_in_clipping_area(ranges);
    tbounds2.stop();
    if (!ret) {
        runtest.pass(std::string("bounds_in_clipping_area(InvalidatedRanges) ") + tbounds2.elapsed());
    } else {
        runtest.fail(std::string("bounds_in_clipping_area(InvalidatedRanges) ") + tbounds2.elapsed());
    }

    Timer tbounds3("bounds_in_clipping_area(geometry::Range2d<int>)");
    ret = renderer->bounds_in_clipping_area(pixelbounds);
    tbounds3.stop();
    if (!ret) {
        runtest.pass(std::string("bounds_in_clipping_area(geometry::Range2d<int>) ") + tbounds3.elapsed());
    } else {
        runtest.fail(std::string("bounds_in_clipping_area(geometry::Range2d<int>) ") + tbounds3.elapsed());
    }
}