~ubuntu-branches/ubuntu/karmic/gnash/karmic

« back to all changes in this revision

Viewing changes to testsuite/libnet.all/test_cque.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2008-10-13 14:29:49 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20081013142949-f6qdvnu4mn05ltdc
Tags: 0.8.4~~bzr9980-0ubuntu1
* new upstream release 0.8.4 (LP: #240325)
* ship new lib usr/lib/gnash/libmozsdk.so.* in mozilla-plugin-gnash
  - update debian/mozilla-plugin-gnash.install
* ship new lib usr/lib/gnash/libgnashnet.so.* in gnash-common
  - update debian/gnash-common.install
* add basic debian/build_head script to build latest CVS head packages.
  - add debian/build_head
* new sound architecture requires build depend on libsdl1.2-dev
  - update debian/control
* head build script now has been completely migrated to bzr (upstream +
  ubuntu)
  - update debian/build_head
* disable kde gui until klash/qt4 has been fixed; keep kde packages as empty
  packages for now.
  - update debian/rules
  - debian/klash.install
  - debian/klash.links
  - debian/klash.manpages
  - debian/konqueror-plugin-gnash.install
* drop libkonq5-dev build dependency accordingly
  - update debian/control
* don't install headers manually anymore. gnash doesnt provide a -dev
  package after all
  - update debian/rules
* update libs installed in gnash-common; libgnashserver-*.so is not available
  anymore (removed); in turn we add the new libgnashcore-*.so
  - update debian/gnash-common.install
* use -Os for optimization and properly pass CXXFLAGS=$(CFLAGS) to configure
  - update debian/rules
* touch firefox .autoreg in postinst of mozilla plugin
  - update debian/mozilla-plugin-gnash.postinst
* link gnash in ubufox plugins directory for the plugin alternative switcher
  - add debian/mozilla-plugin-gnash.links
* suggest ubufox accordingly
  - update debian/control
* add new required build-depends on libgif-dev
  - update debian/control
* add Xb-Npp-Description and Xb-Npp-File as new plugin database meta data
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// 
 
2
//   Copyright (C) 2008 Free Software Foundation, Inc.
 
3
// 
 
4
// This program is free software; you can redistribute it and/or modify
 
5
// it under the terms of the GNU General Public License as published by
 
6
// the Free Software Foundation; either version 3 of the License, or
 
7
// (at your option) any later version.
 
8
// 
 
9
// This program is distributed in the hope that it will be useful,
 
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
// GNU General Public License for more details.
 
13
// 
 
14
// You should have received a copy of the GNU General Public License
 
15
// along with this program; if not, write to the Free Software
 
16
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
17
//
 
18
 
 
19
#ifdef HAVE_CONFIG_H
 
20
#include "gnashconfig.h"
 
21
#endif
 
22
 
 
23
#ifdef HAVE_STDARG_H
 
24
#include <cstdarg>
 
25
#endif
 
26
 
 
27
#include <sys/stat.h>
 
28
#ifdef HAVE_UNISTD_H
 
29
#include <unistd.h>
 
30
#endif
 
31
 
 
32
#include <regex.h>
 
33
#include <cstdio>
 
34
#include <cerrno>
 
35
#include <iostream>
 
36
#include <fstream>
 
37
#include <cstring>
 
38
#include <vector>
 
39
#include <boost/cstdint.hpp>
 
40
 
 
41
#ifdef HAVE_DEJAGNU_H
 
42
#include "dejagnu.h"
 
43
#else
 
44
#include "check.h"
 
45
#endif
 
46
 
 
47
#include "log.h"
 
48
#include "buffer.h"
 
49
#include "network.h"
 
50
#include "cque.h"
 
51
#include "amf.h"
 
52
 
 
53
using namespace amf;
 
54
using namespace std;
 
55
using namespace gnash;
 
56
using namespace boost;
 
57
using namespace amf;
 
58
 
 
59
TestState runtest;
 
60
//LogFile& dbglogfile = LogFile::getDefaultInstance();
 
61
 
 
62
int
 
63
main (int /*argc*/, char** /*argv*/) {
 
64
    gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
 
65
    dbglogfile.setVerbosity();
 
66
 
 
67
    CQue que;
 
68
 
 
69
    Buffer buf;
 
70
    // populate the buffer
 
71
    boost::uint8_t *ptr = buf.reference();
 
72
    for (size_t i=1; i< buf.size(); i++) {
 
73
        ptr[i] = i+' ';
 
74
    }
 
75
 
 
76
//     boost::uint8_t *test = new uint8_t[6];
 
77
//     memcpy(test, "hell", 4);
 
78
 
 
79
    // Push one buffer on the fifo. The default is the incoming fifo,
 
80
    // which is the one where data flows from the network to the queue.
 
81
    que.push(&buf);
 
82
    if (que.size() == 1) {
 
83
        runtest.pass ("CQue::push(Buffer *)");
 
84
    } else {
 
85
        runtest.fail ("CQue::push(Buffer *)");
 
86
    }
 
87
    
 
88
    // Test push. When dumpimg, the second address should be different than the first,
 
89
    // as well as the size. The outgoing queue should be uneffected.
 
90
    Buffer buf1;
 
91
    buf1.resize(112);
 
92
    que.push(&buf1);
 
93
    if (que.size() == 2) {
 
94
        runtest.pass ("CQue::pushin(Buffer *)");
 
95
    } else {
 
96
        runtest.fail ("CQue::pushin(Buffer *)");
 
97
    }
 
98
 
 
99
    // Nuke the array
 
100
    que.clear();
 
101
    if (que.size() == 0) {
 
102
        runtest.pass ("CQue::clearall()");
 
103
    } else {
 
104
        runtest.fail ("CQue::clearall()");
 
105
    }
 
106
 
 
107
    
 
108
    que.push(&buf);
 
109
    Buffer *buf2 = que.peek();
 
110
    if ((buf2 == &buf) && (que.size() == 1)) {
 
111
        runtest.pass ("CQue::peek()");
 
112
    } else {
 
113
        runtest.fail ("CQue::peek()");
 
114
    }
 
115
 
 
116
    Buffer *buf3 = que.peek();
 
117
     if ((buf3 == &buf) && (que.size() == 1)) {
 
118
         runtest.pass ("CQue::pop()");
 
119
     } else {
 
120
         runtest.fail ("CQue::pop()");
 
121
     }
 
122
 
 
123
     que.push(&buf1);
 
124
     que.push(&buf1);
 
125
     size_t firstsize = que.size();
 
126
     que.remove(&buf);
 
127
     if (que.size() == firstsize - 1) {
 
128
         runtest.pass ("CQue::remove()");
 
129
     } else {
 
130
         runtest.fail ("CQue::remove()");
 
131
     }
 
132
 
 
133
     // Make some test buffers
 
134
     Buffer merge1, merge2, merge3;
 
135
     size_t i;
 
136
     ptr = merge1.reference();
 
137
     for (i=0; i<gnash::NETBUFSIZE; i++) {
 
138
         ptr[i] = i*'A';
 
139
     }
 
140
     que.push(&merge1);
 
141
     
 
142
     ptr = merge2.reference();
 
143
     for (i=0; i<gnash::NETBUFSIZE; i++) {
 
144
         ptr[i] = i+'a';
 
145
     }
 
146
     que.push(&merge2);
 
147
 
 
148
     merge3.resize(96);
 
149
     ptr = merge3.reference();
 
150
     for (i=0; i<96; i++) {
 
151
         ptr[i] = i+' ';
 
152
     }
 
153
     que.push(&merge3);
 
154
 
 
155
     // A merge gives us one big buffer where there were several buffers
 
156
     Buffer *foo = que.merge(&merge1);
 
157
     if (foo->size() == (gnash::NETBUFSIZE * 2) + 96) {
 
158
         runtest.pass ("CQue::merge()");
 
159
     } else {
 
160
         runtest.fail ("CQue::merge()");
 
161
     }
 
162
 
 
163
     que.pop();
 
164
 
 
165
//     que.dump();
 
166
}
 
167