gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/rtmp r9636: The Element::init() method has


From: rob
Subject: [Gnash-commit] /srv/bzr/gnash/rtmp r9636: The Element::init() method has been dropped, use make*() methods or
Date: Wed, 17 Sep 2008 21:43:06 -0600
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9636
committer: address@hidden
branch nick: rtmp
timestamp: Wed 2008-09-17 21:43:06 -0600
message:
  The Element::init() method has been dropped, use make*() methods or
  constructors instead. Add more Element test cases. Drop test_write from
  test_sol, as it's totally bogus.
modified:
  testsuite/libamf.all/test_el.cpp
  testsuite/libamf.all/test_sol.cpp
  testsuite/libnet.all/test_rtmp.cpp
  utilities/flvdumper.cpp
=== modified file 'testsuite/libamf.all/test_el.cpp'
--- a/testsuite/libamf.all/test_el.cpp  2008-09-03 20:45:59 +0000
+++ b/testsuite/libamf.all/test_el.cpp  2008-09-18 03:43:06 +0000
@@ -50,7 +50,6 @@
 
 // Prototypes for test cases
 static void test_construct();
-static void test_destruct();
 static void test_make();
 static void test_operators();
 static void test_properties();
@@ -114,112 +113,57 @@
     test_construct();
     test_make();
     test_operators();
-    test_destruct();
     test_properties();
 }
 
 void
 test_properties()
 {
+    std::vector<Element *> data1;
+
+    const char *str1 = "property one";
+    Element *prop1 = new Element(str1);
+    data1.push_back(prop1);
+
+    string str2 = "property two";
+    Element *prop2 = new Element(str2);
+    data1.push_back(prop2);
+
+    Element *prop3 = new Element("property three");
+    data1.push_back(prop3);
+
+    double num = 123.456;
+    Element *prop4 = new Element(num);
+    data1.push_back(prop4);
+    
     Element top;
-    top.makeObject("app");
-
-    Element *prop1 = new Element;
-    prop1->makeString("property one");
-    top.addProperty(prop1);
+    top.makeObject("app", data1);
     
-    Element *prop2 = new Element;
-    prop2->makeString("property two");
-    top.addProperty(prop2);
-
-    if (top.propertySize() == 2) {
-        runtest.pass("Adding property");
+    if ((top.propertySize() == 4)
+        && (top.getType() == Element::OBJECT_AMF0)
+        && (strcmp(top[0]->to_string(), str1) == 0)
+        && (top[1]->to_string() == str2)
+        && (strcmp(top[2]->to_string(), "property three") == 0)
+        && (top[3]->to_number() == num)) {
+        runtest.pass("Made object with properties");
     } else {
-        runtest.fail("Adding property");
+        runtest.fail("Made object with properties");
     }
-    
+
+    data1.clear();
+
 //    top.dump();
 }
 
 void
 test_construct()
 {
-    // First test the init method, which is all the constructor does anyway.. 
First
-    // we test just making regular elements instead of named elements, ie...
-    // AMF "variables".
-//     Element el1;
-//     if (el1.getType() == Element::NOTYPE) {
-//         runtest.pass("Created empty element");
-//     } else {
-//         runtest.fail("Created empty element");
-//     }
-
-    Element el2;
-    double dub = 54.3;
-    el2.init(dub);
-    if ((el2.getType() == Element::NUMBER_AMF0) &&
-        (el2.to_number() == dub)) {
-        runtest.pass("Initialized as double element");
-    } else {
-        runtest.fail("Initialized as double element");
-    }
-
-    Element el3;
+
+    // Test creating number elements. An element with a name is a property.
+    double dub = 23.45;
     bool flag = true;
-    el3.init(flag);
-    if ((el3.getType() == Element::BOOLEAN_AMF0) &&
-        (el3.to_bool() == true)) {
-        runtest.pass("Initialized as bool element");
-    } else {
-        runtest.fail("Initialized as bool element");
-    }
-
-    Element el4;
-    string str = "Hello World";
-    el4.init(str);
-    if ((el4.getType() == Element::STRING_AMF0) &&
-        (el4.getLength() == str.size())) {
-        runtest.pass("Initialized as string element");
-    } else {
-        runtest.fail("Initialized as string element");
-    }
-
-    // Now test init with the variable name
-    Element el5;
-    dub = 2.456;
-    el5.init("test1", dub);
-    if ((el5.getType() == Element::NUMBER_AMF0) &&
-        (strcmp(el5.getName(), "test1") == 0) &&
-        (el5.to_number() == dub)) {
-        runtest.pass("Initialized as double element with name");
-    } else {
-        runtest.fail("Initialized as double element with name");
-    }
-
-    Element el6;
-    flag = true;
-    el6.init("test2", flag);
-    if ((el6.getType() == Element::BOOLEAN_AMF0) &&
-        (strcmp(el6.getName(), "test2") == 0) &&
-        (el6.to_bool() == true)) {
-        runtest.pass("Initialized as bool element with name");
-    } else {
-        runtest.fail("Initialized as bool element with name");
-    }
-
-    Element el7;
-    str = "Hello World";
-    el7.init("test3", str);
-    if ((el7.getType() == Element::STRING_AMF0) &&
-        (strcmp(el7.getName(), "test3") == 0) &&
-        (el7.getLength() == str.size())) {
-        runtest.pass("Initialized as string element with name");
-    } else {
-        runtest.fail("Initialized as string element with name");
-    }
-
-    // Now test the actual constructor
-    dub = 23.45;
+    string str = "Guten Tag";
+
     Element elnum1(dub);
     if ((elnum1.getType() == Element::NUMBER_AMF0) &&
         (elnum1.to_number() == dub)) {
@@ -237,7 +181,6 @@
         runtest.fail("Constructed as bool element");
     }
 
-    str = "Guten Tag";
     Element elstr1(str);
     if ((elstr1.getType() == Element::STRING_AMF0) &&
         (elstr1.getLength() == str.size())) {
@@ -275,11 +218,6 @@
 }
 
 void
-test_destruct()
-{
-}
-
-void
 test_make()
 {
     Element el1;
@@ -351,7 +289,7 @@
 
     Element el8;
     el8.clear();
-    el8.makeObject("app");
+    el8.makeObject();
     if (el8.getType() == Element::OBJECT_AMF0) {
         runtest.pass("Made Object element");
     } else {
@@ -487,6 +425,33 @@
     } else {
         runtest.pass("Element::operator=(Element &)");
     }
+    
+    Element el4;
+    string str4 = "Hello World";
+    el4 = str4;
+    if (el4.to_string() == str4) {
+        runtest.pass("Element::operator=(string &)");
+    } else {
+        runtest.fail("Element::operator=(string &)");
+    }
+
+    Element el5;
+    double num5 = 1234.4567;
+    el5 = num5;
+    if (el5.to_number() == num5) {
+        runtest.pass("Element::operator=(double)");
+    } else {
+        runtest.fail("Element::operator=(double)");
+    }
+
+    Element el6;
+    bool flag6 = true;
+    el6 = flag6;
+    if (el6.to_bool() == flag6) {
+        runtest.pass("Element::operator=(bool)");
+    } else {
+        runtest.fail("Element::operator=(bool)");
+    }
 }
 
 static void

=== modified file 'testsuite/libamf.all/test_sol.cpp'
--- a/testsuite/libamf.all/test_sol.cpp 2008-08-13 19:23:10 +0000
+++ b/testsuite/libamf.all/test_sol.cpp 2008-09-18 03:43:06 +0000
@@ -62,7 +62,7 @@
 static TestState runtest;
 
 static void test_read(std::string &filespec);
-static void test_write(std::string &filespec);
+//static void test_write(std::string &filespec);
 bool test_sol(std::string &filespec);
 
 LogFile& dbglogfile = LogFile::getDefaultInstance();
@@ -175,8 +175,7 @@
     filespec += "/testout.sol";    
     // Write a .sol file
     
-    test_write(filespec);
-//    test_read(filespec);
+//    test_write(filespec);
     
 //    test_sol();
 }
@@ -215,6 +214,7 @@
     delete hex1;
 }
 
+#if 0
 void
 test_write(std::string &filespec)
 {
@@ -229,36 +229,20 @@
 
     double dub = 50.0;
 
-
 //    amf::Element *el = new amf::Element("gain", dub);
-    amf::Element *el = new amf::Element;
-    el->init("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) &&
-        (memcmp(el->getData(), &dub, AMF0_NUMBER_SIZE) == 0) &&
-        (*((double *)el->getData()) == dub) &&
+        (el->to_number() == dub) &&
         (el->getLength() == AMF0_NUMBER_SIZE)) {
         runtest.pass("gain set");
     } else {
         runtest.fail("gain set");
     }
     
-    //uint8_t *foo;
-    //char *ptr;
-#if 0
-    foo = amf_obj.encodeVariable(el); 
-    ptr = (char *)amf_obj.extractVariable(&newel, foo);
-    if ((el.getName() == newel.getName()) &&
-        (el.getLength() == newel.getLength()) &&
-        (newel.getType() == Element::NUMBER_AMF0) &&
-        (*((double *)newel.getData()) == dub)) {
-        runtest.pass("gain number encoded/extracted");
-    } else {
-        runtest.fail("gain number encoded/extracted");
-    }
-#endif
     el = new amf::Element("echosuppression", false);
     sol.addObj(el);
     if ((strcmp(el->getName(), "echosuppression") == 0) &&
@@ -270,17 +254,6 @@
         runtest.fail("echosupression set");
     }
     
-//     foo = amf_obj.encodeVariable(el); 
-//     ptr = (char *)amf_obj.extractVariable(&newel, reinterpret_cast<uint8_t 
*>(foo));
-//     if ((el->getName() == newel.getName()) &&
-//         (el->getType() == Element::BOOLEAN) &&
-//         (el->getLength() == newel.getLength()) &&
-//         (memcmp(el->getData(), newel.getData(), el->getLength()) == 0)) {
-//         runtest.pass("echosupression bool(false) encoded/extracted");
-//     } else {
-//         runtest.fail("echosupression bool(false) encoded/extracted");
-//     }
-    
     string name = "defaultmicrophone";
     string data = "/dev/input/mic";
     el = new amf::Element("defaultmicrophone", data);
@@ -296,7 +269,6 @@
 
     data = "";
     el = new amf::Element("defaultcamera", data);
-    el->init("defaultcamera", data);
     sol.addObj(el);
     if ((strcmp(el->getName(), "defaultcamera") == 0) &&
         (el->getType() == Element::STRING_AMF0) &&
@@ -307,25 +279,23 @@
     }
     
     dub = 100.0;
-    el = new amf::Element;
+    el = new amf::Element("defaultklimit", dub);
 //    el = new amf::Element("defaultklimit", dub);
-    el->init("defaultklimit", dub);
     sol.addObj(el);
     if ((strcmp(el->getName(), "defaultklimit") == 0) &&
         (el->getType() == Element::NUMBER_AMF0) &&
-        (memcmp(el->getData(), &dub, AMF0_NUMBER_SIZE) == 0) &&
-        (*((double *)el->getData()) == dub) &&
+        (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->getData() == 0) &&
+        (el->to_bool() == false) &&
         (el->getLength() == 1)) {
         runtest.pass("defaultalways set");
     } else {
@@ -336,7 +306,7 @@
     sol.addObj(el);
     if ((strcmp(el->getName(), "crossdomainAllow") == 0) &&
         (el->getType() == Element::BOOLEAN_AMF0) &&
-        (*el->getData() == 1) &&
+        (el->to_bool() == true) &&
         (el->getLength() == 1)) {
         runtest.pass("crossdomainAllow set");
     } else {
@@ -364,29 +334,8 @@
     } else {
         runtest.fail("allowThirdPartyLSOAccess set");
     }
-
-#if 0
-    // 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->getName() == "trustedPaths") &&
-        (el->getType() == Element::OBJECT_AMF0)) {
-        runtest.xpass("trustedPaths set");
-    } else {
-        runtest.xfail("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->getType() = Element::OBJECT_AMF0;  
-        el->getLength() = 0;
-    }
-    sol.addObj(el);
-#endif
     
-    el = new amf::Element;
-    el->init("localSecPath", data);
+    el = new amf::Element("localSecPath", data);
     sol.addObj(el);
     if ((strcmp(el->getName(), "localSecPath") == 0) &&
         (el->getType() == Element::STRING_AMF0) &&
@@ -400,8 +349,7 @@
     dub = 1.8379389592608646e-304;
     swapBytes(&dub, 8);
     
-    el = new amf::Element;
-    el->init("localSecPathTime", dub);
+    el = new amf::Element("localSecPathTime", dub);
     sol.addObj(el);
     if ((strcmp(el->getName(), "localSecPathTime") ==0) &&
         (el->getType() == Element::NUMBER_AMF0) &&
@@ -412,11 +360,11 @@
     } else {
         runtest.fail("localSecPathTime set");
     }
-
-//    sol.dump();
+    sol.dump();
     // now write the data to disk
     sol.writeFile(filespec, "settings");
 }
+#endif
 
 static void
 usage (void)

=== modified file 'testsuite/libnet.all/test_rtmp.cpp'
--- a/testsuite/libnet.all/test_rtmp.cpp        2008-09-04 15:17:06 +0000
+++ b/testsuite/libnet.all/test_rtmp.cpp        2008-09-18 03:43:06 +0000
@@ -261,7 +261,7 @@
     if (notest) {
         runtest.fail("RTMP::split(5 packets)");
     } else {
-        // there are 4 pacjets in this message, 2 pings, followed by a 
onStatus,
+        // there are 4 packets in this message, 2 pings, followed by a 
onStatus,
         // followed by a ping, and then the rest of the onStatus message.
         if (queues2->size() == 4) {
             runtest.pass("RTMP::split(5 packets)");
@@ -456,7 +456,7 @@
     RTMPClient client;
     RTMPServer server;
     
-    Buffer *buf1 = hex2mem("00 00 00 00 00 00");  // clear buffer message
+    Buffer *buf1 = hex2mem("00 00 00 00 00 00"); // clear buffer message
     Buffer *buf2 = hex2mem("00 06 cf 03 04 c3"); // ping client from server
     Buffer *buf3 = hex2mem("00 07 cf 03 04 c3"); // Pong, reply from client
     Buffer *buf4 = hex2mem("00 00 00 00 00 01"); // clear buffer message
@@ -515,6 +515,10 @@
     }
 #endif
     
+    "c2 00 06 30 86 0a ae";
+
+    
+    
     // cleanup
     delete ping1;
     delete ping2;

=== modified file 'utilities/flvdumper.cpp'
--- a/utilities/flvdumper.cpp   2008-08-13 22:29:53 +0000
+++ b/utilities/flvdumper.cpp   2008-09-18 03:43:06 +0000
@@ -216,7 +216,7 @@
                 tag  = flv.decodeTagHeader(&buf);
                 
                 total -= sizeof(Flv::previous_size_t);
-                boost::uint32_t bodysize = flv.convert24(tag->bodysize);
+                size_t bodysize = flv.convert24(tag->bodysize);
                 if (bodysize == 0) {
                     cerr << "FLV Tag size is zero, skipping reading packet 
body " << bodysize << endl;
                     continue;


reply via email to

[Prev in Thread] Current Thread [Next in Thread]