Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Diff: Tests/Test10.h
- Revision:
- 24:8f0f9551122a
- Parent:
- 23:408199b5d2cb
- Child:
- 25:55b865c41f21
--- a/Tests/Test10.h Wed Sep 05 16:38:06 2012 +0000 +++ b/Tests/Test10.h Thu Sep 06 12:15:54 2012 +0000 @@ -1,41 +1,57 @@ -#pragma once -#include "VodafoneTestCase.h" -#include "HTTPClient.h" -class Test10 : public VodafoneTestCase { - public: - Test10(VodafoneUSBModem *m, int tcNumber) : VodafoneTestCase(m, tcNumber) { - } - - virtual void setupTest() { - - - } - - virtual bool runTest() { - HTTPClient http; - char msgBuffer[125]; - bool outcome = false; - - LOG("Connecting to internet"); - if(_modem->connect("internet","web","web")==0) { - LOG("Connected to internet"); - } else { - LOG("Failed to connect to internet"); - } - - LOG("Test %d, retrieving a 5MB file via HTTP.", _testCaseNumber); - if(http.get("http://www.m2mthings.com/test100.txt", msgBuffer, 125)==0) { - LOG("Got %s",msgBuffer); - outcome = true; - } - _modem->disconnect(); - return outcome; - } - - virtual void endTest() { - - } - - private: - +#pragma once +#include "VodafoneTestCase.h" +#include "HTTPClient.h" + +static const char* gTest10Description = "Connects to internet and downloads 100 byte file.\0"; +class Test10 : public VodafoneTestCase { + public: + Test10(VodafoneUSBModem *m, int tcNumber) : VodafoneTestCase(m, tcNumber) { + } + + virtual void setupTest() { + + + } + + virtual bool runTest() { + HTTPClient http; + char msgBuffer[125]; + bool outcome = true; + LOG("Description: %s",gTest10Description); + LOG("Connecting to internet"); + if(_modem->connect("internet","web","web")==0) { + LOG("Connected to internet"); + } else { + LOG("Failed to connect to internet"); + outcome = false; + } + + LOG("Test %d, retrieving a 5MB file via HTTP.", _testCaseNumber); + if(http.get("http://www.m2mthings.com/test100.txt", msgBuffer, 125)==0) { + LOG("Got \"%s\"",msgBuffer); + char c = 0; + for(int i=0; i<100; i++) { + if(msgBuffer[i]!=c) { + LOG("Strings do not match at char %d (%x,%x)",i,c,msgBuffer[i]); + outcome = false; + break; + } + c++; + if(c==256) + c = 0; + } + } else { + LOG("HTTP get failure"); + outcome = false; + } + _modem->disconnect(); + return outcome; + } + + virtual void endTest() { + + } + + private: + }; \ No newline at end of file