Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Tests/Test10.h
- Committer:
- ashleymills
- Date:
- 2012-09-06
- Revision:
- 25:55b865c41f21
- Parent:
- 24:8f0f9551122a
- Child:
- 26:9eefab9e28df
File content as of revision 25:55b865c41f21:
#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: };